Skip to content
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

Add globus api gcs command for direct GCS Manager API usage #913

Merged
merged 3 commits into from
Dec 11, 2023

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Dec 8, 2023

The addition of this command requires some large-diff-but-small-logic changes to the globus api command definition module.

Firstly, the major logical components of these commands are separated into three helpers:

  • a decorator for the common parameters
  • an "execute service command" helper
  • a "handle scope string" helper (more on why this is needed below)

The command callback passes all of its parameters verbatim to the execution helper, so there's very little change to those parts of the command. The execution helper consumes any object of type globus_sdk.BaseClient, meaning it can be passed any service client, already authenticated/configured, and it uses that object equivalently.

The "handle scope string" component needs to be treated differently because it executes before there is a client object in hand, and alters how that client object is authenticated for later use. It differs subtly between the known services (handled by name) and GCS (where resource_server == endpoint_id).

The GCS variant uses a positional arg for ENDPOINT_ID, so it is declared separately from the other commands. Effectively, it's a different interface wrapping the same functionality.


One thing I noticed while testing was that we're currently doing some name-shadowing (purely accidentally) of service_name, which gets defined in module-scope for use in a loop. In my first draft, this caused a bug as service_name was defined, but didn't have the value I expected. I'd like to fix this in any of a number of ways, but I've kept it out of scope for this PR.

The addition of this command requires some large-diff-but-small-logic
changes to the `globus api` command definition module.

Firstly, the major logical components of these commands are separated
into three helpers:
- a decorator for the common parameters
- an "execute service command" helper
- a "handle scope string" helper (more on why this is needed below)

The command callback passes all of its parameters verbatim to the
execution helper, so there's very little change to those parts of the
command. The execution helper consumes any object of type
`globus_sdk.BaseClient`, meaning it can be passed any service client,
already authenticated/configured, and it uses that object
equivalently.

The "handle scope string" component needs to be treated differently
because it executes *before* there is a client object in hand, and
alters how that client object is authenticated for later use. It
differs subtly between the known services (handled by name) and GCS
(where `resource_server == endpoint_id`).

The GCS variant uses a positional arg for ENDPOINT_ID, so it is
declared separately from the other commands. Effectively, it's a
different interface wrapping the same functionality.
Copy link
Member

@kurtmckee kurtmckee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me, but is there anything additional that needs to be considered that would make it infeasible to just rename the module-level service_name? It seems like keeping that name is just teeing up a pitfall, while renaming it is straightforward.

src/globus_cli/commands/api.py Outdated Show resolved Hide resolved
@sirosen sirosen merged commit b1acf50 into globus:main Dec 11, 2023
18 checks passed
@sirosen sirosen deleted the add-api-gcs branch December 11, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants