Skip to content

Commit ef170a3

Browse files
authored
feat!: Add login query param support to ListCredentialAuthorizations (#3270)
BREAKING CHANGE: `ListCredentialAuthorizations` now takes `opts *CredentialAuthorizationsListOptions` instead of `ListOptions`.
1 parent 057ff1b commit ef170a3

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

github/orgs_credential_authorizations.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,23 @@ type CredentialAuthorization struct {
5555
AuthorizedCredentialExpiresAt *Timestamp `json:"authorized_credential_expires_at,omitempty"`
5656
}
5757

58+
// CredentialAuthorizationsListOptions adds the Login option as supported by the
59+
// list SAML SSO authorizations for organizations endpoint alongside paging options
60+
// such as Page and PerPage.
61+
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization
62+
type CredentialAuthorizationsListOptions struct {
63+
ListOptions
64+
// For credentials authorizations for an organization, limit the list of authorizations to a specific login (aka github username)
65+
Login string `url:"login,omitempty"`
66+
}
67+
5868
// ListCredentialAuthorizations lists credentials authorized through SAML SSO
5969
// for a given organization. Only available with GitHub Enterprise Cloud.
6070
//
6171
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization
6272
//
6373
//meta:operation GET /orgs/{org}/credential-authorizations
64-
func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *ListOptions) ([]*CredentialAuthorization, *Response, error) {
74+
func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *CredentialAuthorizationsListOptions) ([]*CredentialAuthorization, *Response, error) {
6575
u := fmt.Sprintf("orgs/%v/credential-authorizations", org)
6676
u, err := addOptions(u, opts)
6777
if err != nil {

github/orgs_credential_authorizations_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) {
2121

2222
mux.HandleFunc("/orgs/o/credential-authorizations", func(w http.ResponseWriter, r *http.Request) {
2323
testMethod(t, r, http.MethodGet)
24-
testFormValues(t, r, values{"per_page": "2", "page": "2"})
24+
testFormValues(t, r, values{"per_page": "2", "page": "2", "login": "l"})
2525
fmt.Fprint(w, `[
2626
{
2727
"login": "l",
@@ -34,7 +34,11 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) {
3434
]`)
3535
})
3636

37-
opts := &ListOptions{Page: 2, PerPage: 2}
37+
opts := &CredentialAuthorizationsListOptions{
38+
ListOptions: ListOptions{Page: 2, PerPage: 2},
39+
Login: "l",
40+
}
41+
3842
ctx := context.Background()
3943
creds, _, err := client.Organizations.ListCredentialAuthorizations(ctx, "o", opts)
4044
if err != nil {

0 commit comments

Comments
 (0)