Exemple #1
0
 internal AfdCustomDomain(ArmResource options, AfdCustomDomainData resource) : base(options, resource.Id)
 {
     HasData                     = true;
     _data                       = resource;
     _clientDiagnostics          = new ClientDiagnostics(ClientOptions);
     _afdCustomDomainsRestClient = new AfdCustomDomainsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
        AfdCustomDomain IOperationSource <AfdCustomDomain> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AfdCustomDomainData.DeserializeAfdCustomDomainData(document.RootElement);

            return(new AfdCustomDomain(_client, data));
        }
Exemple #3
0
        internal AfdCustomDomain(ArmResource options, AfdCustomDomainData data) : base(options, data.Id)
        {
            HasData                     = true;
            _data                       = data;
            _clientDiagnostics          = new ClientDiagnostics(ClientOptions);
            _afdCustomDomainsRestClient = new AfdCustomDomainsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
#if DEBUG
            ValidateResourceId(Id);
#endif
        }
        public async virtual Task <ArmOperation <AfdCustomDomain> > CreateOrUpdateAsync(bool waitForCompletion, string customDomainName, AfdCustomDomainData customDomain, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(customDomainName, nameof(customDomainName));
            if (customDomain == null)
            {
                throw new ArgumentNullException(nameof(customDomain));
            }

            using var scope = _afdCustomDomainClientDiagnostics.CreateScope("AfdCustomDomainCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _afdCustomDomainRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customDomainName, customDomain, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <AfdCustomDomain>(new AfdCustomDomainOperationSource(Client), _afdCustomDomainClientDiagnostics, Pipeline, _afdCustomDomainRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customDomainName, customDomain).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #5
0
        public virtual AfdCustomDomainCreateOperation CreateOrUpdate(bool waitForCompletion, string customDomainName, AfdCustomDomainData customDomain, CancellationToken cancellationToken = default)
        {
            if (customDomainName == null)
            {
                throw new ArgumentNullException(nameof(customDomainName));
            }
            if (customDomain == null)
            {
                throw new ArgumentNullException(nameof(customDomain));
            }

            using var scope = _clientDiagnostics.CreateScope("AfdCustomDomainCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _afdCustomDomainsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customDomainName, customDomain, cancellationToken);
                var operation = new AfdCustomDomainCreateOperation(Parent, _clientDiagnostics, Pipeline, _afdCustomDomainsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customDomainName, customDomain).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal AfdCustomDomainResource(ArmClient client, AfdCustomDomainData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Exemple #7
0
        public virtual ArmOperation <AfdCustomDomainResource> CreateOrUpdate(WaitUntil waitUntil, string customDomainName, AfdCustomDomainData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(customDomainName, nameof(customDomainName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _afdCustomDomainClientDiagnostics.CreateScope("AfdCustomDomainCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _afdCustomDomainRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customDomainName, data, cancellationToken);
                var operation = new CdnArmOperation <AfdCustomDomainResource>(new AfdCustomDomainOperationSource(Client), _afdCustomDomainClientDiagnostics, Pipeline, _afdCustomDomainRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customDomainName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal AfdCustomDomain(ArmClient armClient, AfdCustomDomainData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }