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

Fb/json leftovers #92

Merged
merged 11 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/cap-multitenancy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Commands for this area are:
* --cds-offboard-all offboard all tenants
... [METADATA] onboard subscription metadata
... [TENANT] filter list for tenant id or subdomain
... --auto-undeploy upgrade with auto undeploy
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --auto-undeploy upgrade with auto undeploy

~ are read-only commands
* are potentially _dangerous_ commands
Expand All @@ -69,6 +69,14 @@ If the provided information is insufficient or seems incomplete, then you can al
If you already know which subaccount or tenant id you want the information for, then you can filter the list or long
list, by providing that information, e.g., `mtx cdsl skyfin-company`.

For automated processes, you can use the `--json` flag and consume the list data as JSON. With the
`--json` flag active, you will get the same data for `cdsl` and `cdsll`. For example, you could get the tenant, global
account and subscription user for each tenant with:

```
mtx cdsl --json | jq '.[] | { tenant: .subscribedTenantId, account: .globalAccountGUID, user: .userId }'
```

## Example for List

Here is an example of listing all subscribed subacconts:
Expand Down
16 changes: 12 additions & 4 deletions docs/hana-management/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ Commands for this area are:
* --hdi-delete-all delete all hdi container instances and bindings
... [TENANT_ID] filter for tenant id
... [PARAMS] create binding with custom parameters
... --reveal show passwords
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --reveal show passwords

~ are read-only commands
* are potentially _dangerous_ commands
Expand All @@ -66,7 +66,7 @@ Commands for this area are:
The list command `mtx hdil` is the most common entry point and will show a table of all hdi container bindings their
most useful associated information.

With the addition of the `--time` option, the list will include both absolute and relative timestamps for creation
With the addition of the `--time` flag, the list will include both absolute and relative timestamps for creation
and the latest update.

If the provided information is insufficient or seems incomplete, then you can always fallback to the long list
Expand All @@ -75,6 +75,14 @@ If the provided information is insufficient or seems incomplete, then you can al
If you already know which tenant id you want the information for, then you can filter the list or long list, by
providing that information, e.g., `mtx hdill <tenant_id>`.

For automated processes, you can use the `--json` flag and consume the list data as JSON. With the
`--json` flag active, you will get the same data for `hdil` and `hdill`. For example, to get the ready state of
the all bindings, you use:

```
mtx hdil --json | jq '.bindings.[] | { binding: .id, ready: .ready }'
```

{: .info}
Note that due to the way `@sap/cds-mtx` works, the number of hdi 'tenants' does not correspond 1:1 with subscribed
subaccounts. Rather there are 2 hdi tenants for each subscribed subaccount, as well as one additional `__META__` hdi
Expand Down Expand Up @@ -134,7 +142,7 @@ evolution.

{: .info}
By default MTX Tool hides passwords, to protect the user from revealing them inadvertantly in screen sharing sessions.
When you first set up connections and want to reveal the passwords, use the `--reveal` option.
When you first set up connections and want to reveal the passwords, use the `--reveal` flag.

![](hana-management-tunnel.gif)

Expand Down
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ commands:
~ uaasp --uaa-service-passcode SERVICE PASSCODE [TENANT] obtain service token for one-time passcode
~ uaasu --uaa-service-user SERVICE USERNAME PASSWORD [TENANT] obtain service token for username password
... [TENANT] obtain token for tenant, fallback to paas tenant
... --decode decode result token
... --json output in json
... --decode decode result token
... --userinfo add detailed user info for passcode or username

=== tenant registry (reg) ===
Expand All @@ -81,8 +81,8 @@ commands:
* --registry-offboard TENANT_ID offboard tenant subscription
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --skip-unchanged skip update for unchanged dependencies
... --only-stale only update subscriptions that have not changed today
... --only-failed only update subscriptions with UPDATE_FAILED state
Expand All @@ -97,9 +97,9 @@ commands:
* --cds-offboard-all offboard all tenants
... [METADATA] onboard subscription metadata
... [TENANT] filter list for tenant id or subdomain
... --auto-undeploy upgrade with auto undeploy
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --auto-undeploy upgrade with auto undeploy

=== hana management (hdi) ===
~ hdil --hdi-list [TENANT_ID] list all hdi container instances
Expand All @@ -113,9 +113,9 @@ commands:
* --hdi-delete-all delete all hdi container instances and bindings
... [TENANT_ID] filter for tenant id
... [PARAMS] create binding with custom parameters
... --reveal show passwords
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --reveal show passwords

=== server diagnostic (srv) ===
~ srv --server-info call server /info
Expand Down
12 changes: 10 additions & 2 deletions docs/tenant-registry/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Commands for this area are:
* --registry-offboard TENANT_ID offboard tenant subscription
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --skip-unchanged skip update for unchanged dependencies
... --only-stale only update subscriptions that have not changed today
... --only-failed only update subscriptions with UPDATE_FAILED state
Expand All @@ -69,7 +69,7 @@ Commands for this area are:
The list command `mtx regl` is the most common entry point and will show a table of all registered subacconts with
their most useful associated information.

With the addition of the `--time` option, the list will include both absolute and relative timestamps for creation
With the addition of the `--time` flag, the list will include both absolute and relative timestamps for creation
and the latest update.

If the provided information is insufficient or seems incomplete, then you can always fallback to the long list
Expand All @@ -78,6 +78,14 @@ If the provided information is insufficient or seems incomplete, then you can al
If you already know which subaccount or tenant id you want the information for, then you can filter the list or long
list, by providing that information, e.g., `mtx regl skyfin-company`.

For automated processes, you can use the `--json` flag and consume the list data as JSON. With the `--json` flag
active, you will get the same data for `regl` and `regll`. For example, to get the subscription url and state for each
tenant, you could use:

```
mtx regl --json | jq '.subscriptions.[] | { url: .url, state: .state }'
```

## Example for List

Here is an example of listing all registered tenants:
Expand Down
22 changes: 21 additions & 1 deletion docs/user-authentication/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Commands for this area are:
~ uaasp --uaa-service-passcode SERVICE PASSCODE [TENANT] obtain service token for one-time passcode
~ uaasu --uaa-service-user SERVICE USERNAME PASSWORD [TENANT] obtain service token for username password
... [TENANT] obtain token for tenant, fallback to paas tenant
... --decode decode result token
... --json output in json
... --decode decode result token
... --userinfo add detailed user info for passcode or username

~ are read-only commands
Expand Down Expand Up @@ -155,6 +155,26 @@ only be trusted if that account has successfully subscribed to the xsapp.
So, `mtx uaasc destination skyfin-company`, will give you the corresponding JWT, which can then be decoded or used as
`Authorization` header in an HTTP client.

## Output in JSON

All uaa commands support the `--json` flag. When this flag is active, the tool will produce JSON output.

| active flags | output structure |
| :------------------- | :--------------------------------------------------- |
| `--json` | `{ "token": "<bearer token>" }` |
| `--json`, `--decode` | `{ "header": "<JWT header>", "body": "<JWT body>" }` |

When this flag is active, the regular logging is disabled, so that the
output processing can be automated with, e.g., [jq](https://jqlang.github.io/jq/).

```
mtx uaac --json | jq .token
mtx uaac --json --decode | jq .body.scope
```

Note that errors are still written in plain text. Since errors are written to `STDERR`, not `STDOUT`, this will not disrupt
any pipes that might be used to process the output.

## Example for Saas Service

Here is an example of retrieving a JWT for the bound destination service:
Expand Down
12 changes: 6 additions & 6 deletions src/cliOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ commands:
~ uaasp --uaa-service-passcode SERVICE PASSCODE [TENANT] obtain service token for one-time passcode
~ uaasu --uaa-service-user SERVICE USERNAME PASSWORD [TENANT] obtain service token for username password
... [TENANT] obtain token for tenant, fallback to paas tenant
... --decode decode result token
... --json output in json
... --decode decode result token
... --userinfo add detailed user info for passcode or username

=== tenant registry (reg) ===
Expand All @@ -84,8 +84,8 @@ commands:
* --registry-offboard TENANT_ID offboard tenant subscription
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --skip-unchanged skip update for unchanged dependencies
... --only-stale only update subscriptions that have not changed today
... --only-failed only update subscriptions with UPDATE_FAILED state
Expand All @@ -100,9 +100,9 @@ commands:
* --cds-offboard-all offboard all tenants
... [METADATA] onboard subscription metadata
... [TENANT] filter list for tenant id or subdomain
... --auto-undeploy upgrade with auto undeploy
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --auto-undeploy upgrade with auto undeploy

=== hana management (hdi) ===
~ hdil --hdi-list [TENANT_ID] list all hdi container instances
Expand All @@ -116,9 +116,9 @@ commands:
* --hdi-delete-all delete all hdi container instances and bindings
... [TENANT_ID] filter for tenant id
... [PARAMS] create binding with custom parameters
... --reveal show passwords
... --time list includes timestamps
... --json list in json
... --time list includes timestamps
... --reveal show passwords

=== server diagnostic (srv) ===
~ srv --server-info call server /info
Expand Down
Loading
Loading