Go API client for mcaasapi
Table Of Contents - Introduction - Authentication - Get a Space ID - Roles and Permissions - Getting Started Guide - Machine Blueprint Creation Example - Cluster Blueprint Creation Example - Cluster Creation Example # Introduction Welcome to the APIs for HPE GreenLake for Private Cloud Enterprise: containers. This document describes the API protocol and available endpoints for the containers service. The containers service APIs are built on HTTP. Our API is RESTful. It has predictable resource URLs. It returns HTTP response codes to indicate errors. It also accepts and returns JSON in the HTTP body. You can use your favorite HTTP/REST library for your programming language to use the containers service APIs. # Authentication To authenticate with the containers service, you must obtain the access token using either of the following options.
Option 1: Creating an API client (recommended)
An API client allows nonhuman entities (an application service account, for instance) programmatic access to a resource on a space. 1. <a href="
https://support.hpe.com/hpesc/public/docDisplay?docId=a00092451en_us&page=greenlakecentral-create-api-client.html" target="_blank"> Create an API client <img src="
https://raw.githubusercontent.com/grommet/grommet-icons/stable/img/share.svg" height="12">
Note: Make sure to save the
Issuer Url,
Client ID, and
Client Secret. 2. <a href="
https://support.hpe.com/hpesc/public/docDisplay?docId=a00092451en_us&page=GUID-1CEA233B-C4B0-41B7-9A25-7A36D9FC0312.html" target="_blank"> Create an assignment for the API client <img src="
https://raw.githubusercontent.com/grommet/grommet-icons/stable/img/share.svg" height="12">
Note: Make sure to assign
Private Cloud Cluster Owner
(cluster-admin) or
Private Cloud Cluster Resource Contributor
(developer) role. 3. Make a REST call to generate the API access token, using the issuer URL, client ID, and client secret from step 1:
curl -i -X POST \\ '{issuerUrl}/v1/token' \\ -H 'Content-Type: application/x-www-form-urlencoded' \\ -d 'client_id={clientID}' \\ -d 'client_secret={clientSecret}' \\ -d grant_type=client_credentials \\ -d scope=hpe-tenant
Obtain the
access_token
from the response.
Option 2: Getting the token directly from the UI
To authenticate with the containers service API, you can obtain the access token from <a href="
https://client.greenlake.hpe.com" target="_blank"> HPE GreenLake Central <img src="
https://raw.githubusercontent.com/grommet/grommet-icons/stable/img/share.svg" height="12"> . Log into
HPE GreenLake Central. Click the <img src="
https://raw.githubusercontent.com/grommet/grommet-icons/stable/img/user.svg"> icon in the top right corner and then click
API Access. In the API Access page, click the <img src="
https://raw.githubusercontent.com/grommet/grommet-icons/stable/img/clipboard.svg"> icon to copy the personal access token.
> <img src="
https://raw.githubusercontent.com/grommet/grommet-icons/stable/img/circle-information.svg">
INFO: For both the options, the access token lease expires in
15 minutes. # Get a Space ID You must obtain the space ID for the space on which you have access. Use the UI to get the space ID.  # Roles and Permissions The containers service provides two default roles for customers:
Private Cloud Cluster Owner and
Private Cloud Cluster Resource Contributor. The
Private Cloud Cluster Owner role is for a cluster administrator who gets all the required permissions to execute all the APIs documented in this guide. The
Private Cloud Cluster Resource Contributor role is for developers with only selective permissions, so that they can execute only a selected list of APIs. Each API has details about "Required Permissions to access the API" and "Default Roles which can access the API" # Getting Started Guide Our getting started guide will demonstrate a machine blueprint creation, a cluster blueprint creation and then a cluster creation using that cluster blueprint. Here are the set of APIs that you will likely execute: + Sites + Gets all Sites + Machine Providers + Gets all Machine Providers + Machine Blueprints + Create a Machine Blueprint + Cluster Providers + Gets all Cluster Providers + Cluster Blueprints + Creates a Cluster Blueprint + Clusters + Create a Cluster + Get a specific Cluster ## Machine Blueprint Creation Example Use the steps in this section to create a machine blueprint that can be used by the cluster blueprint. ### Step 1 ### Obtain the 'applianceID' for the site on which you want to create a cluster by running the '
Gets all Sites' API. Note the
applianceID
. ### Step 2 ### Get a list of all machine providers for the specified 'applianceID' by running the '
Gets all Machine Providers' API. Make a note of the
name
,
workerType
, one of the
osImages
, one of the
computeInstanceTypes
and one of the
storageInstanceTypes
. ### Step 3 ### Create a machine blueprint by running the '
Create a Machine Blueprint' API. Designate the machine role as "worker", and in the request body, provide the values that you noted in the previous step. Make note of the 'id' and 'name' values of the machine blueprint. ## Cluster Blueprint Creation Example ### Step 1 ### List all the cluster providers for the specified 'applianceId' by running the '
Gets all Cluster Providers' API. Make note of the
name
, one of the
kubernetesVersions
and one of the
storageClasses
. ### Step 2 ### Create a cluster blueprint by running the
Creates a Cluster Blueprint API, and, in the request body, providing the values noted in the previous step. Take note of the 'id' value in the response body. ## Cluster Creation Example ### Step 1 ### Create the cluster by running the '
Creates a Cluster' API. In the response body, observe the details of the newly created cluster. Make note of the 'clusterID' value. ### Step 2 ### Monitor the cluster provisioning state of the specified 'clusterID' by running the
Get a specific Cluster
API. After the state turns ready, the cluster is ready for use! ``
Overview
This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.
- API version: v1
- Package version: v0.5.11
- Build package: io.swagger.codegen.v3.generators.go.GoClientCodegen
Installation
Example Usage
import "github.com/HewlettPackard/hpegl-containers-go-sdk/pkg/mcaasapi"
...
apiUrl := "<actual url>"
accessToken := "<actual token"
cfg := &mcaasapi.Configuration{
BasePath: apiUrl,
DefaultHeader: make(map[string]string),
UserAgent: "hpecli",
}
client = mcaasapi.NewAPIClient(cfg)
ctx = context.WithValue(gocontext.Background(), mcaasapi.ContextAccessToken, accessToken)
myThing, _, err := client.<XYZ>API.<Function>(ctx)
import "./mcaasapi"
Documentation for API Endpoints
All URIs are relative to https://mcaas.us1.greenlake-hpe.com/mcaas
Documentation For Models