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

            using var scope = _clientDiagnostics.CreateScope("AfdRouteCollection.Get");
            scope.Start();
            try
            {
                var response = await _afdRoutesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new AfdRoute(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 public async virtual Task<Response<AfdRoute>> GetAsync(CancellationToken cancellationToken = default)
 {
     using var scope = _afdRouteClientDiagnostics.CreateScope("AfdRoute.Get");
     scope.Start();
     try
     {
         var response = await _afdRouteRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
         if (response.Value == null)
             throw await _afdRouteClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
         return Response.FromValue(new AfdRoute(Client, response.Value), response.GetRawResponse());
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }