rl10

package
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIName is used by rsc to display the command line help.
	APIName = "RightScale RightLink10 API"
)
View Source
const APIVersion = "unversioned"

API Version

Variables

View Source
var GenMetadata = map[string]*metadata.Resource{
	"DebugCookbookPath": &metadata.Resource{
		Name:        "DebugCookbookPath",
		Description: `Manipulate debug cookbook directory location`,
		Actions: []*metadata.Action{
			&metadata.Action{
				Name:        "show",
				Description: `Retrieve debug cookbook directory location`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/debug/cookbook",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/debug/cookbook`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},

			&metadata.Action{
				Name:        "update",
				Description: `Set debug cookbook directory location`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "PUT",
						Pattern:    "/rll/debug/cookbook",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/debug/cookbook`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "path",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "path",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
			},

			&metadata.Action{
				Name:        "delete",
				Description: `Remove debug cookbook directory location`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "DELETE",
						Pattern:    "/rll/debug/cookbook",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/debug/cookbook`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},
		},
	},
	"Env": &metadata.Resource{
		Name:        "Env",
		Description: `Manipulate global script environment variables`,
		Actions: []*metadata.Action{
			&metadata.Action{
				Name:        "index",
				Description: `Retrieve all environment variables`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/env",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/env`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},

			&metadata.Action{
				Name:        "show",
				Description: `Retrieve environment variable value`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/env/%s",
						Variables:  []string{"name"},
						Regexp:     regexp.MustCompile(`/rll/env/([^/]+)`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},

			&metadata.Action{
				Name:        "update",
				Description: `Set environment variable value`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "PUT",
						Pattern:    "/rll/env/%s",
						Variables:  []string{"name"},
						Regexp:     regexp.MustCompile(`/rll/env/([^/]+)`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "payload",
						Description: ``,
						Type:        "string",
						Location:    metadata.PayloadParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
				Payload: "string",
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "payload",
						Description: ``,
						Type:        "string",
						Location:    metadata.PayloadParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
			},

			&metadata.Action{
				Name:        "delete",
				Description: `Delete environment variable`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "DELETE",
						Pattern:    "/rll/env/%s",
						Variables:  []string{"name"},
						Regexp:     regexp.MustCompile(`/rll/env/([^/]+)`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},
		},
	},
	"Proc": &metadata.Resource{
		Name:        "Proc",
		Description: `List of process variables, such as version, identity, and protocol_version`,
		Actions: []*metadata.Action{
			&metadata.Action{
				Name:        "index",
				Description: `List all process variables`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/proc",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/proc`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},

			&metadata.Action{
				Name:        "show",
				Description: `Retrieve process variable value`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/proc/%s",
						Variables:  []string{"name"},
						Regexp:     regexp.MustCompile(`/rll/proc/([^/]+)`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},
		},
	},
	"Rl10": &metadata.Resource{
		Name:        "Rl10",
		Description: `Miscellaneous RightLink 10 local requests`,
		Actions: []*metadata.Action{
			&metadata.Action{
				Name:        "upgrade",
				Description: `Relaunch the RightLink process using a specified binary`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "POST",
						Pattern:    "/rll/upgrade",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/upgrade`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "exec",
						Description: `Absolute path to binary`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "exec",
						Description: `Absolute path to binary`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
			},

			&metadata.Action{
				Name:        "run_recipe",
				Description: `Run git-based scripts (as recipes) synchronously`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "POST",
						Pattern:    "/rll/run/recipe",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/run/recipe`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "arguments",
						Description: `Script argument values`,
						Type:        "map",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "json",
						Description: `JSON hash of "name": "value" pairs`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "recipe",
						Description: `Name of recipe`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "arguments",
						Description: `Script argument values`,
						Type:        "map[string]interface{}",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "json",
						Description: `JSON hash of "name": "value" pairs`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "recipe",
						Description: `Name of recipe`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
			},

			&metadata.Action{
				Name:        "run_right_script",
				Description: `Run RightScripts synchronously`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "POST",
						Pattern:    "/rll/run/right_script",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/run/right_script`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "arguments",
						Description: `Script argument values`,
						Type:        "map",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "right_script",
						Description: `Name of script`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "right_script_id",
						Description: `Id of script`,
						Type:        "int",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "arguments",
						Description: `Script argument values`,
						Type:        "map[string]interface{}",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "right_script",
						Description: `Name of script`,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "right_script_id",
						Description: `Id of script`,
						Type:        "int",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
				},
			},
		},
	},
	"TSS": &metadata.Resource{
		Name:        "TSS",
		Description: `Manipulate the TSS proxy (this is deprecated, please use the /rll/tss/control resource)`,
		Actions: []*metadata.Action{
			&metadata.Action{
				Name:        "get_hostname",
				Description: `Get the TSS hostname to proxy (deprecated, RL10 knows the hostname)`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/tss/hostname",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/tss/hostname`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},

			&metadata.Action{
				Name:        "put_hostname",
				Description: `Set the TSS hostname to proxy (deprecated, RL10 knows the hostname)`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "PUT",
						Pattern:    "/rll/tss/hostname",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/tss/hostname`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "hostname",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "hostname",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   true,
						NonBlank:    false,
					},
				},
			},
		},
	},
	"TSSControl": &metadata.Resource{
		Name:        "TSSControl",
		Description: `Manipulate monitoring (TSS) settings`,
		Actions: []*metadata.Action{
			&metadata.Action{
				Name:        "show",
				Description: `Show monitoring features`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "GET",
						Pattern:    "/rll/tss/control",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/tss/control`),
					},
				},
				CommandFlags: []*metadata.ActionParam{},
				APIParams:    []*metadata.ActionParam{},
			},

			&metadata.Action{
				Name:        "update",
				Description: `Enable/disable monitoring features`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "PUT",
						Pattern:    "/rll/tss/control",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/tss/control`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "enable_monitoring",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
						ValidValues: []string{"false", "true", "none", "util", "extra", "all"},
					},
					&metadata.ActionParam{
						Name:        "tss_id",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "enable_monitoring",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
						ValidValues: []string{"false", "true", "none", "util", "extra", "all"},
					},
					&metadata.ActionParam{
						Name:        "tss_id",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
				},
			},

			&metadata.Action{
				Name:        "put_control",
				Description: `Control the TSS monitoring (deprecated, use the /rll/tss/control resource)`,
				PathPatterns: []*metadata.PathPattern{
					&metadata.PathPattern{
						HTTPMethod: "PUT",
						Pattern:    "/rll/tss/control",
						Variables:  []string{},
						Regexp:     regexp.MustCompile(`/rll/tss/control`),
					},
				},
				CommandFlags: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "enable_monitoring",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "tss_id",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
				},
				APIParams: []*metadata.ActionParam{
					&metadata.ActionParam{
						Name:        "enable_monitoring",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
					&metadata.ActionParam{
						Name:        "tss_id",
						Description: ``,
						Type:        "string",
						Location:    metadata.QueryParam,
						Mandatory:   false,
						NonBlank:    false,
					},
				},
			},
		},
	},
}

Consists of a map of resource name to resource metadata.

Functions

func RegisterCommands

func RegisterCommands(registrar rsapi.APICommandRegistrar)

RegisterCommands registers all the commands with the kinpin application.

Types

type API

type API struct {
	*rsapi.API
}

API is the RightLink 10 client.

func FromCommandLine

func FromCommandLine(cmdLine *cmd.CommandLine) (*API, error)

FromCommandLine builds the API client from the command line.

func New

func New(host string, auth rsapi.Authenticator) *API

New returns a client that uses RL10 authentication. accountId, host and auth arguments are not used. If no HTTP client is specified then the default client is used.

func NewRL10

func NewRL10() (*API, error)

NewRL10 returns a RL10 client that uses the information stored in /var/run/rightlink/secret to do auth and configure the host. The client behaves identically to the one returned by New in all other aspects.

func (*API) BuildRequest

func (a *API) BuildRequest(resource, action, href string, params rsapi.APIParams) (*http.Request, error)

BuildRequest builds a HTTP request from a resource name and href and an action name and parameters. It is intended for generic clients that need to consume APIs in a generic maner. The method builds an HTTP request that can be fed to PerformRequest.

func (*API) DebugCookbookPathLocator

func (api *API) DebugCookbookPathLocator(href string) *DebugCookbookPathLocator

DebugCookbookPathLocator builds a locator from the given href.

func (*API) EnvLocator

func (api *API) EnvLocator(href string) *EnvLocator

EnvLocator builds a locator from the given href.

func (*API) ProcLocator

func (api *API) ProcLocator(href string) *ProcLocator

ProcLocator builds a locator from the given href.

func (*API) Rl10Locator

func (api *API) Rl10Locator(href string) *Rl10Locator

Rl10Locator builds a locator from the given href.

func (*API) RunCommand

func (a *API) RunCommand(cmd string) (*http.Response, error)

RunCommand parses and runs the command with the given name.

func (*API) ShowAPIActions

func (a *API) ShowAPIActions(cmd string) error

ShowAPIActions displays the command hrefs.

func (*API) ShowCommandHelp

func (a *API) ShowCommandHelp(cmd string) error

ShowCommandHelp displays the command help.

func (*API) TSSControlLocator

func (api *API) TSSControlLocator(href string) *TSSControlLocator

TSSControlLocator builds a locator from the given href.

func (*API) TSSLocator

func (api *API) TSSLocator(href string) *TSSLocator

TSSLocator builds a locator from the given href.

type DebugCookbookPath

type DebugCookbookPath struct {
}

Manipulate debug cookbook directory location

type DebugCookbookPathLocator

type DebugCookbookPathLocator struct {
	Href
	// contains filtered or unexported fields
}

DebugCookbookPathLocator exposes the DebugCookbookPath resource actions.

func (*DebugCookbookPathLocator) Delete

func (loc *DebugCookbookPathLocator) Delete() error

DELETE /rll/debug/cookbook

Remove debug cookbook directory location

func (*DebugCookbookPathLocator) Show

func (loc *DebugCookbookPathLocator) Show() (string, error)

GET /rll/debug/cookbook

Retrieve debug cookbook directory location

func (*DebugCookbookPathLocator) Update

func (loc *DebugCookbookPathLocator) Update(path string) (string, error)

PUT /rll/debug/cookbook

Set debug cookbook directory location

type Env

type Env struct {
}

Manipulate global script environment variables

type EnvLocator

type EnvLocator struct {
	Href
	// contains filtered or unexported fields
}

EnvLocator exposes the Env resource actions.

func (*EnvLocator) Delete

func (loc *EnvLocator) Delete() error

DELETE /rll/env/:name

Delete environment variable

func (*EnvLocator) Index

func (loc *EnvLocator) Index() (string, error)

GET /rll/env

Retrieve all environment variables

func (*EnvLocator) Show

func (loc *EnvLocator) Show() (string, error)

GET /rll/env/:name

Retrieve environment variable value

func (*EnvLocator) Update

func (loc *EnvLocator) Update(payload string) (string, error)

PUT /rll/env/:name

Set environment variable value

type Href

type Href string

An Href contains the relative path to a resource or resource collection, e.g. "/api/servers/123" or "/api/servers".

func (*Href) ActionPath

func (r *Href) ActionPath(rName, aName string) (*metadata.ActionPath, error)

ActionPath computes the path to the given resource action. For example given the href "/api/servers/123" calling ActionPath with resource "servers" and action "clone" returns the path "/api/servers/123/clone" and verb POST. The algorithm consists of extracting the variables from the href by looking up a matching pattern from the resource metadata. The variables are then substituted in the action path. If there are more than one pattern that match the href then the algorithm picks the one that can substitute the most variables.

type Proc

type Proc struct {
}

List of process variables, such as version, identity, and protocol_version

type ProcLocator

type ProcLocator struct {
	Href
	// contains filtered or unexported fields
}

ProcLocator exposes the Proc resource actions.

func (*ProcLocator) Index

func (loc *ProcLocator) Index() (string, error)

GET /rll/proc

List all process variables

func (*ProcLocator) Show

func (loc *ProcLocator) Show() (string, error)

GET /rll/proc/:name

Retrieve process variable value

type Rl10

type Rl10 struct {
}

Miscellaneous RightLink 10 local requests

type Rl10Locator

type Rl10Locator struct {
	Href
	// contains filtered or unexported fields
}

Rl10Locator exposes the Rl10 resource actions.

func (*Rl10Locator) RunRecipe

func (loc *Rl10Locator) RunRecipe(recipe string, options rsapi.APIParams) (string, error)

POST /rll/run/recipe

Run git-based scripts (as recipes) synchronously

func (*Rl10Locator) RunRightScript

func (loc *Rl10Locator) RunRightScript(options rsapi.APIParams) (string, error)

POST /rll/run/right_script

Run RightScripts synchronously

func (*Rl10Locator) Upgrade

func (loc *Rl10Locator) Upgrade(exec string) (string, error)

POST /rll/upgrade

Relaunch the RightLink process using a specified binary

type TSS

type TSS struct {
}

Manipulate the TSS proxy (this is deprecated, please use the /rll/tss/control resource)

type TSSControl

type TSSControl struct {
}

Manipulate monitoring (TSS) settings

type TSSControlLocator

type TSSControlLocator struct {
	Href
	// contains filtered or unexported fields
}

TSSControlLocator exposes the TSSControl resource actions.

func (*TSSControlLocator) PutControl

func (loc *TSSControlLocator) PutControl(options rsapi.APIParams) (string, error)

PUT /rll/tss/control

Control the TSS monitoring (deprecated, use the /rll/tss/control resource)

func (*TSSControlLocator) Show

func (loc *TSSControlLocator) Show() (string, error)

GET /rll/tss/control

Show monitoring features

func (*TSSControlLocator) Update

func (loc *TSSControlLocator) Update(options rsapi.APIParams) (string, error)

PUT /rll/tss/control

Enable/disable monitoring features

type TSSLocator

type TSSLocator struct {
	Href
	// contains filtered or unexported fields
}

TSSLocator exposes the TSS resource actions.

func (*TSSLocator) GetHostname

func (loc *TSSLocator) GetHostname() (string, error)

GET /rll/tss/hostname

Get the TSS hostname to proxy (deprecated, RL10 knows the hostname)

func (*TSSLocator) PutHostname

func (loc *TSSLocator) PutHostname(hostname string) (string, error)

PUT /rll/tss/hostname

Set the TSS hostname to proxy (deprecated, RL10 knows the hostname)

Jump to

Keyboard shortcuts

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