diff --git a/.changeset/update-openapi-c4fbef6545cc.md b/.changeset/update-openapi-c4fbef6545cc.md new file mode 100644 index 0000000000..8d04836214 --- /dev/null +++ b/.changeset/update-openapi-c4fbef6545cc.md @@ -0,0 +1,6 @@ +--- +"cf": minor +--- + +Update the generated command surface for Forge OpenAPI release +`c4fbef6545cc3ae3ef7724398dc12e1fecbd9183`. diff --git a/packages/cli/generate.ts b/packages/cli/generate.ts index 89b3798532..00aeb7068e 100644 --- a/packages/cli/generate.ts +++ b/packages/cli/generate.ts @@ -17,7 +17,7 @@ import type { ForgeOpenApiDocument } from "./generator/openapi.js"; const bundle = process.env.FORGE_OPENAPI_BUNDLE; // Bump this SHA to generate the commands from a new release. -const FORGE_OPENAPI_VERSION = "d35bb4402f3864b83e802be14ca7f58eb920528b"; +const FORGE_OPENAPI_VERSION = "c4fbef6545cc3ae3ef7724398dc12e1fecbd9183"; const FORGE_OPENAPI_RELEASE = `openapi@${FORGE_OPENAPI_VERSION}`; const FORGE_OPENAPI_ASSET = "openapi.forge.json"; const FORGE_OPENAPI_ASSET_URL = `https://github.com/cloudflare/forge/releases/download/${FORGE_OPENAPI_RELEASE}/${FORGE_OPENAPI_ASSET}`; diff --git a/packages/cli/src/commands/_generated/_meta/commands.json b/packages/cli/src/commands/_generated/_meta/commands.json index 090d2ad16d..d432b3c95e 100644 --- a/packages/cli/src/commands/_generated/_meta/commands.json +++ b/packages/cli/src/commands/_generated/_meta/commands.json @@ -2299,6 +2299,30 @@ "operationId": "accounts.delete", "hideCommand": false }, + { + "command": "cf accounts entitlements get", + "name": "get", + "fullPath": ["accounts", "entitlements", "get"], + "description": "Returns the list of entitlements (features and their allocations) for a given account or zone. Each entitlement describes a product feature the account or zone is permitted to use and the allocation value (boolean, count, range, enum, or string) that governs its behaviour.", + "summary": "Get account or zone Entitlements", + "usage": "cf accounts entitlements get", + "arguments": [], + "options": [ + { + "name": "dry-run", + "type": "boolean", + "required": false, + "description": "Validate and show what would happen without executing", + "default": false + } + ], + "category": "read", + "hasRequestBody": false, + "httpMethod": "GET", + "apiPath": "/{account_or_zone}/{account_or_zone_id}/entitlements", + "operationId": "accounts.entitlements.get", + "hideCommand": false + }, { "command": "cf accounts get", "name": "get", @@ -164825,6 +164849,7 @@ "accounts billing history": "Operations for billing.history", "accounts billing payment-methods": "Operations for billing.payment-methods", "accounts categories": "Browse the categories used to classify applications", + "accounts entitlements": "Operations for entitlements", "accounts logs": "Operations for logs", "accounts logs audit": "Operations for logs.audit", "accounts members": "Operations for members", diff --git a/packages/cli/src/commands/_generated/_meta/schemas.json b/packages/cli/src/commands/_generated/_meta/schemas.json index f6171579b9..0433ed2b3a 100644 --- a/packages/cli/src/commands/_generated/_meta/schemas.json +++ b/packages/cli/src/commands/_generated/_meta/schemas.json @@ -1575,6 +1575,26 @@ "hasRequestBody": false, "requestBodyFields": [] }, + "accounts entitlements get": { + "operationId": "accounts.entitlements.get", + "httpMethod": "GET", + "path": "/{account_or_zone}/{account_or_zone_id}/entitlements", + "pathParams": [ + { + "name": "account_or_zone", + "type": "string", + "required": true + }, + { + "name": "account_or_zone_id", + "type": "string", + "required": true + } + ], + "queryParams": [], + "hasRequestBody": false, + "requestBodyFields": [] + }, "accounts get": { "operationId": "accounts.get", "httpMethod": "GET", diff --git a/packages/cli/src/commands/_generated/_operations/accounts/entitlements/get.ts b/packages/cli/src/commands/_generated/_operations/accounts/entitlements/get.ts new file mode 100644 index 0000000000..130c8c2bd0 --- /dev/null +++ b/packages/cli/src/commands/_generated/_operations/accounts/entitlements/get.ts @@ -0,0 +1,17 @@ +/** @generated from accounts.entitlements.get */ +import { path } from "#api"; + +export default { + method: "GET", + path: (request: Record) => + path`/${request.account_or_zone}/${request.account_or_zone_id}/entitlements`, + errors: { + 400: "BadRequestError", + 401: "UnauthorizedError", + 403: "ForbiddenError", + 404: "NotFoundError", + 405: "MethodNotAllowedError", + 500: "InternalServerError", + 503: "ServiceUnavailableError", + }, +} as const; diff --git a/packages/cli/src/commands/_generated/accounts/entitlements/get.ts b/packages/cli/src/commands/_generated/accounts/entitlements/get.ts new file mode 100644 index 0000000000..6b69637367 --- /dev/null +++ b/packages/cli/src/commands/_generated/accounts/entitlements/get.ts @@ -0,0 +1,96 @@ +import operation from "../../_operations/accounts/entitlements/get.js"; +import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +/** + * get command + * @generated from apis/overlays/accounts.ts + */ +import type { Argv, CommandModule } from "yargs"; +import { + createCommandClient, + getAccountId, + getZoneId, + resolveAccountIdSilent, +} from "#lib/auth.js"; +import { formatDryRun } from "#lib/dry-run.js"; +import { LOCAL_ACCOUNT_ID } from "#lib/local.js"; +import { formatOutput } from "#lib/output.js"; +import { withProgress } from "#lib/progress.js"; +import { runWithTelemetry } from "#lib/telemetry/index.js"; + +function builder(yargs: Argv) { + return yargs + .usage( + "$0 accounts entitlements get\n\nReturns the list of entitlements (features and their allocations) for a given account or zone. Each entitlement describes a product feature the account or zone is permitted to use and the allocation value (boolean, count, range, enum, or string) that governs its behaviour." + ) + .option("dry-run", { + type: "boolean", + description: "Validate and show what would happen without executing", + default: false, + }); +} + +type Args = InferArgs; + +const command: CommandModule = { + command: "get", + describe: "Get account or zone Entitlements", + builder, + handler: async (argv): Promise => + runWithTelemetry( + { + command: "accounts entitlements get", + classification: { + safeFlags: ["dry-run"], + } satisfies ArgClassification, + }, + argv as Record, + async () => { + if (argv.dryRun) { + const __cfDryRunAccountId = + argv.zone === undefined + ? await resolveAccountIdSilent() + : undefined; + const accountOrZone = argv.zone === undefined ? "accounts" : "zones"; + const accountOrZoneId = + argv.zone ?? __cfDryRunAccountId ?? ""; + formatDryRun({ + command: "cf accounts entitlements get", + method: "GET", + url: `https://api.cloudflare.com/client/v4/${accountOrZone}/${accountOrZoneId}/entitlements`, + pathParams: { + "account-or-zone": String(accountOrZone), + "account-or-zone-id": String(accountOrZoneId), + }, + bodyKind: "none", + }); + return; + } + const client = await createCommandClient(argv); + const accountOrZone = argv.zone === undefined ? "accounts" : "zones"; + const accountOrZoneId = + accountOrZone === "zones" + ? await getZoneId({ zone: argv.zone }, client, { + quiet: argv.quiet, + }) + : argv.local + ? LOCAL_ACCOUNT_ID + : await getAccountId(); + if (accountOrZone === "zones") { + argv.zoneId = accountOrZoneId; + } else { + argv.accountId = accountOrZoneId; + } + + const result = await withProgress(`Loading`, async () => + client.send(operation, { + account_or_zone: accountOrZone, + account_or_zone_id: accountOrZoneId, + }) + ); + formatOutput(result, { successLabel: `Loaded` }); + } + ), +}; + +export default command; diff --git a/packages/cli/src/commands/_generated/accounts/entitlements/index.ts b/packages/cli/src/commands/_generated/accounts/entitlements/index.ts new file mode 100644 index 0000000000..335b9d6433 --- /dev/null +++ b/packages/cli/src/commands/_generated/accounts/entitlements/index.ts @@ -0,0 +1,20 @@ +import $get from "./get.js"; +import type { CommonYargsOptions } from "#lib/cli-types.js"; +/** + * entitlements command group + * @generated from apis/overlays/accounts.ts + */ +import type { CommandModule } from "yargs"; + +const command: CommandModule = { + command: "entitlements", + describe: "Operations for entitlements", + + builder: (yargs) => { + return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + }, + + handler: () => {}, +}; + +export default command; diff --git a/packages/cli/src/commands/_generated/accounts/index.ts b/packages/cli/src/commands/_generated/accounts/index.ts index e3b5c45bbf..7ca05b961a 100644 --- a/packages/cli/src/commands/_generated/accounts/index.ts +++ b/packages/cli/src/commands/_generated/accounts/index.ts @@ -3,6 +3,7 @@ import $billing from "./billing/index.js"; import $categories from "./categories/index.js"; import $create from "./create.js"; import $delete from "./delete.js"; +import $entitlements from "./entitlements/index.js"; import $get from "./get.js"; import $list from "./list.js"; import $logs from "./logs/index.js"; @@ -38,6 +39,7 @@ const command: CommandModule = { .command($applications) .command($billing) .command($categories) + .command($entitlements) .command($logs) .command($members) .command($organization)