commit | eba243a9227d82401822b14e0c3d57035cbed72d | [log] [tgz] |
---|---|---|
author | Cody Oss <6331106+codyoss@users.noreply.github.com> | Wed Jul 10 22:34:45 2024 |
committer | GitHub <noreply@github.com> | Wed Jul 10 22:34:45 2024 |
tree | b4e75d4b03c20809fbad3ecd655b08d51c98d1dc | |
parent | 4a713f714e522fc9b642b6e877f387b45b45d92c [diff] |
chore: generate based on discovery-artifact-manager (#2682) Most other languages do not pull discovery documents directly from the discovery service, instead they share a cache. This change makes Go use that same cache while also maintaining the cached files in this repo. Other changes: - Added a dryrun flag to discogen for local testing - downgraded discogen deps to work with Go 1.20 - return no doc error if the file in the index is not cached locally. This operates the same as when we pulled from the disco service, where if we got a non-2XX we would silently skip generating an api Internal bug: 352084622
$ go get google.golang.org/api/tasks/v1 $ go get google.golang.org/api/moderator/v1 $ go get google.golang.org/api/urlshortener/v1 ... etc ...
and using:
package main import ( "context" "net/http" "google.golang.org/api/urlshortener/v1" ) func main() { ctx := context.Background() svc, err := urlshortener.NewService(ctx) // ... }
These are auto-generated Go libraries from the Google Discovery Service's JSON description files.
Due to the auto-generated nature of this collection of libraries they may contain breaking changes from one release to the next. The generator itself and the code it produces are considered beta for this reason.
These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.
If you're working with Google Cloud Platform APIs such as Datastore or Pub/Sub, please use the Cloud Client Libraries for Go instead. These are the new and idiomatic Go libraries targeted specifically at Google Cloud Platform Services.
By default, each API will use Google Application Default Credentials for authorization credentials used in calling the API endpoints. This will allow your application to run in many environments without requiring explicit configuration.
// import "google.golang.org/api/sheets/v4" client, err := sheets.NewService(ctx)
To authorize using a JSON key file, pass option.WithCredentialsFile
to the NewService
function of the desired package. For example:
client, err := sheets.NewService(ctx, option.WithCredentialsFile("path/to/keyfile.json"))
You can exert more control over authorization by using the golang.org/x/oauth2
package to create an oauth2.TokenSource
. Then pass option.WithTokenSource
to the NewService
function:
tokenSource := ...
svc, err := sheets.NewService(ctx, option.WithTokenSource(tokenSource))
For some more information related to all of the generated clients please read through our package documentation.