AI Usage Statement: Nearly all client logic and tests in this repository were generated using AI assistance.
This Go package provides a client for interacting with the AWS Innovation Sandbox API. It supports JWT-based authentication and simplifies making requests to the API.
Add the module to your project:
go get github.com/gymshark/aws-go-isb-client
The client uses JWT bearer tokens for authentication. You can generate a JWT for an admin user using the provided helper:
import (
"time"
"github.com/gymshark/aws-go-isb-client"
)
user := isbclient.NewAdminUserClaims("admin@gymshark.com")
secret := "your-shared-secret" // Secret value from the CloudFormation stack output `JwtSecretArn`
expiresIn := 2*time.Hour
jwtToken, err := isbclient.GenerateJWT(user, secret, expiresIn)
if err != nil {
// handle error
}
The secret is the value stored in the secret referenced by the CloudFormation stack output
JwtSecretArn
.
Create a new client instance with the API base URL and your JWT token:
client := isbclient.NewClient("https://<CloudFrontDistributionUrl>/api", jwtToken)
<CloudFrontDistributionUrl>
should be replaced with theCloudFrontDistributionUrl
output from the CloudFormation compute stack.
Note: The following client methods are generated from the OpenAPI specification in
spec.yaml
. Refer to the spec for endpoint details and request/response structures.
Fetch a paginated list of leases:
resp, err := client.GetLeases(ctx, queryBuilder)
Fetch a lease by its ID:
leaseReq := &isbclient.GetLeaseByIDRequest{LeaseID: "lease-id"}
resp, err := client.GetLeaseByID(ctx, leaseReq)
Request a new lease:
leaseReq := &isbclient.CreateLeaseRequest{
LeaseTemplateUUID: "template-uuid",
Comments: "optional comment",
}
resp, err := client.CreateLease(ctx, leaseReq)
Create a lease for another user. See Acting on Behalf of Another User (Lease Creation) for details and usage:
resp, err := client.CreateLeaseAsUser(ctx, leaseReq, "target.user@gymshark.com", jwtSecret)
Fetch available lease templates:
resp, err := client.GetLeaseTemplates(ctx, queryBuilder)
Fetch all leases using pagination:
resp, err := client.FetchAllLeases(ctx, getLeasesReq)
Fetch all lease templates using pagination:
resp, err := client.FetchAllLeaseTemplates(ctx, getLeaseTemplatesReq)
Fetch a paginated list of accounts:
resp, err := client.GetAccounts(ctx, queryBuilder)
Fetch all accounts using pagination:
resp, err := client.FetchAllAccounts(ctx, getAccountsReq)
Refer to the source code for available methods and request/response types.
To create a lease for another user, use the CreateLeaseAsUser
method.
This method generates a JWT for the target user using the
NewUserUserClaims
helper and makes the request with that token. These methods are generated from the OpenAPI specification inspec.yaml
.
userEmail := "target.user@gymshark.com"
jwtSecret := "your-shared-secret"
leaseReq := &isbclient.CreateLeaseRequest{
LeaseTemplateUUID: "template-uuid",
Comments: "Lease for automation",
}
resp, err := client.CreateLeaseAsUser(ctx, leaseReq, userEmail, jwtSecret)
if err != nil {
// handle error
}
// process resp
This uses the NewUserUserClaims
helper to generate the JWT for the specified user.
Supported roles for JWT claims:
Admin
Manager
User
Run all tests:
go test ./...