{"id":24567051,"url":"https://github.com/grafana/k6-cloud-openapi-client-go","last_synced_at":"2025-10-04T07:25:50.246Z","repository":{"id":272787660,"uuid":"888372319","full_name":"grafana/k6-cloud-openapi-client-go","owner":"grafana","description":"Go client for the Grafana Cloud k6 REST API v6.","archived":false,"fork":false,"pushed_at":"2025-04-16T13:42:01.000Z","size":347,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":103,"default_branch":"main","last_synced_at":"2025-04-16T20:22:40.228Z","etag":null,"topics":["api","client","cloud","k6"],"latest_commit_sha":null,"homepage":"https://api.k6.io","language":"Mustache","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-14T09:36:01.000Z","updated_at":"2025-04-16T13:40:25.000Z","dependencies_parsed_at":"2025-04-16T15:02:38.281Z","dependency_job_id":null,"html_url":"https://github.com/grafana/k6-cloud-openapi-client-go","commit_stats":null,"previous_names":["grafana/k6-cloud-openapi-client-go"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-cloud-openapi-client-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-cloud-openapi-client-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-cloud-openapi-client-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-cloud-openapi-client-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/k6-cloud-openapi-client-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250243866,"owners_count":21398412,"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","cloud","k6"],"created_at":"2025-01-23T13:15:54.877Z","updated_at":"2025-10-04T07:25:45.189Z","avatar_url":"https://github.com/grafana.png","language":"Mustache","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k6-cloud-openapi-client-go\n\nGo client for the\n[Grafana Cloud k6 REST API v6](https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-rest-api/v6/).\n\n_Code generated with the [openapi-generator](https://openapi-generator.tech/) and the OpenAPI specification that can be\nfound at https://api.k6.io/cloud/v6/openapi._\n\n## Getting started\n\n### Installation\n\nInstall the following dependency:\n\n```sh\ngo get github.com/grafana/k6-cloud-openapi-client-go\n```\n\n### Usage\n\nTo use it, you need to import the main `k6` package:\n\n```go\nimport k6 \"github.com/grafana/k6-cloud-openapi-client-go/k6\"\n```\n\n#### Configuration\n\nDefault configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.\n\nAlternatively, you can define your own server list with:\n\n```go\ncfg := k6.NewConfiguration()\ncfg.Servers = []k6.ServerConfiguration{\n    {URL: \"\u003cyour-server-url\u003e\"},\n}\n```\n\n#### Initialization\n\nOnce you have a configuration, you can initialize the client:\n\n```go\nclient := k6.NewAPIClient(cfg)\n```\n\n#### Authentication\n\nThe authentication schema used by the API is HTTP Bearer token authentication and the way to provide the token\nin the client is by using the `k6.ContextAccessToken` context key, as follows:\n\n\n```go\n// You may want to use `context.Background()` if your application doesn't have a context yet.\nctx = context.WithValue(ctx, k6.ContextAccessToken, \"\u003cyour-token\u003e\")\n```\n\n#### Using the client's APIs\n\nBelow, you can see a **full example** of how to use the client to get the list of all the projects:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/grafana/k6-cloud-openapi-client-go/k6\"\n)\n\nfunc main() {\n\t// First, we initialize the configuration and the client:\n\tcfg := k6.NewConfiguration()\n\tclient := k6.NewAPIClient(cfg)\n\n\t// Then, we prepare the context with the Bearer token:\n\tctx := context.WithValue(context.Background(), k6.ContextAccessToken, \"\u003cyour-token\u003e\")\n\n\t// Now, we can build the base request:\n\treq := client.ProjectsAPI.ProjectsList(ctx).\n\t\t// Specify what stack id we want to make the request for:\n\t\tXStackId(123 /*\u003cyour-stack-id\u003e*/).\n\t\t// Specify some optional parameters, like sorting by creation date:\n\t\tOrderby(\"created\").\n\t\t// Request the total amount of projects to be present in the response:\n\t\tCount(true)\n\n\t// And finally, execute the request:\n\tprojectsRes, httpRes, err := req.Execute()\n\tif err != nil {\n\t\tlog.Fatalf(\"ProjectsList request failed: %s\", err.Error())\n\t}\n\n\t// We print the status code and the total amount of projects, if present,\n\t// as well as the name of each project:\n\tlog.Printf(\"Status code: %d\", httpRes.StatusCode)\n\tif projectsRes.HasCount() {\n\t\tlog.Printf(\"Total amount of projects: %d\", *projectsRes.Count)\n\t}\n\n\tlog.Println(\"The list of available projects is:\")\n\tfor _, p := range projectsRes.Value {\n\t\tlog.Printf(\"%s\\n\", p.GetName())\n\t}\n}\n```\n\n#### Examples\n\nIf you want to see more working examples, navigate to the [examples](./examples) directory.\n\n#### Docs\n\nIf you want to see the docs of the APIs, navigate to the\n[./k6/README.md](k6/README.md#documentation-for-api-endpoints).\n\n## Other\n\n### Versioning\n\nThis project follows the [Semantic Versioning](https://semver.org/) guidelines, \nusing [pre-release syntax](https://semver.org/#spec-item-9) to indicate the client's version. \n\nSo, for instance, we can fix a bug in the client if needed, while keeping it targeting the same API version.\n\nFor instance, given `1.0.0-0.1.0`:\n- The API version (from spec) would be: `1.0.0`\n- The client version would be `0.1.0`.\n\n### Contributing\n\nIn you case you're willing to contribute to this project, navigate to [DEVELOPMENT](./DEVELOPMENT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fk6-cloud-openapi-client-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fk6-cloud-openapi-client-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fk6-cloud-openapi-client-go/lists"}