SqlPrivateEndpointConnectionResource IOperationSource <SqlPrivateEndpointConnectionResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = SqlPrivateEndpointConnectionData.DeserializeSqlPrivateEndpointConnectionData(document.RootElement);

            return(new SqlPrivateEndpointConnectionResource(_client, data));
        }
Example #2
0
        public async Task <Response <SqlPrivateEndpointConnectionData> > GetAsync(string subscriptionId, string resourceGroupName, string serverName, string privateEndpointConnectionName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
            Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName));

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

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

                value = SqlPrivateEndpointConnectionData.DeserializeSqlPrivateEndpointConnectionData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal SqlPrivateEndpointConnectionResource(ArmClient client, SqlPrivateEndpointConnectionData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual async Task <ArmOperation <SqlPrivateEndpointConnectionResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string privateEndpointConnectionName, SqlPrivateEndpointConnectionData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _sqlPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("SqlPrivateEndpointConnectionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _sqlPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <SqlPrivateEndpointConnectionResource>(new SqlPrivateEndpointConnectionOperationSource(Client), _sqlPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _sqlPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).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 ArmOperation <SqlPrivateEndpointConnectionResource> Update(WaitUntil waitUntil, SqlPrivateEndpointConnectionData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _sqlPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("SqlPrivateEndpointConnectionResource.Update");
            scope.Start();
            try
            {
                var response  = _sqlPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new SqlArmOperation <SqlPrivateEndpointConnectionResource>(new SqlPrivateEndpointConnectionOperationSource(Client), _sqlPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _sqlPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.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;
            }
        }