示例#1
0
        public async virtual Task <Response <PublicIPPrefix> > GetAsync(string publicIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("PublicIPPrefixContainer.Get");
            scope.Start();
            try
            {
                if (publicIpPrefixName == null)
                {
                    throw new ArgumentNullException(nameof(publicIpPrefixName));
                }

                var response = await _restClient.GetAsync(Id.ResourceGroupName, publicIpPrefixName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new PublicIPPrefix(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 public virtual async Task<Response<PublicIPPrefixResource>> GetAsync(string expand = null, CancellationToken cancellationToken = default)
 {
     using var scope = _publicIPPrefixClientDiagnostics.CreateScope("PublicIPPrefixResource.Get");
     scope.Start();
     try
     {
         var response = await _publicIPPrefixRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false);
         if (response.Value == null)
             throw new RequestFailedException(response.GetRawResponse());
         return Response.FromValue(new PublicIPPrefixResource(Client, response.Value), response.GetRawResponse());
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
示例#3
0
        public async virtual Task <Response <PublicIPPrefix> > GetAsync(string publicIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(publicIpPrefixName, nameof(publicIpPrefixName));

            using var scope = _publicIPPrefixClientDiagnostics.CreateScope("PublicIPPrefixCollection.Get");
            scope.Start();
            try
            {
                var response = await _publicIPPrefixRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, publicIpPrefixName, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _publicIPPrefixClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new PublicIPPrefix(ArmClient, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }