Skip to content

Commit

Permalink
[SDK-4715] Update documentation to state List related functions shoul…
Browse files Browse the repository at this point in the history
…d be paginated (#328)
  • Loading branch information
ewanharris committed Dec 11, 2023
1 parent 9fef632 commit 5698f33
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 24 deletions.
10 changes: 8 additions & 2 deletions management/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ func (m *ActionManager) Delete(ctx context.Context, id string, opts ...RequestOp
return m.management.Request(ctx, "DELETE", m.management.URI("actions", "actions", id), nil, opts...)
}

// List all actions.
// List actions.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Actions/get_actions
func (m *ActionManager) List(ctx context.Context, opts ...RequestOption) (l *ActionList, err error) {
Expand All @@ -266,7 +268,9 @@ func (m *ActionManager) Version(ctx context.Context, id string, versionID string
return
}

// Versions lists all versions of an action.
// Versions lists versions of an action.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_action_versions
func (m *ActionManager) Versions(ctx context.Context, id string, opts ...RequestOption) (c *ActionVersionList, err error) {
Expand All @@ -286,6 +290,8 @@ func (m *ActionManager) UpdateBindings(ctx context.Context, triggerID string, b

// Bindings lists the bindings of a trigger.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Actions/get_bindings
func (m *ActionManager) Bindings(ctx context.Context, triggerID string, opts ...RequestOption) (bl *ActionBindingList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("actions", "triggers", triggerID, "bindings"), &bl, applyActionsListDefaults(opts))
Expand Down
3 changes: 2 additions & 1 deletion management/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type BlacklistToken struct {
// BlacklistManager manages Auth0 BlacklistToken resources.
type BlacklistManager manager

// List all tokens that are blacklisted.
// List tokens that are blacklisted.
//
// Note: The JWT specification states that the `jti` field can be used to
// prevent replay attacks. Though Auth0 tokens do not include a `jti`, you can
Expand All @@ -30,6 +30,7 @@ type BlacklistManager manager
// token gets stolen, it (or the tokens issued after it) should be blacklisted
// and let expire.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
// See: https://auth0.com/docs/api/management/v2#!/Blacklists/get_tokens
func (m *BlacklistManager) List(ctx context.Context, opts ...RequestOption) (bl []*BlacklistToken, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("blacklists", "tokens"), &bl, applyListDefaults(opts))
Expand Down
8 changes: 6 additions & 2 deletions management/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ func (m *ClientManager) Read(ctx context.Context, id string, opts ...RequestOpti
return
}

// List all client applications.
// List client applications.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Clients/get_clients
func (m *ClientManager) List(ctx context.Context, opts ...RequestOption) (c *ClientList, err error) {
Expand Down Expand Up @@ -587,7 +589,9 @@ func (m *ClientManager) UpdateCredential(ctx context.Context, clientID, credenti
return nil
}

// ListCredentials lists all client credentials associated with the client application.
// ListCredentials lists client credentials associated with the client application.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
func (m *ClientManager) ListCredentials(ctx context.Context, clientID string, opts ...RequestOption) (c []*Credential, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("clients", clientID, "credentials"), &c, applyListDefaults(opts))
return
Expand Down
6 changes: 5 additions & 1 deletion management/client_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ func (m *ClientGrantManager) Delete(ctx context.Context, id string, opts ...Requ
return m.management.Request(ctx, "DELETE", m.management.URI("client-grants", id), nil, opts...)
}

// List all client grants.
// List client grants.
//
// This method forces the `include_totals=true` and defaults to `per_page=50` if
// not provided.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grants
func (m *ClientGrantManager) List(ctx context.Context, opts ...RequestOption) (gs *ClientGrantList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("client-grants"), &gs, applyListDefaults(opts))
Expand All @@ -101,6 +103,8 @@ func (m *ClientGrantManager) List(ctx context.Context, opts ...RequestOption) (g
//
// This method forces the `include_totals=true` and defaults to `per_page=50` if
// not provided.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
func (m *ClientGrantManager) Organizations(ctx context.Context, id string, opts ...RequestOption) (o *OrganizationList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("client-grants", id, "organizations"), &o, applyListDefaults(opts))
return
Expand Down
4 changes: 3 additions & 1 deletion management/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,9 @@ func (m *ConnectionManager) Read(ctx context.Context, id string, opts ...Request
return
}

// List all connections.
// List connections.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Connections/get_connections
func (m *ConnectionManager) List(ctx context.Context, opts ...RequestOption) (c *ConnectionList, err error) {
Expand Down
2 changes: 2 additions & 0 deletions management/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type GrantManager manager

// List the grants associated with your account.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Grants/get_grants
func (m *GrantManager) List(ctx context.Context, opts ...RequestOption) (g *GrantList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("grants"), &g, applyListDefaults(opts))
Expand Down
4 changes: 3 additions & 1 deletion management/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ func (m *HookManager) Delete(ctx context.Context, id string, opts ...RequestOpti
return m.management.Request(ctx, "DELETE", m.management.URI("hooks", id), nil, opts...)
}

// List all hooks.
// List hooks.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Hooks/get_hooks
func (m *HookManager) List(ctx context.Context, opts ...RequestOption) (l *HookList, err error) {
Expand Down
16 changes: 14 additions & 2 deletions management/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ type OrganizationManager manager

// List available organizations.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations
func (m *OrganizationManager) List(ctx context.Context, opts ...RequestOption) (o *OrganizationList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("organizations"), &o, applyListDefaults(opts))
Expand Down Expand Up @@ -240,6 +242,8 @@ func (m *OrganizationManager) ReadByName(ctx context.Context, name string, opts

// Connections retrieves connections enabled for an organization.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections
func (m *OrganizationManager) Connections(ctx context.Context, id string, opts ...RequestOption) (c *OrganizationConnectionList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("organizations", id, "enabled_connections"), &c, applyListDefaults(opts))
Expand Down Expand Up @@ -279,6 +283,8 @@ func (m *OrganizationManager) UpdateConnection(ctx context.Context, id string, c
}

// Invitations retrieves invitations to organization.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
// Note that when paginating this response the `HasNext` helper cannot be used, so instead check the length of the returned list
// manually and break when there are 0 entries. See https://github.com/auth0/go-auth0/issues/48 for more context.
//
Expand Down Expand Up @@ -314,6 +320,8 @@ func (m *OrganizationManager) DeleteInvitation(ctx context.Context, id string, i

// Members lists organization members.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
func (m *OrganizationManager) Members(ctx context.Context, id string, opts ...RequestOption) (o *OrganizationMemberList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("organizations", id, "members"), &o, applyListDefaults(opts))
Expand Down Expand Up @@ -348,6 +356,8 @@ func (m *OrganizationManager) DeleteMembers(ctx context.Context, id string, memb

// MemberRoles retrieves the roles assigned to an organization member.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2/#!/Organizations/get_organization_member_roles
func (m *OrganizationManager) MemberRoles(ctx context.Context, id string, memberID string, opts ...RequestOption) (r *OrganizationMemberRoleList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("organizations", id, "members", memberID, "roles"), &r, applyListDefaults(opts))
Expand Down Expand Up @@ -381,6 +391,8 @@ func (m *OrganizationManager) DeleteMemberRoles(ctx context.Context, id string,
}

// ClientGrants retrieves the client grants assigned to an organization.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
func (m *OrganizationManager) ClientGrants(ctx context.Context, id string, opts ...RequestOption) (g *ClientGrantList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("organizations", id, "client-grants"), &g, applyListDefaults(opts))
return
Expand All @@ -393,12 +405,12 @@ func (m *OrganizationManager) AssociateClientGrant(ctx context.Context, id strin
}{
GrantID: grantID,
}
err = m.management.Request(ctx, "POST", m.management.URI("organizations", id, "client-grants"), &body, applyListDefaults(opts))
err = m.management.Request(ctx, "POST", m.management.URI("organizations", id, "client-grants"), &body, opts...)
return
}

// RemoveClientGrant removes a client grant from an organization.
func (m *OrganizationManager) RemoveClientGrant(ctx context.Context, id string, grantID string, opts ...RequestOption) (err error) {
err = m.management.Request(ctx, "DELETE", m.management.URI("organizations", id, "client-grants", grantID), nil, applyListDefaults(opts))
err = m.management.Request(ctx, "DELETE", m.management.URI("organizations", id, "client-grants", grantID), nil, opts...)
return
}
4 changes: 3 additions & 1 deletion management/resource_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (m *ResourceServerManager) Delete(ctx context.Context, id string, opts ...R
return m.management.Request(ctx, "DELETE", m.management.URI("resource-servers", id), nil, opts...)
}

// List all resource server.
// List resource server.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers
func (m *ResourceServerManager) List(ctx context.Context, opts ...RequestOption) (rl *ResourceServerList, err error) {
Expand Down
12 changes: 9 additions & 3 deletions management/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (m *RoleManager) Delete(ctx context.Context, id string, opts ...RequestOpti
return m.management.Request(ctx, "DELETE", m.management.URI("roles", id), &Role{}, opts...)
}

// List all roles that can be assigned to users or groups.
// List roles that can be assigned to users or groups.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Roles/get_roles
func (m *RoleManager) List(ctx context.Context, opts ...RequestOption) (r *RoleList, err error) {
Expand All @@ -97,7 +99,9 @@ func (m *RoleManager) AssignUsers(ctx context.Context, id string, users []*User,
return m.management.Request(ctx, "POST", m.management.URI("roles", id, "users"), &u, opts...)
}

// Users retrieves all users associated with a role.
// Users retrieves users associated with a role.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Roles/get_role_user
func (m *RoleManager) Users(ctx context.Context, id string, opts ...RequestOption) (u *UserList, err error) {
Expand All @@ -114,7 +118,9 @@ func (m *RoleManager) AssociatePermissions(ctx context.Context, id string, permi
return m.management.Request(ctx, "POST", m.management.URI("roles", id, "permissions"), &p, opts...)
}

// Permissions retrieves all permissions granted by a role.
// Permissions retrieves permissions granted by a role.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Roles/get_role_permission
func (m *RoleManager) Permissions(ctx context.Context, id string, opts ...RequestOption) (p *PermissionList, err error) {
Expand Down
4 changes: 3 additions & 1 deletion management/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ func (m *RuleManager) Delete(ctx context.Context, id string, opts ...RequestOpti
return m.management.Request(ctx, "DELETE", m.management.URI("rules", id), nil, opts...)
}

// List all rules.
// List rules.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Rules/get_rules
func (m *RuleManager) List(ctx context.Context, opts ...RequestOption) (r *RuleList, err error) {
Expand Down
4 changes: 3 additions & 1 deletion management/rule_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (m *RuleConfigManager) Delete(ctx context.Context, key string, opts ...Requ
return m.management.Request(ctx, "DELETE", m.management.URI("rules-configs", key), nil, opts...)
}

// List all rule configuration variables.
// List rule configuration variables.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Rules_Configs/get_rules_configs
func (m *RuleConfigManager) List(ctx context.Context, opts ...RequestOption) (r []*RuleConfig, err error) {
Expand Down
16 changes: 13 additions & 3 deletions management/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ func (m *UserManager) Delete(ctx context.Context, id string, opts ...RequestOpti
return m.management.Request(ctx, "DELETE", m.management.URI("users", id), nil, opts...)
}

// List all users. This method forces the `include_totals` option.
// List users. This method forces the `include_totals` option.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_users
func (m *UserManager) List(ctx context.Context, opts ...RequestOption) (ul *UserList, err error) {
Expand Down Expand Up @@ -478,7 +480,9 @@ func (m *UserManager) ListByEmail(ctx context.Context, email string, opts ...Req
return
}

// Roles lists all roles associated with a user.
// Roles lists roles associated with a user.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_user_roles
func (m *UserManager) Roles(ctx context.Context, id string, opts ...RequestOption) (r *RoleList, err error) {
Expand Down Expand Up @@ -512,6 +516,8 @@ func (m *UserManager) RemoveRoles(ctx context.Context, id string, roles []*Role,

// Permissions lists the permissions associated to the user.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_permissions
func (m *UserManager) Permissions(ctx context.Context, id string, opts ...RequestOption) (p *PermissionList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("users", id, "permissions"), &p, applyListDefaults(opts))
Expand Down Expand Up @@ -653,6 +659,8 @@ func (m *UserManager) Unlink(ctx context.Context, id, provider, userID string, o

// Organizations lists user's organizations.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_organizations
func (m *UserManager) Organizations(ctx context.Context, id string, opts ...RequestOption) (p *OrganizationList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("users", id, "organizations"), &p, applyListDefaults(opts))
Expand All @@ -661,6 +669,8 @@ func (m *UserManager) Organizations(ctx context.Context, id string, opts ...Requ

// ListAuthenticationMethods retrieves a list of authentication methods.
//
// For information on how to paginate using this function see https://pkg.go.dev/github.com/auth0/go-auth0/management#hdr-Page_Based_Pagination
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods
func (m *UserManager) ListAuthenticationMethods(ctx context.Context, userID string, opts ...RequestOption) (a *AuthenticationMethodList, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("users", userID, "authentication-methods"), &a, applyListDefaults(opts))
Expand All @@ -671,7 +681,7 @@ func (m *UserManager) ListAuthenticationMethods(ctx context.Context, userID stri
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods_by_authentication_method_id
func (m *UserManager) GetAuthenticationMethodByID(ctx context.Context, userID string, id string, opts ...RequestOption) (a *AuthenticationMethod, err error) {
err = m.management.Request(ctx, "GET", m.management.URI("users", userID, "authentication-methods", id), &a, applyListDefaults(opts))
err = m.management.Request(ctx, "GET", m.management.URI("users", userID, "authentication-methods", id), &a, opts...)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ interactions:
- application/json
User-Agent:
- Go-Auth0/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_OjbL69ZRTlpNCzsC/client-grants?include_totals=true&per_page=50
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_OjbL69ZRTlpNCzsC/client-grants
method: POST
response:
proto: HTTP/2.0
Expand Down
Loading

0 comments on commit 5698f33

Please sign in to comment.