public virtual Response <PolicyAssignmentResource> Get(string policyAssignmentName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); using var scope = _policyAssignmentClientDiagnostics.CreateScope("PolicyAssignmentCollection.Get"); scope.Start(); try { var response = _policyAssignmentRestClient.Get(Id, policyAssignmentName, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new PolicyAssignmentResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <PolicyAssignment> Get(CancellationToken cancellationToken = default) { using var scope = _policyAssignmentClientDiagnostics.CreateScope("PolicyAssignment.Get"); scope.Start(); try { var response = _policyAssignmentRestClient.Get(Id.Parent, Id.Name, cancellationToken); if (response.Value == null) { throw _policyAssignmentClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new PolicyAssignment(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }