Esempio n. 1
0
        public async Task <Response <ManagedDatabaseSecurityAlertPolicy> > GetAsync(string resourceGroupName, string managedInstanceName, string databaseName, SecurityAlertPolicyName securityAlertPolicyName, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (managedInstanceName == null)
            {
                throw new ArgumentNullException(nameof(managedInstanceName));
            }
            if (databaseName == null)
            {
                throw new ArgumentNullException(nameof(databaseName));
            }

            using var message = CreateGetRequest(resourceGroupName, managedInstanceName, databaseName, securityAlertPolicyName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = ManagedDatabaseSecurityAlertPolicy.DeserializeManagedDatabaseSecurityAlertPolicy(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 public virtual async Task <Response <ManagedDatabaseSecurityAlertPolicy> > CreateOrUpdateAsync(string resourceGroupName, string managedInstanceName, string databaseName, SecurityAlertPolicyName securityAlertPolicyName, ManagedDatabaseSecurityAlertPolicy parameters, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("ManagedDatabaseSecurityAlertPoliciesOperations.CreateOrUpdate");
     scope.Start();
     try
     {
         return(await RestClient.CreateOrUpdateAsync(resourceGroupName, managedInstanceName, databaseName, securityAlertPolicyName, parameters, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }