Add REST command support with method and URL options
All checks were successful
build / build (push) Successful in 12s
All checks were successful
build / build (push) Successful in 12s
This commit is contained in:
24
src/cli.ts
24
src/cli.ts
@@ -15,6 +15,8 @@ import {
|
||||
type CliValues = {
|
||||
help?: boolean;
|
||||
type?: string;
|
||||
method?: string;
|
||||
url?: string;
|
||||
"display-name"?: string;
|
||||
"app-id"?: string;
|
||||
resources?: string;
|
||||
@@ -39,6 +41,7 @@ Commands:
|
||||
login Authenticate selected resources
|
||||
logout Sign out and clear login state
|
||||
get-token Get access token (azurerm|devops)
|
||||
rest Call REST API endpoint
|
||||
list-apps List Entra applications
|
||||
list-app-permissions List required permissions for an app
|
||||
list-app-grants List OAuth2 grants for an app
|
||||
@@ -88,6 +91,19 @@ Options:
|
||||
-t, --type <value> Token type: azurerm|devops`;
|
||||
}
|
||||
|
||||
function usageRest(): string {
|
||||
return `Usage: sk-az-tools rest [--method <httpMethod>] --url <url> [--header <name: value>] [global options]
|
||||
|
||||
Options:
|
||||
--method <httpMethod> HTTP method (default: GET; examples: GET, POST, PATCH, DELETE)
|
||||
--url <url> Full URL to call
|
||||
--header <name: value> Extra request header; example: "Content-Type: application/json"
|
||||
|
||||
Authorization is added automatically for:
|
||||
management.azure.com Uses azurerm token
|
||||
dev.azure.com Uses devops token`;
|
||||
}
|
||||
|
||||
function usageListAppPermissions(): string {
|
||||
return `Usage: sk-az-tools list-app-permissions --app-id|-i <appId> [--resolve|-r] [--short|-s] [--filter|-f <glob>] [global options]
|
||||
|
||||
@@ -131,6 +147,8 @@ function usageCommand(command: string): string {
|
||||
return usageLogout();
|
||||
case "get-token":
|
||||
return usageGetToken();
|
||||
case "rest":
|
||||
return usageRest();
|
||||
case "list-app-permissions":
|
||||
return usageListAppPermissions();
|
||||
case "list-app-grants":
|
||||
@@ -162,6 +180,8 @@ async function main(): Promise<void> {
|
||||
options: {
|
||||
help: { type: "boolean", short: "h" },
|
||||
type: { type: "string", short: "t" },
|
||||
method: { type: "string" },
|
||||
url: { type: "string" },
|
||||
"display-name": { type: "string", short: "n" },
|
||||
"app-id": { type: "string", short: "i" },
|
||||
resources: { type: "string" },
|
||||
@@ -194,7 +214,9 @@ async function main(): Promise<void> {
|
||||
const output = command === "list-app-permissions" && typedValues.short
|
||||
? omitPermissionGuidColumns(filtered)
|
||||
: filtered;
|
||||
const headerSpec = parseHeaderSpec(typedValues.header);
|
||||
const headerSpec = command === "rest"
|
||||
? parseHeaderSpec(undefined)
|
||||
: parseHeaderSpec(typedValues.header);
|
||||
|
||||
renderOutput(command, output, outputFormat, headerSpec);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user