/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { expect, test } from "vitest"; import { Incidentio } from "../index.js"; test("Incidents Incidents V2 #List", async () => { const incidentio = new Incidentio(); const result = await incidentio.incidents.list({ pageSize: 25, after: "01FDAG4SAP5TYPT98WGR2N7W91", status: { "one_of": [ "01GBSQF3FHF7FWZQNWGHAVQ804", ], }, statusCategory: { "one_of": [ "active", ], }, createdAt: { "created_at[gte]": [ "2024-05-01", ], }, updatedAt: { "updated_at[gte]": [ "2024-05-01", ], }, severity: { "one_of": [ "01GBSQF3FHF7FWZQNWGHAVQ804", ], }, incidentType: { "one_of": [ "01GBSQF3FHF7FWZQNWGHAVQ804", ], }, incidentRole: { "01GBSQF3FHF7FWZQNWGHAVQ804": { "one_of": [ "01GBSQF3FHF7FWZQNWGHAVQ804", "01ET65M7ZARSFZ6TFDFVQDN9AA", ], }, }, customField: { "01GBSQF3FHF7FWZQNWGHAVQ804": { "one_of": [ "01GBSQF3FHF7FWZQNWGHAVQ804", "01ET65M7ZARSFZ6TFDFVQDN9AA", ], }, }, mode: { "one_of": [ "retrospective", ], }, }); expect(result).toBeDefined(); expect(result).toBeDefined(); expect(result).toEqual({ incidents: [ { callUrl: "https://zoom.us/foo", createdAt: new Date("2021-08-17T13:28:57.801578Z"), creator: { apiKey: { id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "My test API key", }, user: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, }, customFieldEntries: [ { customField: { description: "Which team is impacted by this issue", fieldType: "single_select", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Affected Team", options: [ { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, ], }, values: [ { valueCatalogEntry: { aliases: [ "lawrence@incident.io", "lawrence", ], externalId: "761722cd-d1d7-477b-ac7e-90f9e079dc33", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Primary On-call", }, valueLink: "https://google.com/", valueNumeric: "123.456", valueOption: { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, valueText: "This is my text field, I hope you like it", }, ], }, ], durationMetrics: [ { durationMetric: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Lasted", }, valueSeconds: 1, }, ], externalIssueReference: { issueName: "INC-123", issuePermalink: "https://linear.app/incident-io/issue/INC-1609/find-copywriter-to-write-up", provider: "asana", }, id: "01FDAG4SAP5TYPT98WGR2N7W91", incidentRoleAssignments: [ { assignee: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, role: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "The person currently coordinating the incident", id: "01FCNDV6P870EA6S7TK1DSYDG0", instructions: "Take point on the incident; Make sure people are clear on responsibilities", name: "Incident Lead", required: false, roleType: "lead", shortform: "lead", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentStatus: { category: "triage", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Impact has been **fully mitigated**, and we're ready to learn from this incident.", id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Closed", rank: 4, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, incidentTimestampValues: [ { incidentTimestamp: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Impact started", rank: 1, }, value: { value: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentType: { createInTriage: "always", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Customer facing production outages", id: "01FCNDV6P870EA6S7TK1DSYDG0", isDefault: false, name: "Production Outage", privateIncidentsOnly: false, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, mode: "standard", name: "Our database is sad", permalink: "https://app.incident.io/incidents/123", postmortemDocumentUrl: "https://docs.google.com/my_doc_id", reference: "INC-123", severity: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Issues with **low impact**.", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Minor", rank: 1, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, slackChannelId: "C02AW36C1M5", slackChannelName: "inc-165-green-parrot", slackTeamId: "T02A1FSLE8J", summary: "Our database is really really sad, and we don't know why yet.", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), visibility: "public", workloadMinutesLate: 40.7, workloadMinutesSleeping: 0, workloadMinutesTotal: 60.7, workloadMinutesWorking: 20, }, ], paginationMeta: { after: "01FCNDV6P870EA6S7TK1DSYDG0", pageSize: 25, totalRecordCount: 238, }, }); }); test("Incidents Incidents V2 #Create", async () => { const incidentio = new Incidentio(); const result = await incidentio.incidents.create({ customFieldEntries: [ { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", values: [ { id: "01FCNDV6P870EA6S7TK1DSYDG0", valueCatalogEntryId: "01FCNDV6P870EA6S7TK1DSYDG0", valueLink: "https://google.com/", valueNumeric: "123.456", valueOptionId: "01FCNDV6P870EA6S7TK1DSYDG0", valueText: "This is my text field, I hope you like it", valueTimestamp: "", }, ], }, ], id: "01FDAG4SAP5TYPT98WGR2N7W91", idempotencyKey: "alert-uuid", incidentRoleAssignments: [ { assignee: { email: "bob@example.com", id: "01G0J1EXE7AXZ2C93K61WBPYEH", slackUserId: "USER123", }, incidentRoleId: "01FH5TZRWMNAFB0DZ23FD1TV96", }, ], incidentStatusId: "01G0J1EXE7AXZ2C93K61WBPYEH", incidentTimestampValues: [ { incidentTimestampId: "01FCNDV6P870EA6S7TK1DSYD5H", value: new Date("2021-08-17T13:28:57.801578Z"), }, ], incidentTypeId: "01FH5TZRWMNAFB0DZ23FD1TV96", mode: "standard", name: "Our database is sad", retrospectiveIncidentOptions: { postmortemDocumentUrl: "https://docs.google.com/my_doc_id", slackChannelId: "abc123", }, severityId: "01FH5TZRWMNAFB0DZ23FD1TV96", slackChannelNameOverride: "inc-123-database-down", slackTeamId: "T02A1FSLE8J", summary: "Our database is really really sad, and we don't know why yet.", visibility: "public", }); expect(result).toBeDefined(); expect(result).toBeDefined(); expect(result).toEqual({ incident: { callUrl: "https://zoom.us/foo", createdAt: new Date("2021-08-17T13:28:57.801578Z"), creator: { apiKey: { id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "My test API key", }, user: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, }, customFieldEntries: [ { customField: { description: "Which team is impacted by this issue", fieldType: "single_select", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Affected Team", options: [ { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, ], }, values: [ { valueCatalogEntry: { aliases: [ "lawrence@incident.io", "lawrence", ], externalId: "761722cd-d1d7-477b-ac7e-90f9e079dc33", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Primary On-call", }, valueLink: "https://google.com/", valueNumeric: "123.456", valueOption: { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, valueText: "This is my text field, I hope you like it", }, ], }, ], durationMetrics: [ { durationMetric: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Lasted", }, valueSeconds: 1, }, ], externalIssueReference: { issueName: "INC-123", issuePermalink: "https://linear.app/incident-io/issue/INC-1609/find-copywriter-to-write-up", provider: "asana", }, id: "01FDAG4SAP5TYPT98WGR2N7W91", incidentRoleAssignments: [ { assignee: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, role: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "The person currently coordinating the incident", id: "01FCNDV6P870EA6S7TK1DSYDG0", instructions: "Take point on the incident; Make sure people are clear on responsibilities", name: "Incident Lead", required: false, roleType: "lead", shortform: "lead", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentStatus: { category: "triage", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Impact has been **fully mitigated**, and we're ready to learn from this incident.", id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Closed", rank: 4, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, incidentTimestampValues: [ { incidentTimestamp: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Impact started", rank: 1, }, value: { value: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentType: { createInTriage: "always", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Customer facing production outages", id: "01FCNDV6P870EA6S7TK1DSYDG0", isDefault: false, name: "Production Outage", privateIncidentsOnly: false, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, mode: "standard", name: "Our database is sad", permalink: "https://app.incident.io/incidents/123", postmortemDocumentUrl: "https://docs.google.com/my_doc_id", reference: "INC-123", severity: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Issues with **low impact**.", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Minor", rank: 1, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, slackChannelId: "C02AW36C1M5", slackChannelName: "inc-165-green-parrot", slackTeamId: "T02A1FSLE8J", summary: "Our database is really really sad, and we don't know why yet.", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), visibility: "public", workloadMinutesLate: 40.7, workloadMinutesSleeping: 0, workloadMinutesTotal: 60.7, workloadMinutesWorking: 20, }, }); }); test("Incidents Incidents V2 #Show", async () => { const incidentio = new Incidentio(); const result = await incidentio.incidents.get({ id: "01FDAG4SAP5TYPT98WGR2N7W91", }); expect(result).toBeDefined(); expect(result).toBeDefined(); expect(result).toEqual({ incident: { callUrl: "https://zoom.us/foo", createdAt: new Date("2021-08-17T13:28:57.801578Z"), creator: { apiKey: { id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "My test API key", }, user: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, }, customFieldEntries: [ { customField: { description: "Which team is impacted by this issue", fieldType: "single_select", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Affected Team", options: [ { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, ], }, values: [ { valueCatalogEntry: { aliases: [ "lawrence@incident.io", "lawrence", ], externalId: "761722cd-d1d7-477b-ac7e-90f9e079dc33", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Primary On-call", }, valueLink: "https://google.com/", valueNumeric: "123.456", valueOption: { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, valueText: "This is my text field, I hope you like it", }, ], }, ], durationMetrics: [ { durationMetric: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Lasted", }, valueSeconds: 1, }, ], externalIssueReference: { issueName: "INC-123", issuePermalink: "https://linear.app/incident-io/issue/INC-1609/find-copywriter-to-write-up", provider: "asana", }, id: "01FDAG4SAP5TYPT98WGR2N7W91", incidentRoleAssignments: [ { assignee: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, role: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "The person currently coordinating the incident", id: "01FCNDV6P870EA6S7TK1DSYDG0", instructions: "Take point on the incident; Make sure people are clear on responsibilities", name: "Incident Lead", required: false, roleType: "lead", shortform: "lead", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentStatus: { category: "triage", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Impact has been **fully mitigated**, and we're ready to learn from this incident.", id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Closed", rank: 4, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, incidentTimestampValues: [ { incidentTimestamp: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Impact started", rank: 1, }, value: { value: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentType: { createInTriage: "always", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Customer facing production outages", id: "01FCNDV6P870EA6S7TK1DSYDG0", isDefault: false, name: "Production Outage", privateIncidentsOnly: false, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, mode: "standard", name: "Our database is sad", permalink: "https://app.incident.io/incidents/123", postmortemDocumentUrl: "https://docs.google.com/my_doc_id", reference: "INC-123", severity: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Issues with **low impact**.", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Minor", rank: 1, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, slackChannelId: "C02AW36C1M5", slackChannelName: "inc-165-green-parrot", slackTeamId: "T02A1FSLE8J", summary: "Our database is really really sad, and we don't know why yet.", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), visibility: "public", workloadMinutesLate: 40.7, workloadMinutesSleeping: 0, workloadMinutesTotal: 60.7, workloadMinutesWorking: 20, }, }); }); test("Incidents Incidents V2 #Edit", async () => { const incidentio = new Incidentio(); const result = await incidentio.incidents.update({ id: "01G18REBY9AYH6CMWCJ2CVCYCH", editRequestBody: { incident: { callUrl: "https://zoom.us/foo", customFieldEntries: [ { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", values: [ { id: "01FCNDV6P870EA6S7TK1DSYDG0", valueCatalogEntryId: "01FCNDV6P870EA6S7TK1DSYDG0", valueLink: "https://google.com/", valueNumeric: "123.456", valueOptionId: "01FCNDV6P870EA6S7TK1DSYDG0", valueText: "This is my text field, I hope you like it", valueTimestamp: "", }, ], }, ], incidentRoleAssignments: [ { assignee: { email: "bob@example.com", id: "01G0J1EXE7AXZ2C93K61WBPYEH", slackUserId: "USER123", }, incidentRoleId: "01FH5TZRWMNAFB0DZ23FD1TV96", }, ], incidentStatusId: "01FH5TZRWMNAFB0DZ23FD1TV96", incidentTimestampValues: [ { incidentTimestampId: "01FCNDV6P870EA6S7TK1DSYD5H", value: new Date("2021-08-17T13:28:57.801578Z"), }, ], name: "Our database is sad", severityId: "01FH5TZRWMNAFB0DZ23FD1TV96", slackChannelNameOverride: "inc-123-database-down", summary: "Our database is really really sad, and we don't know why yet.", }, notifyIncidentChannel: true, }, }); expect(result).toBeDefined(); expect(result).toBeDefined(); expect(result).toEqual({ incident: { callUrl: "https://zoom.us/foo", createdAt: new Date("2021-08-17T13:28:57.801578Z"), creator: { apiKey: { id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "My test API key", }, user: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, }, customFieldEntries: [ { customField: { description: "Which team is impacted by this issue", fieldType: "single_select", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Affected Team", options: [ { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, ], }, values: [ { valueCatalogEntry: { aliases: [ "lawrence@incident.io", "lawrence", ], externalId: "761722cd-d1d7-477b-ac7e-90f9e079dc33", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Primary On-call", }, valueLink: "https://google.com/", valueNumeric: "123.456", valueOption: { customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0", id: "01FCNDV6P870EA6S7TK1DSYDG0", sortKey: 10, value: "Product", }, valueText: "This is my text field, I hope you like it", }, ], }, ], durationMetrics: [ { durationMetric: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Lasted", }, valueSeconds: 1, }, ], externalIssueReference: { issueName: "INC-123", issuePermalink: "https://linear.app/incident-io/issue/INC-1609/find-copywriter-to-write-up", provider: "asana", }, id: "01FDAG4SAP5TYPT98WGR2N7W91", incidentRoleAssignments: [ { assignee: { email: "lisa@incident.io", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Lisa Karlin Curtis", role: "viewer", slackUserId: "U02AYNF2XJM", }, role: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "The person currently coordinating the incident", id: "01FCNDV6P870EA6S7TK1DSYDG0", instructions: "Take point on the incident; Make sure people are clear on responsibilities", name: "Incident Lead", required: false, roleType: "lead", shortform: "lead", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentStatus: { category: "triage", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Impact has been **fully mitigated**, and we're ready to learn from this incident.", id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Closed", rank: 4, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, incidentTimestampValues: [ { incidentTimestamp: { id: "01FCNDV6P870EA6S7TK1DSYD5H", name: "Impact started", rank: 1, }, value: { value: new Date("2021-08-17T13:28:57.801578Z"), }, }, ], incidentType: { createInTriage: "always", createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Customer facing production outages", id: "01FCNDV6P870EA6S7TK1DSYDG0", isDefault: false, name: "Production Outage", privateIncidentsOnly: false, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, mode: "standard", name: "Our database is sad", permalink: "https://app.incident.io/incidents/123", postmortemDocumentUrl: "https://docs.google.com/my_doc_id", reference: "INC-123", severity: { createdAt: new Date("2021-08-17T13:28:57.801578Z"), description: "Issues with **low impact**.", id: "01FCNDV6P870EA6S7TK1DSYDG0", name: "Minor", rank: 1, updatedAt: new Date("2021-08-17T13:28:57.801578Z"), }, slackChannelId: "C02AW36C1M5", slackChannelName: "inc-165-green-parrot", slackTeamId: "T02A1FSLE8J", summary: "Our database is really really sad, and we don't know why yet.", updatedAt: new Date("2021-08-17T13:28:57.801578Z"), visibility: "public", workloadMinutesLate: 40.7, workloadMinutesSleeping: 0, workloadMinutesTotal: 60.7, workloadMinutesWorking: 20, }, }); });