whisk

package
v0.0.0-...-be237bf Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthRequired = true
	AuthOptional = false
)
View Source
const APPLICATION_ERR bool = true
View Source
const DISPLAY_MSG bool = true
View Source
const DISPLAY_USAGE bool = true
View Source
const EXITCODE_ERR_GENERAL int = 1
View Source
const EXITCODE_ERR_HTTP_RESP int = 4
View Source
const EXITCODE_ERR_NETWORK int = 3
View Source
const EXITCODE_ERR_USAGE int = 2
View Source
const MaxNameLen int = 25
View Source
const NO_DISPLAY_MSG bool = false
View Source
const NO_DISPLAY_USAGE bool = false
View Source
const NO_MSG_DISPLAYED bool = false

Variables

This section is empty.

Functions

func Debug

func Debug(dl DebugLevel, msgFormat string, args ...interface{})

Function for tracing debug level messages to stdout

Output format:
[file-or-function-name]:line-#:[DebugLevel] The formated message without any appended \n

func IsHttpRespSuccess

func IsHttpRespSuccess(r *http.Response) bool

func IsVerbose

func IsVerbose() bool

func SetDebug

func SetDebug(b bool)

func SetVerbose

func SetVerbose(b bool)

func Verbose

func Verbose(msgFormat string, args ...interface{})

Function for tracing debug level messages to stdout

Output format:
[file-or-function-name]:line-#:[DebugLevel] The formated message without any appended \n

Types

type Action

type Action struct {
	Namespace   string           `json:"namespace,omitempty"`
	Name        string           `json:"name,omitempty"`
	Version     string           `json:"version,omitempty"`
	Publish     bool             `json:"publish"`
	Exec        *Exec            `json:"exec,omitempty"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
	Limits      *Limits          `json:"limits,omitempty"`
}

type ActionListOptions

type ActionListOptions struct {
	Limit int  `url:"limit"`
	Skip  int  `url:"skip"`
	Docs  bool `url:"docs,omitempty"`
}

type ActionSequence

type ActionSequence []KeyValues

type ActionService

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

func (*ActionService) Delete

func (s *ActionService) Delete(actionName string) (*http.Response, error)

func (*ActionService) Get

func (s *ActionService) Get(actionName string) (*Action, *http.Response, error)

func (*ActionService) Insert

func (s *ActionService) Insert(action *Action, sharedSet bool, overwrite bool) (*Action, *http.Response, error)

func (*ActionService) Invoke

func (s *ActionService) Invoke(actionName string, payload *json.RawMessage, blocking bool) (*Activation, *http.Response, error)

func (*ActionService) List

func (s *ActionService) List(packageName string, options *ActionListOptions) ([]Action, *http.Response, error)

type Activation

type Activation struct {
	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name,omitempty"`
	Version   string `json:"version,omitempty"`
	Publish   bool   `json:"publish,omitempty"`

	Subject      string `json:"subject,omitempty"`
	ActivationID string `json:"activationId,omitempty"`
	Cause        string `json:"cause,omitempty"`
	Start        int64  `json:"start,omitempty"` // When action started (in milliseconds since January 1, 1970 UTC)
	End          int64  `json:"end"`             // Since a 0 is a valid value from server, don't omit
	Response     `json:"response,omitempty"`
	Logs         []string         `json:"logs,omitempty"`
	Annotations  *json.RawMessage `json:"annotations,omitempty"`
}

type ActivationListOptions

type ActivationListOptions struct {
	Name  string `url:"name,omitempty"`
	Limit int    `url:"limit"`
	Skip  int    `url:"skip"`
	Since int64  `url:"since,omitempty"`
	Upto  int64  `url:"upto,omitempty"`
	Docs  bool   `url:"docs,omitempty"`
}

type ActivationService

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

func (*ActivationService) Get

func (s *ActivationService) Get(activationID string) (*Activation, *http.Response, error)

func (*ActivationService) List

func (*ActivationService) Logs

func (s *ActivationService) Logs(activationID string) (*Activation, *http.Response, error)

func (*ActivationService) Result

func (s *ActivationService) Result(activationID string) (*Response, *http.Response, error)

type Annotations

type Annotations []map[string]interface{}

type Binding

type Binding struct {
	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name,omitempty"`
}

type BindingPackage

type BindingPackage struct {
	Namespace   string           `json:"-"`
	Name        string           `json:"-"`
	Version     string           `json:"version,omitempty"`
	Publish     bool             `json:"publish"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
	Binding     `json:"binding"`
}

Use this struct when creating a binding Publish is NOT optional; Binding is a namespace/name object, not a bool

func (*BindingPackage) GetName

func (p *BindingPackage) GetName() string

type BindingUpdates

type BindingUpdates struct {
	//Added   []Binding `json:"added,omitempty"`
	//Updated []Binding `json:"updated,omitempty"`
	//Deleted []Binding `json:"deleted,omitempty"`
	Added   []string `json:"added,omitempty"`
	Updated []string `json:"updated,omitempty"`
	Deleted []string `json:"deleted,omitempty"`
}

type Client

type Client struct {
	*Config
	Transport *http.Transport

	Sdks        *SdkService
	Triggers    *TriggerService
	Actions     *ActionService
	Rules       *RuleService
	Activations *ActivationService
	Packages    *PackageService
	Namespaces  *NamespaceService
	Info        *InfoService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, config *Config) (*Client, error)

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.

func (*Client) NewRequest

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

func (*Client) NewRequestUrl

func (c *Client) NewRequestUrl(method string, urlRelResource *url.URL, body interface{}) (*http.Request, error)

Create a HTTP request object using URL stored in url.URL object Arguments:

method         - HTTP verb (i.e. "GET", "PUT", etc)
urlRelResource - *url.URL structure representing the relative resource URL, including query params
body           - optional. Object whose contents will be JSON encoded and placed in HTTP request body

type Config

type Config struct {
	Namespace string // NOTE :: Default is "_"
	AuthToken string
	Host      string
	BaseURL   *url.URL // NOTE :: Default is "openwhisk.ng.bluemix.net"
	Version   string
	Verbose   bool
	Debug     bool // For detailed tracing
	Insecure  bool
}

type DebugLevel

type DebugLevel string
const (
	DbgInfo  DebugLevel = "Inf"
	DbgWarn  DebugLevel = "Wrn"
	DbgError DebugLevel = "Err"
	DbgFatal DebugLevel = "Ftl"
)

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	ErrMsg   string         `json:"error"` // error message string
	Code     int64          `json:"code"`  // validation error code
}

For containing the server response body when an error message is returned Here's an example error response body with HTTP status code == 400

{
    "error": "namespace contains invalid characters",
    "code": 1422870
}

func (ErrorResponse) Error

func (r ErrorResponse) Error() string

type Exec

type Exec struct {
	Kind       string   `json:"kind,omitempty"`
	Code       string   `json:"code"`
	Image      string   `json:"image,omitempty"`
	Init       string   `json:"init,omitempty"`
	Jar        string   `json:"jar,omitempty"`
	Main       string   `json:"main,omitempty"`
	Components []string `json:"components,omitempty"` // List of fully qualified actions
}

type Info

type Info struct {
	Whisk   string `json:"whisk,omitempty"`
	Version string `json:"version,omitempty"`
	Build   string `json:"build,omitempty"`
	BuildNo string `json:"buildno,omitempty"`
}

type InfoService

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

func (*InfoService) Get

func (s *InfoService) Get() (*Info, *http.Response, error)

type KeyValue

type KeyValue struct {
	Key   string      `json:"key,omitempty"`
	Value interface{} `json:"value"` // Whisk permits empty values, do not add 'omitempty'
}

type KeyValues

type KeyValues struct {
	Key    string   `json:"key,omitempty"`
	Values []string `json:"value,omitempty"`
}

type Limits

type Limits struct {
	Timeout *int `json:"timeout,omitempty"`
	Memory  *int `json:"memory,omitempty"`
	Logsize *int `json:"logs,omitempty"`
}

type Log

type Log struct {
	Log    string `json:"log,omitempty"`
	Stream string `json:"stream,omitempty"`
	Time   string `json:"time,omitempty"`
}

MWD - This structure may no longer be needed as the log format is now a string and not JSON

type Namespace

type Namespace struct {
	Name     string `json:"name"`
	Contents struct {
		Actions  []Action            `json:"actions"`
		Packages []Package           `json:"packages"`
		Triggers []TriggerFromServer `json:"triggers"`
		Rules    []Rule              `json:"rules"`
	} `json:"contents,omitempty"`
}

type NamespaceService

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

func (*NamespaceService) Get

func (s *NamespaceService) Get(nsName string) (*Namespace, *http.Response, error)

func (*NamespaceService) List

func (s *NamespaceService) List() ([]Namespace, *http.Response, error)

get a list of available namespaces

type Package

type Package struct {
	Namespace   string           `json:"namespace,omitempty"`
	Name        string           `json:"name,omitempty"`
	Version     string           `json:"version,omitempty"`
	Publish     bool             `json:"publish"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
	Binding     `json:"binding,omitempty"`
	Actions     []Action `json:"actions,omitempty"`
	Feeds       []Action `json:"feeds,omitempty"`
}

Use this struct to represent the package/binding sent from the Whisk server Binding is a bool ???MWD20160602 now seeing Binding as a struct???

func (*Package) GetName

func (p *Package) GetName() string

type PackageInterface

type PackageInterface interface {
	GetName() string
}

type PackageListOptions

type PackageListOptions struct {
	Public bool `url:"public,omitempty"`
	Limit  int  `url:"limit"`
	Skip   int  `url:"skip"`
	Since  int  `url:"since,omitempty"`
	Docs   bool `url:"docs,omitempty"`
}

type PackageService

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

func (*PackageService) Delete

func (s *PackageService) Delete(packageName string) (*http.Response, error)

func (*PackageService) Get

func (s *PackageService) Get(packageName string) (*Package, *http.Response, error)

func (*PackageService) Insert

func (s *PackageService) Insert(x_package PackageInterface, overwrite bool) (*Package, *http.Response, error)

func (*PackageService) List

func (s *PackageService) List(options *PackageListOptions) ([]Package, *http.Response, error)

func (*PackageService) Refresh

func (s *PackageService) Refresh() (*BindingUpdates, *http.Response, error)

type Parameters

type Parameters *json.RawMessage

type Parameters []KeyValue

type Response

type Response struct {
	Status     string `json:"status,omitempty"`
	StatusCode int    `json:"statusCode,omitempty"`
	Success    bool   `json:"success"`
	Result     `json:"result,omitempty"`
}

type Result

type Result map[string]interface{}

type Rule

type Rule struct {
	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name,omitempty"`
	Version   string `json:"version,omitempty"`
	Publish   bool   `json:"publish,omitempty"`

	Status  string `json:"status"`
	Trigger string `json:"trigger"`
	Action  string `json:"action"`
}

type RuleListOptions

type RuleListOptions struct {
	Limit int  `url:"limit"`
	Skip  int  `url:"skip"`
	Docs  bool `url:"docs,omitempty"`
}

type RuleService

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

func (*RuleService) Delete

func (s *RuleService) Delete(ruleName string) (*http.Response, error)

func (*RuleService) Get

func (s *RuleService) Get(ruleName string) (*Rule, *http.Response, error)

func (*RuleService) Insert

func (s *RuleService) Insert(rule *Rule, overwrite bool) (*Rule, *http.Response, error)

func (*RuleService) List

func (s *RuleService) List(options *RuleListOptions) ([]Rule, *http.Response, error)

func (*RuleService) SetState

func (s *RuleService) SetState(ruleName string, state string) (*Rule, *http.Response, error)

type Sdk

type Sdk struct {
}

Structure for SDK request responses

type SdkRequest

type SdkRequest struct {
}

type SdkService

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

func (*SdkService) Install

func (s *SdkService) Install(relFileUrl string) (*http.Response, error)

Install artifact {component = docker || swift || iOS}

type SentActionNoPublish

type SentActionNoPublish struct {
	Namespace   string           `json:"-"`
	Version     string           `json:"-"`
	Publish     bool             `json:"publish,omitempty"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
	Exec        *Exec            `json:"exec,omitempty"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Limits      *Limits          `json:"limits,omitempty"`
	Error       string           `json:"error,omitempty"`
	Code        int              `json:"code,omitempty"`
}

type SentActionPublish

type SentActionPublish struct {
	Namespace   string           `json:"-"`
	Version     string           `json:"-"`
	Publish     bool             `json:"publish"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
	Exec        *Exec            `json:"exec,omitempty"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Limits      *Limits          `json:"limits,omitempty"`
	Error       string           `json:"error,omitempty"`
	Code        int              `json:"code,omitempty"`
}

type SentPackageNoPublish

type SentPackageNoPublish struct {
	Namespace   string           `json:"-"`
	Name        string           `json:"-"`
	Version     string           `json:"version,omitempty"`
	Publish     bool             `json:"publish,omitempty"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
}

Use this struct to update a package/binding with no change to the Publish setting

func (*SentPackageNoPublish) GetName

func (p *SentPackageNoPublish) GetName() string

type SentPackagePublish

type SentPackagePublish struct {
	Namespace   string           `json:"-"`
	Name        string           `json:"-"`
	Version     string           `json:"version,omitempty"`
	Publish     bool             `json:"publish"`
	Annotations *json.RawMessage `json:"annotations,omitempty"`
	Parameters  *json.RawMessage `json:"parameters,omitempty"`
}

Use this struct to create/update a package/binding with the Publish setting

func (*SentPackagePublish) GetName

func (p *SentPackagePublish) GetName() string

type Trigger

type Trigger struct {
	Namespace    string           `json:"namespace,omitempty"`
	Name         string           `json:"-"`
	Version      string           `json:"version,omitempty"`
	Publish      bool             `json:"publish,omitempty"`
	ActivationId string           `json:"activationId,omitempty"`
	Annotations  *json.RawMessage `json:"annotations,omitempty"`
	Parameters   *json.RawMessage `json:"parameters,omitempty"`
}

type TriggerFromServer

type TriggerFromServer struct {
	Namespace    string           `json:"namespace"`
	Name         string           `json:"name"`
	Version      string           `json:"version"`
	Publish      bool             `json:"publish"`
	ActivationId string           `json:"activationId,omitempty"`
	Annotations  *json.RawMessage `json:"annotations"`
	Parameters   *json.RawMessage `json:"parameters"`
	Limits       `json:"limits"`
}

type TriggerListOptions

type TriggerListOptions struct {
	Limit int  `url:"limit"`
	Skip  int  `url:"skip"`
	Docs  bool `url:"docs,omitempty"`
}

type TriggerService

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

func (*TriggerService) Delete

func (s *TriggerService) Delete(triggerName string) (*TriggerFromServer, *http.Response, error)

func (*TriggerService) Fire

func (s *TriggerService) Fire(triggerName string, payload *json.RawMessage) (*TriggerFromServer, *http.Response, error)

func (*TriggerService) Get

func (s *TriggerService) Get(triggerName string) (*TriggerFromServer, *http.Response, error)

func (*TriggerService) Insert

func (s *TriggerService) Insert(trigger *Trigger, overwrite bool) (*TriggerFromServer, *http.Response, error)

func (*TriggerService) List

type WhiskErrorMessage

type WhiskErrorMessage struct {
	Error *string `json:"error"`
}

type WhiskErrorResponse

type WhiskErrorResponse struct {
	Response WhiskErrorResult `json:"response"`
}

type WhiskErrorResult

type WhiskErrorResult struct {
	Status  string            `json:"status"`
	Success bool              `json:"success"`
	Result  WhiskErrorMessage `json:"result"`
}

type WskError

type WskError struct {
	RootErr          error // Parent error
	ExitCode         int   // Error code to be returned to the OS
	DisplayMsg       bool  // When true, the error message should be displayed to console
	MsgDisplayed     bool  // When true, the error message has already been displayed, don't display it again
	DisplayUsage     bool  // When true, the CLI usage should be displayed before exiting
	ApplicationError bool  // When true, the error is a result of an application failure
}

func MakeWskError

func MakeWskError(err error, exitCode int, flags ...bool) (resWhiskError *WskError)

Instantiate a WskError structure Parameters:

error   - RootErr. object implementing the error interface
int     - ExitCode.  Used if error object does not have an exit code OR if ExitCodeOverride is true
bool    - DisplayMsg.  If true, the error message should be displayed on the console
bool    - DisplayUsage.  If true, the command usage syntax/help should be displayed on the console
bool    - MsgDisplayed.  If true, the error message has been displayed on the console
bool    - DisplayPreview.  If true, the error message will be prefixed with "error: "

func MakeWskErrorFromWskError

func MakeWskErrorFromWskError(baseError error, whiskError error, exitCode int, flags ...bool) (resWhiskError *WskError)

Instantiate a WskError structure Parameters:

error       - RootErr. object implementing the error interface
WskError    - WskError being wrappered.  It's exitcode will be used as this WskError's exitcode.  Ignored if nil
int         - ExitCode. Used if error object is nil or if the error object is not a WskError
bool        - DisplayMsg. If true, the error message should be displayed on the console
bool        - DisplayUsage. If true, the command usage syntax/help should be displayed on the console
bool        - MsgDisplayed. If true, the error message has been displayed on the console
bool        - ApplicationError. If true, the error is a result of an application error

func (WskError) Error

func (whiskError WskError) Error() string

Prints the error message contained inside an WskError. An error prefix may, or may not be displayed depending on the WskError's setting for DisplayPrefix.

Parameters:

err     - WskError object used to display an error message from

Jump to

Keyboard shortcuts

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