/appconfiguration-go-admin-sdk

IBM Cloud App Configuration Go Admin SDK

Primary LanguageGoApache License 2.0Apache-2.0

IBM Cloud App Configuration Go Admin SDK

Go client library to interact with the various IBM Cloud® App Configuration APIs.

Table of Contents

Overview

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.

Prerequisites

Installation

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.

Go modules

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.

go get command

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

Using the 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.

Basic usage

  • 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.

Examples

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.

Using private endpoints

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,
	}

Questions

If you are having difficulties using this SDK or have a question about the IBM Cloud services, please ask a question at Stack Overflow.

Issues

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.

Open source @ IBM

Find more open source projects on the IBM Github Page

Contributing

See CONTRIBUTING.

License

This SDK project is released under the Apache 2.0 license. The license's full text can be found in LICENSE.