Exemple #1
0
        AfdOriginResource IOperationSource <AfdOriginResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AfdOriginData.DeserializeAfdOriginData(document.RootElement);

            return(new AfdOriginResource(_client, data));
        }
 internal AfdOrigin(ArmResource options, AfdOriginData resource) : base(options, resource.Id)
 {
     HasData               = true;
     _data                 = resource;
     _clientDiagnostics    = new ClientDiagnostics(ClientOptions);
     _afdOriginsRestClient = new AfdOriginsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Exemple #3
0
        public virtual AfdOriginCreateOperation CreateOrUpdate(string originName, AfdOriginData origin, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (originName == null)
            {
                throw new ArgumentNullException(nameof(originName));
            }
            if (origin == null)
            {
                throw new ArgumentNullException(nameof(origin));
            }

            using var scope = _clientDiagnostics.CreateScope("AfdOriginCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _afdOriginsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin, cancellationToken);
                var operation = new AfdOriginCreateOperation(Parent, _clientDiagnostics, Pipeline, _afdOriginsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #4
0
        internal AfdOrigin(ArmResource options, AfdOriginData data) : base(options, data.Id)
        {
            HasData               = true;
            _data                 = data;
            _clientDiagnostics    = new ClientDiagnostics(ClientOptions);
            _afdOriginsRestClient = new AfdOriginsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
#if DEBUG
            ValidateResourceId(Id);
#endif
        }
 internal AfdOrigin(ArmClient client, AfdOriginData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public async virtual Task <ArmOperation <AfdOrigin> > CreateOrUpdateAsync(bool waitForCompletion, string originName, AfdOriginData origin, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(originName, nameof(originName));
            Argument.AssertNotNull(origin, nameof(origin));

            using var scope = _afdOriginClientDiagnostics.CreateScope("AfdOriginCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _afdOriginRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <AfdOrigin>(new AfdOriginOperationSource(Client), _afdOriginClientDiagnostics, Pipeline, _afdOriginRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, origin).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #7
0
        public virtual ArmOperation <AfdOriginResource> CreateOrUpdate(WaitUntil waitUntil, string originName, AfdOriginData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(originName, nameof(originName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _afdOriginClientDiagnostics.CreateScope("AfdOriginCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _afdOriginRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, data, cancellationToken);
                var operation = new CdnArmOperation <AfdOriginResource>(new AfdOriginOperationSource(Client), _afdOriginClientDiagnostics, Pipeline, _afdOriginRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }