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

            using var scope = _clientDiagnostics.CreateScope("DataMaskingPolicy.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _dataMaskingPoliciesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, parameters, cancellationToken);
                var operation = new DataMaskingPolicyCreateOrUpdateOperation(this, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
 internal DataMaskingPolicy(ArmResource options, DataMaskingPolicyData resource) : base(options, resource.Id)
 {
     HasData                        = true;
     _data                          = resource;
     Parent                         = options;
     _clientDiagnostics             = new ClientDiagnostics(ClientOptions);
     _dataMaskingPoliciesRestClient = new DataMaskingPoliciesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
     _dataMaskingRulesRestClient    = new DataMaskingRulesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
        public async Task <Response <DataMaskingPolicyData> > CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string serverName, string databaseName, DataMaskingPolicyData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
            Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
            Argument.AssertNotNull(data, nameof(data));

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

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

                value = DataMaskingPolicyData.DeserializeDataMaskingPolicyData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal DataMaskingPolicy(ArmClient armClient, DataMaskingPolicyData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public async virtual Task <DataMaskingPolicyCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, DataMaskingPolicyData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _dataMaskingPolicyClientDiagnostics.CreateScope("DataMaskingPolicy.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _dataMaskingPolicyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new DataMaskingPolicyCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 6
0
 internal DataMaskingPolicyResource(ArmClient client, DataMaskingPolicyData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Exemplo n.º 7
0
        public virtual ArmOperation <DataMaskingPolicyResource> CreateOrUpdate(WaitUntil waitUntil, DataMaskingPolicyData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _dataMaskingPolicyClientDiagnostics.CreateScope("DataMaskingPolicyResource.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _dataMaskingPolicyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, data, cancellationToken);
                var operation = new SqlArmOperation <DataMaskingPolicyResource>(Response.FromValue(new DataMaskingPolicyResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 8
0
        internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string serverName, string databaseName, DataMaskingPolicyData parameters)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();

            uri.Reset(_endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/resourceGroups/", false);
            uri.AppendPath(resourceGroupName, true);
            uri.AppendPath("/providers/Microsoft.Sql/servers/", false);
            uri.AppendPath(serverName, true);
            uri.AppendPath("/databases/", false);
            uri.AppendPath(databaseName, true);
            uri.AppendPath("/dataMaskingPolicies/", false);
            uri.AppendPath("Default", true);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(parameters);
            request.Content = content;
            message.SetProperty("SDKUserAgent", _userAgent);
            return(message);
        }
Exemplo n.º 9
0
        public async virtual Task <ArmOperation <DataMaskingPolicy> > CreateOrUpdateAsync(bool waitForCompletion, DataMaskingPolicyData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _dataMaskingPolicyClientDiagnostics.CreateScope("DataMaskingPolicy.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _dataMaskingPolicyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, parameters, cancellationToken).ConfigureAwait(false);

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