diff --git a/docs/cli/schema.json b/docs/cli/schema.json index 14bb33e8..33bcc0ae 100644 --- a/docs/cli/schema.json +++ b/docs/cli/schema.json @@ -66828,6 +66828,13 @@ "type": "string", "required": false, "summary": "Contains a project ID. If specified, the result will be filtered to only those origin projects that are linked to the specified project ID in a cross-project search configuration." + }, + { + "role": "flag", + "name": "tags", + "type": "string", + "required": false, + "summary": "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." } ], "summary": "Get Elasticsearch projects", @@ -66844,6 +66851,20 @@ ], "name": "create", "parameters": [ + { + "role": "flag", + "name": "name", + "type": "string", + "required": true, + "summary": "Descriptive name for a project." + }, + { + "role": "flag", + "name": "region-id", + "type": "string", + "required": true, + "summary": "Unique human-readable identifier for a region in Elastic Cloud." + }, { "role": "flag", "name": "wait", @@ -67096,6 +67117,13 @@ "type": "string", "required": false, "summary": "Contains a project ID. If specified, the result will be filtered to only those origin projects that are linked to the specified project ID in a cross-project search configuration." + }, + { + "role": "flag", + "name": "tags", + "type": "string", + "required": false, + "summary": "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." } ], "summary": "Get Observability projects", @@ -67112,6 +67140,20 @@ ], "name": "create", "parameters": [ + { + "role": "flag", + "name": "name", + "type": "string", + "required": true, + "summary": "Descriptive name for a project." + }, + { + "role": "flag", + "name": "region-id", + "type": "string", + "required": true, + "summary": "Unique human-readable identifier for a region in Elastic Cloud." + }, { "role": "flag", "name": "wait", @@ -67364,6 +67406,13 @@ "type": "string", "required": false, "summary": "Contains a project ID. If specified, the result will be filtered to only those origin projects that are linked to the specified project ID in a cross-project search configuration." + }, + { + "role": "flag", + "name": "tags", + "type": "string", + "required": false, + "summary": "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." } ], "summary": "Get Security projects", @@ -67380,6 +67429,20 @@ ], "name": "create", "parameters": [ + { + "role": "flag", + "name": "name", + "type": "string", + "required": true, + "summary": "Descriptive name for a project." + }, + { + "role": "flag", + "name": "region-id", + "type": "string", + "required": true, + "summary": "Unique human-readable identifier for a region in Elastic Cloud." + }, { "role": "flag", "name": "wait", @@ -67662,6 +67725,13 @@ "type": "string", "required": false, "summary": "The project alias to filter the link candidates by." + }, + { + "role": "flag", + "name": "tags", + "type": "string", + "required": false, + "summary": "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." } ], "summary": "Get Elasticsearch project link candidates", @@ -67718,6 +67788,13 @@ "type": "string", "required": false, "summary": "The project alias to filter the link candidates by." + }, + { + "role": "flag", + "name": "tags", + "type": "string", + "required": false, + "summary": "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." } ], "summary": "Get Observability project link candidates", @@ -67774,6 +67851,13 @@ "type": "string", "required": false, "summary": "The project alias to filter the link candidates by." + }, + { + "role": "flag", + "name": "tags", + "type": "string", + "required": false, + "summary": "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." } ], "summary": "Get Security project link candidates", @@ -67927,7 +68011,29 @@ "traffic-filters" ], "name": "create-traffic-filter", - "parameters": [], + "parameters": [ + { + "role": "flag", + "name": "name", + "type": "string", + "required": true, + "summary": "Name of the traffic filter" + }, + { + "role": "flag", + "name": "type", + "type": "string", + "required": true, + "summary": "Type of the traffic filter" + }, + { + "role": "flag", + "name": "region", + "type": "string", + "required": true, + "summary": "The traffic filter can be attached only to projects in the specific region" + } + ], "summary": "Create a traffic filter", "intent": { "requiresAuth": true diff --git a/src/cloud/apis/elasticsearch-projects.ts b/src/cloud/apis/elasticsearch-projects.ts index 3dde8b0d..7f061f78 100644 --- a/src/cloud/apis/elasticsearch-projects.ts +++ b/src/cloud/apis/elasticsearch-projects.ts @@ -9,6 +9,7 @@ * and elastic/elastic-client-generator-js to regenerate this file again. */ +import { z } from 'zod' import type { CloudApiDefinition } from '../types.ts' export const elasticsearchProjectsApis: CloudApiDefinition[] = [ @@ -21,6 +22,7 @@ export const elasticsearchProjectsApis: CloudApiDefinition[] = [ queryParams: [ { name: "traffic_filter", type: "string", description: "Filters the returned list of projects. Only projects associated with the provided traffic_filter will be returned." }, { name: "linked", type: "string", description: "Contains a project ID. If specified, the result will be filtered to only those origin projects that are linked to the specified project ID in a cross-project search configuration." }, + { name: "tags", type: "string", description: "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." }, ], }, { @@ -29,6 +31,10 @@ export const elasticsearchProjectsApis: CloudApiDefinition[] = [ description: "Create an Elasticsearch project", method: "POST", path: "/api/v1/serverless/projects/elasticsearch", + body: z.object({ + name: z.string().describe("Descriptive name for a project."), + region_id: z.string().describe("Unique human-readable identifier for a region in Elastic Cloud."), + }), }, { name: "get-elasticsearch-project", diff --git a/src/cloud/apis/linked-candidate-projects.ts b/src/cloud/apis/linked-candidate-projects.ts index 64d27878..17018321 100644 --- a/src/cloud/apis/linked-candidate-projects.ts +++ b/src/cloud/apis/linked-candidate-projects.ts @@ -27,6 +27,7 @@ export const linkedCandidateProjectsApis: CloudApiDefinition[] = [ { name: "region", type: "string", description: "The region to filter the link candidate projects by." }, { name: "name", type: "string", description: "The project name to filter the link candidates by." }, { name: "alias", type: "string", description: "The project alias to filter the link candidates by." }, + { name: "tags", type: "string", description: "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." }, ], }, { @@ -44,6 +45,7 @@ export const linkedCandidateProjectsApis: CloudApiDefinition[] = [ { name: "region", type: "string", description: "The region to filter the link candidate projects by." }, { name: "name", type: "string", description: "The project name to filter the link candidates by." }, { name: "alias", type: "string", description: "The project alias to filter the link candidates by." }, + { name: "tags", type: "string", description: "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." }, ], }, { @@ -61,6 +63,7 @@ export const linkedCandidateProjectsApis: CloudApiDefinition[] = [ { name: "region", type: "string", description: "The region to filter the link candidate projects by." }, { name: "name", type: "string", description: "The project name to filter the link candidates by." }, { name: "alias", type: "string", description: "The project alias to filter the link candidates by." }, + { name: "tags", type: "string", description: "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." }, ], }, ] diff --git a/src/cloud/apis/observability-projects.ts b/src/cloud/apis/observability-projects.ts index 0e4eaa9e..31f9da51 100644 --- a/src/cloud/apis/observability-projects.ts +++ b/src/cloud/apis/observability-projects.ts @@ -9,6 +9,7 @@ * and elastic/elastic-client-generator-js to regenerate this file again. */ +import { z } from 'zod' import type { CloudApiDefinition } from '../types.ts' export const observabilityProjectsApis: CloudApiDefinition[] = [ @@ -21,6 +22,7 @@ export const observabilityProjectsApis: CloudApiDefinition[] = [ queryParams: [ { name: "traffic_filter", type: "string", description: "traffic filters associated with this project" }, { name: "linked", type: "string", description: "Contains a project ID. If specified, the result will be filtered to only those origin projects that are linked to the specified project ID in a cross-project search configuration." }, + { name: "tags", type: "string", description: "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." }, ], }, { @@ -29,6 +31,10 @@ export const observabilityProjectsApis: CloudApiDefinition[] = [ description: "Create an observability project", method: "POST", path: "/api/v1/serverless/projects/observability", + body: z.object({ + name: z.string().describe("Descriptive name for a project."), + region_id: z.string().describe("Unique human-readable identifier for a region in Elastic Cloud."), + }), }, { name: "get-observability-project", diff --git a/src/cloud/apis/security-projects.ts b/src/cloud/apis/security-projects.ts index a4146035..febbdfce 100644 --- a/src/cloud/apis/security-projects.ts +++ b/src/cloud/apis/security-projects.ts @@ -9,6 +9,7 @@ * and elastic/elastic-client-generator-js to regenerate this file again. */ +import { z } from 'zod' import type { CloudApiDefinition } from '../types.ts' export const securityProjectsApis: CloudApiDefinition[] = [ @@ -21,6 +22,7 @@ export const securityProjectsApis: CloudApiDefinition[] = [ queryParams: [ { name: "traffic_filter", type: "string", description: "traffic filters associated with this project" }, { name: "linked", type: "string", description: "Contains a project ID. If specified, the result will be filtered to only those origin projects that are linked to the specified project ID in a cross-project search configuration." }, + { name: "tags", type: "string", description: "If specified, the result will be filtered to only those projects that have the specified tags and corresponding values." }, ], }, { @@ -29,6 +31,10 @@ export const securityProjectsApis: CloudApiDefinition[] = [ description: "Create a security project", method: "POST", path: "/api/v1/serverless/projects/security", + body: z.object({ + name: z.string().describe("Descriptive name for a project."), + region_id: z.string().describe("Unique human-readable identifier for a region in Elastic Cloud."), + }), }, { name: "get-security-project", diff --git a/src/cloud/apis/traffic-filters.ts b/src/cloud/apis/traffic-filters.ts index 035852e2..f409629c 100644 --- a/src/cloud/apis/traffic-filters.ts +++ b/src/cloud/apis/traffic-filters.ts @@ -9,6 +9,7 @@ * and elastic/elastic-client-generator-js to regenerate this file again. */ +import { z } from 'zod' import type { CloudApiDefinition } from '../types.ts' export const trafficFiltersApis: CloudApiDefinition[] = [ @@ -29,6 +30,11 @@ export const trafficFiltersApis: CloudApiDefinition[] = [ description: "Create a traffic filter", method: "POST", path: "/api/v1/serverless/traffic-filters", + body: z.object({ + name: z.string().describe("Name of the traffic filter"), + type: z.string().describe("Type of the traffic filter"), + region: z.string().describe("The traffic filter can be attached only to projects in the specific region"), + }), }, { name: "get-traffic-filter-metadata", diff --git a/src/config/profiles.ts b/src/config/profiles.ts index 86dd292c..3da5eca0 100644 --- a/src/config/profiles.ts +++ b/src/config/profiles.ts @@ -48,9 +48,6 @@ export function resolveBuiltinProfile (name: BuiltInProfile): { allowed: readonl 'kb', // All stack commands (Elasticsearch + Kibana) - // Individual serverless-incompatible ES endpoints will be filtered in a - // future iteration once per-command availability metadata is added to the - // API manifest (see issue #283 for tracking). 'stack.*', // Cloud cross-cutting namespaces (apply to both Hosted and Serverless) diff --git a/test/cloud/register.test.ts b/test/cloud/register.test.ts index 3cd3137d..c78c7c38 100644 --- a/test/cloud/register.test.ts +++ b/test/cloud/register.test.ts @@ -5,6 +5,7 @@ import { describe, it } from 'node:test' import assert from 'node:assert/strict' +import { z } from 'zod' import { registerCloudCommands, simplifyProjectCommandName } from '../../src/cloud/register.ts' import type { CloudApiDefinition } from '../../src/cloud/types.ts' @@ -219,6 +220,21 @@ describe('registerCloudCommands', () => { assert.deepEqual(regions.commands.map((c) => c.name()), ['list-regions', 'get-region']) }) + it('exposes --name and --region-id flags on create project commands', () => { + const defs: CloudApiDefinition[] = [ + { name: 'create-elasticsearch-project', namespace: 'elasticsearch-projects', description: 'Create', method: 'POST', path: '/api/v1/serverless/projects/elasticsearch', + body: z.object({ name: z.string(), region_id: z.string() }) }, + ] + const group = registerCloudCommands(defs) + const createCmd = group.commands.find((c) => c.name() === 'serverless')! + .commands.find((c) => c.name() === 'projects')! + .commands.find((c) => c.name() === 'search')! + .commands.find((c) => c.name() === 'create')! + const flags = createCmd.options.map((o) => o.long) + assert.ok(flags.includes('--name'), '--name flag should be registered') + assert.ok(flags.includes('--region-id'), '--region-id flag should be registered') + }) + it('adds --wait flag to create project commands only', () => { const defs: CloudApiDefinition[] = [ { name: 'create-elasticsearch-project', namespace: 'elasticsearch-projects', description: 'Create', method: 'POST', path: '/api/v1/serverless/projects/elasticsearch' },