Esempio n. 1
0
        public async virtual Task <Response <InstancePool> > GetAsync(string instancePoolName, CancellationToken cancellationToken = default)
        {
            if (instancePoolName == null)
            {
                throw new ArgumentNullException(nameof(instancePoolName));
            }

            using var scope = _clientDiagnostics.CreateScope("InstancePoolCollection.Get");
            scope.Start();
            try
            {
                var response = await _instancePoolsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, instancePoolName, cancellationToken).ConfigureAwait(false);

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

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