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-clientThe 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 theCloudFrontDistributionUrloutput 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 a lease template by its ID:
req := &isbclient.GetLeaseTemplateByIDRequest{LeaseTemplateID: "template-uuid"}
resp, err := client.GetLeaseTemplateByID(ctx, req)Create a new lease template:
req := &isbclient.CreateLeaseTemplateRequest{
Name: "My Template",
Description: "Template description",
RequiresApproval: true,
MaxSpend: 100.0,
}
resp, err := client.CreateLeaseTemplate(ctx, req)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)Fetch an account by its AWS account ID:
req := &isbclient.GetAccountByIDRequest{AwsAccountId: "123456789012"}
resp, err := client.GetAccountByID(ctx, req)Fetch a paginated list of unregistered accounts:
resp, err := client.GetUnregisteredAccounts(ctx, queryBuilder)Fetch all unregistered accounts using pagination:
resp, err := client.FetchAllUnregisteredAccounts(ctx, getUnregisteredAccountsReq)Unfreeze a frozen lease:
req := &isbclient.UnfreezeLeaseRequest{LeaseID: "lease-id"}
resp, err := client.UnfreezeLease(ctx, req)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
NewUserUserClaimshelper 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 respThis uses the NewUserUserClaims helper to generate the JWT for the specified user.
Supported roles for JWT claims:
AdminManagerUser
Run all tests:
go test ./...