public virtual Response <ServiceEndpointPolicy> Get(string expand = null, CancellationToken cancellationToken = default) { using var scope = _serviceEndpointPolicyClientDiagnostics.CreateScope("ServiceEndpointPolicy.Get"); scope.Start(); try { var response = _serviceEndpointPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken); if (response.Value == null) { throw _serviceEndpointPolicyClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ServiceEndpointPolicy(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <ServiceEndpointPolicy> Get(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 = _restClient.Get(Id.ResourceGroupName, serviceEndpointPolicyName, expand, cancellationToken: cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ServiceEndpointPolicy(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }