Ejemplo n.º 1
0
 internal CdnEndpoint(ArmResource options, CdnEndpointData resource) : base(options, resource.Id)
 {
     HasData                 = true;
     _data                   = resource;
     _clientDiagnostics      = new ClientDiagnostics(ClientOptions);
     _cdnEndpointsRestClient = new CdnEndpointsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Ejemplo n.º 2
0
        CdnEndpointResource IOperationSource <CdnEndpointResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ScrubId(CdnEndpointData.DeserializeCdnEndpointData(document.RootElement));

            return(new CdnEndpointResource(_client, data));
        }
Ejemplo n.º 3
0
        internal CdnEndpoint(ArmResource options, CdnEndpointData data) : base(options, data.Id)
        {
            HasData                 = true;
            _data                   = data;
            _clientDiagnostics      = new ClientDiagnostics(ClientOptions);
            _cdnEndpointsRestClient = new CdnEndpointsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
#if DEBUG
            ValidateResourceId(Id);
#endif
        }
Ejemplo n.º 4
0
        internal CdnEndpoint(ArmResource options, CdnEndpointData data) : base(options, data.Id)
        {
            HasData            = true;
            _data              = data;
            _clientDiagnostics = new ClientDiagnostics(ClientOptions);
            ClientOptions.TryGetApiVersion(ResourceType, out string apiVersion);
            _cdnEndpointsRestClient = new CdnEndpointsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri, apiVersion);
#if DEBUG
            ValidateResourceId(Id);
#endif
        }
        public async virtual Task <CdnEndpointCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string endpointName, CdnEndpointData endpointInput, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName));
            if (endpointInput == null)
            {
                throw new ArgumentNullException(nameof(endpointInput));
            }

            using var scope = _cdnEndpointClientDiagnostics.CreateScope("CdnEndpointCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _cdnEndpointRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken).ConfigureAwait(false);

                var operation = new CdnEndpointCreateOrUpdateOperation(ArmClient, _cdnEndpointClientDiagnostics, Pipeline, _cdnEndpointRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 6
0
        public virtual async Task <ArmOperation <CdnEndpoint> > CreateOrUpdateAsync(WaitUntil waitUntil, string endpointName, CdnEndpointData endpointInput, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName));
            Argument.AssertNotNull(endpointInput, nameof(endpointInput));

            using var scope = _cdnEndpointClientDiagnostics.CreateScope("CdnEndpointCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _cdnEndpointRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <CdnEndpoint>(new CdnEndpointOperationSource(Client), _cdnEndpointClientDiagnostics, Pipeline, _cdnEndpointRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 7
0
 internal CdnEndpoint(ArmClient armClient, CdnEndpointData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual ArmOperation <CdnEndpoint> CreateOrUpdate(bool waitForCompletion, string endpointName, CdnEndpointData endpointInput, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName));
            if (endpointInput == null)
            {
                throw new ArgumentNullException(nameof(endpointInput));
            }

            using var scope = _cdnEndpointClientDiagnostics.CreateScope("CdnEndpointCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _cdnEndpointRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken);
                var operation = new CdnArmOperation <CdnEndpoint>(new CdnEndpointOperationSource(Client), _cdnEndpointClientDiagnostics, Pipeline, _cdnEndpointRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 9
0
        public virtual CdnEndpointCreateOperation CreateOrUpdate(string endpointName, CdnEndpointData endpointInput, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (endpointName == null)
            {
                throw new ArgumentNullException(nameof(endpointName));
            }
            if (endpointInput == null)
            {
                throw new ArgumentNullException(nameof(endpointInput));
            }

            using var scope = _clientDiagnostics.CreateScope("CdnEndpointCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _cdnEndpointsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken);
                var operation = new CdnEndpointCreateOperation(Parent, _clientDiagnostics, Pipeline, _cdnEndpointsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }