Skip to content

Commit ce438a4

Browse files
authored
Manage Organization Invitations (#1424)
* feat(organization): add Invitations method to OrganizationAPI - Implemented the Invitations method in the OrganizationAPI interface to list invitations for an organization. - Generated corresponding mock methods in organization_mock.go for testing. - This change enhances the API's functionality by allowing retrieval of organization invitations, aligning with the management API documentation. * feat(invitations): add commands to list organization invitations - Introduced `invitationsOrganizationCmd` to handle invitations management. - Added `listInvitationsOrganizationCmd` for listing organization invitations with options for pagination and output formats. - Implemented `getOrgInvitationsWithSpinner` and `getOrgInvitations` methods for fetching invitations from the API. - Created `invitationsView` struct for displaying invitation details in a structured format. * feat(invitations): add documentation for managing organization invitations - Introduced a new section for managing invitations within organizations. - Added a new file `auth0_orgs_invitations.md` detailing the invitation management commands. - Created `auth0_orgs_invitations_list.md` to document the command for listing invitations. - Updated existing documentation files to include links to the new invitations section. This change enhances the usability of the Auth0 CLI by providing clear guidance on managing organization invitations. * feat(organization): add CreateInvitation method to OrganizationAPI - Implemented CreateInvitation method in OrganizationAPI interface to facilitate creating invitations for organizations. - Added corresponding mock methods in organization_mock.go for testing purposes. - This change enhances the API's functionality, allowing users to manage organization invitations more effectively. * feat(invitations): implement create invitation command and update docs - Added `create` command to manage organization invitations, allowing users to create new invitations. - Introduced flags for inviter name, invitee email, client ID, connection ID, TTL seconds, and metadata. - Updated `auth0_orgs_invitations.md` to include the new command. - Created detailed documentation in `auth0_orgs_invitations_create.md` for usage and examples. - Enhanced `auth0_orgs_invitations_list.md` to reference the new create command. - Updated `invitations.go` to reflect changes in field names for consistency. * feat(invitations): add delete invitation command and related functionality - Implemented the DeleteInvitation method in the OrganizationAPI interface to allow deletion of invitations. - Added DeleteInvitation mock methods in organization_mock.go for testing purposes. - Created a new delete command in organizations.go to handle invitation deletions, including interactive and non-interactive modes. - Introduced invitationPickerOptions method to facilitate selection of invitations for deletion. - Added unit tests for invitationPickerOptions to ensure correct behavior under various scenarios. * fix(arguments): ensure if user can be prompted before fetching picker options - Fixed PickMany to validate if the command can prompt for required arguments. - This prevents making redundant GET api calls to list picker options. - Removed the unused selectArgument function to streamline the code. * feat(invitations): add show invitation command and related functionality - Implemented the `show` command for displaying organization invitations. - Added `Invitation` method to the `OrganizationAPI` interface in `organization.go`. - Created mock methods in `organization_mock.go` for testing the new functionality. - Updated `invitations.go` to include a new renderer method for showing invitations. * feat(invitations): add aliase invs for invitations commands - Introduced aliases for the invitations commands to enhance usability: - Updated examples in the command documentation to reflect the new aliases. - This change aims to streamline command usage and improve user experience. * feat(invitations): add integration tests for organization invitations - Implemented new test cases for listing, creating, showing, and deleting organization invitations. - Added tests to verify behavior with valid and invalid inputs, including edge cases for missing arguments and invalid IDs. - Created a new script `get-org-invitation-id.sh` to facilitate the retrieval of invitation IDs for testing. - Updated existing `get-app-id.sh` script to ensure compatibility with the organization-invitation functionality. * feat(invitations): add required scopes for organization invitations - Added new required scopes for managing organization invitations: - `read:organization_invitations` - `create:organization_invitations` - `delete:organization_invitations` This change is necessary to ensure that the application has the appropriate permissions to handle organization invitations effectively. * feat(tests): Use generic extra scopes for testing instead of organization_invitations - Replaced the previous organization invitation scopes with generic extra scopes for better test coverage. * chore(invitations): increase retry count for organization invitation tests * feat(tests): add cleanup script for app identifier after deletion - Introduced a new script `delete-app-id.sh` to remove the app identifier file created during integration tests. - This script ensures that the identifier file is deleted only if the app is successfully removed, preventing stale data in subsequent test runs. - Updated the test case for app deletion to call this cleanup script after the app is deleted. * chore(invitations): remove TODO comment regarding additional fields in invitationsView * chore(invitations): remove the short form for the `--client-id` flag in the command - Updated example commands in the documentation to reflect the removal of the short form. - Ensured consistency in the command usage by using the long form for `--client-id`. * fix(invitations): update invitation retrieval method in organizationPickerOptions - Changed the method of fetching organization invitations from a local function to a direct API call. - Updated the variable names for clarity, changing `invitations` to `orgInvitations` and `value` to `id`. * fix(invitations): update metadata handling in invitation creation - Changed AppMetadata and UserMetadata from map[string]string to string to accept JSON formatted input. - Updated help text for flags to clarify expected data format. - Adjusted JSON unmarshalling logic in createInvitationOrganizationCmd to handle new string format. - Ensured compatibility with existing functionality while improving data handling for user and app metadata. * fix(invitations): enhance documentation for organization invitations - Updated the long descriptions for commands related to organization invitations to provide clearer guidance on usage. - Added interactive and non-interactive usage instructions for the following commands: - `auth0 orgs invs create` - `auth0 orgs invs list` - `auth0 orgs invs show` - Improved user understanding of how to manage invitations effectively. * chore(invitations): improve organization invitation commands - Changed the variable name from `ID` to `OrgID` for clarity in `listInvitationsOrganizationCmd`. - Removed the `getOrgInvitationsWithSpinner` function as it was redundant. - Added sorting flag to invitation list API req. * fix(invitations): update invitation list has next logic - Enhanced the logic in `getOrgInvitations` to determine if there are more invitations based on whether the current page is empty, using a new helper function `isEmptyInvitationList`. * feat(invitations): enhance organization invitation commands to read org and inv id as flags - Added new flags for Organization ID and Invitation ID to improve command usability. - Updated command arguments to use flags instead of positional arguments for better clarity. - Revised command descriptions and examples to reflect the new flag usage. - Ensured that the commands now support interactive and non-interactive modes consistently. * chore(invitations): add an example to disable email sending for invitations * fix(invitations): remove CreatedAt field from invitations view - Removed the CreatedAt field from the invitationsView struct and its related methods. - Updated AsTableHeader, AsTableRow, and KeyValues methods to reflect this change. - This simplifies the invitation display by focusing on relevant fields, improving clarity for users. * feat(invitations): add unit tests for invitationsView methods - Implemented unit tests for the invitationsView struct to ensure proper functionality. - Added tests for AsTableHeader, AsTableRow, KeyValues, Object, and makeInvitationsView methods. - These tests validate the expected output for various invitation attributes, enhancing code reliability and maintainability. * chore(invitations): replace auth0.String with pointer function for invitation fields * feat(arguments, flags, input): introduced `PickMany` and `PickManyU` methods in the `Flag` struct to handle multiple flag selections. - Updated `askMultiSelect` to accept an `isUpdate` parameter for better control over input validation. - Modified `PickMany` in the `Argument` struct to support the new multi-select behavior. * refactor(invitations): update invs delete to accept org and inv ids as flag. - Enhanced the delete command to accept multiple invitation IDs in flag for deletion. - Improved command examples for clarity on usage. * refactor(invitations): update test commands to use org-id on invitation-id flags - Updated test cases for listing, creating, showing, and deleting organization invitations to reflect this change. * refactor(invitations): update error messages and command flags - Changed error messages for missing Org ID and Invitation ID to be more descriptive. - Updated the command for creating an invitation to explicitly include the `--org-id` flag for clarity. - Adjusted the command for listing invitations to use the `--org-id` flag instead of positional arguments. * refactor(invitations): reorder Connection ID in invitations display - Updated the invitationsView struct to move ConnectionID to the end of the fields. - Adjusted the AsTableHeader, AsTableRow, and KeyValues methods to reflect the new order. - This change improves the consistency of the output format when displaying invitation details. * refactor(tests): update organization invitation tests and remove unused script - Refactored organization invitation test cases for clarity and consistency. - Removed the `delete-app-id.sh` script as it was no longer needed. - Introduced `get-org-inv-app-id.sh` to handle organization invitation app ID creation and management. - Ensured that the new script enables organization support for the created app. * refactor(flags, input): simplify flag multi-selection methods - Removed the isUpdate parameter from PickMany and pickManyFlag methods to streamline the flag selection process. - Updated askMultiSelect to directly use prompt.AskMultiSelect * refactor(scripts): update app_id retrieval in get-org-invitation-id.sh - Changed the app_id retrieval in get-org-invitation-id.sh to use get-org-inv-app-id.sh instead of get-app-id.sh. - This change ensures that the correct application ID is used for organization invitations, improving the accuracy of the integration tests.
1 parent 445949f commit ce438a4

25 files changed

Lines changed: 1249 additions & 21 deletions

docs/auth0_orgs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The Auth0 Organizations feature best supports business-to-business (B2B) impleme
1111

1212
- [auth0 orgs create](auth0_orgs_create.md) - Create a new organization
1313
- [auth0 orgs delete](auth0_orgs_delete.md) - Delete an organization
14+
- [auth0 orgs invitations](auth0_orgs_invitations.md) - Manage invitations of an organization
1415
- [auth0 orgs list](auth0_orgs_list.md) - List your organizations
1516
- [auth0 orgs members](auth0_orgs_members.md) - Manage members of an organization
1617
- [auth0 orgs open](auth0_orgs_open.md) - Open the settings page of an organization

docs/auth0_orgs_create.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ auth0 orgs create [flags]
5555

5656
- [auth0 orgs create](auth0_orgs_create.md) - Create a new organization
5757
- [auth0 orgs delete](auth0_orgs_delete.md) - Delete an organization
58+
- [auth0 orgs invitations](auth0_orgs_invitations.md) - Manage invitations of an organization
5859
- [auth0 orgs list](auth0_orgs_list.md) - List your organizations
5960
- [auth0 orgs members](auth0_orgs_members.md) - Manage members of an organization
6061
- [auth0 orgs open](auth0_orgs_open.md) - Open the settings page of an organization

docs/auth0_orgs_delete.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ auth0 orgs delete [flags]
4949

5050
- [auth0 orgs create](auth0_orgs_create.md) - Create a new organization
5151
- [auth0 orgs delete](auth0_orgs_delete.md) - Delete an organization
52+
- [auth0 orgs invitations](auth0_orgs_invitations.md) - Manage invitations of an organization
5253
- [auth0 orgs list](auth0_orgs_list.md) - List your organizations
5354
- [auth0 orgs members](auth0_orgs_members.md) - Manage members of an organization
5455
- [auth0 orgs open](auth0_orgs_open.md) - Open the settings page of an organization

docs/auth0_orgs_invitations.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
layout: default
3+
has_toc: false
4+
has_children: true
5+
---
6+
# auth0 orgs invitations
7+
8+
Manage invitations of an organization. Invitations enable adding users to an organization by sending an email containing the join link. To learn more, read [Invite Members to Organizations](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members).
9+
10+
## Commands
11+
12+
- [auth0 orgs invitations create](auth0_orgs_invitations_create.md) - Create a new invitation to an organization
13+
- [auth0 orgs invitations delete](auth0_orgs_invitations_delete.md) - Delete invitation(s) from an organization
14+
- [auth0 orgs invitations list](auth0_orgs_invitations_list.md) - List invitations of an organization
15+
- [auth0 orgs invitations show](auth0_orgs_invitations_show.md) - Show an organization invitation
16+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
layout: default
3+
parent: auth0 orgs invitations
4+
has_toc: false
5+
---
6+
# auth0 orgs invitations create
7+
8+
Create a new invitation to an organization with required and optional parameters.
9+
10+
To create interactively, use `auth0 orgs invs create` with no flags and answer the prompts.
11+
12+
To create non-interactively, supply the organization id and the other parameters through flags.
13+
14+
## Usage
15+
```
16+
auth0 orgs invitations create [flags]
17+
```
18+
19+
## Examples
20+
21+
```
22+
auth0 orgs invs create
23+
auth0 orgs invs create --org-id <org-id>
24+
auth0 orgs invs create --org-id <org-id> --inviter-name "Inviter Name" --invitee-email "invitee@example.com"
25+
auth0 orgs invs create --org-id <org-id> --invitee-email "invitee@example.com" --client-id "client_id"
26+
auth0 orgs invs create --org-id <org-id> -n "Inviter Name" -e "invitee@example.com" --client-id "client_id" --connection-id "connection_id" -t 86400
27+
auth0 orgs invs create --org-id <org-id> --json --send-email=false --inviter-name "Inviter Name"
28+
```
29+
30+
31+
## Flags
32+
33+
```
34+
-a, --app-metadata string Data related to the user that affects the application's core functionality, formatted as JSON
35+
--client-id string Auth0 client ID. Used to resolve the application's login initiation endpoint.
36+
--connection-id string The id of the connection to force invitee to authenticate with.
37+
-e, --invitee-email string Email address of the person being invited.
38+
-n, --inviter-name string Name of the person sending the invitation.
39+
--json Output in json format.
40+
--json-compact Output in compact json format.
41+
--org-id string ID of the organization.
42+
-r, --roles strings Roles IDs to associate with the user.
43+
-s, --send-email Whether to send the invitation email to the invitee. (default true)
44+
-t, --ttl-sec int Number of seconds for which the invitation is valid before expiration.
45+
-u, --user-metadata string Data related to the user that does not affect the application's core functionality, formatted as JSON
46+
```
47+
48+
49+
## Inherited Flags
50+
51+
```
52+
--debug Enable debug mode.
53+
--no-color Disable colors.
54+
--no-input Disable interactivity.
55+
--tenant string Specific tenant to use.
56+
```
57+
58+
59+
## Related Commands
60+
61+
- [auth0 orgs invitations create](auth0_orgs_invitations_create.md) - Create a new invitation to an organization
62+
- [auth0 orgs invitations delete](auth0_orgs_invitations_delete.md) - Delete invitation(s) from an organization
63+
- [auth0 orgs invitations list](auth0_orgs_invitations_list.md) - List invitations of an organization
64+
- [auth0 orgs invitations show](auth0_orgs_invitations_show.md) - Show an organization invitation
65+
66+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
layout: default
3+
parent: auth0 orgs invitations
4+
has_toc: false
5+
---
6+
# auth0 orgs invitations delete
7+
8+
Delete invitation(s) from an organization.
9+
10+
To delete interactively, use `auth0 orgs invs delete` with no flags.
11+
12+
To delete non-interactively, supply the organization id, invitation id(s) and the `--force` flag to skip confirmation.
13+
14+
## Usage
15+
```
16+
auth0 orgs invitations delete [flags]
17+
```
18+
19+
## Examples
20+
21+
```
22+
auth0 orgs invs delete
23+
auth0 orgs invs rm
24+
auth0 orgs invs delete --org-id <org-id> --invitation-id <invitation-id>
25+
auth0 orgs invs delete --org-id <org-id> --invitation-id <inv-id1>,<inv-id2>,<inv-id3>
26+
auth0 orgs invs delete --org-id <org-id> --invitation-id <invitation-id> --force
27+
```
28+
29+
30+
## Flags
31+
32+
```
33+
--force Skip confirmation.
34+
-i, --invitation-id strings ID of the invitation.
35+
--org-id string ID of the organization.
36+
```
37+
38+
39+
## Inherited Flags
40+
41+
```
42+
--debug Enable debug mode.
43+
--no-color Disable colors.
44+
--no-input Disable interactivity.
45+
--tenant string Specific tenant to use.
46+
```
47+
48+
49+
## Related Commands
50+
51+
- [auth0 orgs invitations create](auth0_orgs_invitations_create.md) - Create a new invitation to an organization
52+
- [auth0 orgs invitations delete](auth0_orgs_invitations_delete.md) - Delete invitation(s) from an organization
53+
- [auth0 orgs invitations list](auth0_orgs_invitations_list.md) - List invitations of an organization
54+
- [auth0 orgs invitations show](auth0_orgs_invitations_show.md) - Show an organization invitation
55+
56+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
layout: default
3+
parent: auth0 orgs invitations
4+
has_toc: false
5+
---
6+
# auth0 orgs invitations list
7+
8+
List the invitations of an organization.
9+
10+
To list interactively, use `auth0 orgs invs list` with no flags.
11+
12+
To list non-interactively, supply the organization id through the flags.
13+
14+
## Usage
15+
```
16+
auth0 orgs invitations list [flags]
17+
```
18+
19+
## Examples
20+
21+
```
22+
auth0 orgs invs list
23+
auth0 orgs invs ls --org-id <org-id>
24+
auth0 orgs invs list --org-id <org-id> --number 100
25+
auth0 orgs invs ls --org-id <org-id> -n 50 --json
26+
auth0 orgs invs ls --org-id <org-id> -n 500 --json-compact
27+
auth0 orgs invs ls --org-id <org-id> --csv
28+
```
29+
30+
31+
## Flags
32+
33+
```
34+
--csv Output in csv format.
35+
--json Output in json format.
36+
--json-compact Output in compact json format.
37+
-n, --number int Number of organization invitations to retrieve. Minimum 1, maximum 1000. (default 100)
38+
--org-id string ID of the organization.
39+
```
40+
41+
42+
## Inherited Flags
43+
44+
```
45+
--debug Enable debug mode.
46+
--no-color Disable colors.
47+
--no-input Disable interactivity.
48+
--tenant string Specific tenant to use.
49+
```
50+
51+
52+
## Related Commands
53+
54+
- [auth0 orgs invitations create](auth0_orgs_invitations_create.md) - Create a new invitation to an organization
55+
- [auth0 orgs invitations delete](auth0_orgs_invitations_delete.md) - Delete invitation(s) from an organization
56+
- [auth0 orgs invitations list](auth0_orgs_invitations_list.md) - List invitations of an organization
57+
- [auth0 orgs invitations show](auth0_orgs_invitations_show.md) - Show an organization invitation
58+
59+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
layout: default
3+
parent: auth0 orgs invitations
4+
has_toc: false
5+
---
6+
# auth0 orgs invitations show
7+
8+
Display information about an organization invitation.
9+
10+
To show interactively, use `auth0 orgs invs show` with no flags.
11+
12+
To show non-interactively, supply the organization id and invitation id through the flags.
13+
14+
## Usage
15+
```
16+
auth0 orgs invitations show [flags]
17+
```
18+
19+
## Examples
20+
21+
```
22+
auth0 orgs invs show
23+
auth0 orgs invs show --org-id <org-id>
24+
auth0 orgs invs show --org-id <org-id> --invitation-id <invitation-id>
25+
auth0 orgs invs show --org-id <org-id> --invitation-id <invitation-id> --json
26+
auth0 orgs invs show --org-id <org-id> --i <invitation-id> --json-compact
27+
```
28+
29+
30+
## Flags
31+
32+
```
33+
-i, --invitation-id string ID of the invitation.
34+
--json Output in json format.
35+
--json-compact Output in compact json format.
36+
--org-id string ID of the organization.
37+
```
38+
39+
40+
## Inherited Flags
41+
42+
```
43+
--debug Enable debug mode.
44+
--no-color Disable colors.
45+
--no-input Disable interactivity.
46+
--tenant string Specific tenant to use.
47+
```
48+
49+
50+
## Related Commands
51+
52+
- [auth0 orgs invitations create](auth0_orgs_invitations_create.md) - Create a new invitation to an organization
53+
- [auth0 orgs invitations delete](auth0_orgs_invitations_delete.md) - Delete invitation(s) from an organization
54+
- [auth0 orgs invitations list](auth0_orgs_invitations_list.md) - List invitations of an organization
55+
- [auth0 orgs invitations show](auth0_orgs_invitations_show.md) - Show an organization invitation
56+
57+

docs/auth0_orgs_list.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ auth0 orgs list [flags]
4848

4949
- [auth0 orgs create](auth0_orgs_create.md) - Create a new organization
5050
- [auth0 orgs delete](auth0_orgs_delete.md) - Delete an organization
51+
- [auth0 orgs invitations](auth0_orgs_invitations.md) - Manage invitations of an organization
5152
- [auth0 orgs list](auth0_orgs_list.md) - List your organizations
5253
- [auth0 orgs members](auth0_orgs_members.md) - Manage members of an organization
5354
- [auth0 orgs open](auth0_orgs_open.md) - Open the settings page of an organization

docs/auth0_orgs_open.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ auth0 orgs open [flags]
3636

3737
- [auth0 orgs create](auth0_orgs_create.md) - Create a new organization
3838
- [auth0 orgs delete](auth0_orgs_delete.md) - Delete an organization
39+
- [auth0 orgs invitations](auth0_orgs_invitations.md) - Manage invitations of an organization
3940
- [auth0 orgs list](auth0_orgs_list.md) - List your organizations
4041
- [auth0 orgs members](auth0_orgs_members.md) - Manage members of an organization
4142
- [auth0 orgs open](auth0_orgs_open.md) - Open the settings page of an organization

0 commit comments

Comments
 (0)