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

            using var scope = _clientDiagnostics.CreateScope("JobCredentialCollection.Get");
            scope.Start();
            try
            {
                var response = await _jobCredentialsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, credentialName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new JobCredential(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 public virtual async Task<Response<JobCredentialResource>> GetAsync(CancellationToken cancellationToken = default)
 {
     using var scope = _jobCredentialClientDiagnostics.CreateScope("JobCredentialResource.Get");
     scope.Start();
     try
     {
         var response = await _jobCredentialRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
         if (response.Value == null)
             throw new RequestFailedException(response.GetRawResponse());
         return Response.FromValue(new JobCredentialResource(Client, response.Value), response.GetRawResponse());
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }