configuration-aggregator-go-sdk

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2025 License: Apache-2.0

README

Build Status semantic-release

IBM Cloud Configuration Aggregator Go SDK Version 0.0.2

Go client library to interact with the various IBM Cloud Configuration Aggregator API SDK APIs.

Disclaimer: this SDK is being released initially as a pre-release version. Changes might occur which impact applications that use this SDK.

Table of Contents

Overview

The IBM Cloud Configuration Aggregator Go SDK allows developers to programmatically interact with the following IBM Cloud services:

Service Name Package name
Configuration Aggregator configurationaggregatorv1

Prerequisites

  • An IBM Cloud account.
  • An IAM API key to allow the SDK to access your account. Create one here.
  • Go version 1.20 or above.

Installation

The current version of this SDK: 0.0.2

Go modules

If your application uses Go modules for dependency management (recommended), just add an import for each service that you will use in your application.
Here is an example:

import (
	"github.com/IBM/configuration-aggregator-go-sdk/configurationaggregatorv1"
)

Next, run go build or go mod tidy to download and install the new dependencies and replace your application's go.mod file.

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/configuration-aggregator-go-sdk

Be sure to use the appropriate package name from the service table above for the services used by your application.

Using the SDK

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/go-sdk-core/v5/core"
	"github.com/IBM/configuration-aggregator-go-sdk/configurationaggregatorv1"
)

func main() {
	authenticator := &core.IamAuthenticator{
		ApiKey: "<IBM_CLOUD_API_KEY>",
		URL:    "https://iam.cloud.ibm.com",
	}
	instanceID := "provide_your_instance_id"
	region:="region_of_the_url"
	configurationAggregatorServiceOptions := &configurationaggregatorv1.ConfigurationAggregatorV1Options{
		Authenticator: authenticator,
		URL:           "https://" + region + ".apprapp.cloud.ibm.com/apprapp/config_aggregator/v1/instances/" + instanceID,
	}
	configurationAggregatorService, err := configurationaggregatorv1.NewConfigurationAggregatorV1(configurationAggregatorServiceOptions)

	if err != nil {
		panic(err)
	}

	replaceSettingsOptions := configurationAggregatorService.NewReplaceSettingsOptions()
	replaceSettingsOptions.TrustedProfileID = core.StringPtr("your_trusted_profile_id")
	replaceSettingsOptions.ResourceCollectionEnabled = core.BoolPtr(true)
	replaceSettingsOptions.Regions = []string{"all"}
	replaceSettingsResponse, _, err := configurationAggregatorService.ReplaceSettings(replaceSettingsOptions)
	if err != nil {
		panic(err)
	}
	replaceSettings, _ := json.MarshalIndent(replaceSettingsResponse, "", "  ")
	fmt.Println(string(replaceSettings))
	getSettingsOptions := configurationAggregatorService.NewGetSettingsOptions()
	getSettingsResponse, _, err := configurationAggregatorService.GetSettings(getSettingsOptions)
	if err != nil {
		panic(err)
	}
	getSettings, _ := json.MarshalIndent(getSettingsResponse, "", "  ")
	fmt.Println(string(getSettings))
	getResourceCollectionStatusOptions := configurationAggregatorService.NewGetResourceCollectionStatusOptions()
    getResourceCollectionStatusResponse, _, err := configurationAggregatorService.GetResourceCollectionStatus(getResourceCollectionStatusOptions)
    if err != nil {
        panic(err)
    }
    getResourceCollectionStatus, _ := json.MarshalIndent(getResourceCollectionStatusResponse, "", "  ")
    fmt.Println(string(getResourceCollectionStatus))
	listConfigsOptions := configurationAggregatorService.NewListConfigsOptions()

	pager, err := configurationAggregatorService.NewConfigsPager(listConfigsOptions)
	if err != nil {
		panic(err)
	}

	var allResults []configurationaggregatorv1.Config
	for pager.HasNext() {
		nextPage, err := pager.GetNext()
		if err != nil {
			panic(err)
		}
		allResults = append(allResults, nextPage...)
	}
	listConfigs, _ := json.MarshalIndent(listConfigsResponse, "", "  ")
	fmt.Println(string(listConfigs))

}



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](/issues). 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.

Directories

Path Synopsis
Package configurationaggregatorv1 : Operations and models for the ConfigurationAggregatorV1 service
Package configurationaggregatorv1 : Operations and models for the ConfigurationAggregatorV1 service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL