コード例 #1
0
 internal CustomIpPrefix(ArmResource options, CustomIpPrefixData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new CustomIPPrefixesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
コード例 #2
0
        public async Task <Response <CustomIpPrefixData> > GetAsync(string subscriptionId, string resourceGroupName, string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (customIpPrefixName == null)
            {
                throw new ArgumentNullException(nameof(customIpPrefixName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, customIpPrefixName, expand);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                CustomIpPrefixData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = CustomIpPrefixData.DeserializeCustomIpPrefixData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
コード例 #3
0
        CustomIpPrefix IOperationSource <CustomIpPrefix> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = CustomIpPrefixData.DeserializeCustomIpPrefixData(document.RootElement);

            return(new CustomIpPrefix(_client, data));
        }
コード例 #4
0
 internal CustomIpPrefix(ArmResource options, CustomIpPrefixData resource) : base(options, new ResourceIdentifier(resource.Id))
 {
     HasData                     = true;
     _data                       = resource;
     _clientDiagnostics          = new ClientDiagnostics(ClientOptions);
     _customIPPrefixesRestClient = new CustomIPPrefixesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
コード例 #5
0
 internal CustomIpPrefixData(string id, string name, string type, string location, IDictionary <string, string> tags, ExtendedLocation extendedLocation, string etag, IList <string> zones, string cidr, string signedMessage, string authorizationMessage, CustomIpPrefixData customIpPrefixParent, IReadOnlyList <CustomIpPrefixData> childCustomIpPrefixes, CommissionedState?commissionedState, IReadOnlyList <WritableSubResource> publicIpPrefixes, string resourceGuid, string failedReason, ProvisioningState?provisioningState) : base(id, name, type, location, tags)
 {
     ExtendedLocation      = extendedLocation;
     Etag                  = etag;
     Zones                 = zones;
     Cidr                  = cidr;
     SignedMessage         = signedMessage;
     AuthorizationMessage  = authorizationMessage;
     CustomIpPrefixParent  = customIpPrefixParent;
     ChildCustomIpPrefixes = childCustomIpPrefixes;
     CommissionedState     = commissionedState;
     PublicIpPrefixes      = publicIpPrefixes;
     ResourceGuid          = resourceGuid;
     FailedReason          = failedReason;
     ProvisioningState     = provisioningState;
 }
コード例 #6
0
        public async virtual Task <ArmOperation <CustomIpPrefix> > CreateOrUpdateAsync(bool waitForCompletion, string customIpPrefixName, CustomIpPrefixData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(customIpPrefixName, nameof(customIpPrefixName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _customIpPrefixCustomIPPrefixesClientDiagnostics.CreateScope("CustomIpPrefixCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _customIpPrefixCustomIPPrefixesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, customIpPrefixName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <CustomIpPrefix>(new CustomIpPrefixOperationSource(Client), _customIpPrefixCustomIPPrefixesClientDiagnostics, Pipeline, _customIpPrefixCustomIPPrefixesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, customIpPrefixName, parameters).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #7
0
        public async virtual Task <CustomIPPrefixCreateOrUpdateOperation> CreateOrUpdateAsync(string customIpPrefixName, CustomIpPrefixData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (customIpPrefixName == null)
            {
                throw new ArgumentNullException(nameof(customIpPrefixName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, customIpPrefixName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new CustomIPPrefixCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, customIpPrefixName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #8
0
        public virtual CustomIpPrefixCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string customIpPrefixName, CustomIpPrefixData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(customIpPrefixName, nameof(customIpPrefixName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _customIpPrefixCustomIPPrefixesClientDiagnostics.CreateScope("CustomIpPrefixCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _customIpPrefixCustomIPPrefixesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, customIpPrefixName, parameters, cancellationToken);
                var operation = new CustomIpPrefixCreateOrUpdateOperation(ArmClient, _customIpPrefixCustomIPPrefixesClientDiagnostics, Pipeline, _customIpPrefixCustomIPPrefixesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, customIpPrefixName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #9
0
 internal CustomIpPrefix(ArmClient armClient, CustomIpPrefixData data) : this(armClient, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }