public async virtual Task <Response <ServiceEndpointPolicy> > GetAsync(string serviceEndpointPolicyName, string expand = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ServiceEndpointPolicyCollection.Get"); scope.Start(); try { if (serviceEndpointPolicyName == null) { throw new ArgumentNullException(nameof(serviceEndpointPolicyName)); } var response = await _restClient.GetAsync(Id.ResourceGroupName, serviceEndpointPolicyName, expand, cancellationToken : cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new ServiceEndpointPolicy(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <ServiceEndpointPolicy> > GetAsync(string expand = null, CancellationToken cancellationToken = default) { using var scope = _serviceEndpointPolicyClientDiagnostics.CreateScope("ServiceEndpointPolicy.Get"); scope.Start(); try { var response = await _serviceEndpointPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _serviceEndpointPolicyClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new ServiceEndpointPolicy(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <ServiceEndpointPolicyResource> > GetAsync(string serviceEndpointPolicyName, string expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(serviceEndpointPolicyName, nameof(serviceEndpointPolicyName)); using var scope = _serviceEndpointPolicyClientDiagnostics.CreateScope("ServiceEndpointPolicyCollection.Get"); scope.Start(); try { var response = await _serviceEndpointPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, serviceEndpointPolicyName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ServiceEndpointPolicyResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }