{"id":14971704,"url":"https://github.com/grafana/grafana-openapi-client-go","last_synced_at":"2025-04-07T12:03:38.553Z","repository":{"id":190612634,"uuid":"678410701","full_name":"grafana/grafana-openapi-client-go","owner":"grafana","description":"Grafana OpenAPI Client for Go","archived":false,"fork":false,"pushed_at":"2025-03-17T12:37:15.000Z","size":1730,"stargazers_count":64,"open_issues_count":8,"forks_count":9,"subscribers_count":119,"default_branch":"main","last_synced_at":"2025-03-31T11:01:42.787Z","etag":null,"topics":["go","grafana","openapi","swagger"],"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/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-08-14T13:43:09.000Z","updated_at":"2025-03-28T16:32:51.000Z","dependencies_parsed_at":"2023-09-22T13:41:32.365Z","dependency_job_id":"ddeb59ed-1f9e-4ade-b04c-059a90fba6f8","html_url":"https://github.com/grafana/grafana-openapi-client-go","commit_stats":{"total_commits":98,"total_committers":12,"mean_commits":8.166666666666666,"dds":0.6428571428571428,"last_synced_commit":"d1c93bae4198667e9a01ad2958bcc4b613364daf"},"previous_names":["grafana/grafana-openapi-client-go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fgrafana-openapi-client-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fgrafana-openapi-client-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fgrafana-openapi-client-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fgrafana-openapi-client-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/grafana-openapi-client-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648976,"owners_count":20972945,"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":["go","grafana","openapi","swagger"],"created_at":"2024-09-24T13:45:41.337Z","updated_at":"2025-04-07T12:03:38.531Z","avatar_url":"https://github.com/grafana.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grafana HTTP OpenAPI Client for Go\n\nThis HTTP Go client for [Grafana](https://github.com/grafana/grafana) is generated from [Grafana's OpenAPI specification](https://github.com/grafana/grafana/blob/main/public/api-merged.json) using [swagger for Go](https://github.com/go-swagger/go-swagger).\n\nBoth code and non-code contributions are very welcome - please feel free to open an issue or PR in this repository if you spot a possible improvement!\n\n## Dependencies\n\nThis project uses [bingo](https://github.com/bwplotka/bingo) (located in [.bingo/](.bingo/)), a tool to automate the versioning of Go packages. Here, bingo manages verison of [swagger for Go](https://github.com/go-swagger/go-swagger) version so that the client generation is consistent.\n\n**[Required]**  In order to generate the client, you must have installed bingo locally. Then, get swagger at the version specified in bingo's [swagger.mod](.bingo/swagger.mod).\n```bash\ngo install github.com/bwplotka/bingo@latest\nbingo get swagger\n```\n\n## Generate the client\n\nOnce bingo \u0026 swagger are installed (see [Dependencies](#dependencies)), generate the client for _all Grafana APIs_, with the following `make` command:\n\n```bash\nmake generate-client\n```\n\nThis runs the Swagger generation command.\n\nTo generate the client for a _specific Grafana API_, find the name of its tag and model in the [Grafana OpenAPI specification](https://github.com/grafana/grafana/blob/main/public/api-merged.json). Then, set those as environment variables and run the command to generate it:\n```bash\nexport API_TAG=folders\nexport MODEL=Folder\nmake generate-client\n```\n\n### How to use custom templates\n\nIn order to generate the client, `go-swagger` uses default templates. These templates can be customised to add custom configuration that are applied each time the client is generated.\n\nFor more information, check out the `go-swagger` docs on how to [use custom templates](https://github.com/go-swagger/go-swagger/blob/master/docs/generate/templates.md). The default template definitions for the client can be found in [go-swagger/generator/templates/client/](https://github.com/go-swagger/go-swagger/tree/master/generator/templates/client).\n\nIn this project, the custom templates can be found in `templates/`. They are provided to the generation command through the flag `--template-dir=templates`.\n\nThe custom templates provide added functionality for things such as authentication, TLS/SSL, retries, and custom error handling.\n\n## Build the client\n\n### Configuration\n\nThe client has the following friendly configuration options:\n\n```go\nimport goapi \"github.com/grafana/grafana-openapi-client-go/client\"\n\ncfg := \u0026goapi.TransportConfig{\n    // Host is the doman name or IP address of the host that serves the API.\n    Host:       \"localhost:3000\",\n    // BasePath is the URL prefix for all API paths, relative to the host root.\n    BasePath:   \"/api\",\n    // Schemes are the transfer protocols used by the API (http or https).\n    Schemes:    []string{\"http\"},\n    // APIKey is an optional API key or service account token.\n    APIKey:     os.Getenv(\"API_ACCESS_TOKEN\"),\n    // BasicAuth is optional basic auth credentials.\n    BasicAuth:  url.UserPassword(\"admin\", \"admin\"),\n    // OrgID provides an optional organization ID.\n    // OrgID is only supported with BasicAuth since API keys are already org-scoped.\n    OrgID:      1,\n    // TLSConfig provides an optional configuration for a TLS client\n    TLSConfig:  \u0026tls.Config{},\n    // NumRetries contains the optional number of attempted retries\n    NumRetries: 3,\n    // RetryTimeout sets an optional time to wait before retrying a request\n    RetryTimeout: 0,\n    // RetryStatusCodes contains the optional list of status codes to retry\n    // Use \"x\" as a wildcard for a single digit (default: [429, 5xx])\n    RetryStatusCodes: []string{\"420\", \"5xx\"},\n    // HTTPHeaders contains an optional map of HTTP headers to add to each request\n    HTTPHeaders: map[string]string{},\n}\n\nclient := goapi.NewHTTPClientWithConfig(strfmt.Default, cfg)\n```\n\n### Examples\n\nCheckout how the Grafana Terraform Provider initialises and uses the client [here](https://github.com/grafana/terraform-provider-grafana/blob/2988bb3560acc55f3e686532f44109a224825568/internal/provider/provider.go#L419-L446).\n\nThe `goswagger` documentation have more information about how to [build a client](https://goswagger.io/go-swagger/generate/client/).\n\n### Roadmap\n\nWe are planning a few improvements around processes such as automation, testing, release, and integration into other dependencies. Some of this work is tracked [here](https://github.com/grafana/grafana/issues/47827).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fgrafana-openapi-client-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fgrafana-openapi-client-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fgrafana-openapi-client-go/lists"}