{"id":16569976,"url":"https://github.com/andygrunwald/go-incident","last_synced_at":"2025-03-21T11:33:43.831Z","repository":{"id":41971280,"uuid":"479703987","full_name":"andygrunwald/go-incident","owner":"andygrunwald","description":"Go client library for accessing the Incident.io API","archived":false,"fork":false,"pushed_at":"2024-04-19T12:40:53.000Z","size":61,"stargazers_count":5,"open_issues_count":8,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-01T06:09:25.542Z","etag":null,"topics":["api","client-library","go","golang","hacktoberfest","incident-management","incident-response-tooling","incidentio"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andygrunwald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"andygrunwald","custom":"https://paypal.me/andygrunwald"}},"created_at":"2022-04-09T11:20:02.000Z","updated_at":"2024-04-27T21:47:19.000Z","dependencies_parsed_at":"2024-04-19T14:00:07.060Z","dependency_job_id":null,"html_url":"https://github.com/andygrunwald/go-incident","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":0.25,"last_synced_commit":"869909b14bc7dec6d3c8c0505f543b2e44f243c0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fgo-incident","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fgo-incident/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fgo-incident/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fgo-incident/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andygrunwald","download_url":"https://codeload.github.com/andygrunwald/go-incident/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135908,"owners_count":20403798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client-library","go","golang","hacktoberfest","incident-management","incident-response-tooling","incidentio"],"created_at":"2024-10-11T21:16:09.903Z","updated_at":"2025-03-21T11:33:43.512Z","avatar_url":"https://github.com/andygrunwald.png","language":"Go","funding_links":["https://github.com/sponsors/andygrunwald","https://paypal.me/andygrunwald"],"categories":[],"sub_categories":[],"readme":"# go-incident: Go client library for [Incident.io](https://incident.io/)\n\n[![GoDoc](https://img.shields.io/static/v1?label=godoc\u0026message=reference\u0026color=blue)](https://pkg.go.dev/github.com/andygrunwald/go-incident)\n\nGo client library for accessing the [Incident.io](https://incident.io/) [API](https://api-docs.incident.io/).\n\n## Installation\n\ngo-incident is compatible with modern Go releases in module mode, with Go installed:\n\n```bash\ngo get github.com/andygrunwald/go-incident\n```\n\nwill resolve and add the package to the current development module, along with its dependencies.\n\nAlternatively the same can be achieved if you use import in a package:\n\n```go\nimport \"github.com/andygrunwald/go-incident\"\n```\n\nand run `go get` without parameters.\n\nFinally, to use the top-of-trunk version of this repo, use the following command:\n\n```bash\ngo get github.com/andygrunwald/go-incident@main\n```\n\n## Usage\n\n```go\nimport \"github.com/andygrunwald/go-incident\"\n```\n\nConstruct a new Incident.io client, then use the various services on the client to access different parts of the [Incident.io API](https://api-docs.incident.io/).\nFor example:\n\n```go\napiKey := \"\u003cmy-secret-api-key\u003e\"\nclient := incident.NewClient(apiKey, nil)\n\n// List all incidents for your organisation.\nincidents, response, err := client.Incidents.List(context.Background(), nil)\n```\n\nSome API methods have optional parameters that can be passed. For example:\n\n```go\napiKey := \"\u003cmy-secret-api-key\u003e\"\nclient := incident.NewClient(apiKey, nil)\n\n// List only closed incidents for your organisation in page chunks of 5.\nopt := \u0026incident.IncidentsListOptions{\n    PageSize: 5,\n    Status: []string{\n        incident.IncidentStatusClosed,\n    },\n}\nincidents, response, err := client.Incidents.List(context.Background(), opt)\n```\n\nThe services of a client divide the API into logical chunks and correspond to the structure of the [Incident.io API](https://api-docs.incident.io/) documentation .\n\nNOTE: Using the [context](https://pkg.go.dev/context) package, one can easily pass cancelation signals and deadlines to various services of the client for handling a request.\nIn case there is no context available, then `context.Background()` can be used as a starting point.\n\nFor more sample code snippets, head over to the [example](https://github.com/andygrunwald/go-incident/tree/master/example) directory.\n\n### Authentication\n\nFor all requests made to the incident.io API, you'll need an API key.\nRight now, there is no public incident.io API.\n\nTo create an API key, head to the incident dashboard and visit [API keys](https://app.incident.io/settings/api-keys).\n\nThe API key will be passed as the first argument, when constructing a new client:\n\n```go\napiKey := \"\u003cmy-secret-api-key\u003e\"\nclient := incident.NewClient(apiKey, nil)\n```\n\n### Errors\n\nErrors provided by the Incident.io API will be mapped to the [ErrorResponse](https://pkg.go.dev/github.com/andygrunwald/go-incident#ErrorResponse) type and can be investigated further:\n\n```go\n// Do a API call ...\nif err != nil {\n    if responseErr, ok := err.(*incident.ErrorResponse); ok {\n        // Do something with responseErr, like printing\n        fmt.Printf(\"%+v\", responseErr.Type)\n    }\n}\n```\n\nAll error details provided by the API are available.\nSee [Making requests \u003e Errors in the Incident.ip API docs](https://api-docs.incident.io/#section/Making-requests/Errors) for more details.\n\n### Pagination\n\nSome requests support pagination.\nPagination options are described in the options per API call once supported.\nThe returned data contains a [PaginationMeta](https://pkg.go.dev/github.com/andygrunwald/go-incident#PaginationMeta) struct with paging information.\n\n```go\napiKey := \"\u003cmy-secret-api-key\u003e\"\nclient := incident.NewClient(apiKey, nil)\n\nopt := \u0026incident.IncidentsListOptions{\n    PageSize: 5,\n}\n\n// Get all pages of incidents\nvar allIncidents []incident.Incident\nfor {\n    incidents, _, err := client.Incidents.List(context.Background(), opt)\n    if err != nil {\n        panic(err)\n    }\n    allIncidents = append(allIncidents, incidents.Incidents...)\n\n    // Calculate if there is a next page\n    if incidents.PaginationMeta.TotalRecordCount == int64(len(allIncidents)) {\n        break\n    }\n    opt.After = incidents.Incidents[len(incidents.Incidents)-1].Id\n}\n```\n\n## Contributing\n\nI would like to cover the entire Incident.io API and contributions are of course always welcome.\nThe calling pattern is pretty well established, so adding new methods is relatively straightforward.\n\n## Inspired by\n\nThe structure, code and documentation of this project is inspired by [google/go-github](https://github.com/google/go-github).\n\n## License\n\nThis library is distributed under the MIT License found in the [LICENSE](./LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandygrunwald%2Fgo-incident","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandygrunwald%2Fgo-incident","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandygrunwald%2Fgo-incident/lists"}