public async Task<Response<ServerVulnerabilityAssessmentData>> GetAsync(string subscriptionId, string resourceGroupName, string serverName, VulnerabilityAssessmentName vulnerabilityAssessmentName, 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, vulnerabilityAssessmentName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ServerVulnerabilityAssessmentData value = default;
                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
                        value = ServerVulnerabilityAssessmentData.DeserializeServerVulnerabilityAssessmentData(document.RootElement);
                        return Response.FromValue(value, message.Response);
                    }
Ejemplo n.º 2
0
 internal ServerVulnerabilityAssessment(ArmResource options, ServerVulnerabilityAssessmentData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _serverVulnerabilityAssessmentsRestClient = new ServerVulnerabilityAssessmentsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
 internal ServerVulnerabilityAssessmentResource(ArmClient client, ServerVulnerabilityAssessmentData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual ArmOperation <ServerVulnerabilityAssessmentResource> Update(WaitUntil waitUntil, ServerVulnerabilityAssessmentData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _serverVulnerabilityAssessmentClientDiagnostics.CreateScope("ServerVulnerabilityAssessmentResource.Update");
            scope.Start();
            try
            {
                var response  = _serverVulnerabilityAssessmentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new SqlArmOperation <ServerVulnerabilityAssessmentResource>(Response.FromValue(new ServerVulnerabilityAssessmentResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 5
0
        public virtual ArmOperation <ServerVulnerabilityAssessment> CreateOrUpdate(bool waitForCompletion, VulnerabilityAssessmentName vulnerabilityAssessmentName, ServerVulnerabilityAssessmentData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _serverVulnerabilityAssessmentClientDiagnostics.CreateScope("ServerVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _serverVulnerabilityAssessmentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken);
                var operation = new SqlArmOperation <ServerVulnerabilityAssessment>(Response.FromValue(new ServerVulnerabilityAssessment(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal ServerVulnerabilityAssessment(ArmClient armClient, ServerVulnerabilityAssessmentData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public async virtual Task <ServerVulnerabilityAssessmentCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, VulnerabilityAssessmentName vulnerabilityAssessmentName, ServerVulnerabilityAssessmentData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _serverVulnerabilityAssessmentClientDiagnostics.CreateScope("ServerVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _serverVulnerabilityAssessmentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ServerVulnerabilityAssessmentCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ServerVulnerabilityAssessmentCreateOrUpdateOperation CreateOrUpdate(VulnerabilityAssessmentName vulnerabilityAssessmentName, ServerVulnerabilityAssessmentData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ServerVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _serverVulnerabilityAssessmentsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken);
                var operation = new ServerVulnerabilityAssessmentCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }