/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { incidentsCreate } from "../funcs/incidentsCreate.js"; import { incidentsGet } from "../funcs/incidentsGet.js"; import { incidentsList } from "../funcs/incidentsList.js"; import { incidentsUpdate } from "../funcs/incidentsUpdate.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; export class Incidents extends ClientSDK { /** * List Incidents V2 * * @remarks * List all incidents for an organisation. * * This endpoint supports a number of filters, which can help find incidents matching certain * criteria. * * Filters are provided as query parameters, but due to the dynamic nature of what you can * query by (different accounts have different custom fields, statuses, etc) they are more * complex than most. * * To help, here are some exemplar curl requests with a human description of what they search * for. * * Note that: * - Filters may be used together, and the result will be incidents that match all filters. * - IDs are normally in UUID format, but have been replaced with shorter strings to improve * readability. * - All query parameters must be URI encoded. * * ### By status * * With status of id=ABC, find all incidents that are set to that status: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'status[one_of]=ABC' * * Or all incidents that are not set to status with id=ABC: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'status[not_in]=ABC' * * ### By created_at or updated_at * * Find all incidents that follow specified date parameters for created_at and updated_at fields. * Possible values are "gte" (greater than or equal to) and "lte" (less than or equal to). The * following example finds all incidents created before or on 2021-01-02T00:00:00Z: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'created_at[lte]=2021-01-02' * * ### By status category * * Find all incidents that are in a status category. Possible values are "triage", * "declined", "merged", "canceled", "live", "learning" and "closed": * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'status_category[one_of]=live' * * Or all incidents that are not in a status category: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'status_category[not_in]=live' * * ### By severity * * With severity of id=ABC, find all incidents that are set to that severity: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'severity[one_of]=ABC' * * Or all incidents where severity rank is greater-than-or-equal-to the rank of severity * id=ABC: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'severity[gte]=ABC' * * Or all incidents where severity rank is less-than-or-equal-to the rank of severity id=ABC: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'severity[lte]=ABC' * * ### By incident type * * With incident type of id=ABC, find all incidents that are of that type: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'incident_type[one_of]=ABC' * * Or all incidents not of that type: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'incident_type[not_in]=ABC' * * ### By incident mode * * By default, we return standard and retrospective incidents. This means that test and * tutorial incidents are filtered out. To override this behaviour, you can use the * mode filter to specify which modes you want to get. * * To find incidents of all modes: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'mode[one_of]=standard&mode[one_of]=retrospective&mode[one_of]=test&mode[one_of]=tutorial' * * To find just test incidents: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'mode[one_of]=test' * * ### By incident role * * Roles and custom fields have another nested layer in the query parameter, to account for * operations against any of the roles or custom fields created in the account. * * With incident role id=ABC, find all incidents where that role is unset: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'incident_role[ABC][is_blank]=true' * * Or where the role has been set: * * curl --get 'https://api.incident.io/v2/incidents' \ * --data 'incident_role[ABC][is_blank]=false' * * ### By option custom fields * * With an option custom field id=ABC, all incidents that have field ABC set to the custom * field option of id=XYZ: * * curl \ * --get 'https://api.incident.io/v2/incidents' \ * --data 'custom_field[ABC][one_of]=XYZ' * * Or all incidents that do not have custom field id=ABC set to option id=XYZ: * * curl \ * --get 'https://api.incident.io/v2/incidents' \ * --data 'custom_field[ABC][not_in]=XYZ' */ async list( request: operations.IncidentsV2NumberListRequest, options?: RequestOptions, ): Promise { return unwrapAsync(incidentsList( this, request, options, )); } /** * Create Incidents V2 * * @remarks * Create a new incident. * * Note that if the incident mode is set to "retrospective" then the new incident * will not be announced in Slack. */ async create( request: components.CreateRequestBody11, options?: RequestOptions, ): Promise { return unwrapAsync(incidentsCreate( this, request, options, )); } /** * Show Incidents V2 * * @remarks * Get a single incident. * * The ID supplied can be either the incident's full ID, or the numeric part of its * reference. For example, to get INC-123, you could use either its full ID or: * * curl \ * --get 'https://api.incident.io/v2/incidents/123 */ async get( request: operations.IncidentsV2NumberShowRequest, options?: RequestOptions, ): Promise { return unwrapAsync(incidentsGet( this, request, options, )); } /** * Edit Incidents V2 * * @remarks * Edit an existing incident. * * This endpoint allows you to edit the properties of an existing incident: e.g. set the severity or update custom fields. * * When using this endpoint, only fields that are provided will be edited (omitted fields * will be ignored). */ async update( request: operations.IncidentsV2NumberEditRequest, options?: RequestOptions, ): Promise { return unwrapAsync(incidentsUpdate( this, request, options, )); } }