This repository contains the SPIRL SDK for the Go programming language.
This repository is "source available". Outside contributions are not accepted.
To report a bug or make a feature request, please file an issue.
To add this module to your project:
go get github.com/spirl/spirl-sdk-go@latestTo use the SDK, you must first initialize a client using the github.com/spirl/spirl-sdk-go/spirlsdk/client package.
c, err := client.New(auth) // see "Authentication" below
if err != nil {
// handle error
}Use accessors to get methods for the various APIs. For example, to list trust domains in your SPIRL account:
result, err := c.TrustDomain().ListTrustDomains(ctx, trustdomainsdk.ListTrustDomainsParams{})
if err != nil {
// handle error
}The client should be closed when no longer needed:
if err := c.Close(); err != nil {
// handle error
}The SDK authenticates to SPIRL on-demand. The SDK client is configured with an
authenticator for the purpose of obtaining an authentication token. The SDK
client does not persist authentication tokens by default, implying that newly
initialized SDK clients always need to authenticate. Token persistence can
be configured via the client.WithTokenStore option.
The SDK supports authenticating using one of two methods:
- OAuth2 authentication to an Identity Provider
- Service Account authentication
See the example for a demonstration on authenticating to SPIRL using OAuth2.
SDK callers are responsible for opening the browser for the user to complete the login flow. The pairing code should also be conveyed to the user so they can assert they are logging into the correct session.
A service account is an entity in your SPIRL account provisioned with a specific role. Before you can authenticate with a service account, you need to create the service account and generate a key for it.
To create a service account:
spirlctl iam service-account create <name> --role-name <role>For example, to create a service account sdk-example with the admin role:
spirlctl iam service-account create sdk-example --role-name adminThen you can generate a key for the service account:
spirlctl iam service-account key add --service-account sdk-exampleThe output of these commands will contain the service account key ID as well as the service account key. See the example for a demonstration on authenticating to SPIRL using these values.
Browse the examples folder for help doing a few common operations.