public async Task <Response <ServerAutomaticTuningData> > GetAsync(string subscriptionId, string resourceGroupName, string serverName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (serverName == null)
            {
                throw new ArgumentNullException(nameof(serverName));
            }

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

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

                value = ServerAutomaticTuningData.DeserializeServerAutomaticTuningData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal ServerAutomaticTuning(ArmResource options, ServerAutomaticTuningData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     Parent             = options;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _serverAutomaticTuningRestClient = new ServerAutomaticTuningRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Пример #3
0
        public virtual Response <ServerAutomaticTuning> Update(ServerAutomaticTuningData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _serverAutomaticTuningClientDiagnostics.CreateScope("ServerAutomaticTuning.Update");
            scope.Start();
            try
            {
                var response = _serverAutomaticTuningRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, parameters, cancellationToken);
                return(Response.FromValue(new ServerAutomaticTuning(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <Response <ServerAutomaticTuning> > UpdateAsync(ServerAutomaticTuningData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ServerAutomaticTuning.Update");
            scope.Start();
            try
            {
                var response = await _serverAutomaticTuningRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, parameters, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new ServerAutomaticTuning(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #5
0
 internal ServerAutomaticTuning(ArmClient client, ServerAutomaticTuningData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Пример #6
0
        public virtual async Task <Response <ServerAutomaticTuningResource> > UpdateAsync(ServerAutomaticTuningData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _serverAutomaticTuningClientDiagnostics.CreateScope("ServerAutomaticTuningResource.Update");
            scope.Start();
            try
            {
                var response = await _serverAutomaticTuningRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, data, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new ServerAutomaticTuningResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }