Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Add login query param support to ListCredentialAuthorizations #3270

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion github/orgs_credential_authorizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,23 @@ type CredentialAuthorization struct {
AuthorizedCredentialExpiresAt *Timestamp `json:"authorized_credential_expires_at,omitempty"`
}

// CredentialAuthorizationsListOptions adds the Login option as supported by the
// list SAML SSO authorizations for organizations endpoint alongside paging options
// such as Page and PerPage
zeusdeux marked this conversation as resolved.
Show resolved Hide resolved
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization
type CredentialAuthorizationsListOptions struct {
ListOptions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chose to embed ListOptions instead of extending it as it is reused for other List* functions which don't necessarily support the login query parameter.

// For credentials authorizations for an organization, limit the list of authorizations to a specific login (aka github username)
Login string `url:"login,omitempty"`
}

// ListCredentialAuthorizations lists credentials authorized through SAML SSO
// for a given organization. Only available with GitHub Enterprise Cloud.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization
//
//meta:operation GET /orgs/{org}/credential-authorizations
func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *ListOptions) ([]*CredentialAuthorization, *Response, error) {
func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *CredentialAuthorizationsListOptions) ([]*CredentialAuthorization, *Response, error) {
u := fmt.Sprintf("orgs/%v/credential-authorizations", org)
u, err := addOptions(u, opts)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion github/orgs_credential_authorizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) {
]`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
opts := &CredentialAuthorizationsListOptions{
ListOptions: ListOptions{Page: 2, PerPage: 2},
}

ctx := context.Background()
creds, _, err := client.Organizations.ListCredentialAuthorizations(ctx, "o", opts)
if err != nil {
Expand Down
Loading