Skip to content

angelotinho/uhc-sdk-go

 
 

Repository files navigation

UHC SDK

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:

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 examples directory.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Go 97.1%
  • Makefile 1.5%
  • Shell 1.4%