MCPcopy Create free account
hub / github.com/auth0/auth0-cli / getOrgInvitations

Method getOrgInvitations

internal/cli/organizations.go:1145–1179  ·  view source on GitHub ↗
(
	context context.Context,
	orgID string,
	number int,
)

Source from the content-addressed store, hash-verified

1143}
1144
1145func (c *cli) getOrgInvitations(
1146 context context.Context,
1147 orgID string,
1148 number int,
1149) ([]management.OrganizationInvitation, error) {
1150 list, err := getWithPagination(
1151 number,
1152 func(opts ...management.RequestOption) (result []interface{}, hasNext bool, apiErr error) {
1153 // Add sort option to existing opts.
1154 opts = append(opts, management.Sort("created_at:-1"))
1155 invitations, apiErr := c.api.Organization.Invitations(context, url.PathEscape(orgID), opts...)
1156 if apiErr != nil {
1157 return nil, false, apiErr
1158 }
1159 var output []interface{}
1160 for _, invitation := range invitations.OrganizationInvitations {
1161 if invitation != nil {
1162 output = append(output, *invitation)
1163 }
1164 }
1165 // Invitations does not return total count yet, so we determine there is a next page if current page is not empty.
1166 return output, !isEmptyInvitationList(invitations), nil
1167 },
1168 )
1169 if err != nil {
1170 return nil, fmt.Errorf("failed to list invitations of organization with ID %q: %w", orgID, err)
1171 }
1172
1173 var typedList []management.OrganizationInvitation
1174 for _, item := range list {
1175 typedList = append(typedList, item.(management.OrganizationInvitation))
1176 }
1177
1178 return typedList, nil
1179}
1180
1181func isEmptyInvitationList(invs *management.OrganizationInvitationList) bool {
1182 return invs == nil || len(invs.OrganizationInvitations) == 0

Callers 1

Calls 4

getWithPaginationFunction · 0.85
isEmptyInvitationListFunction · 0.85
ErrorfMethod · 0.80
InvitationsMethod · 0.65

Tested by

no test coverage detected