Skip to content

Latest commit

 

History

History
254 lines (182 loc) · 11.7 KB

README.md

File metadata and controls

254 lines (182 loc) · 11.7 KB

Webhook

(webhook)

Available Operations

createWebhook

Creates an outbound webhook.

Example Usage

import { Circleci } from "circleci-v2-sdk";
import { Events, TypeT } 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.webhook.createWebhook({
    events: [
      Events.JobCompleted,
    ],
    name: "<value>",
    scope: {
      id: "ef8f63e3-b7d2-4240-88ac-4c59d30daac8",
      type: TypeT.Project,
    },
    signingSecret: "<value>",
    url: "http://ragged-suppression.name",
    verifyTls: false,
  });

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

run();

Parameters

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

Response

Promise<operations.CreateWebhookResponse>

Errors

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

deleteWebhook

Deletes an outbound webhook

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.webhook.deleteWebhook({
    webhookId: "90ed7052-6bb0-4b60-93ab-e4433ee4e2bb",
  });

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

run();

Parameters

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

Response

Promise<operations.DeleteWebhookResponse>

Errors

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

getWebhookById

Get an outbound webhook by id.

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.webhook.getWebhookById({
    webhookId: "48f47148-587e-42d6-8c80-5b1461e57de9",
  });

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

run();

Parameters

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

Response

Promise<operations.GetWebhookByIdResponse>

Errors

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

getWebhooks

Get a list of outbound webhooks that match the given scope-type and scope-id

Example Usage

import { Circleci } from "circleci-v2-sdk";
import { ScopeType } 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.webhook.getWebhooks({
    scopeId: "14ccf55a-42ac-416c-bacd-a992e8b59ec0",
    scopeType: ScopeType.Project,
  });

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

run();

Parameters

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

Response

Promise<operations.GetWebhooksResponse>

Errors

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

updateWebhook

Updates an outbound webhook.

Example Usage

import { Circleci } from "circleci-v2-sdk";
import { UpdateWebhookEvents } 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.webhook.updateWebhook({
    requestBody: {
      events: [
        UpdateWebhookEvents.JobCompleted,
      ],
    },
    webhookId: "ac255204-82ad-4436-900a-b198d2970788",
  });

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

run();

Parameters

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

Response

Promise<operations.UpdateWebhookResponse>

Errors

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