Go SDK
Integrate Aquil Safety from Go with typed request models, typed query params, and API defaults.
The Aquil Safety Go SDK provides a typed interface for the Aquil API in Go applications. It reduces raw HTTP plumbing and gives you typed models for request payloads and query parameters.
Installation
go get github.com/aquil-safety/go-aquilAuthentication
NewClient expects a Bearer JWT (not an internal ingestion key):
token := "your_api_token_here"
client := aquil.NewClient(&token)SDK-first usage
Typed request bodies
Use typed structs from the SDK package instead of raw maps.
incidentResp, err := client.CreateIncident(ctx, aquil.CreateIncidentRequest{
Name: "Example incident from Go SDK",
IdempotencyKey: fmt.Sprintf("go-aquil-example-%d", time.Now().Unix()),
SeverityID: severityID,
Visibility: "organization",
Source: "manual",
})Typed query params
pageSize := 25
resp, err := client.ListIncidents(ctx, aquil.ListIncidentsParams{
PageSize: &pageSize,
StatusOneOf: "new,open",
SeverityNotIn: "sev4",
})OpenAPI defaults surfaced as SDK constants
aquil.DefaultInviteExpiresInDays(14)aquil.DefaultAckTimeoutSeconds(60)aquil.DefaultMaxGapMinutes(0)
Main typed models
- Incident:
CreateIncidentRequest,PatchIncidentRequest,ResolveIncidentRequest,DeclineIncidentRequest,MergeIncidentRequest,CreateIncidentNoteRequest,StartIncidentPagingRequest - Workspaces:
CreateWorkspaceRequest,PatchCurrentWorkspaceRequest,SwitchCurrentWorkspaceRequest,PatchCurrentWorkspaceMemberRoleRequest,CreateCurrentWorkspaceInviteRequest - Escalations:
CreateEscalationPolicyRequest,PatchEscalationPolicyRequest,EscalationPolicyCreateStep - Schedules:
CreateScheduleRequest,PatchScheduleRequest,CreateScheduleShiftRequest,MergeScheduleShiftsRequest - Sensor events:
CreateSensorEventRequest,SensorEventLocation - Suppressions:
CreateSuppressionRequest
End-to-end incident example
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
severitiesResp, err := client.ListSeverities(ctx)
if err != nil {
log.Fatal(err)
}
var severities struct {
Data []struct {
ID string `json:"id"`
} `json:"data"`
}
if err := json.Unmarshal(severitiesResp.Body, &severities); err != nil {
log.Fatal(err)
}
if len(severities.Data) == 0 {
log.Fatal("no severities configured")
}
incidentResp, err := client.CreateIncident(ctx, aquil.CreateIncidentRequest{
Name: "Example incident from Go SDK",
IdempotencyKey: fmt.Sprintf("go-aquil-example-%d", time.Now().Unix()),
SeverityID: severities.Data[0].ID,
Visibility: "organization",
Source: "manual",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(string(incidentResp.Body))Repository
- Source package:
github.com/aquil-safety/go-aquil