Beispiel #1
0
        public async virtual Task <Response <PolicyExemption> > GetAsync(string policyExemptionName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(policyExemptionName, nameof(policyExemptionName));

            using var scope = _policyExemptionClientDiagnostics.CreateScope("PolicyExemptionCollection.Get");
            scope.Start();
            try
            {
                var response = await _policyExemptionRestClient.GetAsync(Id, policyExemptionName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _policyExemptionClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new PolicyExemption(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Beispiel #2
0
        public virtual async Task <Response <PolicyExemption> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _policyExemptionClientDiagnostics.CreateScope("PolicyExemption.Get");
            scope.Start();
            try
            {
                var response = await _policyExemptionRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false);

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