= UHC SDK
ifdef::env-github[]
image:https://godoc.org/github.com/openshift-online/uhc-sdk-go?status.svg[GoDoc,
link=https://godoc.org/github.com/openshift-online/uhc-sdk-go/pkg/client]
image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License,
link=https://opensource.org/licenses/Apache-2.0]
endif::[]
This project contains a Go library that simplifies the use of the _UHC_
API, available in `api.openshift.com`.
To use it import the `github.com/openshift-online/uhc-sdk-go/pkg/client` package,
and then use it to send requests to the API. For example, if you need to create
a cluster you can use the following code:
[source,go]
----
package main
import (
"fmt"
"os"
"github.com/openshift-online/uhc-sdk-go/pkg/client"
)
func main() {
// Create the connection, and remember to close it:
connection, err := client.NewConnectionBuilder().
Tokens("eyJ...").
Build()
if err != nil {
fmt.Fprintf(os.Stderr, "Can't build connection: %v\n", err)
os.Exit(1)
}
defer connection.Close()
// Send a request to create a cluster:
response, err := connection.Post().
Path("/api/clusters_mgmt/v1/clusters").
String(`{
"name": "mycluster",
"flavour": {
"id": "4"
},
"region": {
"id": "us-east-1",
},
"dns": {
"base_domain": "mydomain.com"
},
"aws": {
"access_key_id": "...",
"secret_access_key": "..."
}
}`).
Send()
if err != nil {
fmt.Fprintf(os.Stderr, "Can't create cluster: %s\n", err)
os.Exit(1)
}
// Print the result:
fmt.Printf("%d\n", response.Status())
fmt.Printf("%s\n", response.String())
}
----
There are more examples in the link:examples[examples] directory.
== CLI
See also the command-line tool https://github.com/openshift-online/uhc-cli built on top of this SDK.