calm

package
v0.0.0-...-4787336 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const NUTANIX_CALM_PASS = "NUTANIX_CALM_PASS"

NUTANIX_CALM_PASS used to define calm login password via env

View Source
const NUTANIX_CALM_URL = "NUTANIX_CALM_URL"

NUTANIX_CALM_URL used to define custom calm URL endpoint

View Source
const NUTANIX_CALM_USER = "NUTANIX_CALM_USER"

NUTANIX_CALM_USER used to define calm login user via env

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(conf *ServiceConfig) error

CheckConfig will ensure that the minimal amount of information is present in the config

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse looks for common response errors Need to fill this in at some point

func FormatCredentials

func FormatCredentials(a AuthCredentials) string

FormatCredentials takes in an AuthCredential type and returns a base64 encoded string in the proper format for use by the REST API

Types

type APIVersion

type APIVersion struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type AdditionalProperties

type AdditionalProperties struct {
	Type  string `json:"type"`
	Items Items  `json:"items"`
}

type Attrs

type Attrs struct {
	Type                 string `json:"type"`
	Description          string `json:"description"`
	AdditionalProperties bool   `json:"additionalProperties"`
}

type AuthCredentials

type AuthCredentials struct {
	Username string
	Password string
}

AuthCredentials are the username and password received from ENV variables never hard code these values into any code!

func GetCredentials

func GetCredentials(conf *ServiceConfig) (AuthCredentials, error)

GetCredentials gets the username and password from the ENV variables for use in the application

type BlueprintAbortRequest

type BlueprintAbortRequest struct{}

type BlueprintAbortResponse

type BlueprintAbortResponse struct{}

type BlueprintCloneRequest

type BlueprintCloneRequest struct{}

type BlueprintCloneResponse

type BlueprintCloneResponse struct{}

type BlueprintCreateRequest

type BlueprintCreateRequest struct{}

type BlueprintCreateResponse

type BlueprintCreateResponse struct{}

type BlueprintDownloadRequest

type BlueprintDownloadRequest struct{}

type BlueprintDownloadResponse

type BlueprintDownloadResponse struct{}

type BlueprintExportRequest

type BlueprintExportRequest struct{}

BlueprintExportRequest is the export request which only needs a UUID

type BlueprintExportResponse

type BlueprintExportResponse struct {
}

BlueprintExportResponse is the output from the export request

type BlueprintGetPendingLaunchRequest

type BlueprintGetPendingLaunchRequest struct{}

type BlueprintGetPendingLaunchResponse

type BlueprintGetPendingLaunchResponse struct{}

type BlueprintGetRuntimeVariablesRequest

type BlueprintGetRuntimeVariablesRequest struct{}

type BlueprintGetRuntimeVariablesResponse

type BlueprintGetRuntimeVariablesResponse struct{}

type BlueprintImportRequest

type BlueprintImportRequest struct{}

type BlueprintImportResponse

type BlueprintImportResponse struct{}

type BlueprintLaunchMarketplaceRequest

type BlueprintLaunchMarketplaceRequest struct{}

type BlueprintLaunchMarketplaceResponse

type BlueprintLaunchMarketplaceResponse struct{}

type BlueprintLaunchRequest

type BlueprintLaunchRequest struct{}

type BlueprintLaunchResponse

type BlueprintLaunchResponse struct{}

type BlueprintRunRequest

type BlueprintRunRequest struct {
	Description string   `json:"description"`
	Required    []string `json:"required"`
	Type        string   `json:"type"`
	Properties  struct {
		Spec struct {
			Description string `json:"description"`
			Type        string `json:"type"`
			Title       string `json:"title"`
			Properties  struct {
				TargetDetails struct {
					Type                 string `json:"type"`
					Description          string `json:"description"`
					AdditionalProperties bool   `json:"additionalProperties"`
				} `json:"targetDetails"`
				Machine struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"machine"`
				ProviderOperationPayload struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"provider_operation_payload"`
				Attrs struct {
					Type                 string `json:"type"`
					Description          string `json:"description"`
					AdditionalProperties bool   `json:"additionalProperties"`
				} `json:"attrs"`
				Port struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"port"`
				Runid struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"runid"`
			} `json:"properties"`
		} `json:"spec"`
		APIVersion struct {
			Type        string `json:"type"`
			Description string `json:"description"`
		} `json:"api_version"`
		Metadata struct {
			Description string   `json:"description"`
			Required    []string `json:"required"`
			Type        string   `json:"type"`
			Title       string   `json:"title"`
			Properties  struct {
				LastUpdateTime struct {
					ReadOnly    bool   `json:"readOnly"`
					Type        string `json:"type"`
					Description string `json:"description"`
					Format      string `json:"format"`
				} `json:"last_update_time"`
				UseCategoriesMapping struct {
					Default     bool   `json:"default"`
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"use_categories_mapping"`
				Kind struct {
					Default     string   `json:"default"`
					ReadOnly    bool     `json:"readOnly"`
					Type        string   `json:"type"`
					Description string   `json:"description"`
					XNtnxEnum   []string `json:"x-ntnx-enum"`
				} `json:"kind"`
				UUID struct {
					Pattern     string `json:"pattern"`
					Type        string `json:"type"`
					Description string `json:"description"`
					Format      string `json:"format"`
				} `json:"uuid"`
				ProjectReference struct {
					Description string   `json:"description"`
					Required    []string `json:"required"`
					Type        string   `json:"type"`
					Title       string   `json:"title"`
					Properties  struct {
						Kind struct {
							Default     string   `json:"default"`
							ReadOnly    bool     `json:"readOnly"`
							Type        string   `json:"type"`
							Description string   `json:"description"`
							XNtnxEnum   []string `json:"x-ntnx-enum"`
						} `json:"kind"`
						Name struct {
							ReadOnly bool   `json:"readOnly"`
							Type     string `json:"type"`
						} `json:"name"`
						UUID struct {
							Pattern string `json:"pattern"`
							Type    string `json:"type"`
							Format  string `json:"format"`
						} `json:"uuid"`
					} `json:"properties"`
				} `json:"project_reference"`
				CreationTime struct {
					ReadOnly    bool   `json:"readOnly"`
					Type        string `json:"type"`
					Description string `json:"description"`
					Format      string `json:"format"`
				} `json:"creation_time"`
				SpecVersion struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"spec_version"`
				SpecHash struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"spec_hash"`
				CategoriesMapping struct {
					Type                 string `json:"type"`
					Description          string `json:"description"`
					AdditionalProperties struct {
						Type  string `json:"type"`
						Items struct {
							Type string `json:"type"`
						} `json:"items"`
					} `json:"additionalProperties"`
				} `json:"categories_mapping"`
				ShouldForceTranslate struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"should_force_translate"`
				OwnerReference struct {
					Description string   `json:"description"`
					Required    []string `json:"required"`
					Type        string   `json:"type"`
					Title       string   `json:"title"`
					Properties  struct {
						Kind struct {
							Default     string   `json:"default"`
							ReadOnly    bool     `json:"readOnly"`
							Type        string   `json:"type"`
							Description string   `json:"description"`
							XNtnxEnum   []string `json:"x-ntnx-enum"`
						} `json:"kind"`
						Name struct {
							ReadOnly bool   `json:"readOnly"`
							Type     string `json:"type"`
						} `json:"name"`
						UUID struct {
							Pattern string `json:"pattern"`
							Type    string `json:"type"`
							Format  string `json:"format"`
						} `json:"uuid"`
					} `json:"properties"`
				} `json:"owner_reference"`
				Categories struct {
					Type                 string `json:"type"`
					Description          string `json:"description"`
					AdditionalProperties struct {
						Type string `json:"type"`
					} `json:"additionalProperties"`
				} `json:"categories"`
				Name struct {
					ReadOnly    bool   `json:"readOnly"`
					Type        string `json:"type"`
					Description string `json:"description"`
					MaxLength   int    `json:"maxLength"`
				} `json:"name"`
			} `json:"properties"`
		} `json:"metadata"`
	} `json:"properties"`
	Title string `json:"title"`
}

BlueprintRunRequest is the request used run a blueprint

type BlueprintRunResponse

type BlueprintRunResponse struct {
	Required   []string `json:"required"`
	Type       string   `json:"type"`
	Properties struct {
		Status struct {
			Required    []string `json:"required"`
			Description string   `json:"description"`
			Properties  struct {
				TrlID struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"trl_id"`
				RequestID struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"request_id"`
				RunID struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"run_id"`
			} `json:"properties"`
		} `json:"status"`
		Metadata struct {
			Description string   `json:"description"`
			Required    []string `json:"required"`
			Type        string   `json:"type"`
			Title       string   `json:"title"`
			Properties  struct {
				LastUpdateTime struct {
					ReadOnly    bool   `json:"readOnly"`
					Type        string `json:"type"`
					Description string `json:"description"`
					Format      string `json:"format"`
				} `json:"last_update_time"`
				UseCategoriesMapping struct {
					Default     bool   `json:"default"`
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"use_categories_mapping"`
				Kind struct {
					Default     string   `json:"default"`
					ReadOnly    bool     `json:"readOnly"`
					Type        string   `json:"type"`
					Description string   `json:"description"`
					XNtnxEnum   []string `json:"x-ntnx-enum"`
				} `json:"kind"`
				UUID struct {
					Pattern     string `json:"pattern"`
					Type        string `json:"type"`
					Description string `json:"description"`
					Format      string `json:"format"`
				} `json:"uuid"`
				ProjectReference struct {
					Description string   `json:"description"`
					Required    []string `json:"required"`
					Type        string   `json:"type"`
					Title       string   `json:"title"`
					Properties  struct {
						Kind struct {
							Default     string   `json:"default"`
							ReadOnly    bool     `json:"readOnly"`
							Type        string   `json:"type"`
							Description string   `json:"description"`
							XNtnxEnum   []string `json:"x-ntnx-enum"`
						} `json:"kind"`
						Name struct {
							ReadOnly bool   `json:"readOnly"`
							Type     string `json:"type"`
						} `json:"name"`
						UUID struct {
							Pattern string `json:"pattern"`
							Type    string `json:"type"`
							Format  string `json:"format"`
						} `json:"uuid"`
					} `json:"properties"`
				} `json:"project_reference"`
				CreationTime struct {
					ReadOnly    bool   `json:"readOnly"`
					Type        string `json:"type"`
					Description string `json:"description"`
					Format      string `json:"format"`
				} `json:"creation_time"`
				SpecVersion struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"spec_version"`
				SpecHash struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"spec_hash"`
				CategoriesMapping struct {
					Type                 string `json:"type"`
					Description          string `json:"description"`
					AdditionalProperties struct {
						Type  string `json:"type"`
						Items struct {
							Type string `json:"type"`
						} `json:"items"`
					} `json:"additionalProperties"`
				} `json:"categories_mapping"`
				ShouldForceTranslate struct {
					Type        string `json:"type"`
					Description string `json:"description"`
				} `json:"should_force_translate"`
				OwnerReference struct {
					Description string   `json:"description"`
					Required    []string `json:"required"`
					Type        string   `json:"type"`
					Title       string   `json:"title"`
					Properties  struct {
						Kind struct {
							Default     string   `json:"default"`
							ReadOnly    bool     `json:"readOnly"`
							Type        string   `json:"type"`
							Description string   `json:"description"`
							XNtnxEnum   []string `json:"x-ntnx-enum"`
						} `json:"kind"`
						Name struct {
							ReadOnly bool   `json:"readOnly"`
							Type     string `json:"type"`
						} `json:"name"`
						UUID struct {
							Pattern string `json:"pattern"`
							Type    string `json:"type"`
							Format  string `json:"format"`
						} `json:"uuid"`
					} `json:"properties"`
				} `json:"owner_reference"`
				Categories struct {
					Type                 string `json:"type"`
					Description          string `json:"description"`
					AdditionalProperties struct {
						Type string `json:"type"`
					} `json:"additionalProperties"`
				} `json:"categories"`
				Name struct {
					ReadOnly    bool   `json:"readOnly"`
					Type        string `json:"type"`
					Description string `json:"description"`
					MaxLength   int    `json:"maxLength"`
				} `json:"name"`
			} `json:"properties"`
		} `json:"metadata"`
	} `json:"properties"`
}

BlueprintRunResponse is the response from calling Run

type BlueprintService

type BlueprintService Service

BlueprintService handles communication to the Calm BPs REST API endpoint

func (*BlueprintService) Export

Export will export the identified blueprint

func (*BlueprintService) Run

Run makes the call to cluster run

func (*BlueprintService) Upload

Upload will update the cluster defined by the UUID with the provided information

type BlueprintUploadRequest

type BlueprintUploadRequest struct {
	Type string `json:"type"`
}

BlueprintUploadRequest is the request to upload a blueprint

type BlueprintUploadResponse

type BlueprintUploadResponse struct{}

type Categories

type Categories struct {
	Type                 string                `json:"type"`
	Description          string                `json:"description"`
	AdditionalProperties *AdditionalProperties `json:"additionalProperties"`
}

type CategoriesMapping

type CategoriesMapping struct {
	Type                 string                `json:"type"`
	Description          string                `json:"description"`
	AdditionalProperties *AdditionalProperties `json:"additionalProperties"`
}

type Client

type Client struct {
	CalmURL *url.URL

	Login AuthCredentials

	Blueprints *BlueprintService
	// contains filtered or unexported fields
}

Client is an HTTP Client

func NewClient

func NewClient(httpClient *http.Client, conf *ServiceConfig) (*Client, error)

NewClient is used for Nutanix Calm client instantiation

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request

type CreationTime

type CreationTime struct {
	ReadOnly    bool   `json:"readOnly"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Format      string `json:"format"`
}

type Items

type Items struct {
	Type string `json:"type"`
}

type Kind

type Kind struct {
	Default     string   `json:"default"`
	ReadOnly    bool     `json:"readOnly"`
	Type        string   `json:"type"`
	Description string   `json:"description"`
	XNtnxEnum   []string `json:"x-ntnx-enum"`
}

type LastUpdateTime

type LastUpdateTime struct {
	ReadOnly    bool   `json:"readOnly"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Format      string `json:"format"`
}

type Machine

type Machine struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type Metadata

type Metadata struct {
	Description string      `json:"description"`
	Required    []string    `json:"required"`
	Type        string      `json:"type"`
	Title       string      `json:"title"`
	Properties  *Properties `json:"properties"`
}

type Name

type Name struct {
	ReadOnly    bool   `json:"readOnly"`
	Type        string `json:"type"`
	Description string `json:"description"`
	MaxLength   int    `json:"maxLength"`
}

type OwnerReference

type OwnerReference struct {
	Description string      `json:"description"`
	Required    []string    `json:"required"`
	Type        string      `json:"type"`
	Title       string      `json:"title"`
	Properties  *Properties `json:"properties"`
}

type Port

type Port struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type ProjectReference

type ProjectReference struct {
	Description string      `json:"description"`
	Required    []string    `json:"required"`
	Type        string      `json:"type"`
	Title       string      `json:"title"`
	Properties  *Properties `json:"properties"`
}

type Properties

type Properties struct {
	LastUpdateTime           *LastUpdateTime           `json:"last_update_time"`
	UseCategoriesMapping     *UseCategoriesMapping     `json:"use_categories_mapping"`
	Kind                     *Kind                     `json:"kind"`
	UUID                     *UUID                     `json:"uuid"`
	ProjectReference         *ProjectReference         `json:"project_reference"`
	CreationTime             *CreationTime             `json:"creation_time"`
	SpecVersion              *SpecVersion              `json:"spec_version"`
	SpecHash                 *SpecHash                 `json:"spec_hash"`
	CategoriesMapping        *CategoriesMapping        `json:"categories_mapping"`
	ShouldForceTranslate     *ShouldForceTranslate     `json:"should_force_translate"`
	OwnerReference           *OwnerReference           `json:"owner_reference"`
	Categories               *Categories               `json:"categories"`
	Name                     *Name                     `json:"name"`
	Spec                     *Spec                     `json:"spec"`
	APIVersion               *APIVersion               `json:"api_version"`
	Metadata                 *Metadata                 `json:"metadata"`
	TargetDetails            *TargetDetails            `json:"targetDetails"`
	Machine                  *Machine                  `json:"machine"`
	ProviderOperationPayload *ProviderOperationPayload `json:"provider_operation_payload"`
	Attrs                    *Attrs                    `json:"attrs"`
	Port                     *Port                     `json:"port"`
	Runid                    *Runid                    `json:"runid"`
}

type ProviderOperationPayload

type ProviderOperationPayload struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type Runid

type Runid struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is used to create endpoint specific services to utilize concurrency with timeouts

type ServiceConfig

type ServiceConfig struct {
	URL  *string
	User *string
	Pass *string
}

ServiceConfig is the configuration to use PC

type ShouldForceTranslate

type ShouldForceTranslate struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type Spec

type Spec struct {
	Description string      `json:"description"`
	Type        string      `json:"type"`
	Title       string      `json:"title"`
	Properties  *Properties `json:"properties"`
}

type SpecHash

type SpecHash struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type SpecVersion

type SpecVersion struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type TargetDetails

type TargetDetails struct {
	Type                 string `json:"type"`
	Description          string `json:"description"`
	AdditionalProperties bool   `json:"additionalProperties"`
}

type UUID

type UUID struct {
	Pattern     string `json:"pattern"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Format      string `json:"format"`
}

type UseCategoriesMapping

type UseCategoriesMapping struct {
	Default     bool   `json:"default"`
	Type        string `json:"type"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

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