{"id":13666302,"url":"https://github.com/elastic/cloud-sdk-go","last_synced_at":"2025-04-05T22:08:57.262Z","repository":{"id":36031167,"uuid":"214076084","full_name":"elastic/cloud-sdk-go","owner":"elastic","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T12:15:52.000Z","size":5212,"stargazers_count":22,"open_issues_count":12,"forks_count":48,"subscribers_count":66,"default_branch":"master","last_synced_at":"2025-03-29T21:07:42.199Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elastic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-10T03:15:07.000Z","updated_at":"2025-02-21T16:34:44.000Z","dependencies_parsed_at":"2023-10-14T21:02:29.292Z","dependency_job_id":"25f68432-986a-4173-a54e-ce94c1e5e473","html_url":"https://github.com/elastic/cloud-sdk-go","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fcloud-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fcloud-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fcloud-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Fcloud-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elastic","download_url":"https://codeload.github.com/elastic/cloud-sdk-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406091,"owners_count":20933803,"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":[],"created_at":"2024-08-02T06:01:14.614Z","updated_at":"2025-04-05T22:08:57.221Z","avatar_url":"https://github.com/elastic.png","language":"Go","readme":"# Elastic Cloud Go SDK\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/elastic/cloud-sdk-go.svg)](https://pkg.go.dev/github.com/elastic/cloud-sdk-go)\n\nGo SDK for Elastic Cloud. Its goal is to provide common ground for all Elastic Cloud programmatic code in Go.\n\n## Installation\n\nRun the following `go get` command to install the SDK in your module dependencies directory:\n\n```console\ngo get -u github.com/elastic/cloud-sdk-go\n```\n\n## Usage\n\nSee the [`pkg/api`](https://pkg.go.dev/github.com/elastic/cloud-sdk-go/pkg/api) package for more in depth documentation.\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/elastic/cloud-sdk-go/pkg/api\"\n\t\"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi\"\n\t\"github.com/elastic/cloud-sdk-go/pkg/auth\"\n)\n\nvar (\n\tlogFormat = log.Lmsgprefix | log.Llongfile\n\n\terrLog  = log.New(os.Stderr, \"ERROR \", logFormat)\n\twarnLog = log.New(os.Stdout, \"WARN \", logFormat)\n\tinfoLog = log.New(os.Stdout, \"INFO \", logFormat)\n)\n\nfunc main() {\n\t// Export your apikey as an environment variable as EC_API_KEY. To generate\n\t// a new API key go to ESS or ECE Web UI \u003e API Keys \u003e Generate API Key.\n\tapiKey := os.Getenv(\"EC_API_KEY\")\n\tif apiKey == \"\" {\n\t\twarnLog.Print(\"unable to obtain value from EC_API_KEY environment variable\")\n\t}\n\n\t// Create a API instance with an API key as means of authentication.\n\tess, err := api.NewAPI(api.Config{\n\t\tClient:     new(http.Client),\n\t\tAuthWriter: auth.APIKey(apiKey),\n\t})\n\tif err != nil {\n\t\terrLog.Fatal(err)\n\t}\n\n\t// List the user's deployments via the `deploymentapi` package (Recommended).\n\tres, err := deploymentapi.List(deploymentapi.ListParams{API: ess})\n\tif err != nil {\n\t\terrLog.Fatal(err)\n\t}\n\tinfoLog.Printf(\"found %d deployents\", len(res.Deployments))\n\n\tencoder := json.NewEncoder(infoLog.Writer())\n\tencoder.SetIndent(\"\", \"  \")\n\n\tif err := encoder.Encode(res); err != nil {\n\t\terrLog.Fatal(err)\n\t}\n}\n```\n\n## High level package overview\n\nThe project's structure is based off the standard Go project layout. Therefore, all of our library code that we expect other projects to import is placed in the `pkg/` directory.\n\nThe main packages for interacting directly with our public API endpoints can be found within the [`pkg/api`](https://github.com/elastic/cloud-sdk-go/tree/master/pkg/api) directory. The source code for these APIs are the [`client`](https://github.com/elastic/cloud-sdk-go/tree/master/pkg/client) and [`models`](https://github.com/elastic/cloud-sdk-go/tree/master/pkg/models), which are generated off the [public API swagger specification](./api/apidocs.json).\n\nThe rest are a series of packages that can be leveraged in many ways. For a detailed package description visit the SDK's packages documentation at [pkg.go.dev](https://pkg.go.dev/github.com/elastic/cloud-sdk-go). Alternatively you can use the [godoc](https://pkg.go.dev/golang.org/x/tools/cmd/godoc) command on the root level of this project.\n\n## Getting started\n\n[Ecctl](https://github.com/elastic/ecctl) (the Elastic Cloud CLI tool) depends heavily on cloud-sdk-go. You can use ecctl command packages as a reference on how to leverage the SDK. One good example is the [command](https://github.com/elastic/ecctl/blob/master/cmd/deployment/list.go) used to list deployments.\n\nAlternatively, if you wish to write your own APIs, take a look at our [sample code](./examples/platform/main.go), which retrieves information about the active platform, to get an idea on how the client is used.\n\nWe always welcome contributions! Take a look at our [contributing guide](./CONTRIBUTING.md) if this is something that interests you.\n\n","funding_links":[],"categories":["Clients \u0026 SDKs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Fcloud-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felastic%2Fcloud-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Fcloud-sdk-go/lists"}