AddressResource IOperationSource <AddressResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AddressResourceData.DeserializeAddressResourceData(document.RootElement);

            return(new AddressResource(_client, data));
        }
Esempio n. 2
0
 internal AddressResource(ArmClient client, AddressResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Esempio n. 3
0
        public virtual async Task <ArmOperation <AddressResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string addressName, AddressResourceData addressResource, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(addressName, nameof(addressName));
            Argument.AssertNotNull(addressResource, nameof(addressResource));

            using var scope = _addressResourceClientDiagnostics.CreateScope("AddressResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _addressResourceRestClient.CreateAddressAsync(Id.SubscriptionId, Id.ResourceGroupName, addressName, addressResource, cancellationToken).ConfigureAwait(false);

                var operation = new EdgeOrderArmOperation <AddressResource>(new AddressResourceOperationSource(Client), _addressResourceClientDiagnostics, Pipeline, _addressResourceRestClient.CreateCreateAddressRequest(Id.SubscriptionId, Id.ResourceGroupName, addressName, addressResource).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual AddressResourceCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string addressName, AddressResourceData addressResource, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(addressName, nameof(addressName));
            if (addressResource == null)
            {
                throw new ArgumentNullException(nameof(addressResource));
            }

            using var scope = _addressResourceClientDiagnostics.CreateScope("AddressResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _addressResourceRestClient.CreateAddress(Id.SubscriptionId, Id.ResourceGroupName, addressName, addressResource, cancellationToken);
                var operation = new AddressResourceCreateOrUpdateOperation(ArmClient, _addressResourceClientDiagnostics, Pipeline, _addressResourceRestClient.CreateCreateAddressRequest(Id.SubscriptionId, Id.ResourceGroupName, addressName, addressResource).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }