Skip to content

Latest commit

 

History

History
590 lines (418 loc) · 29 KB

README.md

File metadata and controls

590 lines (418 loc) · 29 KB

Project

(project)

Overview

[EXPERIMENTAL] Endpoints related to creating and managing a project.

Available Operations

createCheckoutKey

Not available to projects that use GitLab or GitHub App. Creates a new checkout key. This API request is only usable with a user API token. Please ensure that you have authorized your account with GitHub before creating user keys. This is necessary to give CircleCI the permission to create a user key associated with your GitHub user account. You can find this page by visiting Project Settings > Checkout SSH Keys

Example Usage

import { Circleci } from "circleci-v2-sdk";
import { CheckoutKeyInputType } from "circleci-v2-sdk/dist/sdk/models/operations";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.createCheckoutKey({
    requestBody: {
      type: CheckoutKeyInputType.DeployKey,
    },
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateCheckoutKeyRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.CreateCheckoutKeyResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

createEnvVar

Creates a new environment variable.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.createEnvVar({
    requestBody: {
      name: "foo",
      value: "xxxx1234",
    },
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateEnvVarRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.CreateEnvVarResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

createProject

[EXPERIMENTAL] Creates a new CircleCI project, and returns a list of the default advanced settings. Can only be called on a repo with a main branch and an existing config.yml file. Not yet available to projects that use GitLab or GitHub App.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.createProject({
    organization: "CircleCI-Public",
    project: "api-preview-docs",
    provider: "gh",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateProjectRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.CreateProjectResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

deleteCheckoutKey

Deletes the checkout key via md5 or sha256 fingerprint. sha256 keys should be url-encoded.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.deleteCheckoutKey({
    fingerprint: "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f",
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteCheckoutKeyRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.DeleteCheckoutKeyResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

deleteEnvVar

Deletes the environment variable named :name.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.deleteEnvVar({
    name: "foo",
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteEnvVarRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.DeleteEnvVarResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

getCheckoutKey

Returns an individual checkout key via md5 or sha256 fingerprint. sha256 keys should be url-encoded.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.getCheckoutKey({
    fingerprint: "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f",
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetCheckoutKeyRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.GetCheckoutKeyResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

getEnvVar

Returns the masked value of environment variable :name.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.getEnvVar({
    name: "foo",
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetEnvVarRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.GetEnvVarResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

getProjectBySlug

Retrieves a project by project slug.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.getProjectBySlug({
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetProjectBySlugRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.GetProjectBySlugResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

getProjectSettings

[EXPERIMENTAL] Returns a list of the advanced settings for a CircleCI project, whether enabled (true) or not (false).

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.getProjectSettings({
    organization: "CircleCI-Public",
    project: "api-preview-docs",
    provider: "gh",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetProjectSettingsRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.GetProjectSettingsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

listCheckoutKeys

Returns a sequence of checkout keys for :project.

Example Usage

import { Circleci } from "circleci-v2-sdk";
import { Digest } from "circleci-v2-sdk/dist/sdk/models/operations";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.listCheckoutKeys({
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListCheckoutKeysRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.ListCheckoutKeysResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

listEnvVars

Returns four 'x' characters, in addition to the last four ASCII characters of the value, consistent with the display of environment variable values on the CircleCI website.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.listEnvVars({
    projectSlug: "gh/CircleCI-Public/api-preview-docs",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListEnvVarsRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.ListEnvVarsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

patchProjectSettings

[EXPERIMENTAL] Updates one or more of the advanced settings for a CircleCI project.

Example Usage

import { Circleci } from "circleci-v2-sdk";

async function run() {
  const sdk = new Circleci({
    security: {
      apiKeyHeader: "<YOUR_API_KEY_HERE>",
    },
  });

  const res = await sdk.project.patchProjectSettings({
    organization: "CircleCI-Public",
    project: "api-preview-docs",
    projectSettings: {
      advanced: {
        prOnlyBranchOverrides: [
          "<value>",
        ],
      },
    },
    provider: "gh",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.PatchProjectSettingsRequest ✔️ The request object to use for the request.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.PatchProjectSettingsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /