Beispiel #1
0
        FrontDoorSecurityPolicyResource IOperationSource <FrontDoorSecurityPolicyResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = FrontDoorSecurityPolicyData.DeserializeFrontDoorSecurityPolicyData(document.RootElement);

            return(new FrontDoorSecurityPolicyResource(_client, data));
        }
Beispiel #2
0
 internal FrontDoorSecurityPolicyResource(ArmClient client, FrontDoorSecurityPolicyData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Beispiel #3
0
        public virtual async Task <ArmOperation <FrontDoorSecurityPolicyResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string securityPolicyName, FrontDoorSecurityPolicyData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _frontDoorSecurityPolicyClientDiagnostics.CreateScope("FrontDoorSecurityPolicyCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _frontDoorSecurityPolicyRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, data, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <FrontDoorSecurityPolicyResource>(new FrontDoorSecurityPolicyOperationSource(Client), _frontDoorSecurityPolicyClientDiagnostics, Pipeline, _frontDoorSecurityPolicyRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }