Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples of generated API client usage? #312

Closed
aknuds1 opened this issue Jul 1, 2021 · 2 comments
Closed

Examples of generated API client usage? #312

aknuds1 opened this issue Jul 1, 2021 · 2 comments
Labels
documentation This is a problem with documentation.

Comments

@aknuds1
Copy link
Contributor

aknuds1 commented Jul 1, 2021

Do there exist any examples of generated API client code usage? I've been able to generate an API client for some Grafana endpoints, but can't yet figure out how to e.g. configure the API server address.

@skmcgrail
Copy link
Member

skmcgrail commented Jul 20, 2021

The Smithy code-generator currently doesn't have an opinionated structure on how endpoints are set or determined for a client. So the base generated client does not generate or register middleware that sets the endpoint. We have a pair GoIntegration plugin on the the SDK side that has an opinionated approach to endpoints (EndpointResolver type that takes a name of a region and returns an SDK specific endpoint structure describing a resolved endpoint). We then have our generated code based on the service's endpoints description and create a resolver and middleware that queries the endpoint and sets the endpoint for the underlying transport.

See AwsEndpointGenerator and EndpointGenerator for more in depth detail on how we are doing the code generation. ResolveEndpoint is an example of the generated middleware for the service client.

For the SDK's use case we needed to have a per client endpoint resolver and middleware due to our push to move away from a giant endpoints structure, and instead ship endpoints alongside the clients themselves. Depending on your use case you likely don't need this level of complexity.

@jasdel jasdel added the documentation This is a problem with documentation. label Jul 29, 2021
@lucix-aws
Copy link
Contributor

I would note that smithy-go now supports modeled endpoint resolution, though the feature isn't part of the public IDL docs. That aside I have #458 open to track making smithy-go usable on its own, as of this writing it heavily depends on additional codegen support added in the v2 SDK to produce a working client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation.
Projects
None yet
Development

No branches or pull requests

4 participants