-
Notifications
You must be signed in to change notification settings - Fork 27
Added globus flows registered-api list command #1258
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelog.d/20260512_133746_8730430+m1yag1_sc_49700_add_list_gras.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Enhancements | ||
|
|
||
| * Added `globus flows registered-api list` command to list registered APIs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import typing as t | ||
|
|
||
| import click | ||
| import globus_sdk | ||
| from globus_sdk.paging import Paginator | ||
|
|
||
| from globus_cli.login_manager import LoginManager | ||
| from globus_cli.parsing import ColonDelimitedChoiceTuple, command | ||
| from globus_cli.termio import Field, display, formatters | ||
| from globus_cli.utils import PagingWrapper | ||
|
|
||
| ROLE_TYPES = ("owner", "administrator", "viewer") | ||
| ORDER_BY_FIELDS = ("id", "name", "created_timestamp", "updated_timestamp") | ||
|
|
||
|
|
||
| @command("list") | ||
| @click.option( | ||
| "--filter-role", | ||
| "filter_roles", | ||
| type=click.Choice(ROLE_TYPES), | ||
| help="Filter results by the registered API's role type associated with the caller", | ||
| multiple=True, | ||
| ) | ||
| @click.option( | ||
| "--orderby", | ||
| default=("created_timestamp:DESC",), | ||
| show_default=True, | ||
| type=ColonDelimitedChoiceTuple( | ||
| choices=tuple( | ||
| f"{field}:{order}" for field in ORDER_BY_FIELDS for order in ("ASC", "DESC") | ||
| ), | ||
| case_sensitive=False, | ||
| ), | ||
| multiple=True, | ||
| metavar=f"[{'|'.join(ORDER_BY_FIELDS)}]:[ASC|DESC]", | ||
| help=""" | ||
| Sort results by the given field and ordering. | ||
| ASC for ascending, DESC for descending. | ||
|
|
||
| This option can be specified multiple times to sort by multiple fields. | ||
| """, | ||
| ) | ||
| @click.option( | ||
| "--limit", | ||
| default=25, | ||
| show_default=True, | ||
| metavar="N", | ||
| type=click.IntRange(1), | ||
| help="The maximum number of results to return.", | ||
| ) | ||
| @LoginManager.requires_login("flows") | ||
| def list_command( | ||
| login_manager: LoginManager, | ||
| *, | ||
| filter_roles: tuple[t.Literal["owner", "administrator", "viewer"], ...], | ||
| orderby: tuple[ | ||
| tuple[ | ||
| t.Literal["id", "name", "created_timestamp", "updated_timestamp"], | ||
| t.Literal["ASC", "DESC"], | ||
| ], | ||
| ..., | ||
| ], | ||
| limit: int, | ||
| ) -> None: | ||
| """ | ||
| List registered APIs. | ||
| """ | ||
| flows_client = login_manager.get_flows_client() | ||
| paginator = Paginator.wrap(flows_client.list_registered_apis) | ||
| api_iterator = PagingWrapper( | ||
| paginator( | ||
| filter_roles=filter_roles or globus_sdk.MISSING, | ||
| orderby=",".join(f"{field} {order}" for field, order in orderby), | ||
| ).items(), | ||
| json_conversion_key="registered_apis", | ||
| limit=limit, | ||
| ) | ||
|
|
||
| fields = [ | ||
| Field("Registered API ID", "id"), | ||
| Field("Name", "name"), | ||
| Field("Created At", "created_timestamp", formatter=formatters.Date), | ||
| Field("Updated At", "updated_timestamp", formatter=formatters.Date), | ||
| ] | ||
|
|
||
| display( | ||
| api_iterator, | ||
| fields=fields, | ||
| json_converter=api_iterator.json_converter, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.