diff --git a/client/index.ts b/client/index.ts index bcee33c..ebb3c1c 100644 --- a/client/index.ts +++ b/client/index.ts @@ -12,6 +12,8 @@ export type { DecisionSettings } from "./models/DecisionSettings.ts"; export type { get_usage_export_job_status } from "./models/get_usage_export_job_status.ts"; export type { JSONDuration } from "./models/JSONDuration.ts"; export type { PatchClaimsRequest } from "./models/PatchClaimsRequest.ts"; +export type { pipeline } from "./models/pipeline.ts"; +export type { pipelineRequest } from "./models/pipelineRequest.ts"; export type { Policy } from "./models/Policy.ts"; export type { PolicyBundle } from "./models/PolicyBundle.ts"; export type { project_settings } from "./models/project_settings.ts"; diff --git a/client/models/pipeline.ts b/client/models/pipeline.ts new file mode 100644 index 0000000..4a550ba --- /dev/null +++ b/client/models/pipeline.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type pipeline = { + created_at?: string; + id?: string; + number?: number; + state?: "created" | "errored" | "setup-pending" | "setup" | "pending"; +}; diff --git a/client/models/pipelineRequest.ts b/client/models/pipelineRequest.ts new file mode 100644 index 0000000..3685286 --- /dev/null +++ b/client/models/pipelineRequest.ts @@ -0,0 +1,46 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type pipelineRequest = { + checkout?: { + /** + * The branch that should be used to check out code on a checkout step. + * Note that branch and tag are mutually exclusive. + * To trigger a pipeline for a PR by number use pull//head for the PR ref or pull//merge for the merge ref (GitHub only) + * + */ + branch?: string; + /** + * The tag that should be used to check out code on a checkout step. + * The commit that this tag points to is used for the pipeline. Note that branch and tag are mutually exclusive. + * + */ + tag?: string; + }; + config?: { + /** + * The branch that should be used to fetch the config file. + * Note that branch and tag are mutually exclusive. + * To trigger a pipeline for a PR by number use pull//head for the PR ref or pull//merge for the merge ref (GitHub only) + * + */ + branch?: string; + /** + * The tag that should be used to fetch the config file. + * The commit that this tag points to is used for the pipeline. + * Note that branch and tag are mutually exclusive. + * + */ + tag?: string; + }; + /** + * The unique id for the pipeline definition. This can be found in the page Project Settings > Pipelines. + */ + definition_id?: string; + /** + * An object containing pipeline parameters and their values. + * Pipeline parameters have the following size limits: 100 max entries, 128 maximum key length, 512 maximum value length. + * + */ + parameters?: any; +}; diff --git a/client/services/PipelineService.ts b/client/services/PipelineService.ts index d0aa0c6..750288a 100644 --- a/client/services/PipelineService.ts +++ b/client/services/PipelineService.ts @@ -1,3 +1,5 @@ +import type { pipeline } from "../models/pipeline.ts"; +import type { pipelineRequest } from "../models/pipelineRequest.ts"; import type { CancelablePromise } from "../core/CancelablePromise.ts"; import { OpenAPI } from "../core/OpenAPI.ts"; import { request as __request } from "../core/request.ts"; @@ -659,7 +661,7 @@ export class PipelineService { } /** * Trigger a new pipeline - * Not yet available to projects that use GitLab or GitHub App. Triggers a new pipeline on the project. + * Not available to projects that use GitLab or GitHub App. Triggers a new pipeline on the project. **GitHub App users should use the [new Trigger Pipeline API](#tag/Pipeline/operation/triggerPipelineRun)**. * @returns any Error response. * @throws ApiError */ @@ -1006,4 +1008,47 @@ export class PipelineService { }, }); } + /** + * [Recommended] Trigger a new pipeline + * Trigger a pipeline given a pipeline definition ID. Supports all integrations except GitLab. + * @returns pipeline Successful response. + * @throws ApiError + */ + public static triggerPipelineRun({ + provider, + organization, + project, + requestBody, + }: { + /** + * The `provider` segment of a project or org slug, the first of the three. This may be a VCS. For projects that use GitHub App, use `circleci`. + */ + provider: "github" | "gh" | "bitbucket" | "bb" | "circleci"; + /** + * The `organization` segment of a project or org slug, the second of the three. For GitHub OAuth or Bitbucket projects, this is the organization name. For projects that use GitLab or GitHub App, use the organization ID (found in Organization Settings). + */ + organization: string; + /** + * The `project` segment of a project slug, the third of the three. For GitHub OAuth or Bitbucket projects, this is the repository name. For projects that use GitLab or GitHub App, use the project ID (found in Project Settings). + */ + project: string; + requestBody?: pipelineRequest; + }): CancelablePromise { + return __request(OpenAPI, { + method: "POST", + url: "/project/{provider}/{organization}/{project}/pipeline/run", + path: { + provider: provider, + organization: organization, + project: project, + }, + body: requestBody, + mediaType: "application/json", + errors: { + 400: `Unexpected request body provided.`, + 401: `Credentials provided are invalid.`, + 404: `Entity not found.`, + }, + }); + } } diff --git a/swagger.json b/swagger.json index 07ee7f1..367aca3 100644 --- a/swagger.json +++ b/swagger.json @@ -189,6 +189,17 @@ "type": "string" } }, + "providerNoGitlab": { + "description": "The `provider` segment of a project or org slug, the first of the three. This may be a VCS. For projects that use GitHub App, use `circleci`.", + "example": "gh", + "in": "path", + "name": "provider", + "required": true, + "schema": { + "enum": ["github", "gh", "bitbucket", "bb", "circleci"], + "type": "string" + } + }, "restriction_id": { "description": "An opaque identifier of a context restriction.", "example": "1c23d2cb-07b1-4a28-8af3-e369732050ed", @@ -899,6 +910,88 @@ "required": ["usage_export_job_id", "state", "download_urls"], "type": "object" }, + "pipeline": { + "additionalProperties": false, + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "number": { + "example": 25, + "type": "integer" + }, + "state": { + "enum": ["created", "errored", "setup-pending", "setup", "pending"], + "type": "string" + } + }, + "type": "object" + }, + "pipelineRequest": { + "additionalProperties": false, + "properties": { + "checkout": { + "additionalProperties": false, + "example": { + "tag": "v2" + }, + "properties": { + "branch": { + "description": "The branch that should be used to check out code on a checkout step.\nNote that branch and tag are mutually exclusive.\nTo trigger a pipeline for a PR by number use pull//head for the PR ref or pull//merge for the merge ref (GitHub only)\n", + "example": "main", + "type": "string" + }, + "tag": { + "description": "The tag that should be used to check out code on a checkout step.\nThe commit that this tag points to is used for the pipeline. Note that branch and tag are mutually exclusive.\n", + "example": "v2", + "type": "string" + } + }, + "type": "object" + }, + "config": { + "additionalProperties": false, + "example": { + "branch": "main" + }, + "properties": { + "branch": { + "description": "The branch that should be used to fetch the config file.\nNote that branch and tag are mutually exclusive.\nTo trigger a pipeline for a PR by number use pull//head for the PR ref or pull//merge for the merge ref (GitHub only)\n", + "example": "main", + "type": "string" + }, + "tag": { + "description": "The tag that should be used to fetch the config file.\nThe commit that this tag points to is used for the pipeline.\nNote that branch and tag are mutually exclusive.\n", + "example": "v2", + "type": "string" + } + }, + "type": "object" + }, + "definition_id": { + "description": "The unique id for the pipeline definition. This can be found in the page Project Settings > Pipelines.", + "example": "2338d0ae-5541-4bbf-88a2-55e9f7281f80", + "format": "uuid", + "type": "string" + }, + "parameters": { + "additionalProperties": true, + "description": "An object containing pipeline parameters and their values.\nPipeline parameters have the following size limits: 100 max entries, 128 maximum key length, 512 maximum value length.\n", + "example": { + "example_param": "my value", + "example_param2": true, + "example_param3": 3 + }, + "type": "object" + } + }, + "type": "object" + }, "project_settings": { "additionalProperties": false, "properties": { @@ -7868,7 +7961,7 @@ "tags": ["Pipeline"] }, "post": { - "description": "Not yet available to projects that use GitLab or GitHub App. Triggers a new pipeline on the project.", + "description": "Not available to projects that use GitLab or GitHub App. Triggers a new pipeline on the project. **GitHub App users should use the [new Trigger Pipeline API](#tag/Pipeline/operation/triggerPipelineRun)**.", "operationId": "triggerPipeline", "parameters": [ { @@ -9635,6 +9728,55 @@ "tags": ["Project"] } }, + "/project/{provider}/{organization}/{project}/pipeline/run": { + "post": { + "description": "Trigger a pipeline given a pipeline definition ID. Supports all integrations except GitLab.", + "operationId": "triggerPipelineRun", + "parameters": [ + { + "$ref": "#/components/parameters/providerNoGitlab" + }, + { + "$ref": "#/components/parameters/organization" + }, + { + "$ref": "#/components/parameters/project" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pipelineRequest" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pipeline" + } + } + }, + "description": "Successful response." + }, + "400": { + "$ref": "#/components/responses/400_unexpected_request_body" + }, + "401": { + "$ref": "#/components/responses/401_invalid_token" + }, + "404": { + "$ref": "#/components/responses/404_entity_not_found" + } + }, + "summary": "[Recommended] Trigger a new pipeline", + "tags": ["Pipeline"] + } + }, "/project/{provider}/{organization}/{project}/settings": { "get": { "description": "[__EXPERIMENTAL__] Returns a list of the advanced settings for a CircleCI project, whether enabled (true) or not (false).",