# Schedules
(*schedules*)

## Overview

### Available Operations

* [list](#list) - List Schedules V2
* [create](#create) - Create Schedules V2
* [delete](#delete) - Destroy Schedules V2
* [get](#get) - Show Schedules V2
* [update](#update) - Update Schedules V2

## list

List configured schedules.

### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.schedules.list({
    pageSize: 25,
    after: "01FDAG4SAP5TYPT98WGR2N7W91",
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { schedulesList } from "incidentio/funcs/schedulesList.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await schedulesList(incidentio, {
    pageSize: 25,
    after: "01FDAG4SAP5TYPT98WGR2N7W91",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.SchedulesV2NumberListRequest](../../models/operations/schedulesv2numberlistrequest.md)                                                                             | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ListResponseBody16](../../models/components/listresponsebody16.md)\>**

### Errors

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


## create

Create a new schedule.

### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.schedules.create({
    schedule: {
      annotations: {
        "incident.io/terraform/version": "version-of-terraform",
      },
      config: {
        rotations: [
          {
            effectiveFrom: new Date("2021-08-17T13:28:57.801578Z"),
            handoverStartAt: new Date("2021-08-17T13:28:57.801578Z"),
            handovers: [
              {
                interval: 1,
                intervalType: "daily",
              },
            ],
            id: "01G0J1EXE7AXZ2C93K61WBPYEH",
            layers: [
              {
                id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                name: "Layer 1",
              },
            ],
            name: "My Rotation",
            users: [
              {
                email: "bob@example.com",
                id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                slackUserId: "USER123",
              },
            ],
            workingInterval: [
              {
                endTime: "17:00",
                startTime: "09:00",
                weekday: "tuesday",
              },
            ],
          },
        ],
      },
      holidaysPublicConfig: {
        countryCodes: [
          "abc123",
        ],
      },
      name: "My Schedule",
      timezone: "America/Los_Angeles",
    },
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { schedulesCreate } from "incidentio/funcs/schedulesCreate.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await schedulesCreate(incidentio, {
    schedule: {
      annotations: {
        "incident.io/terraform/version": "version-of-terraform",
      },
      config: {
        rotations: [
          {
            effectiveFrom: new Date("2021-08-17T13:28:57.801578Z"),
            handoverStartAt: new Date("2021-08-17T13:28:57.801578Z"),
            handovers: [
              {
                interval: 1,
                intervalType: "daily",
              },
            ],
            id: "01G0J1EXE7AXZ2C93K61WBPYEH",
            layers: [
              {
                id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                name: "Layer 1",
              },
            ],
            name: "My Rotation",
            users: [
              {
                email: "bob@example.com",
                id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                slackUserId: "USER123",
              },
            ],
            workingInterval: [
              {
                endTime: "17:00",
                startTime: "09:00",
                weekday: "tuesday",
              },
            ],
          },
        ],
      },
      holidaysPublicConfig: {
        countryCodes: [
          "abc123",
        ],
      },
      name: "My Schedule",
      timezone: "America/Los_Angeles",
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [components.CreateRequestBody12](../../models/components/createrequestbody12.md)                                                                                               | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ShowResponseBody14](../../models/components/showresponsebody14.md)\>**

### Errors

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


## delete

Archives a single schedule.

### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  await incidentio.schedules.delete({
    id: "01G0J1EXE7AXZ2C93K61WBPYEH",
  });
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { schedulesDelete } from "incidentio/funcs/schedulesDelete.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await schedulesDelete(incidentio, {
    id: "01G0J1EXE7AXZ2C93K61WBPYEH",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.SchedulesV2NumberDestroyRequest](../../models/operations/schedulesv2numberdestroyrequest.md)                                                                       | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<void\>**

### Errors

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


## get

Get a single schedule.

### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.schedules.get({
    id: "01G0J1EXE7AXZ2C93K61WBPYEH",
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { schedulesGet } from "incidentio/funcs/schedulesGet.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await schedulesGet(incidentio, {
    id: "01G0J1EXE7AXZ2C93K61WBPYEH",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.SchedulesV2NumberShowRequest](../../models/operations/schedulesv2numbershowrequest.md)                                                                             | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ShowResponseBody14](../../models/components/showresponsebody14.md)\>**

### Errors

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


## update

Update a schedule.

### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.schedules.update({
    id: "01G0J1EXE7AXZ2C93K61WBPYEH",
    updateRequestBody8: {
      schedule: {
        annotations: {
          "incident.io/terraform/version": "version-of-terraform",
        },
        config: {
          rotations: [
            {
              effectiveFrom: new Date("2021-08-17T13:28:57.801578Z"),
              handoverStartAt: new Date("2021-08-17T13:28:57.801578Z"),
              handovers: [
                {
                  interval: 1,
                  intervalType: "daily",
                },
              ],
              id: "01G0J1EXE7AXZ2C93K61WBPYEH",
              layers: [
                {
                  id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                  name: "Layer 1",
                },
              ],
              name: "My Rotation",
              users: [
                {
                  email: "bob@example.com",
                  id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                  slackUserId: "USER123",
                },
              ],
              workingInterval: [
                {
                  endTime: "17:00",
                  startTime: "09:00",
                  weekday: "tuesday",
                },
              ],
            },
          ],
        },
        holidaysPublicConfig: {
          countryCodes: [
            "abc123",
          ],
        },
        name: "My Schedule",
        timezone: "America/Los_Angeles",
      },
    },
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { schedulesUpdate } from "incidentio/funcs/schedulesUpdate.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await schedulesUpdate(incidentio, {
    id: "01G0J1EXE7AXZ2C93K61WBPYEH",
    updateRequestBody8: {
      schedule: {
        annotations: {
          "incident.io/terraform/version": "version-of-terraform",
        },
        config: {
          rotations: [
            {
              effectiveFrom: new Date("2021-08-17T13:28:57.801578Z"),
              handoverStartAt: new Date("2021-08-17T13:28:57.801578Z"),
              handovers: [
                {
                  interval: 1,
                  intervalType: "daily",
                },
              ],
              id: "01G0J1EXE7AXZ2C93K61WBPYEH",
              layers: [
                {
                  id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                  name: "Layer 1",
                },
              ],
              name: "My Rotation",
              users: [
                {
                  email: "bob@example.com",
                  id: "01G0J1EXE7AXZ2C93K61WBPYEH",
                  slackUserId: "USER123",
                },
              ],
              workingInterval: [
                {
                  endTime: "17:00",
                  startTime: "09:00",
                  weekday: "tuesday",
                },
              ],
            },
          ],
        },
        holidaysPublicConfig: {
          countryCodes: [
            "abc123",
          ],
        },
        name: "My Schedule",
        timezone: "America/Los_Angeles",
      },
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.SchedulesV2NumberUpdateRequest](../../models/operations/schedulesv2numberupdaterequest.md)                                                                         | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ShowResponseBody14](../../models/components/showresponsebody14.md)\>**

### Errors

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