public async virtual Task <ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreateOrUpdateOperation> CreateOrUpdateAsync(string ruleId, VulnerabilityAssessmentPolicyBaselineName baselineName, DatabaseVulnerabilityAssessmentRuleBaselineData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (ruleId == null)
            {
                throw new ArgumentNullException(nameof(ruleId));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaselineCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _managedDatabaseVulnerabilityAssessmentRuleBaselinesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, ruleId, baselineName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual async Task <ArmOperation <ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaselineResource> > UpdateAsync(WaitUntil waitUntil, DatabaseVulnerabilityAssessmentRuleBaselineData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _managedInstanceDatabaseVulnerabilityAssessmentRuleBaselineManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientDiagnostics.CreateScope("ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaselineResource.Update");
            scope.Start();
            try
            {
                var response = await _managedInstanceDatabaseVulnerabilityAssessmentRuleBaselineManagedDatabaseVulnerabilityAssessmentRuleBaselinesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Parent.Name, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name.ToVulnerabilityAssessmentPolicyBaselineName(), data, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaselineResource>(Response.FromValue(new ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaselineResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <ArmOperation <ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaseline> > CreateOrUpdateAsync(bool waitForCompletion, string ruleId, VulnerabilityAssessmentPolicyBaselineName baselineName, DatabaseVulnerabilityAssessmentRuleBaselineData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(ruleId, nameof(ruleId));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _managedInstanceDatabaseVulnerabilityAssessmentRuleBaselineManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientDiagnostics.CreateScope("ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaselineCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _managedInstanceDatabaseVulnerabilityAssessmentRuleBaselineManagedDatabaseVulnerabilityAssessmentRuleBaselinesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, ruleId, baselineName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaseline>(Response.FromValue(new ManagedInstanceDatabaseVulnerabilityAssessmentRuleBaseline(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }