@solarwinds/squadcast-sdk-typescript
v1.0.0
Published
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *openapi* API.
Readme
Squadcast SDK for TypeScript
Developer-friendly & type-safe Typescript SDK specifically catered to leverage openapi API.
Table of Contents
SDK Installation
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add @solarwinds/squadcast-sdk-typescriptPNPM
pnpm add @solarwinds/squadcast-sdk-typescriptBun
bun add @solarwinds/squadcast-sdk-typescriptYarn
yarn add @solarwinds/squadcast-sdk-typescript[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
SDK Example Usage
Example
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
const squadcastSDK = new SquadcastSDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.analytics.getOrganization({
from: "<value>",
to: "<value>",
});
console.log(result);
}
run();
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
| ------------ | ---- | ----------- |
| bearerAuth | http | HTTP Bearer |
To authenticate with the API the bearerAuth parameter must be set when initializing the SDK client instance. For example:
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
const squadcastSDK = new SquadcastSDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.analytics.getOrganization({
from: "<value>",
to: "<value>",
});
console.log(result);
}
run();
Available Resources and Operations
analytics
- getOrganization - Get Org level analytics
- getTeam - Get Team level analytics
auditLogs
- list - List all Audit Logs
- export - Initiate an asynchronous export of audit logs based on the provided filters. The export file will be generated and available for download. Use 'Get details of Audit Logs export history by ID' API to retrieve the download URL.
- listExportHistory - List all Audit Logs export history
- getById - Get audit log by ID
auditLogs.exportHistory
- get - Get details of Audit Logs export history by ID
communicationCards
- createSlackChannel - Create Slack Channel in Communication Card
- delete - Delete Communication Card
components
- list - List Components
- deleteById - Delete Component By ID
dedupKeyOverlays
- renderTemplate - Render Dedup Key template
- getForAlertSource - Get Dedup Key Overlay for Alert Source
- update - Update Dedup Key Overlay
deduplicationRules
- getRules - Get Deduplication Rules
- createOrUpdate - Create or Update Deduplication Rules
escalationPolicies
- listByTeam - Get Escalation Policy By team
- create - Create Escalation Policies
- remove - Remove Escalation Policy
- getById - Get Escalation Policy By ID
- update - Update Escalation Policy
exports
- getDetails - Get Export Details
exportSchedule
- refreshIcalLink - Refresh Schedule ICal Link
extensions.msteams
- getConfig - Get MSTeams Config
extensions.webhooks
globalEventRules
- list - List Global Event Rules
- create - Create Global Event Rule
- deleteById - Delete Global Event Rule by ID
- getById - Get Global Event Rule by ID
- updateById - Update Global Event Rule by ID
globalEventRules.rulesets
- create - Create Ruleset
- get - Get Ruleset
- update - Update Ruleset
- reorder - Reorder Ruleset
- listRules - List Ruleset Rules
- createRule - Create Rule
- updateRule - Update Rule by ID
globalEventRules.rulesets.rules
- get - Get Rule by ID
- reorderByIndex - Reorder Ruleset By Index
globalOncallReminderRules
- delete - Delete Global Oncall Reminder Rules
- get - Get Global Oncall Reminder Rules
- create - Create Global Oncall Reminder Rules
- update - Update Global Oncall Reminder Rules
incidentActions.circleci
- rebuild - Rebuild a Project In CircleCI
incidents
- archiveSlackChannel - Archive Slack Channel
- getAllCommunicationCards - Get All Communication Card
- updateCommunicationCard - Update Communication Card
- attachRunbooks - Attach Runbooks
- createJiraServerTicket - Create a Ticket on Jira Server
- createInServiceNow - Create an Incident in ServiceNow
- triggerWebhook - Trigger a Webhook Manually
- getAdditionalResponders - Get Additional Responders
- removeAdditionalResponder - Remove Additional Responders
- markAsTransient - Mark as Transient
- updatePostmortem - Update Postmortem By Incident
- unsnoozeNotifications - Unsnooze Incident Notifications
- export - Incident Export
- exportAsync - Incident Export Async
- bulkUpdatePriority - Bulk Incidents Priority Update
- bulkResolve - Bulk Resolve Incidents
- getById - Get Incident by ID
- acknowledge - Acknowledge Incident
- markSloFalsePositive - Mark Incident SLO False Positive
- updatePriority - Incident Priority Update
- reassign - Reassign Incident
- resolve - Resolve Incident
- getStatusByRequestIds - Get Incidents Status By RequestIDs
incidents.actions.jiraCloud
- createTicket - Create a Ticket on Jira Cloud
incidents.additionalResponders
- add - Add Additional Responders
incidents.autoPauseTransientAlerts
- markAsNotTransient - Mark as Not Transient
incidents.communicationCards
- create - Create Communication Card
incidents.events
- list - Get Incident Events
incidents.notes
incidents.postmortems
- getAll - Get All Postmortems
- getByIncident - Get Postmortem By Incident
- create - Create Postmortem
incidents.snooze
- set - Snooze Incident Notifications
incidents.tags
incidentsV3
- bulkAcknowledge - Bulk Acknowledge Incidents
issues
issueStates
- list - List Status Page Issue States
maintenances
- create - Create Maintenance
- deleteById - Delete Maintenance By ID
msteams
- createOrUpdateConfiguration - Create Or Update MSTeams Configuration
notes
- delete - Delete Note
overlays
- getAllDedupKeysByService - Get All Dedup Key Overlay by Service
overrides
- list - List Overrides
postmortems
- deleteByIncident - Delete Postmortem By Incident
rotations
- getScheduleRotations - List Schedule Rotations
- delete - Delete Rotation
- getById - Get Schedule Rotation by ID
- getParticipants - Get Rotation Participants
- updateParticipants - Update Rotation Participants
routingRules
- get - Get Routing Rules
- createOrUpdate - Create or Update Routing Rules
rules
- deleteById - Delete Rule by ID
rulesets
- deleteById - Delete GER Ruleset
runbooks
- listByTeam - Get All Runbooks By Team
- create - Create Runbook
- remove - Remove Runbook
- getById - Get Runbook By ID
- update - Update Runbook
schedule.export
- deleteICalLink - Delete ICal Link
schedules
- list - List Schedules
- create - Create Schedule
- delete - Delete Schedule
- getById - Get Schedule by ID
- update - Update Schedule
- changeTimezone - Change Timezone
- clone - Clone Schedule
- createIcalLink - Create Schedule ICal Link
- deleteOverride - Delete Schedule Override
- getOverrideById - Get Override by ID
- createRotation - Create Rotation
schedules.actions
- pauseResume - Pause/Resume Schedule
schedules.export
- getIcalLink - Get Schedule ICal Link
schedules.overrides
schedules.rotations
- update - Update Rotation
services
- list - Get All Services
- create - Create Service
- listByName - Get Services By Name
- getById - Get Service By ID
- update - Update Service
- delete - Delete Service
- createOrUpdateIAGConfig - Intelligent Alert Grouping (IAG)
- updateNotificationDelayConfig - Delayed Notification Config
- updateSlackExtension - Update Slack Extension
- getCustomContentTemplates - Get All Custom Content Template Overlay by Service
services.aptaConfig
- createOrUpdate - Auto Pause Transient Alerts (APTA)
services.dependencies
- createOrUpdate - Create or Update Dependencies
services.maintenance
- get - Get Maintenance Mode
- createOrUpdate - Create or Update Maintenance Mode
services.overlay
- getOptinForKeyBasedDeduplication - Get Opt-in for Key Based Deduplication for a service
services.overlays
- optinKeyBasedDeduplication - Opt-in for Key Based Deduplication for a service
- renderCustomContent - Render Custom Content Overlay
- deleteCustomContent - Delete Notification Template Overlay
- getCustomContentTemplate - Get Custom Content Template Overlay
services.overlays.customContent
- createOrUpdate - Create or Update Notification Template Overlay
services.overlays.dedupKey
- delete - Delete Dedup Key Overlay
services.suppressionRules
- list - Get Suppression Rules
- createOrUpdate - Create or Update Suppression Rules
services.taggingRules
- list - Get Tagging Rules
- createOrUpdate - Create or Update Tagging Rules
slo
- markAffected - Mark SLO Affected
slos
- list - Get All SLOs
- create - Create SLO
- update - Update SLO
- remove - Remove SLO
- getById - Get SLO By ID
- markFalsePositive - Mark SLO False Positive
squads
- list - Get All Squads
- createV4 - Create Squad
- updateMember - Update Squad Member
- updateName - Update Squad Name
- delete - Delete Squad
squads.members
- remove - Remove Squad Member
squadsV4
statusPages
- list - List Status Pages
- create - Create Status Page
- delete - Delete Status Page By ID
- getById - Get Status Page By ID
- updateById - Update Status Page By ID
- getIssueById - Get Issue By ID
- listStatuses - List Status Page Statuses
statusPages.componentGroups
- list - List Component Groups
- create - Create Component Group
- deleteById - Delete Component Group By ID
- getById - Get Component Group By ID
statusPages.components
- create - Create Component
- getById - Get Component By ID
- updateById - Update Component By ID
statusPages.issues
statusPages.maintenances
- list - List Maintenances
- getById - Get Maintenance By ID
- updateById - Update Maintenance By ID
statusPageSubscribers
- list - List Subscribers
teams
- list - Get All Teams
- create - Create Team
- getById - Get Team By ID
- update - Update Team
- remove - Remove Team
- listMembers - Get All Team Members
- getRoles - Get All Team Roles
teams.members
- add - Add Team Member
- bulkAdd - Add Bulk Team Member
- remove - Remove Team Member
- update - Update Team Member
teams.roles
tokens
- create - Create Token
users
- getAllTokens - Get All Tokens
- removeToken - Remove Token
- list - Get All Users
- add - Add User
- updateOrgLevelPermissions - Update Org Level Permissions
- delete - Delete User
- getRoles - Get User Roles
- removeFromOrg - Remove User From Org
- getById - Get User By ID
- updateById - Update User by userID
webforms
- getAll - Get All Webforms
- create - Create Webform
- update - Update Webform
- remove - Remove Webform
- getById - Get Webform By ID
webhooks
workflowActions
- getById - Get Workflow Action By ID
workflowLogs
- get - Get Workflow Logs
workflows
- list - List Workflows
- create - Create Workflow
- bulkEnableDisable - Bulk Enable/Disable Workflows
- delete - Delete Workflow
- getById - Get Workflow By ID
- update - Update Workflow
- updateActionsOrder - Update Actions Order
- deleteAction - Delete Workflow Action
- updateAction - Update Workflow Action
- enableDisable - Enable/Disable Workflow
workflows.actions
- create - Create Action
Standalone functions
All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
analyticsGetOrganization- Get Org level analyticsanalyticsGetTeam- Get Team level analyticsauditLogsExport- Initiate an asynchronous export of audit logs based on the provided filters. The export file will be generated and available for download. Use 'Get details of Audit Logs export history by ID' API to retrieve the download URL.auditLogsExportHistoryGet- Get details of Audit Logs export history by IDauditLogsGetById- Get audit log by IDauditLogsList- List all Audit LogsauditLogsListExportHistory- List all Audit Logs export historycommunicationCardsCreateSlackChannel- Create Slack Channel in Communication CardcommunicationCardsDelete- Delete Communication CardcomponentsDeleteById- Delete Component By IDcomponentsList- List ComponentsdedupKeyOverlaysGetForAlertSource- Get Dedup Key Overlay for Alert SourcededupKeyOverlaysRenderTemplate- Render Dedup Key templatededupKeyOverlaysUpdate- Update Dedup Key OverlaydeduplicationRulesCreateOrUpdate- Create or Update Deduplication RulesdeduplicationRulesGetRules- Get Deduplication RulesescalationPoliciesCreate- Create Escalation PoliciesescalationPoliciesGetById- Get Escalation Policy By IDescalationPoliciesListByTeam- Get Escalation Policy By teamescalationPoliciesRemove- Remove Escalation PolicyescalationPoliciesUpdate- Update Escalation PolicyexportScheduleRefreshIcalLink- Refresh Schedule ICal LinkexportsGetDetails- Get Export DetailsextensionsMsteamsGetConfig- Get MSTeams ConfigextensionsWebhooksCreate- Create WebhookextensionsWebhooksUpdate- Update WebhookglobalEventRulesCreate- Create Global Event RuleglobalEventRulesDeleteById- Delete Global Event Rule by IDglobalEventRulesGetById- Get Global Event Rule by IDglobalEventRulesList- List Global Event RulesglobalEventRulesRulesetsCreate- Create RulesetglobalEventRulesRulesetsCreateRule- Create RuleglobalEventRulesRulesetsGet- Get RulesetglobalEventRulesRulesetsListRules- List Ruleset RulesglobalEventRulesRulesetsReorder- Reorder RulesetglobalEventRulesRulesetsRulesGet- Get Rule by IDglobalEventRulesRulesetsRulesReorderByIndex- Reorder Ruleset By IndexglobalEventRulesRulesetsUpdate- Update RulesetglobalEventRulesRulesetsUpdateRule- Update Rule by IDglobalEventRulesUpdateById- Update Global Event Rule by IDglobalOncallReminderRulesCreate- Create Global Oncall Reminder RulesglobalOncallReminderRulesDelete- Delete Global Oncall Reminder RulesglobalOncallReminderRulesGet- Get Global Oncall Reminder RulesglobalOncallReminderRulesUpdate- Update Global Oncall Reminder RulesincidentActionsCircleciRebuild- Rebuild a Project In CircleCIincidentsAcknowledge- Acknowledge IncidentincidentsActionsJiraCloudCreateTicket- Create a Ticket on Jira CloudincidentsAdditionalRespondersAdd- Add Additional RespondersincidentsArchiveSlackChannel- Archive Slack ChannelincidentsAttachRunbooks- Attach RunbooksincidentsAutoPauseTransientAlertsMarkAsNotTransient- Mark as Not TransientincidentsBulkResolve- Bulk Resolve IncidentsincidentsBulkUpdatePriority- Bulk Incidents Priority UpdateincidentsCommunicationCardsCreate- Create Communication CardincidentsCreateInServiceNow- Create an Incident in ServiceNowincidentsCreateJiraServerTicket- Create a Ticket on Jira ServerincidentsEventsList- Get Incident EventsincidentsExport- Incident ExportincidentsExportAsync- Incident Export AsyncincidentsGetAdditionalResponders- Get Additional RespondersincidentsGetAllCommunicationCards- Get All Communication CardincidentsGetById- Get Incident by IDincidentsGetStatusByRequestIds- Get Incidents Status By RequestIDsincidentsMarkAsTransient- Mark as TransientincidentsMarkSloFalsePositive- Mark Incident SLO False PositiveincidentsNotesCreate- Create NotesincidentsNotesList- Get All NotesincidentsNotesUpdate- Update NoteincidentsPostmortemsCreate- Create PostmortemincidentsPostmortemsGetAll- Get All PostmortemsincidentsPostmortemsGetByIncident- Get Postmortem By IncidentincidentsReassign- Reassign IncidentincidentsRemoveAdditionalResponder- Remove Additional RespondersincidentsResolve- Resolve IncidentincidentsSnoozeSet- Snooze Incident NotificationsincidentsTagsAppend- Append TagincidentsTagsUpdate- Update TagincidentsTriggerWebhook- Trigger a Webhook ManuallyincidentsUnsnoozeNotifications- Unsnooze Incident NotificationsincidentsUpdateCommunicationCard- Update Communication CardincidentsUpdatePostmortem- Update Postmortem By IncidentincidentsUpdatePriority- Incident Priority UpdateincidentsV3BulkAcknowledge- Bulk Acknowledge IncidentsissuesCreate- Create IssueissuesDelete- Delete Issue By IDissueStatesList- List Status Page Issue StatesmaintenancesCreate- Create MaintenancemaintenancesDeleteById- Delete Maintenance By IDmsteamsCreateOrUpdateConfiguration- Create Or Update MSTeams ConfigurationnotesDelete- Delete NoteoverlaysGetAllDedupKeysByService- Get All Dedup Key Overlay by ServiceoverridesList- List OverridespostmortemsDeleteByIncident- Delete Postmortem By IncidentrotationsDelete- Delete RotationrotationsGetById- Get Schedule Rotation by IDrotationsGetParticipants- Get Rotation ParticipantsrotationsGetScheduleRotations- List Schedule RotationsrotationsUpdateParticipants- Update Rotation ParticipantsroutingRulesCreateOrUpdate- Create or Update Routing RulesroutingRulesGet- Get Routing RulesrulesDeleteById- Delete Rule by IDrulesetsDeleteById- Delete GER RulesetrunbooksCreate- Create RunbookrunbooksGetById- Get Runbook By IDrunbooksListByTeam- Get All Runbooks By TeamrunbooksRemove- Remove RunbookrunbooksUpdate- Update RunbookscheduleExportDeleteICalLink- Delete ICal LinkschedulesActionsPauseResume- Pause/Resume ScheduleschedulesChangeTimezone- Change TimezoneschedulesClone- Clone ScheduleschedulesCreate- Create ScheduleschedulesCreateIcalLink- Create Schedule ICal LinkschedulesCreateRotation- Create RotationschedulesDelete- Delete ScheduleschedulesDeleteOverride- Delete Schedule OverrideschedulesExportGetIcalLink- Get Schedule ICal LinkschedulesGetById- Get Schedule by IDschedulesGetOverrideById- Get Override by IDschedulesList- List SchedulesschedulesOverridesCreate- Create Schedule OverrideschedulesOverridesUpdate- Update Schedule OverrideschedulesRotationsUpdate- Update RotationschedulesUpdate- Update ScheduleservicesAptaConfigCreateOrUpdate- Auto Pause Transient Alerts (APTA)servicesCreate- Create ServiceservicesCreateOrUpdateIAGConfig- Intelligent Alert Grouping (IAG)servicesDelete- Delete ServiceservicesDependenciesCreateOrUpdate- Create or Update DependenciesservicesGetById- Get Service By IDservicesGetCustomContentTemplates- Get All Custom Content Template Overlay by ServiceservicesList- Get All ServicesservicesListByName- Get Services By NameservicesMaintenanceCreateOrUpdate- Create or Update Maintenance ModeservicesMaintenanceGet- Get Maintenance ModeservicesOverlayGetOptinForKeyBasedDeduplication- Get Opt-in for Key Based Deduplication for a serviceservicesOverlaysCustomContentCreateOrUpdate- Create or Update Notification Template OverlayservicesOverlaysDedupKeyDelete- Delete Dedup Key OverlayservicesOverlaysDeleteCustomContent- Delete Notification Template OverlayservicesOverlaysGetCustomContentTemplate- Get Custom Content Template OverlayservicesOverlaysOptinKeyBasedDeduplication- Opt-in for Key Based Deduplication for a serviceservicesOverlaysRenderCustomContent- Render Custom Content OverlayservicesSuppressionRulesCreateOrUpdate- Create or Update Suppression RulesservicesSuppressionRulesList- Get Suppression RulesservicesTaggingRulesCreateOrUpdate- Create or Update Tagging RulesservicesTaggingRulesList- Get Tagging RulesservicesUpdate- Update ServiceservicesUpdateNotificationDelayConfig- Delayed Notification ConfigservicesUpdateSlackExtension- Update Slack ExtensionsloMarkAffected- Mark SLO AffectedslosCreate- Create SLOslosGetById- Get SLO By IDslosList- Get All SLOsslosMarkFalsePositive- Mark SLO False PositiveslosRemove- Remove SLOslosUpdate- Update SLOsquadsCreateV4- Create SquadsquadsDelete- Delete SquadsquadsList- Get All SquadssquadsMembersRemove- Remove Squad MembersquadsUpdateMember- Update Squad MembersquadsUpdateName- Update Squad NamesquadsV4GetById- Get Squad By IDsquadsV4Update- Update SquadstatusPagesComponentGroupsCreate- Create Component GroupstatusPagesComponentGroupsDeleteById- Delete Component Group By IDstatusPagesComponentGroupsGetById- Get Component Group By IDstatusPagesComponentGroupsList- List Component GroupsstatusPagesComponentsCreate- Create ComponentstatusPagesComponentsGetById- Get Component By IDstatusPagesComponentsUpdateById- Update Component By IDstatusPagesCreate- Create Status PagestatusPagesDelete- Delete Status Page By IDstatusPagesGetById- Get Status Page By IDstatusPagesGetIssueById- Get Issue By IDstatusPagesIssuesList- List IssuesstatusPagesIssuesUpdate- Update IssuestatusPagesList- List Status PagesstatusPagesListStatuses- List Status Page StatusesstatusPagesMaintenancesGetById- Get Maintenance By IDstatusPagesMaintenancesList- List MaintenancesstatusPagesMaintenancesUpdateById- Update Maintenance By IDstatusPageSubscribersList- List SubscribersstatusPagesUpdateById- Update Status Page By IDteamsCreate- Create TeamteamsGetById- Get Team By IDteamsGetRoles- Get All Team RolesteamsList- Get All TeamsteamsListMembers- Get All Team MembersteamsMembersAdd- Add Team MemberteamsMembersBulkAdd- Add Bulk Team MemberteamsMembersRemove- Remove Team MemberteamsMembersUpdate- Update Team MemberteamsRemove- Remove TeamteamsRolesCreate- Create Team RoleteamsRolesRemove- Remove Team RoleteamsRolesUpdate- Update Team RoleteamsUpdate- Update TeamtokensCreate- Create TokenusersAdd- Add UserusersDelete- Delete UserusersGetAllTokens- Get All TokensusersGetById- Get User By IDusersGetRoles- Get User RolesusersList- Get All UsersusersRemoveFromOrg- Remove User From OrgusersRemoveToken- Remove TokenusersUpdateById- Update User by userIDusersUpdateOrgLevelPermissions- Update Org Level PermissionswebformsCreate- Create WebformwebformsGetAll- Get All WebformswebformsGetById- Get Webform By IDwebformsRemove- Remove WebformwebformsUpdate- Update WebformwebhooksDelete- Delete WebhookwebhooksGetAll- Get All WebhookswebhooksGetById- Get Webhook By IDworkflowActionsGetById- Get Workflow Action By IDworkflowLogsGet- Get Workflow LogsworkflowsActionsCreate- Create ActionworkflowsBulkEnableDisable- Bulk Enable/Disable WorkflowsworkflowsCreate- Create WorkflowworkflowsDelete- Delete WorkflowworkflowsDeleteAction- Delete Workflow ActionworkflowsEnableDisable- Enable/Disable WorkflowworkflowsGetById- Get Workflow By IDworkflowsList- List WorkflowsworkflowsUpdate- Update WorkflowworkflowsUpdateAction- Update Workflow ActionworkflowsUpdateActionsOrder- Update Actions Order
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you
make your SDK calls as usual, but the returned response object will also be an
async iterable that can be consumed using the for await...of
syntax.
Here's an example of one such pagination call:
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
import { RFCDate } from "@solarwinds/squadcast-sdk-typescript/types";
const squadcastSDK = new SquadcastSDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.auditLogs.list({
pageSize: 832442,
pageNumber: 555332,
startDate: new RFCDate("2023-03-04"),
endDate: new RFCDate("2024-08-07"),
});
for await (const page of result) {
console.log(page);
}
}
run();
File uploads
Certain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
[!TIP]
Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:
- Node.js v20+: Since v20, Node.js comes with a native
openAsBlobfunction innode:fs.- Bun: The native
Bun.filefunction produces a file handle that can be used for streaming file uploads.- Browsers: All supported browsers return an instance to a
Filewhen reading the value from an<input type="file">element.- Node.js v18: A file stream can be created using the
fileFromhelper fromfetch-blob/from.js.
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
import { openAsBlob } from "node:fs";
const squadcastSDK = new SquadcastSDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.escalationPolicies.update({
escalationPolicyID: "<id>",
v3EscalationPoliciesUpdateEscalationPolicyRequest: await openAsBlob(
"example.file",
),
});
console.log(result);
}
run();
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
const squadcastSDK = new SquadcastSDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.analytics.getOrganization({
from: "<value>",
to: "<value>",
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
const squadcastSDK = new SquadcastSDK({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.analytics.getOrganization({
from: "<value>",
to: "<value>",
});
console.log(result);
}
run();
Error Handling
SquadcastSDKError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |
| error.statusCode | number | HTTP response status code eg 404 |
| error.headers | Headers | HTTP response headers |
| error.body | string | HTTP body. Can be empty string if no body is returned. |
| error.rawResponse | Response | Raw HTTP response |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |
Example
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
import * as errors from "@solarwinds/squadcast-sdk-typescript/models/errors";
const squadcastSDK = new SquadcastSDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
try {
const result = await squadcastSDK.analytics.getOrganization({
from: "<value>",
to: "<value>",
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.SquadcastSDKError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.BadRequestError) {
console.log(error.data$.meta); // models.CommonV3ErrorMeta
}
}
}
}
run();
Error Classes
Primary errors:
SquadcastSDKError: The base class for HTTP error responses.PaymentRequiredError: Client error. Status code402. *ForbiddenError: Access is forbidden. Status code403. *NotFoundError: The server cannot find the requested resource. Status code404. *ConflictError: The request conflicts with the current state of the server. Status code409. *UnprocessableEntityError: Client error. Status code422. *InternalServerError: Server error. Status code500. *BadGatewayError: Server error. Status code502. *ServiceUnavailableError: Service unavailable. Status code503. *GatewayTimeoutError: Server error. Status code504. *UnauthorizedError: Access is unauthorized. Status code401. *BadRequestError: The server could not understand the request due to invalid syntax. Status code400. *
Network errors:
ConnectionError: HTTP client was unable to make a request to a server.RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.RequestAbortedError: HTTP request was aborted by the client.InvalidRequestError: Any input used to create a request is invalid.UnexpectedClientError: Unrecognised or unexpected error.
Inherit from SquadcastSDKError:
CommonV4Error: The server could not understand the request due to invalid syntax. Applicable to 32 of 230 methods.*ResponseBodyError1: Represents a CircleCI error response for a 400 status code. Status code400. Applicable to 1 of 230 methods.*ResponseBodyError2: Represents a CircleCI error response for a 400 status code. Status code400. Applicable to 1 of 230 methods.*ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
const squadcastSDK = new SquadcastSDK({
serverURL: "https://api.squadcast.com",
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await squadcastSDK.analytics.getOrganization({
from: "<value>",
to: "<value>",
});
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
import { HTTPClient } from "@solarwinds/squadcast-sdk-typescript/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new SquadcastSDK({ httpClient: httpClient });Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console's interface as an SDK option.
[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
import { SquadcastSDK } from "@solarwinds/squadcast-sdk-typescript";
const sdk = new SquadcastSDK({ debugLogger: console });Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
