IPAllocation IOperationSource <IPAllocation> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = IPAllocationData.DeserializeIPAllocationData(document.RootElement);

            return(new IPAllocation(_client, data));
        }
예제 #2
0
        public async Task <Response <IPAllocationData> > GetAsync(string subscriptionId, string resourceGroupName, string ipAllocationName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (ipAllocationName == null)
            {
                throw new ArgumentNullException(nameof(ipAllocationName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, ipAllocationName, expand);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = IPAllocationData.DeserializeIPAllocationData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
예제 #3
0
 internal IPAllocation(ArmClient client, IPAllocationData data) : this(client, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }
예제 #4
0
        public virtual async Task <ArmOperation <IPAllocation> > CreateOrUpdateAsync(WaitUntil waitUntil, string ipAllocationName, IPAllocationData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(ipAllocationName, nameof(ipAllocationName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _ipAllocationIpAllocationsClientDiagnostics.CreateScope("IPAllocationCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _ipAllocationIpAllocationsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <IPAllocation>(new IPAllocationOperationSource(Client), _ipAllocationIpAllocationsClientDiagnostics, Pipeline, _ipAllocationIpAllocationsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #5
0
 internal IPAllocationResource(ArmClient client, IPAllocationData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }