depresourceapi

package
v1.2.30 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package depresourceapi contains curated functions which iteract with the deployment resources API, exposing an API which its usage is preferred over the direct client calls.

Index

Constants

View Source
const (
	// DefaultTemplateID is used when there's no template ID specified in
	// the request.
	DefaultTemplateID = "default"

	// DefaultDataSize defines the default node size for data nodes when not
	// specified.
	DefaultDataSize = 4096

	// DefaultDataZoneCount defines the default number of zones a deployment
	// spans.
	DefaultDataZoneCount = 1

	// DefaultElasticsearchRefID is used when the RefID is not specified.
	DefaultElasticsearchRefID = "main-elasticsearch"
)
View Source
const (
	// DataNode identifies the node type which stores data.
	DataNode = "data"

	// MasterNode identifies the node type which is master elegible.
	MasterNode = "master"

	// MLNode identifies the node type performing the Machine Learning.
	MLNode = "ml"
)
View Source
const (
	// DefaultApmRefID is used when the RefID is not specified.
	DefaultApmRefID = "main-apm"
)
View Source
const (
	// DefaultAppSearchRefID is used when the RefID is not specified.
	DefaultAppSearchRefID = "main-appsearch"
)
View Source
const (
	// DefaultEnterpriseSearchRefID is used when the RefID is not specified.
	DefaultEnterpriseSearchRefID = "main-enterprise_search"
)
View Source
const (
	// DefaultKibanaRefID is used when the RefID is not specified.
	DefaultKibanaRefID = "main-kibana"
)

Variables

View Source
var (
	// DefaultTopology will be used when no topology is specified.
	DefaultTopology = []ElasticsearchTopologyElement{
		DefaultTopologyElement,
	}

	// DefaultTopologyElement defines the element used in DefaultTopology
	DefaultTopologyElement = ElasticsearchTopologyElement{
		NodeType:  DataNode,
		Size:      DefaultDataSize,
		ZoneCount: DefaultDataZoneCount,
	}
)

Functions

func BuildElasticsearchTopology

BuildElasticsearchTopology receives an ElasticsearchCluster topology from the deployment template definition and what the user has specified through a simplified version of the deployment topology, iterating over the template topology and triying to match the types that the user can specify: ["ml", "data", "master"], with their instance configuration ID. the matchNodeType function takes care of the matching. Once the NodeType has beeen matched, any overrides coming from the user- specified topology settings are set, overriding the default deployment template defined defaults.

func CancelPlan

CancelPlan cancels a deployment resource plan.

func DeleteStateless

func DeleteStateless(params DeleteStatelessParams) error

DeleteStateless deletes a stateless deployment resource like APM, Kibana and App Search.

func LatestStackVersion

func LatestStackVersion(params LatestStackVersionParams) (string, error)

LatestStackVersion obtains the latest stack version from the API given an empty version from the parameters, if the passed version is not empty, then it will be returned.

func NewApm

func NewApm(params NewStateless) (*models.ApmPayload, error)

NewApm creates a *models.ApmPayload from the parameters. It relies on a simplified single dimension memory size and zone count to construct the Apm's topology.

func NewAppSearch

func NewAppSearch(params NewStateless) (*models.AppSearchPayload, error)

NewAppSearch creates a *models.AppSearchPayload from the parameters. It relies on a simplified single dimension memory size and zone count to construct the AppSearch's topology.

func NewElasticsearch

func NewElasticsearch(params NewElasticsearchParams) (*models.ElasticsearchPayload, error)

NewElasticsearch creates a *models.ElasticsearchPayload from the parameters. It relies on a simplified definition of the full API ElasticsearchPayload. See BuildElasticsearchTopology for more information on how the construction of ElasticsearchPayload works.

func NewEnterpriseSearch

func NewEnterpriseSearch(params NewStateless) (*models.EnterpriseSearchPayload, error)

NewEnterpriseSearch creates a *models.EnterpriseSearchPayload from the parameters. It relies on a simplified single dimension memory size and zone count to construct the EnterpriseSearch's topology.

func NewKibana

func NewKibana(params NewStateless) (*models.KibanaPayload, error)

NewKibana creates a *models.KibanaPayload from the parameters. It relies on a simplified single dimension memory size and zone count to construct the Kibana's topology.

func NewPayload

NewPayload creates the payload for a deployment // * Auto-discovers the latest Stack version if Version is not specified.

func ParseElasticsearchInput

func ParseElasticsearchInput(params ParseElasticsearchInputParams) (*models.ElasticsearchPayload, error)

ParseElasticsearchInput handles all but the API parameters as optional, providing a nicer API when it's used. The bulk of what it does is:

  • If a Payload is already specified, it returns it.
  • Tries to create an []ElasticsearchTopologyElement from a raw []string.
  • If the previous step returns an empty slice, it uses a default slice which might override the values when Size or ZoneCount are set in the params.

When all of those steps are done, it finally calls NewElasticsearch building the resulting ElasticsearchPayload.

func ResetElasticsearchPassword

ResetElasticsearchPassword resets an deployment's elasticsearch password and returns the Username and Password.

func Restore

func Restore(params RestoreParams) error

Restore upgrades a stateless deployment resource like APM, Kibana and App Search.

func Shutdown

func Shutdown(params ShutdownParams) error

Shutdown stops all the running instances for the specified resource kind ref ID on a Deployment. If no refID is specified, it tries to autodiscover it.

func Start

Start starts all instances belonging to a deployment resource kind.

func StartAllOrSpecified

StartAllOrSpecified starts all or defined instances belonging to a deployment resource.

func StartInstances

StartInstances starts defined instances belonging to a deployment resource.

func StartInstancesMaintenanceMode

func StartInstancesMaintenanceMode(params StartInstancesParams) (*models.DeploymentResourceCommandResponse, error)

StartInstancesMaintenanceMode starts maintenance mode of defined instances belonging to a deployment resource.

func StartMaintenanceMode

func StartMaintenanceMode(params StartParams) (*models.DeploymentResourceCommandResponse, error)

StartMaintenanceMode starts maintenance mode of all instances belonging to a deployment resource kind.

func StartMaintenanceModeAllOrSpecified

func StartMaintenanceModeAllOrSpecified(params StartInstancesParams) (*models.DeploymentResourceCommandResponse, error)

StartMaintenanceModeAllOrSpecified starts all or defined instances belonging to a deployment resource.

func Stop

Stop stops all instances belonging to a deployment resource kind.

func StopAllOrSpecified

StopAllOrSpecified stops all or defined instances belonging to a deployment resource.

func StopInstances

StopInstances stops defined instances belonging to a deployment resource.

func StopInstancesMaintenanceMode

func StopInstancesMaintenanceMode(params StopInstancesParams) (*models.DeploymentResourceCommandResponse, error)

StopInstancesMaintenanceMode stops maintenance mode of defined instances belonging to a deployment resource.

func StopMaintenanceMode

func StopMaintenanceMode(params StopParams) (*models.DeploymentResourceCommandResponse, error)

StopMaintenanceMode stops maintenance mode of all instances belonging to a deployment resource kind.

func StopMaintenanceModeAllOrSpecified

func StopMaintenanceModeAllOrSpecified(params StopInstancesParams) (*models.DeploymentResourceCommandResponse, error)

StopMaintenanceModeAllOrSpecified stops all or defined instances belonging to a deployment resource.

func UpgradeStateless

func UpgradeStateless(params Params) (*models.DeploymentResourceUpgradeResponse, error)

UpgradeStateless upgrades a stateless deployment resource like APM, Kibana and App Search.

Types

type BuildElasticsearchTopologyParams

type BuildElasticsearchTopologyParams struct {
	// Deployment Template ID from which the ClusterTopology comes from.
	TemplateID string

	// API-obtained slice of the Elasticsearch Deployment topology.
	ClusterTopology []*models.ElasticsearchClusterTopologyElement

	// User specified desired topology from which a new topology will be built.
	Topology []ElasticsearchTopologyElement
}

BuildElasticsearchTopologyParams is consumed by BuildElasticsearchTopology.

type CancelPlanParams

type CancelPlanParams struct {
	Params

	ForceDelete bool
}

CancelPlanParams is consumed by CancelPlan

type DeleteStatelessParams

type DeleteStatelessParams struct {
	Params
}

DeleteStatelessParams is consumed by Delete

func (*DeleteStatelessParams) Validate

func (params *DeleteStatelessParams) Validate() error

Validate ensures the parameters are usable by the consuming function.

type ElasticsearchTopologyElement

type ElasticsearchTopologyElement struct {
	// NodeType can be one of "data", "master" or "ml".
	NodeType string `json:"node_type"`

	// Number of zones to span the cluster on.
	ZoneCount int32 `json:"zone_count,omitempty"`

	// Memory size of the cluster node.
	Size int32 `json:"size"`
}

ElasticsearchTopologyElement is a single cluster topology element, meaning a number of instances (controlled by ZoneCount) for a single NodeType.

func NewElasticsearchTopology

func NewElasticsearchTopology(topology []string) ([]ElasticsearchTopologyElement, error)

NewElasticsearchTopology creates a []ElasticsearchTopologyElement from a slice of raw strings which are then unmarshaled into the desired slice type. If any of the topology elements is not usable, an error is returned.

func NewElasticsearchTopologyElement

func NewElasticsearchTopologyElement(size, zoneCount int32) ElasticsearchTopologyElement

NewElasticsearchTopologyElement creates a new topology element given a zone count and node size. Using DefaultTopologyElement as the blueprint.

func (*ElasticsearchTopologyElement) Validate

func (element *ElasticsearchTopologyElement) Validate() error

Validate ensures the parameters are usable by the consuming function.

type GetDeploymentInfoParams

type GetDeploymentInfoParams struct {
	*api.API
	DeploymentID string
}

GetDeploymentInfoParams is consumed by GetDeploymentInfo.

func (GetDeploymentInfoParams) Validate

func (params GetDeploymentInfoParams) Validate() error

Validate ensures the parameters are usable by the consuming function.

type GetDeploymentInfoResponse

type GetDeploymentInfoResponse struct {
	// RefID is the ElasticsearchRefID.
	RefID string

	// Deployment template which the Elasticsearch resource is using.
	DeploymentTemplate string
}

GetDeploymentInfoResponse is returned by GetDeploymentInfo.

func GetDeploymentInfo

func GetDeploymentInfo(params GetDeploymentInfoParams) (GetDeploymentInfoResponse, error)

GetDeploymentInfo obtains the Deployment's elasticsearch relevant info and packs it into GetDeploymentInfoResponse. It is convenient for actions which need to auto-discover information of their deployment.

type InstanceParams

type InstanceParams struct {
	Size      int32
	ZoneCount int32
	RefID     string
}

InstanceParams holds the common instance fields for a resource

type LatestStackVersionParams

type LatestStackVersionParams struct {
	*api.API

	// When specified, the consuming function will return that version.
	Version string

	// Region is required
	Region string

	// If spceified, it's the io.Writer where info messages are written to.
	Writer io.Writer
}

LatestStackVersionParams is consumed by LatestStackVersion.

func (LatestStackVersionParams) Validate

func (params LatestStackVersionParams) Validate() error

Validate ensures the parameters are usable by the consuming function.

type NewElasticsearchParams

type NewElasticsearchParams struct {
	// Required deployment template definition
	*models.DeploymentTemplateInfoV2

	// Optional region name. Defaults to
	Region string

	// Optional name. If not specified it defaults to the autogeneratd ID.
	Name string

	// Optional RefID for the deployment resource.
	RefID string

	// Required: Version is the Elasticsearch Version.
	Version string
	Plugins []string

	// Required Deployment Template ID.
	TemplateID string

	// Topology settings
	Topology []ElasticsearchTopologyElement
}

NewElasticsearchParams is consumed by NewElasticsearch.

func (*NewElasticsearchParams) Validate

func (params *NewElasticsearchParams) Validate() error

Validate ensures the parameters are usable by the consuming function.

type NewPayloadParams

type NewPayloadParams struct {
	*api.API

	// Optional deployment name
	Name string

	// Optional Elastic Stack version, Latest version will be used if empty.
	Version string

	// Required deployment template ID to use to create the deployment.
	DeploymentTemplateID string

	// Required region where the deployment will be created.
	Region string

	// Optionally enable an APM instance.
	ApmEnable bool

	// Optionally enable an AppSearch instance.
	AppsearchEnable bool

	// Optionally enable an Enterprise Search instance.
	EnterpriseSearchEnable bool

	// Optional io.Writer where notices will be written.
	Writer io.Writer

	// Optional Elasticsearch plug-ins to be enabled.
	Plugins []string

	// Optional Elasticsearch Topology Elements to compose a complex multi-
	// topology Elasticsearch cluster. Required when ElasticsearchInstance is
	// empty.
	TopologyElements []string

	// Optional ElasticsearchInstance template for single topology element
	// Elasticsearch clusters.
	ElasticsearchInstance InstanceParams

	// Required KibanaInstance template for the Kibana instance.
	KibanaInstance InstanceParams

	// Optional ApmInstance unless AppsearchEnable is set.
	ApmInstance InstanceParams

	// Optional AppsearchInstance unless AppsearchEnable is set.
	AppsearchInstance InstanceParams

	// Optional EnterpriseSearchInstance unless EnterpriseSearchEnable is set.
	EnterpriseSearchInstance InstanceParams
}

NewPayloadParams is consumed by NewPayload()

type NewStateless

type NewStateless struct {
	*api.API

	// Required deployment template definition
	*models.DeploymentTemplateInfoV2

	// Optional DeploymentID.
	DeploymentID string

	// Required region name.
	Region string

	// Optional ElasticsearchRefID.
	ElasticsearchRefID string

	// Optional name. If not specified it defaults to the autogenerated ID.
	Name string

	// Optional RefID for the stateless deployment resource.
	RefID string

	// Optional: Version is the stateless resource Version. If not set it'll
	// automatically be set to the Elasticsearch RefID version.
	Version string

	// Stateless deployment resource size.
	Size      int32
	ZoneCount int32

	// Optional Deployment Template ID.
	TemplateID string
}

NewStateless is consumed by NewKibana.

func (*NewStateless) Validate

func (params *NewStateless) Validate() error

Validate ensures the parameters are usable by the consuming function.

type Params

type Params struct {
	*api.API

	DeploymentID string
	Kind         string
	RefID        string
}

Params can be embedded in any structure which makes use of the deployment/resource API which always require the fields. Also provides RefID auto-discovery for the deployment resource kind if not specified.

func (*Params) Validate

func (params *Params) Validate() error

Validate ensures the parameters are usable by the consuming function.

type ParseElasticsearchInputParams

type ParseElasticsearchInputParams struct {
	*api.API
	NewElasticsearchParams

	Payload          *models.ElasticsearchPayload
	TopologyElements []string
	Size, ZoneCount  int32
	Writer           io.Writer
}

ParseElasticsearchInputParams is consumed by ParseElasticsearchInput.

func (*ParseElasticsearchInputParams) Validate

func (params *ParseElasticsearchInputParams) Validate() error

Validate ensures the parameters are usable by the consuming function.

type ResetElasticsearchPasswordParams

type ResetElasticsearchPasswordParams struct {
	// Required API instance.
	*api.API

	// Required deployment ID.
	ID string

	// Optional RefID. If not specified, it is autodiscovered.
	RefID string
}

ResetElasticsearchPasswordParams is consumed by ResetElasticsearchPassword.

func (ResetElasticsearchPasswordParams) Validate

func (params ResetElasticsearchPasswordParams) Validate() error

Validate ensures the parameters are usable by ResetElasticsearchPassword.

type RestoreParams

type RestoreParams struct {
	Params

	// Optional
	RestoreSnapshot bool
}

RestoreParams is consumed by Restore

type ShutdownParams

type ShutdownParams struct {
	Params

	// Optional Values
	// Skips taking a snapshot before shutting down the deployment resource.
	SkipSnapshot bool

	// Hides the resource. Hidden resources are not listed by default.
	Hide bool
}

ShutdownParams is consumed by Shutdown.

type StartInstancesParams

type StartInstancesParams struct {
	StartParams
	IgnoreMissing *bool
	InstanceIDs   []string
}

StartInstancesParams is consumed by StartInstances.

func (*StartInstancesParams) Validate

func (params *StartInstancesParams) Validate() error

Validate ensures the parameters are usable by StartInstances.

type StartParams

type StartParams struct {
	Params

	All bool
}

StartParams is consumed by start.

type StopInstancesParams

type StopInstancesParams struct {
	StopParams
	IgnoreMissing *bool
	InstanceIDs   []string
}

StopInstancesParams is consumed by StopInstances.

func (*StopInstancesParams) Validate

func (params *StopInstancesParams) Validate() error

Validate ensures the parameters are usable by StopInstances.

type StopParams

type StopParams struct {
	Params

	All bool
}

StopParams is consumed by Stop.

Jump to

Keyboard shortcuts

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