cbclient

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudBoltBlueprintResult added in v1.0.0

type CloudBoltBlueprintResult struct {
	CloudBoltResult
	Embedded struct {
		Blueprints []CloudBoltReferenceFields `json:"blueprints"`
	} `json:"_embedded"`
}

type CloudBoltClient

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

CloudBoltClient stores the important metadata necessary to make API requests. - BaseURL follows the pattern "https://cloudbolt.myco.ext:443/". - HTTPClient is a client used to make the API calls. - Token is retrieved in `New` and is included in the Bearer Token of request headers.

func New

func New(protocol string, host string, port string, username string, password string, domain string, httpClient *http.Client) *CloudBoltClient

New returns an initialized CloudBoltClient object. Accepts as input: - HTTP Protocol (protocol) e.g., "https" - HTTP Host (host) e.g., "cloudbolt.intranet" - HTTP Port (port) e.g., "443" - Username (username) e.g., "myUserName" - Password (password) e.g., "My Passphrase!" - Domain (domain) e.g., "mydomain.com" - User-provided *HTTPClient (httpClient); provide `nil` to get a server with the following defaults:

  • Timeout set to 60 seconds Provide a custom http.Client if you require unique certificate, timeout, etc., configured.

New does not make any API calls. CloudBoltClient.Authenticate must be called to initialize CloudBoltClient.token. This is done automatically when a request receives an HTTP Authorization error.

func (*CloudBoltClient) Authenticate

func (c *CloudBoltClient) Authenticate() (int, error)

Authenticate forces the CloudBoltClient to re-authenticate Returns an error if there is an HTTP error, or if the HTTP Status Code is >=400

func (*CloudBoltClient) DecomServer added in v1.0.0

func (c *CloudBoltClient) DecomServer(serverId string) (*CloudBoltDecomServerResult, error)

func (*CloudBoltClient) DeployBlueprint

func (c *CloudBoltClient) DeployBlueprint(grpPath string, blueprintID string, resourceName string, bpParams map[string]interface{}, bpItems []map[string]interface{}) (*CloudBoltOrder, error)

func (*CloudBoltClient) GetBlueprint added in v1.0.0

func (c *CloudBoltClient) GetBlueprint(name string) (*CloudBoltReferenceFields, error)

GetBlueprint accepts the name of a Blueprint

func (*CloudBoltClient) GetBlueprintById added in v1.0.0

func (c *CloudBoltClient) GetBlueprintById(id string) (*CloudBoltReferenceFields, error)

func (*CloudBoltClient) GetEnvironment added in v1.0.0

func (c *CloudBoltClient) GetEnvironment(name string) (*CloudBoltReferenceFields, error)

GetEnvironment accepts the name of a Environment

func (*CloudBoltClient) GetEnvironmentById added in v1.0.0

func (c *CloudBoltClient) GetEnvironmentById(id string) (*CloudBoltReferenceFields, error)

func (*CloudBoltClient) GetGroup

func (c *CloudBoltClient) GetGroup(groupPath string) (*CloudBoltGroup, error)

GetGroup accepts a groupPath string parameter of the following format: "/my parent group/some subgroup/a child group/" or just "my parent group"

verifyGroup recursively verifies that this is a valid group/subgroup.

func (*CloudBoltClient) GetGroupById added in v1.0.0

func (c *CloudBoltClient) GetGroupById(id string) (*CloudBoltGroup, error)

func (*CloudBoltClient) GetJob

func (c *CloudBoltClient) GetJob(jobPath string) (*CloudBoltJob, error)

GetJob fetches the Job object from CloudBolt at the given path - Job Path (jobPath) e.g., "/api/v2/jobs/123/"

func (*CloudBoltClient) GetOSBuild added in v1.0.0

func (c *CloudBoltClient) GetOSBuild(name string) (*CloudBoltReferenceFields, error)

GetOSBuild accepts the name of a OSBuild

func (*CloudBoltClient) GetOSBuildById added in v1.0.0

func (c *CloudBoltClient) GetOSBuildById(id string) (*CloudBoltReferenceFields, error)

func (*CloudBoltClient) GetOrder

func (c *CloudBoltClient) GetOrder(orderID string) (*CloudBoltOrder, error)

GetOrder fetches an Order from CloudBolt - Order ID (orderID) e.g., "123"; formatted into a string like "/api/v2/orders/123"

func (*CloudBoltClient) GetResource

func (c *CloudBoltClient) GetResource(resourcePath string) (*CloudBoltResource, error)

GetResource fetches a Resource object from CloudBolt at the given path - Resource Path (resourcePath) e.g., "/api/v2/resources/service/123/"

func (*CloudBoltClient) GetResourceHandler added in v1.0.1

func (c *CloudBoltClient) GetResourceHandler(name string) (*CloudBoltReferenceFields, error)

GetResourceHandler accepts the name of a Resource Handler

func (*CloudBoltClient) GetResourceHandlerById added in v1.0.1

func (c *CloudBoltClient) GetResourceHandlerById(id string) (*CloudBoltReferenceFields, error)

func (*CloudBoltClient) GetServer

func (c *CloudBoltClient) GetServer(serverPath string) (*CloudBoltServer, error)

GetServer fetches a Server object from CloudBolt at the given path - Server Path (serverPath) e.g., "/api/v2/servers/123/"

func (*CloudBoltClient) GetServerById added in v1.0.0

func (c *CloudBoltClient) GetServerById(id string) (*CloudBoltServer, error)

func (*CloudBoltClient) SubmitAction

func (c *CloudBoltClient) SubmitAction(actionPath string, resourcePath string) (*CloudBoltJob, error)

SubmitAction runs an action on the CloudBolt resource or server

type CloudBoltDecomServerResult added in v1.0.0

type CloudBoltDecomServerResult struct {
	Links struct {
		Self CloudBoltHALItem `json:"self"`
	} `json:"_links"`
	ID string `json:"id"`
}

type CloudBoltEnvironmentResult added in v1.0.0

type CloudBoltEnvironmentResult struct {
	CloudBoltResult
	Embedded struct {
		Environments []CloudBoltReferenceFields `json:"environments"`
	} `json:"_embedded"`
}

type CloudBoltGroup

type CloudBoltGroup struct {
	CloudBoltReferenceFields
	Parent CloudBoltHALItem `json:"parent"`
}

type CloudBoltGroupResult added in v1.0.0

type CloudBoltGroupResult struct {
	CloudBoltResult
	Embedded struct {
		Groups []CloudBoltGroup `json:"groups"`
	} `json:"_embedded"`
}

type CloudBoltHALItem

type CloudBoltHALItem struct {
	Href  string `json:"href"`
	Title string `json:"title"`
}

CloudBoltHALItem stores an object's title and API endpoint. This is a common pattern in the CloudBolt API, so it gets used a lot.

type CloudBoltJob

type CloudBoltJob struct {
	Links struct {
		Self          CloudBoltHALItem   `json:"self"`
		Owner         CloudBoltHALItem   `json:"owner"`
		Parent        CloudBoltHALItem   `json:"parent"`
		Subjobs       []CloudBoltHALItem `json:"subjobs"`
		Prerequisite  CloudBoltHALItem   `json:"prerequisite"`
		DependentJobs []CloudBoltHALItem `json:"dependent-jobs"`
		Order         CloudBoltHALItem   `json:"order"`
		Resource      CloudBoltHALItem   `json:"resource"`
		Servers       []CloudBoltHALItem `json:"servers"`
	} `json:"_links"`
	ID             string `json:"id"`
	Type           string `json:"type"`
	Status         string `json:"status"`
	WorkerPid      int    `json:"workerPid"`
	WorkerHostname string `json:"workerHostname"`
	CanBeRequeued  bool   `json:"canBeRequeued"`
	CreatedDate    string `json:"createdDate"`
	UpdatedDate    string `json:"updatedDate"`
	StartDate      string `json:"startDate"`
	EndDate        string `json:"endDate"`
	Output         string `json:"output"`
	Errors         string `json:"errors"`
	TasksDone      int    `json:"tasksDone"`
	TotalTasks     int    `json:"totalTasks"`
	Label          string `json:"label"`
	ExecutionState string `json:"executionState"`
}

CloudBoltJob contains metadata about a Job. Useful for getting the status of a running or completed job.

type CloudBoltOSBuildResult added in v1.0.0

type CloudBoltOSBuildResult struct {
	CloudBoltResult
	Embedded struct {
		OSBuilds []CloudBoltReferenceFields `json:"osBuilds"`
	} `json:"_embedded"`
}

type CloudBoltOrder

type CloudBoltOrder struct {
	Links struct {
		Self       CloudBoltHALItem   `json:"self"`
		Group      CloudBoltHALItem   `json:"group"`
		Owner      CloudBoltHALItem   `json:"owner"`
		ApprovedBy CloudBoltHALItem   `json:"approvedBy"`
		Jobs       []CloudBoltHALItem `json:"jobs"`
		Duplicate  CloudBoltHALItem   `json:"duplicate"`
	} `json:"_links"`
	Name            string `json:"name"`
	ID              string `json:"id"`
	Status          string `json:"status"`
	Rate            string `json:"rate"`
	CreateDate      string `json:"createDate"`
	ApproveDate     string `json:"approveDate"`
	DeploymentItems []struct {
		ID                 string                 `json:"id"`
		ResourceName       string                 `json:"resourceName"`
		ResourceParameters map[string]interface{} `json:"resourceParameters"`
		Blueprint          struct {
			Href  string `json:"href"`
			Title string `json:"title"`
		} `json:"blueprint"`
		BlueprintItemsArguments map[string]interface{} `json:"blueprintItemsArguments"`
		ItemType                string                 `json:"itemType"`
	} `json:"deploymentItems"`
}

type CloudBoltReferenceFields added in v1.0.0

type CloudBoltReferenceFields struct {
	Links struct {
		Self struct {
			Href  string `json:"href"`
			Title string `json:"title"`
		} `json:"self"`
	} `json:"_links"`
	Name string `json:"name"`
	ID   string `json:"id"`
}

type CloudBoltResource

type CloudBoltResource struct {
	Links struct {
		Self           CloudBoltHALItem   `json:"self"`
		ResourceType   CloudBoltHALItem   `json:"resourceType"`
		Blueprint      CloudBoltHALItem   `json:"blueprint"`
		Owner          CloudBoltHALItem   `json:"owner"`
		Group          CloudBoltHALItem   `json:"group"`
		Jobs           []CloudBoltHALItem `json:"jobs"`
		ParentResource CloudBoltHALItem   `json:"parentResource"`
		Servers        []CloudBoltHALItem `json:"servers"`
		Actions        []CloudBoltHALItem `json:"actions"`
	} `json:"_links"`
	Name       string                   `json:"name"`
	ID         string                   `json:"id"`
	Created    string                   `json:"created"`
	Status     string                   `json:"status"`
	Attributes []map[string]interface{} `json:"attributes"`
}

CloudBoltResource contains metadata about Resources (e.g., "Services") in CloudBolt

type CloudBoltResourceHandlerResult added in v1.0.1

type CloudBoltResourceHandlerResult struct {
	CloudBoltResult
	Embedded struct {
		ResourceHandlers []CloudBoltReferenceFields `json:"resourceHandlers"`
	} `json:"_embedded"`
}

type CloudBoltResult

type CloudBoltResult struct {
	Links struct {
		Self CloudBoltHALItem `json:"self"`
	} `json:"_links"`
	Total int `json:"total"`
	Count int `json:"count"`
}

CloudBoltResult stores the response of paginated calls like `/api/v2/blueprints/` These include a link to the page and an `embedded` list of response objects.

type CloudBoltServer

type CloudBoltServer struct {
	Links struct {
		Self            CloudBoltHALItem         `json:"self"`
		Owner           CloudBoltHALItem         `json:"owner"`
		Group           CloudBoltHALItem         `json:"group"`
		Environment     CloudBoltHALItem         `json:"environment"`
		ResourceHandler CloudBoltHALItem         `json:"resource-handler"`
		Actions         []map[string]interface{} `json:"actions"`
		ProvisionJob    CloudBoltHALItem         `json:"provision-job"`
		OsBuild         CloudBoltHALItem         `json:"os-build"`
		Jobs            CloudBoltHALItem         `json:"jobs"`
		History         CloudBoltHALItem         `json:"history"`
	} `json:"_links"`
	ID                   string        `json:"id"`
	Hostname             string        `json:"hostname"`
	PowerStatus          string        `json:"powerStatus"`
	Status               string        `json:"status"`
	IP                   string        `json:"ipAddress"`
	Mac                  string        `json:"mac"`
	DateAddedToCloudbolt string        `json:"dateAddedToCloudBolt"`
	CPUCount             int           `json:"cpuCount"`
	MemorySizeGB         string        `json:"memorySizeGb"`
	DiskSizeGB           int           `json:"diskSizeGB"`
	OsFamily             string        `json:"osFamily"`
	Notes                string        `json:"notes"`
	Labels               []interface{} `json:"labels"`
	Credentials          struct {
		Username string `json:"username"`
		Password string `json:"password"`
		Key      string `json:"key"`
	} `json:"credentials"`
	RateBreakdown          map[string]interface{}   `json:"rateBreakdown"`
	Disks                  []map[string]interface{} `json:"disks"`
	Snapshots              []map[string]interface{} `json:"snapshots"`
	Networks               []map[string]interface{} `json:"networks"`
	Attributes             []map[string]interface{} `json:"attributes"`
	TechSpecificAttributes map[string]interface{}   `json:"techSpecificAttributes"`
}

CloudBoltServer stores metadata about servers in CloudBolt.

Jump to

Keyboard shortcuts

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