{"id":13414008,"url":"https://github.com/codeship/codeship-go","last_synced_at":"2025-05-07T18:41:32.235Z","repository":{"id":56503757,"uuid":"102884066","full_name":"codeship/codeship-go","owner":"codeship","description":"Go library for accessing the Codeship API v2","archived":false,"fork":false,"pushed_at":"2020-11-03T16:20:17.000Z","size":302,"stargazers_count":18,"open_issues_count":1,"forks_count":9,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-09-27T09:19:12.172Z","etag":null,"topics":["api-client","codeship","codeship-api","golang","golang-library"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/codeship/codeship-go","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/codeship.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2017-09-08T16:49:59.000Z","updated_at":"2023-08-29T09:09:52.000Z","dependencies_parsed_at":"2022-08-15T20:00:38.259Z","dependency_job_id":null,"html_url":"https://github.com/codeship/codeship-go","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeship%2Fcodeship-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeship%2Fcodeship-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeship%2Fcodeship-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeship%2Fcodeship-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeship","download_url":"https://codeload.github.com/codeship/codeship-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252936138,"owners_count":21828088,"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","codeship","codeship-api","golang","golang-library"],"created_at":"2024-07-30T20:01:55.075Z","updated_at":"2025-05-07T18:41:32.216Z","avatar_url":"https://github.com/codeship.png","language":"Go","readme":"# Codeship API v2 Client for Go\n\n[![Codeship Status](https://app.codeship.com/projects/c38f3280-792b-0135-21bb-4e0cf8ff365b/status?branch=master)](https://app.codeship.com/projects/244943)\n[![Coverage Status](https://coveralls.io/repos/github/codeship/codeship-go/badge.svg)](https://coveralls.io/github/codeship/codeship-go)\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/codeship/codeship-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/codeship/codeship-go?style=flat-square)](https://goreportcard.com/report/github.com/codeship/codeship-go)\n[![GitHub Release](https://img.shields.io/github/release/codeship/codeship-go.svg?style=flat-square)](https://github.com/codeship/codeship-go/releases)\n\n![Codeship](logo.png)\n\nCodeship [API v2](https://apidocs.codeship.com/v2) client for Go.\n\n## Documentation\n\n[https://godoc.org/github.com/codeship/codeship-go](https://godoc.org/github.com/codeship/codeship-go)\n\n## Usage\n\n`go get -u github.com/codeship/codeship-go`\n\nPackage `codeship` provides a client for using the Codeship API v2.\n\n```go\nimport codeship \"github.com/codeship/codeship-go\"\n```\n\nCreate a new API Client:\n\n```go\nauth := codeship.NewBasicAuth(\"username\", \"password\")\nclient, err := codeship.New(auth)\n```\n\nYou must then scope the client to a single Organization that you have access to:\n\n```go\norg, err := client.Organization(ctx, \"codeship\")\n```\n\nYou can then perform calls to the API on behalf of an Organization:\n\n```go\nprojects, err := org.ListProjects(ctx)\n```\n\n## Authentication\n\nAuthentication is handled automatically via the API Client using the provided authentication mechanism.\n\nIf you would like to manually re-authenticate, you may do this by calling the `Authenticate` method on the `client`:\n\n```go\nerr := client.Authenticate(ctx)\n```\n\n### Two-Factor Authentication\n\nCodeship now supports [Two-Factor Authentication](https://documentation.codeship.com/general/about/2fa/) (2FA).\n\nHowever, it is currently [not possible](https://documentation.codeship.com/general/about/2fa/#2fa-and-the-codeship-api) to use 2FA with the API. If you try to authenticate via this client with a user that has 2FA enabled you will get the following error:\n\n\u003e authentication failed: your account has two-factor authentication enabled, which is not possible to support with the API. Disable two factor authentication or create a dedicated API user without it enabled.\n\nYou must disable 2FA for the user you wish to authenticate with using this client. We hope to support Personal Access Tokens in a future version of the API to mitigate this issue.\n\n## Response\n\nAll API methods also return a `codeship.Response` type that contains the actual `*http.Response` embedded as well as a `Links` type that contains information to be used for pagination.\n\n## Pagination\n\nPagination is provided for all requests that can return multiple results. The methods that are able to be paginated all take a variable argument of type `PaginationOption` such as: `ListProjects(opts ...PaginationOption)`.\n\nWe have defined two helper functions, `Page` and `PerPage`, to make pagination easier.\n\nUsage is as follows:\n\n```go\n// defaults to first page with page_size of 30\nprojects, resp, err := org.ListProjects(ctx)\n\n// paging forwards with 50 results per page\nfor {\n    if resp.IsLastPage() || resp.Next == \"\" {\n        break\n    }\n\n    next, _ := resp.NextPage()\n\n    projects, resp, _ = org.ListProjects(ctx, codeship.Page(next), codeship.PerPage(50))\n}\n\n// paging backwards with 50 results per page\nfor {\n    if current, _ := resp.CurrentPage(); current == 1 || resp.Previous == \"\" {\n        break\n    }\n\n    prev, _ := resp.PreviousPage()\n\n    projects, resp, _ = org.ListProjects(ctx, codeship.Page(prev), codeship.PerPage(50))\n}\n```\n\n## Logging\n\nYou can enable verbose logging of all HTTP requests/responses by configuring the `client` via the functional option `Verbose(verbose bool)` when instantiating the client:\n\n```go\nauth := codeship.NewBasicAuth(\"username\", \"password\")\nclient, err := codeship.New(auth, codeship.Verbose(true))\n```\n\n### Bring your own Logger\n\nThe default logger logs to STDOUT but can be replaced by any type that fulfills the `StdLogger` interface:\n\n```go\n// StdLogger allows you to bring your own log implementation for logging\ntype StdLogger interface {\n\tPrintln(...interface{})\n}\n```\n\nExample:\n\n```go\nimport \"github.com/sirupsen/logrus\"\n\nvar (\n    logger = logrus.New()\n    auth   = codeship.NewBasicAuth(\"username\", \"password\")\n)\n\nclient, err := codeship.New(auth, codeship.Verbose(true), codeship.Logger(logger))\n```\n\n## Contributing\n\nThis project follows Codeship's [Go best practices](https://github.com/codeship/go-best-practices). Please review them and make sure your PR follows the guidelines laid out before submitting.\n\nEveryone interacting in the project and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md).\n\n### Setup\n\nTo install all dependencies and external tools, run:\n\n```bash\nmake setup tools\n```\n\n### Testing\n\n```bash\nmake test\n```\n\nWe aim for \u003e 80% test coverage. You can view the current coverage info by running:\n\n```bash\nmake cover\n```\n\n### Linting\n\n```bash\nmake lint\n```\n\n### Other\n\n```bash\n$ make help\n\nsetup                          Install all dependencies\ntools                          Install external tools\ntest                           Run all the tests\nintegration                    Run integration tests\ncover                          Run all the tests and opens the coverage report\nfmt                            goimports all go files\nlint                           Run all the linters\n```\n","funding_links":[],"categories":["Third-party APIs","第三方api","第三方API","第三方API`第三方API 汇总`","Utility"],"sub_categories":["Utility/Miscellaneous","HTTP Clients","Fail injection","Advanced Console UIs","实用程序/Miscellaneous","查询语","交流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeship%2Fcodeship-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeship%2Fcodeship-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeship%2Fcodeship-go/lists"}