public async virtual Task <Response <NatGateway> > GetAsync(string natGatewayName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (natGatewayName == null)
            {
                throw new ArgumentNullException(nameof(natGatewayName));
            }

            using var scope = _clientDiagnostics.CreateScope("NatGatewayCollection.Get");
            scope.Start();
            try
            {
                var response = await _natGatewaysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, natGatewayName, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new NatGateway(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual async Task <Response <NatGatewayResource> > GetAsync(string expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _natGatewayClientDiagnostics.CreateScope("NatGatewayResource.Get");
            scope.Start();
            try
            {
                var response = await _natGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new NatGatewayResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }