ocm-sdk-go

module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: Apache-2.0

README

= 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:

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

Directories

Path Synopsis
pkg
client
Package client contains a set of objects that simplify usage of `api.openshift.com`.
Package client contains a set of objects that simplify usage of `api.openshift.com`.

Jump to

Keyboard shortcuts

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