Пример #1
0
        public async Task <Response <ServerTrustGroupData> > GetAsync(string subscriptionId, string resourceGroupName, string locationName, string serverTrustGroupName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (locationName == null)
            {
                throw new ArgumentNullException(nameof(locationName));
            }
            if (serverTrustGroupName == null)
            {
                throw new ArgumentNullException(nameof(serverTrustGroupName));
            }

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

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

                value = ServerTrustGroupData.DeserializeServerTrustGroupData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal ServerTrustGroup(ArmResource options, ServerTrustGroupData resource) : base(options, resource.Id)
 {
     HasData                      = true;
     _data                        = resource;
     _clientDiagnostics           = new ClientDiagnostics(ClientOptions);
     _serverTrustGroupsRestClient = new ServerTrustGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Пример #3
0
        ServerTrustGroup IOperationSource <ServerTrustGroup> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ServerTrustGroupData.DeserializeServerTrustGroupData(document.RootElement);

            return(new ServerTrustGroup(_client, data));
        }
Пример #4
0
        public virtual async Task <ArmOperation <ServerTrustGroupResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string serverTrustGroupName, ServerTrustGroupData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(serverTrustGroupName, nameof(serverTrustGroupName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _serverTrustGroupClientDiagnostics.CreateScope("ServerTrustGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _serverTrustGroupRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, _locationName, serverTrustGroupName, data, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <ServerTrustGroupResource>(new ServerTrustGroupOperationSource(Client), _serverTrustGroupClientDiagnostics, Pipeline, _serverTrustGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, _locationName, serverTrustGroupName, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #5
0
        public async virtual Task <ServerTrustGroupCreateOrUpdateOperation> CreateOrUpdateAsync(string locationName, string serverTrustGroupName, ServerTrustGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (locationName == null)
            {
                throw new ArgumentNullException(nameof(locationName));
            }
            if (serverTrustGroupName == null)
            {
                throw new ArgumentNullException(nameof(serverTrustGroupName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ServerTrustGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _serverTrustGroupsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, locationName, serverTrustGroupName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ServerTrustGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _serverTrustGroupsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, locationName, serverTrustGroupName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #6
0
 internal ServerTrustGroup(ArmClient client, ServerTrustGroupData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Пример #7
0
        public virtual ArmOperation <ServerTrustGroupResource> Update(WaitUntil waitUntil, ServerTrustGroupData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _serverTrustGroupClientDiagnostics.CreateScope("ServerTrustGroupResource.Update");
            scope.Start();
            try
            {
                var response  = _serverTrustGroupRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new SqlArmOperation <ServerTrustGroupResource>(new ServerTrustGroupOperationSource(Client), _serverTrustGroupClientDiagnostics, Pipeline, _serverTrustGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ServerTrustGroupCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string serverTrustGroupName, ServerTrustGroupData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(serverTrustGroupName, nameof(serverTrustGroupName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _serverTrustGroupClientDiagnostics.CreateScope("ServerTrustGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _serverTrustGroupRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, _locationName, serverTrustGroupName, parameters, cancellationToken);
                var operation = new ServerTrustGroupCreateOrUpdateOperation(ArmClient, _serverTrustGroupClientDiagnostics, Pipeline, _serverTrustGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, _locationName, serverTrustGroupName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }