api

package
v0.0.0-...-7b2e207 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CocoonStatusCreated indicates a created cocoon
	CocoonStatusCreated = "created"

	// CocoonStatusStarted indicates a started cocoon cocoon
	CocoonStatusStarted = "started"

	// CocoonStatusRunning indicates a running cocoon code
	CocoonStatusRunning = "running"

	// CocoonStatusBuilding indicates a cocoon in build phase
	CocoonStatusBuilding = "building"

	// CocoonStatusStopped indicates a stopped cocoon
	CocoonStatusStopped = "stopped"

	// CocoonStatusDead indicates a dead cocoon
	CocoonStatusDead = "dead"
)
View Source
var ExcludeMethodsFromAuth = []string{
	"/proto_api.API/CreateIdentity",
	"/proto_api.API/Login",
	"/proto_api.API/GetIdentity",
}

ExcludeMethodsFromAuth includes full method names of grpc method to exclude from authentication

Functions

func SetLogLevel

func SetLogLevel(l logging.Level)

SetLogLevel sets the log level of the logger

func ValidateCocoon

func ValidateCocoon(c *types.Cocoon) error

ValidateCocoon validates a cocoon to be created

func ValidateEnvVariables

func ValidateEnvVariables(envs map[string]string) []error

ValidateEnvVariables validates the keys of a map containing environment variable data

func ValidateFirewallRules

func ValidateFirewallRules(firewall interface{}) ([]types.FirewallRule, []error)

ValidateFirewallRules parses and validates the content of a firewall ruleset. It expects a json string or a slice of map[string]strings. It will return a slice of FirewallRule values that represents valid firewall rules. Destination addresses are not resolved.

func ValidateIdentity

func ValidateIdentity(i *types.Identity) error

ValidateIdentity checks whether an identity field values are valid.

func ValidateRelease

func ValidateRelease(r *types.Release) error

ValidateRelease checks whether a release field values are valid.

Types

type API

type API struct {
	EventEmitter *emission.Emitter
	// contains filtered or unexported fields
}

API defines a GRPC api for performing various cocoon operations such as cocoon orchestration, resource allocation etc

func NewAPI

func NewAPI() (*API, error)

NewAPI creates a new GRPCAPI object

func (*API) AddSignatories

func (api *API) AddSignatories(ctx context.Context, req *proto_api.AddSignatoriesRequest) (*proto_api.Response, error)

AddSignatories adds one ore more signatories to a cocoon

func (*API) AddVote

func (api *API) AddVote(ctx context.Context, req *proto_api.AddVoteRequest) (*proto_api.Response, error)

AddVote adds a vote to a release where the logged in user is a signatory

func (*API) CreateCocoon

func (api *API) CreateCocoon(ctx context.Context, req *proto_api.ContractRequest) (*proto_api.Response, error)

CreateCocoon creates a new cocoon and initial release. The new cocoon is also added to the identity's list of cocoons

func (*API) CreateIdentity

func (api *API) CreateIdentity(ctx context.Context, req *proto_api.CreateIdentityRequest) (*proto_api.Response, error)

CreateIdentity creates a new identity. It returns error if identity already exists.

func (*API) DeleteSessions

func (api *API) DeleteSessions(ctx context.Context, req *proto_api.DeleteSessionsRequest) (*proto_api.Response, error)

DeleteSessions deletes all identity sessions or the sessions specified in IDs

func (*API) Deploy

func (api *API) Deploy(ctx context.Context, req *proto_api.DeployRequest) (*proto_api.Response, error)

Deploy instructs the scheduler to start a cocoon. The latest release is fetched and validated to ensure it has enough votes. If the required votes are available, the cocoon is updated with the release value and also executed.

func (*API) GetCocoon

func (api *API) GetCocoon(ctx context.Context, req *proto_api.GetCocoonRequest) (*proto_api.Response, error)

GetCocoon fetches a cocoon

func (*API) GetCocoonStatus

func (api *API) GetCocoonStatus(cocoonID string) (string, error)

GetCocoonStatus fetches the cocoon status.It queries the scheduler discovery service to find out the current service status for the cocoon. If the scheduler discovery service does not say the cocoon is running, we check with the scheduler to know if the cocoon code was deployed successfully.

func (*API) GetIdentity

func (api *API) GetIdentity(ctx context.Context, req *proto_api.GetIdentityRequest) (*proto_api.Response, error)

GetIdentity fetches an identity by email or id. If Email field is set in the request, it will find the identity by the email (converts the email to an identity key format) or if ID field is set, it finds the identity by the id directly.

func (*API) GetLogs

func (api *API) GetLogs(ctx context.Context, req *proto_api.GetLogsRequest) (*proto_api.Response, error)

GetLogs fetches logs

func (*API) GetRelease

func (api *API) GetRelease(ctx context.Context, req *proto_api.GetReleaseRequest) (*proto_api.Response, error)

GetRelease returns a release

func (*API) Interceptors

func (api *API) Interceptors() grpc.UnaryServerInterceptor

Interceptors returns the API interceptors

func (*API) Login

func (api *API) Login(ctx context.Context, req *proto_api.LoginRequest) (*proto_api.Response, error)

Login authenticates a user and returns a JWT token

func (*API) RemoveSignatories

func (api *API) RemoveSignatories(ctx context.Context, req *proto_api.RemoveSignatoriesRequest) (*proto_api.Response, error)

RemoveSignatories removes one or more signatories

func (*API) Start

func (api *API) Start(addr string, endedCh chan bool)

Start starts the server

func (*API) Stop

func (api *API) Stop()

Stop stops the api and returns an exit code.

func (*API) StopCocoon

func (api *API) StopCocoon(ctx context.Context, req *proto_api.StopCocoonRequest) (*proto_api.Response, error)

StopCocoon stops a running cocoon and sets its status to `stopped`

func (*API) UpdateCocoon

func (api *API) UpdateCocoon(ctx context.Context, req *proto_api.ContractRequest) (*proto_api.Response, error)

UpdateCocoon updates a cocoon and optionally creates a new release. A new release is created when Release related fields are changed.

type StackDriverLog

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

StackDriverLog implements LogProvider interface to allow the retrieval of logs from GCP stack driver.

func (*StackDriverLog) Get

func (s *StackDriverLog) Get(ctx context.Context, logName string, numEntries int, source string) ([]types.LogMessage, error)

Get returns a slice of log messages. It will return the a maximum of recent numEntries entries. If source is not set, both stderr and stdout errors will be returned

func (*StackDriverLog) Init

func (s *StackDriverLog) Init(config map[string]interface{}) error

Init initializes the instance

Directories

Path Synopsis
Package proto_api is a generated protocol buffer package.
Package proto_api is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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