public virtual AfdSecurityPolicyUpdateOperation Update(bool waitForCompletion, SecurityPolicyProperties securityPolicyProperties, CancellationToken cancellationToken = default)
        {
            if (securityPolicyProperties == null)
            {
                throw new ArgumentNullException(nameof(securityPolicyProperties));
            }

            using var scope = _afdSecurityPolicyClientDiagnostics.CreateScope("AfdSecurityPolicy.Update");
            scope.Start();
            try
            {
                var response  = _afdSecurityPolicyRestClient.Patch(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, securityPolicyProperties, cancellationToken);
                var operation = new AfdSecurityPolicyUpdateOperation(ArmClient, _afdSecurityPolicyClientDiagnostics, Pipeline, _afdSecurityPolicyRestClient.CreatePatchRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, securityPolicyProperties).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 2
0
        public async virtual Task <AfdSecurityPolicyUpdateOperation> UpdateAsync(bool waitForCompletion, SecurityPolicyProperties securityPolicyProperties, CancellationToken cancellationToken = default)
        {
            if (securityPolicyProperties == null)
            {
                throw new ArgumentNullException(nameof(securityPolicyProperties));
            }

            using var scope = _clientDiagnostics.CreateScope("AfdSecurityPolicy.Update");
            scope.Start();
            try
            {
                var response = await _afdSecurityPoliciesRestClient.PatchAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, securityPolicyProperties, cancellationToken).ConfigureAwait(false);

                var operation = new AfdSecurityPolicyUpdateOperation(this, _clientDiagnostics, Pipeline, _afdSecurityPoliciesRestClient.CreatePatchRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, securityPolicyProperties).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }