Developer-friendly & type-safe Go SDK specifically catered to leverage Squadcast API.
To add the SDK as a dependency to your project:
go get github.com/SquadcastHub/squadcast-sdk-gopackage main
import (
"context"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"log"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.Analytics.GetOrganization(ctx, "<value>", "<value>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
|---|---|---|---|
BearerAuth |
http | HTTP Bearer | SQUADCASTSDK_BEARER_AUTH |
You can configure it using the WithSecurity option when initializing the SDK client instance. For example:
package main
import (
"context"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"log"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.Analytics.GetOrganization(ctx, "<value>", "<value>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}Available methods
- GetOrganization - Get Org level analytics
- GetTeam - Get Team level analytics
- List - Get All Tokens
- CreateSlackChannel - Create Slack Channel in Communication Card
- ArchiveSlackChannel - Archive Slack Channel
- GetByTeam - Get Escalation Policy By team
- Create - Create Escalation Policies
- Remove - Remove Escalation Policy
- GetByID - Get Escalation Policy By ID
- Update - Update Escalation Policy
- GetDetails - Get Export Details
- UpsertConfig - Create Or Update MSTeams Configuration
- List - List Global Event Rules
- Create - Create Global Event Rule
- DeleteRule - Delete Global Event Rule by ID
- GetByID - Get Global Event Rule by ID
- UpdateByID - Update Global Event Rule by ID
- GetRuleset - Get Ruleset
- UpdateRuleset - Update Ruleset
- UpdateRule - Update Rule by ID
- ReorderByIndex - Reorder Ruleset By Index
- Create - Create Ruleset
- Reorder - Reorder Ruleset
- ListRulesetRules - List Ruleset Rules
- Delete - Delete GER Ruleset
- DeleteByID - Delete Rule by ID
- Delete - Delete Global Oncall Reminder Rules
- List - Get Global Oncall Reminder Rules
- Create - Create Global Oncall Reminder Rules
- Update - Update Global Oncall Reminder Rules
- Rebuild - Rebuild a Project In CircleCI
- BulkAcknowledge - Bulk Acknowledge Incidents
- 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
- GetAllPostmortems - Get All Postmortems
- MarkAsTransient - Mark as Transient
- UpdatePostmortem - Update Postmortem By Incident
- UnsnoozeNotifications - Unsnooze Incident Notifications
- CreateJiraCloudTicket - Create a Ticket on Jira Cloud
- CreateJiraServerTicket - Create a Ticket on Jira Server
- CreateInServicenow - Create an Incident in ServiceNow
- TriggerManually - Trigger a Webhook Manually
- Get - Get Additional Responders
- Add - Add Additional Responders
- Delete - Remove Additional Responders
- MarkAsNotTransient - Mark as Not Transient
- Update - Update Communication Card
- GetAll - Get All Communication Card
- Create - Create Communication Card
- Delete - Delete Communication Card
- List - Get Incident Events
- DeleteByIncident - Delete Postmortem By Incident
- GetByIncident - Get Postmortem By Incident
- Create - Create Postmortem
- Attach - Attach Runbooks
- Snooze - Snooze Incident Notifications
- GetConfig - Get MSTeams Config
- List - Get All Notes
- DeleteNotificationTemplate - Delete Notification Template Overlay
- Create - Create Rotation
- GetByID - Get Schedule Rotation by ID
- Update - Update Rotation
- GetParticipants - Get Rotation Participants
- UpdateParticipants - Update Rotation Participants
- ListByTeam - Get All Runbooks By Team
- Create - Create Runbook
- Remove - Remove Runbook
- GetByID - Get Runbook By ID
- Update - Update Runbook
- List - List Schedules
- Create - Create Schedule
- Delete - Delete Schedule
- GetByID - Get Schedule by ID
- Update - Update Schedule
- PauseResume - Pause/Resume Schedule
- ChangeTimezone - Change Timezone
- Clone - Clone Schedule
- GetIcalLink - Get Schedule ICal Link
- RefreshIcalLink - Refresh Schedule ICal Link
- CreateIcalLink - Create Schedule ICal Link
- CreateScheduleOverride - Create Schedule Override
- DeleteRotation - Delete Rotation
- DeleteIcalLink - Delete ICal Link
- List - List Schedule Rotations
- List - Get All Services
- Create - Create Service
- GetByName - Get Services By Name
- GetByID - Get Service By ID
- Update - Update Service
- Delete - Delete Service
- CreateOrUpdateAptaConfig - Auto Pause Transient Alerts (APTA)
- UpsertIagConfig - Intelligent Alert Grouping (IAG)
- UpdateNotificationDelayConfig - Delayed Notification Config
- CreateOrUpdateDependencies - Create or Update Dependencies
- CreateOrUpdateNotificationTemplateOverlay - Create or Update Notification Template Overlay
- GetAllDedupKeyOverlays - Get All Dedup Key Overlay by Service
- UpdateDedupKeyOverlay - Update Dedup Key Overlay
- GetRoutingRules - Get Routing Rules
- CreateOrUpdateSuppressionRules - Create or Update Suppression Rules
- CreateOrUpdateTaggingRules - Create or Update Tagging Rules
- Get - Get Deduplication Rules
- CreateOrUpdate - Create or Update Deduplication Rules
- UpdateSlack - Update Slack Extension
- Get - Get Maintenance Mode
- CreateOrUpdate - Create or Update Maintenance Mode
- GetKeyBasedDeduplicationOptin - Get Opt-in for Key Based Deduplication for a service
- OptInForKeyBasedDeduplication - Opt-in for Key Based Deduplication for a service
- GetCustomContentTemplates - Get All Custom Content Template Overlay by Service
- GetCustomContent - Get Custom Content Template Overlay
- GetDedupKey - Get Dedup Key Overlay for Alert Source
- Render - Render Custom Content Overlay
- CreateOrUpdate - Create or Update Routing Rules
- Get - Get Suppression Rules
- Get - Get Tagging Rules
- ListAll - Get All SLOs
- Create - Create SLO
- Update - Update SLO
- Remove - Remove SLO
- GetByID - Get SLO By ID
- MarkAffected - Mark SLO Affected
- MarkFalsePositive - Mark SLO False Positive
- List - Get All Squads
- RemoveMember - Remove Squad Member
- UpdateMemberRole - Update Squad Member
- UpdateName - Update Squad Name
- Delete - Delete Squad
- List - List Status Pages
- Create - Create Status Page
- DeleteByID - Delete Status Page By ID
- GetByID - Get Status Page By ID
- UpdateByID - Update Status Page By ID
- CreateIssue - Create Issue
- UpdateIssue - Update Issue
- ListMaintenances - List Maintenances
- GetMaintenanceByID - Get Maintenance By ID
- GetStatuses - List Status Page Statuses
- List - List Component Groups
- Create - Create Component Group
- DeleteByID - Delete Component Group By ID
- GetByID - Get Component Group By ID
- List - List Components
- Create - Create Component
- DeleteByID - Delete Component By ID
- GetByID - Get Component By ID
- UpdateByID - Update Component By ID
- List - List Issues
- Delete - Delete Issue By ID
- GetByID - Get Issue By ID
- ListStates - List Status Page Issue States
- Create - Create Maintenance
- DeleteByID - Delete Maintenance By ID
- UpdateByID - Update Maintenance By ID
- List - List Subscribers
- GetAll - Get All Teams
- Create - Create Team
- GetByID - Get Team By ID
- Update - Update Team
- Delete - Remove Team
- AddMember - Add Team Member
- AddBulkMember - Add Bulk Team Member
- RemoveMember - Remove Team Member
- UpdateMember - Update Team Member
- GetAllRoles - Get All Team Roles
- CreateRole - Create Team Role
- RemoveRole - Remove Team Role
- UpdateRole - Update Team Role
- GetAll - Get All Team Members
- CreateUserToken - Create Token
- GetAll - 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
- Update - Update User by userID
- Remove - Remove Token
- Update - Update Squad
- GetAll - Get All Webforms
- Create - Create Webform
- Update - Update Webform
- Remove - Remove Webform
- Get - Get Webform By ID
- 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
- GetAction - Get Workflow Action By ID
- UpdateAction - Update Workflow Action
- ToggleEnable - Enable/Disable Workflow
- GetLogs - Get Workflow Logs
- Create - Create Action
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 have a Next method that can be called to pull down the next group of results. If the
return value of Next is nil, then there are no more pages to be fetched.
Here's an example of one such pagination call:
package main
import (
"context"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"log"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.EscalationPolicies.GetByTeam(ctx, "<id>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}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 retry.Config object to the call by using the WithRetries option:
package main
import (
"context"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"github.com/SquadcastHub/squadcast-sdk-go/retry"
"log"
"models/operations"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.Analytics.GetOrganization(ctx, "<value>", "<value>", nil, nil, operations.WithRetries(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}))
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:
package main
import (
"context"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"github.com/SquadcastHub/squadcast-sdk-go/retry"
"log"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithRetryConfig(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}),
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.Analytics.GetOrganization(ctx, "<value>", "<value>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.
By Default, an API error will return apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.
For example, the GetOrganization function may return the following errors:
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestError | 400 | application/json |
| apierrors.UnauthorizedError | 401 | application/json |
| apierrors.PaymentRequiredError | 402 | application/json |
| apierrors.ForbiddenError | 403 | application/json |
| apierrors.NotFoundError | 404 | application/json |
| apierrors.ConflictError | 409 | application/json |
| apierrors.UnprocessableEntityError | 422 | application/json |
| apierrors.InternalServerError | 500 | application/json |
| apierrors.BadGatewayError | 502 | application/json |
| apierrors.ServiceUnavailableError | 503 | application/json |
| apierrors.GatewayTimeoutError | 504 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
package main
import (
"context"
"errors"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"github.com/SquadcastHub/squadcast-sdk-go/models/apierrors"
"log"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.Analytics.GetOrganization(ctx, "<value>", "<value>", nil, nil)
if err != nil {
var e *apierrors.BadRequestError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.UnauthorizedError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.PaymentRequiredError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.ForbiddenError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.NotFoundError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.ConflictError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.UnprocessableEntityError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.InternalServerError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.BadGatewayError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.ServiceUnavailableError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.GatewayTimeoutError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *apierrors.APIError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
}
}The default server can be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:
package main
import (
"context"
squadcastsdk "github.com/SquadcastHub/squadcast-sdk-go"
"log"
"os"
)
func main() {
ctx := context.Background()
s := squadcastsdk.New(
squadcastsdk.WithServerURL("https://api.squadcast.com"),
squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_BEARER_AUTH")),
)
res, err := s.Analytics.GetOrganization(ctx, "<value>", "<value>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.
import (
"net/http"
"time"
"github.com/SquadcastHub/squadcast-sdk-go"
)
var (
httpClient = &http.Client{Timeout: 30 * time.Second}
sdkClient = squadcastsdk.New(squadcastsdk.WithClient(httpClient))
)This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.
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.
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.