Exemple #1
0
        public virtual async Task <Response <HostPool> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _hostPoolClientDiagnostics.CreateScope("HostPool.Get");
            scope.Start();
            try
            {
                var response = await _hostPoolRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new HostPool(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <Response <HostPool> > GetAsync(string hostPoolName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(hostPoolName, nameof(hostPoolName));

            using var scope = _hostPoolClientDiagnostics.CreateScope("HostPoolCollection.Get");
            scope.Start();
            try
            {
                var response = await _hostPoolRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, hostPoolName, cancellationToken).ConfigureAwait(false);

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