internal CdnOriginGroup(ArmResource options, CdnOriginGroupData resource) : base(options, resource.Id)
 {
     HasData                    = true;
     _data                      = resource;
     _clientDiagnostics         = new ClientDiagnostics(ClientOptions);
     _cdnOriginGroupsRestClient = new CdnOriginGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Пример #2
0
        CdnOriginGroupResource IOperationSource <CdnOriginGroupResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = CdnOriginGroupData.DeserializeCdnOriginGroupData(document.RootElement);

            return(new CdnOriginGroupResource(_client, data));
        }
Пример #3
0
        internal CdnOriginGroup(ArmResource options, CdnOriginGroupData data) : base(options, data.Id)
        {
            HasData                    = true;
            _data                      = data;
            _clientDiagnostics         = new ClientDiagnostics(ClientOptions);
            _cdnOriginGroupsRestClient = new CdnOriginGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
#if DEBUG
            ValidateResourceId(Id);
#endif
        }
        public async virtual Task <CdnOriginGroupCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string originGroupName, CdnOriginGroupData originGroup, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(originGroupName, nameof(originGroupName));
            if (originGroup == null)
            {
                throw new ArgumentNullException(nameof(originGroup));
            }

            using var scope = _cdnOriginGroupClientDiagnostics.CreateScope("CdnOriginGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _cdnOriginGroupRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup, cancellationToken).ConfigureAwait(false);

                var operation = new CdnOriginGroupCreateOrUpdateOperation(ArmClient, _cdnOriginGroupClientDiagnostics, Pipeline, _cdnOriginGroupRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #5
0
        public virtual async Task <ArmOperation <CdnOriginGroup> > CreateOrUpdateAsync(WaitUntil waitUntil, string originGroupName, CdnOriginGroupData originGroup, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(originGroupName, nameof(originGroupName));
            Argument.AssertNotNull(originGroup, nameof(originGroup));

            using var scope = _cdnOriginGroupClientDiagnostics.CreateScope("CdnOriginGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _cdnOriginGroupRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <CdnOriginGroup>(new CdnOriginGroupOperationSource(Client), _cdnOriginGroupClientDiagnostics, Pipeline, _cdnOriginGroupRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual CdnOriginGroupCreateOperation CreateOrUpdate(string originGroupName, CdnOriginGroupData originGroup, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (originGroupName == null)
            {
                throw new ArgumentNullException(nameof(originGroupName));
            }
            if (originGroup == null)
            {
                throw new ArgumentNullException(nameof(originGroup));
            }

            using var scope = _clientDiagnostics.CreateScope("CdnOriginGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _cdnOriginGroupsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup, cancellationToken);
                var operation = new CdnOriginGroupCreateOperation(Parent, _clientDiagnostics, Pipeline, _cdnOriginGroupsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #7
0
 internal CdnOriginGroup(ArmClient client, CdnOriginGroupData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Пример #8
0
        public virtual ArmOperation <CdnOriginGroup> CreateOrUpdate(bool waitForCompletion, string originGroupName, CdnOriginGroupData originGroup, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(originGroupName, nameof(originGroupName));
            if (originGroup == null)
            {
                throw new ArgumentNullException(nameof(originGroup));
            }

            using var scope = _cdnOriginGroupClientDiagnostics.CreateScope("CdnOriginGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _cdnOriginGroupRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup, cancellationToken);
                var operation = new CdnArmOperation <CdnOriginGroup>(new CdnOriginGroupOperationSource(Client), _cdnOriginGroupClientDiagnostics, Pipeline, _cdnOriginGroupRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, originGroupName, originGroup).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }