(cli *cli)
| 1092 | } |
| 1093 | |
| 1094 | func listInvitationsOrganizationCmd(cli *cli) *cobra.Command { |
| 1095 | var inputs struct { |
| 1096 | OrgID string |
| 1097 | Number int |
| 1098 | } |
| 1099 | |
| 1100 | cmd := &cobra.Command{ |
| 1101 | Use: "list", |
| 1102 | Aliases: []string{"ls"}, |
| 1103 | Args: cobra.NoArgs, |
| 1104 | Short: "List invitations of an organization", |
| 1105 | Long: "List the invitations of an organization.\n\n" + |
| 1106 | "To list interactively, use `auth0 orgs invs list` with no flags.\n\n" + |
| 1107 | "To list non-interactively, supply the organization id through the flags.", |
| 1108 | Example: ` auth0 orgs invs list |
| 1109 | auth0 orgs invs ls --org-id <org-id> |
| 1110 | auth0 orgs invs list --org-id <org-id> --number 100 |
| 1111 | auth0 orgs invs ls --org-id <org-id> -n 50 --json |
| 1112 | auth0 orgs invs ls --org-id <org-id> -n 500 --json-compact |
| 1113 | auth0 orgs invs ls --org-id <org-id> --csv`, |
| 1114 | RunE: func(cmd *cobra.Command, args []string) error { |
| 1115 | if inputs.Number < 1 || inputs.Number > 1000 { |
| 1116 | return fmt.Errorf("number flag invalid, please pass a number between 1 and 1000") |
| 1117 | } |
| 1118 | |
| 1119 | if err := organizationIDFlag.Pick(cmd, &inputs.OrgID, cli.organizationPickerOptions); err != nil { |
| 1120 | return err |
| 1121 | } |
| 1122 | |
| 1123 | invitations, err := cli.getOrgInvitations(cmd.Context(), inputs.OrgID, inputs.Number) |
| 1124 | if err != nil { |
| 1125 | return err |
| 1126 | } |
| 1127 | |
| 1128 | cli.renderer.InvitationsList(invitations) |
| 1129 | return nil |
| 1130 | }, |
| 1131 | } |
| 1132 | |
| 1133 | organizationIDFlag.RegisterString(cmd, &inputs.OrgID, "") |
| 1134 | organizationNumber.Help = "Number of organization invitations to retrieve. Minimum 1, maximum 1000." |
| 1135 | organizationNumber.RegisterInt(cmd, &inputs.Number, defaultPageSize) |
| 1136 | |
| 1137 | cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") |
| 1138 | cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") |
| 1139 | cmd.Flags().BoolVar(&cli.csv, "csv", false, "Output in csv format.") |
| 1140 | cmd.MarkFlagsMutuallyExclusive("json", "json-compact", "csv") |
| 1141 | |
| 1142 | return cmd |
| 1143 | } |
| 1144 | |
| 1145 | func (c *cli) getOrgInvitations( |
| 1146 | context context.Context, |
no test coverage detected