Go client library to interact with the various IBM Cloud® App Configuration APIs.
- Overview
- Prerequisites
- Installation
- Using the SDK
- Questions
- Issues
- Open source @ IBM
- Contributing
- License
The IBM Cloud App Configuration Go SDK allows developers to programmatically manage the App Configuration service. Alternately, you can also use the IBM Cloud App Configuration CLI to manage the App Configuration service instance. You can find more information about the CLI here.
- An IBM Cloud account.
- An App Configuration service instance.
- An IAM API key to allow the SDK to access your account. Create one here.
- Go version 1.20 or above.
The current version of this SDK: 0.4.2
Note: The v1.x.x versions of the App Configuration Go Admin SDK have been retracted. Use the latest available version of the SDK.
If your application uses Go modules for dependency management (recommended), just add the import. Here is an example:
import (
"github.com/IBM/appconfiguration-go-admin-sdk/appconfigurationv1"
)
Next, run go build
or go mod tidy
to download and install the new dependencies and update your application's
go.mod
file.
In the example above, the appconfigurationv1
part of the import path is the package name
associated with the App Configuration service.
Alternatively, you can use the go get
command to download and install the appropriate packages needed by your
application:
go get -u github.com/IBM/appconfiguration-go-admin-sdk
Some capabilities such as Percentage rollout & Git configs are applicable only for specific plans (Lite, Standard & enterprise). See here for full list of capabilities that are plan wise.
- All methods return a response and an error. The response contains the body, the headers, the status code, and the status text.
- Use the
URL
parameter to set the Endpoint URL that is specific to your App Configuration service instance.
Construct a service client and use it to create, retrieve and manage resources from your App Configuration instance.
Here's an example main.go
file:
package main
import (
"encoding/json"
"fmt"
"github.com/IBM/appconfiguration-go-admin-sdk/appconfigurationv1"
"github.com/IBM/go-sdk-core/v5/core"
)
func main() {
authenticator := &core.IamAuthenticator{
ApiKey: "<IBM_CLOUD_API_KEY>",
}
options := &appconfigurationv1.AppConfigurationV1Options{
Authenticator: authenticator,
URL: "https://" + region + ".apprapp.cloud.ibm.com/apprapp/feature/v1/instances/" + guid,
}
appConfigurationService, err := appconfigurationv1.NewAppConfigurationV1(options)
if err != nil {
panic(err)
}
createEnvironmentOptions := appConfigurationService.NewCreateEnvironmentOptions(
"Dev environment",
"dev",
)
createEnvironmentOptions.SetDescription("Dev environment description")
createEnvironmentOptions.SetTags("development")
createEnvironmentOptions.SetColorCode("#FDD13A")
environment, response, err := appConfigurationService.CreateEnvironment(createEnvironmentOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(environment, "", " ")
fmt.Println(string(b))
- guid : Instance ID of the App Configuration instance.
- region : Region of the App Configuration instance.
Replace the URL
and ApiKey
values. Then run the go run main.go
command to compile and run your Go program.
Examples for rest APIs can be found here.
Also, more examples are documented in sampleProgram.go file of this repo.
For more information and IBM Cloud SDK usage examples for Go, see the IBM Cloud SDK Common documentation.
If you enable service endpoints in your account, you can send API requests over the IBM Cloud private network. While constructing the service client the endpoint URLs of the IAM(authenticator) & App Configuration(service) should be modified to point to private endpoints. See below
authenticator := &core.IamAuthenticator{
ApiKey: "<IBM_CLOUD_API_KEY>",
URL: "https://private.iam.cloud.ibm.com",
}
options := &appconfigurationv1.AppConfigurationV1Options{
Authenticator: authenticator,
URL: "https://private." + region + ".apprapp.cloud.ibm.com/apprapp/feature/v1/instances/" + guid,
}
If you are having difficulties using this SDK or have a question about the IBM Cloud services, please ask a question at Stack Overflow.
If you encounter an issue with the project, you are welcome to submit a bug report. Before that, please search for similar issues. It's possible that someone has already reported the problem.
Find more open source projects on the IBM Github Page
See CONTRIBUTING.
This SDK project is released under the Apache 2.0 license. The license's full text can be found in LICENSE.