Skip to content

cloud service query: auto-bootstrap query endpoint on 401 #123

@sdairs

Description

@sdairs

Problem

Running cloud service query against a service whose query endpoint hasn't been enabled (or doesn't list the caller's API key) returns HTTP 401 with a helpful hint (added in #115), but the user still has to run two more commands to fix it:

cloud key list                    # find my key ID
cloud service query-endpoint create <service-id> --open-api-key <key-id>

Proposed behaviour

When cloud service query hits 401 and the resolved auth source is an API key:

  1. Look up the caller's API key in openapi_key_get_list by matching on the configured key string (we need a way to map a key string back to its UUID — see "How can I know what API key I'm authenticated with?" follow-up).
  2. On an interactive TTY, prompt: Authorize your API key (<name> <uuid>) for this service's query endpoint? [y/N].
  3. On yes, upsert the endpoint (additively, per cloud service query-endpoint create should be additive #122) and retry the query transparently.
  4. Skipped under --json, --no-interactive, or non-TTY stdin.

Depends on

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions