Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        public virtual ServerTrustGroupCreateOrUpdateOperation CreateOrUpdate(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  = _serverTrustGroupsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, locationName, serverTrustGroupName, parameters, cancellationToken);
                var operation = new ServerTrustGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _serverTrustGroupsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, locationName, serverTrustGroupName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }