bastionzero-sdk-go
is a Go client library for accessing the BastionZero API
v2.
You can view the client API docs here: https://pkg.go.dev/github.com/bastionzero/bastionzero-sdk-go
You can view BastionZero API docs here: https://cloud.bastionzero.com/api/
go get github.com/bastionzero/bastionzero-sdk-go@vX.Y.Z
where X.Y.Z is the version you need.
Alternatively,
go get github.com/bastionzero/bastionzero-sdk-go
to get the latest version.
import "github.com/bastionzero/bastionzero-sdk-go"
Currently, using an API key is the only method of authentication that is supported by this library. You can manage your API keys at the BastionZero API key panel found here. See the admin guide for more information.
After an API key has been created, you can use its secret to create a new client:
client, err := bastionzero.NewFromAPISecret(http.DefaultClient, "bastionzero-api-secret")
if err != nil {
return err
}
// list all target connect policies in your organization
policies, _, err := client.Policies.ListTargetConnectPolicies(context.Background(), nil)
The services of a bastionzero.Client
divide the API into logical chunks and correspond to
the structure of the BastionZero API documentation.
NOTE: Using the context package, one can easily
pass cancellation signals and deadlines to various services of the client for
handling a request. In case there is no context available, then context.Background()
can be used as a starting point.
To create a new environment:
createRequest := &environments.CreateEnvironmentRequest{
Name: "my-new-env",
Description: "An environment created using the BastionZero Go SDK.",
OfflineCleanupTimeoutHours: uint(24),
}
createResponse, _, err := client.Environments.CreateEnvironment(context.TODO(), createRequest)
if err != nil {
return err
}
fmt.Printf("Created new environment with ID: %s", createResponse.ID)
Each version of the client is tagged and the version is updated accordingly.
In general, bastionzero-sdk-go
follows semver as
closely as we can for tagging releases of the package.
This library is distributed under the Apache License 2.0 license found in the LICENSE file and includes open source software under a variety of other licenses.