示例#1
0
        FrontDoorRuleResource IOperationSource <FrontDoorRuleResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = FrontDoorRuleData.DeserializeFrontDoorRuleData(document.RootElement);

            return(new FrontDoorRuleResource(_client, data));
        }
示例#2
0
        public virtual async Task <ArmOperation <FrontDoorRuleResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string ruleName, FrontDoorRuleData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(ruleName, nameof(ruleName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _frontDoorRuleClientDiagnostics.CreateScope("FrontDoorRuleCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _frontDoorRuleRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, data, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <FrontDoorRuleResource>(new FrontDoorRuleOperationSource(Client), _frontDoorRuleClientDiagnostics, Pipeline, _frontDoorRuleRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#3
0
 internal FrontDoorRuleResource(ArmClient client, FrontDoorRuleData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }