コード例 #1
0
        public virtual Response <SubscriptionUsage> Get(string locationName, string usageName, CancellationToken cancellationToken = default)
        {
            if (locationName == null)
            {
                throw new ArgumentNullException(nameof(locationName));
            }
            if (usageName == null)
            {
                throw new ArgumentNullException(nameof(usageName));
            }

            using var scope = _clientDiagnostics.CreateScope("SubscriptionUsageCollection.Get");
            scope.Start();
            try
            {
                var response = _subscriptionUsagesRestClient.Get(Id.SubscriptionId, locationName, usageName, cancellationToken);
                if (response.Value == null)
                {
                    throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new SubscriptionUsage(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #2
0
        public virtual Response <SubscriptionUsageResource> Get(string usageName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(usageName, nameof(usageName));

            using var scope = _subscriptionUsageClientDiagnostics.CreateScope("SubscriptionUsageCollection.Get");
            scope.Start();
            try
            {
                var response = _subscriptionUsageRestClient.Get(Id.SubscriptionId, _locationName, usageName, cancellationToken);
                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new SubscriptionUsageResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #3
0
 public virtual Response <SubscriptionUsage> Get(CancellationToken cancellationToken = default)
 {
     using var scope = _subscriptionUsageClientDiagnostics.CreateScope("SubscriptionUsage.Get");
     scope.Start();
     try
     {
         var response = _subscriptionUsageRestClient.Get(Id.SubscriptionId, Id.Parent.Name, Id.Name, cancellationToken);
         if (response.Value == null)
         {
             throw _subscriptionUsageClientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
         }
         return(Response.FromValue(new SubscriptionUsage(ArmClient, response.Value), response.GetRawResponse()));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }