Exemplo n.º 1
0
        public virtual DatabaseVulnerabilityAssessmentCreateOrUpdateOperation CreateOrUpdate(VulnerabilityAssessmentName vulnerabilityAssessmentName, DatabaseVulnerabilityAssessmentData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ServerDatabaseVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _databaseVulnerabilityAssessmentsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken);
                var operation = new DatabaseVulnerabilityAssessmentCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual ArmOperation <ServerDatabaseVulnerabilityAssessmentResource> CreateOrUpdate(WaitUntil waitUntil, VulnerabilityAssessmentName vulnerabilityAssessmentName, DatabaseVulnerabilityAssessmentData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _serverDatabaseVulnerabilityAssessmentDatabaseVulnerabilityAssessmentsClientDiagnostics.CreateScope("ServerDatabaseVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _serverDatabaseVulnerabilityAssessmentDatabaseVulnerabilityAssessmentsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, vulnerabilityAssessmentName, data, cancellationToken);
                var operation = new SqlArmOperation <ServerDatabaseVulnerabilityAssessmentResource>(Response.FromValue(new ServerDatabaseVulnerabilityAssessmentResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }