예제 #1
0
        public async virtual Task <Response <AfdEndpoint> > GetAsync(string endpointName, CancellationToken cancellationToken = default)
        {
            if (endpointName == null)
            {
                throw new ArgumentNullException(nameof(endpointName));
            }

            using var scope = _clientDiagnostics.CreateScope("AfdEndpointCollection.Get");
            scope.Start();
            try
            {
                var response = await _afdEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new AfdEndpoint(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #2
0
        public virtual async Task <Response <AfdEndpointResource> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _afdEndpointClientDiagnostics.CreateScope("AfdEndpointResource.Get");
            scope.Start();
            try
            {
                var response = await _afdEndpointRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);

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