Пример #1
0
        public async Task <Response <IpAllocation> > GetAsync(string resourceGroupName, string ipAllocationName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (ipAllocationName == null)
            {
                throw new ArgumentNullException(nameof(ipAllocationName));
            }

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

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

                if (document.RootElement.ValueKind == JsonValueKind.Null)
                {
                    value = null;
                }
                else
                {
                    value = IpAllocation.DeserializeIpAllocation(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }
Пример #2
0
        public virtual IpAllocationsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string ipAllocationName, IpAllocation parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (ipAllocationName == null)
            {
                throw new ArgumentNullException(nameof(ipAllocationName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("IpAllocationsClient.StartCreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, ipAllocationName, parameters, cancellationToken);
                return(new IpAllocationsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, ipAllocationName, parameters).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 /// <summary>
 /// Creates or updates an IpAllocation in the specified resource group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='ipAllocationName'>
 /// The name of the IpAllocation.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create or update virtual network operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IpAllocation> BeginCreateOrUpdateAsync(this IIpAllocationsOperations operations, string resourceGroupName, string ipAllocationName, IpAllocation parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, ipAllocationName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates or updates an IpAllocation in the specified resource group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='ipAllocationName'>
 /// The name of the IpAllocation.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create or update virtual network operation.
 /// </param>
 public static IpAllocation BeginCreateOrUpdate(this IIpAllocationsOperations operations, string resourceGroupName, string ipAllocationName, IpAllocation parameters)
 {
     return(operations.BeginCreateOrUpdateAsync(resourceGroupName, ipAllocationName, parameters).GetAwaiter().GetResult());
 }