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

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

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

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