whisk

package
v0.0.0-...-17d5563 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Example (Repl)
in := bytes.NewBufferString("{\"name\":\"Mike\"}\nerr\n")
repl(hello, in, os.Stdout)
Output:

name=Mike
{"message":"Hello, Mike!"}
name=Stranger
{"message":"Hello, Stranger!"}

Index

Examples

Constants

View Source
const (
	Overwrite      = true
	DoNotOverwrite = false
)
View Source
const (
	AuthRequired                   = true
	NoAuth                         = false
	IncludeNamespaceInUrl          = true
	DoNotIncludeNamespaceInUrl     = false
	AppendOpenWhiskPathPrefix      = true
	DoNotAppendOpenWhiskPathPrefix = false
	EncodeBodyAsJson               = "json"
	EncodeBodyAsFormData           = "formdata"
	ProcessTimeOut                 = true
	DoNotProcessTimeOut            = false
	ExitWithErrorOnTimeout         = true
	ExitWithSuccessOnTimeout       = false
	DEFAULT_HTTP_TIMEOUT           = 30
)
View Source
const (
	OPENWHISK_HOME       = "OPENWHISK_HOME"
	HOMEPATH             = "HOME"
	DEFAULT_LOCAL_CONFIG = ".wskprops"
	OPENWHISK_PROPERTIES = "whisk.properties"
	TEST_AUTH_FILE       = "testing.auth"
	OPENWHISK_PRO        = "whisk.api.host.proto"
	OPENWHISK_PORT       = "whisk.api.host.port"
	OPENWHISK_HOST       = "whisk.api.host.name"
	DEFAULT_VERSION      = "v1"
	DEFAULT_NAMESPACE    = "_"

	APIGW_ACCESS_TOKEN = "APIGW_ACCESS_TOKEN"
	APIGW_TENANT_ID    = "APIGW_TENANT_ID"
	APIHOST            = "APIHOST"
	APIVERSION         = "APIVERSION"
	AUTH               = "AUTH"
	CERT               = "CERT"
	KEY                = "KEY"
	NAMESPACE          = "NAMESPACE"

	DEFAULT_SOURCE = "wsk props"
	WSKPROP        = "wsk props"
	WHISK_PROPERTY = "whisk.properties"
)
View Source
const APPLICATION_ERR bool = true
View Source
const DISPLAY_MSG bool = true
View Source
const DISPLAY_PREFIX bool = true
View Source
const DISPLAY_USAGE bool = true
View Source
const EXIT_CODE_ERR_GENERAL int = 1
View Source
const EXIT_CODE_ERR_HTTP_RESP int = 4
View Source
const EXIT_CODE_ERR_NETWORK int = 3
View Source
const EXIT_CODE_ERR_USAGE int = 2
View Source
const EXIT_CODE_NOT_FOUND int = 148
View Source
const EXIT_CODE_TIMED_OUT int = 202
View Source
const MaxNameLen int = 25
View Source
const NOT_ALLOWED int = 149
View Source
const NO_APPLICATION_ERR bool = false
View Source
const NO_DISPLAY_MSG bool = false
View Source
const NO_DISPLAY_PREFIX bool = false
View Source
const NO_DISPLAY_USAGE bool = false
View Source
const NO_MSG_DISPLAYED bool = false
View Source
const TIMED_OUT bool = true

Variables

View Source
var ApiVerbs map[string]bool = map[string]bool{
	"GET":     true,
	"PUT":     true,
	"POST":    true,
	"DELETE":  true,
	"PATCH":   true,
	"HEAD":    true,
	"OPTIONS": true,
}
View Source
var DefaultObfuscateArr = []ObfuscateSet{
	{
		Regex:       "\"[Pp]assword\":\\s*\".*\"",
		Replacement: `"password": "******"`,
	},
}
View Source
var GetDefaultWskProp = func(pi Properties) (*Wskprops, error) {
	var dep *Wskprops
	dep = pi.GetPropsFromWskprops("")
	error := ValidateWskprops(dep)
	if error != nil {
		dep_whisk := pi.GetPropsFromWhiskProperties()
		error_whisk := ValidateWskprops(dep_whisk)
		if error_whisk != nil {
			return dep, error
		} else {
			return dep_whisk, error_whisk
		}
	}
	return dep, error
}
View Source
var GetWskPropFromWhiskProperty = func(pi Properties) (*Wskprops, error) {
	var dep *Wskprops
	dep = pi.GetPropsFromWhiskProperties()
	error := ValidateWskprops(dep)
	return dep, error
}
View Source
var GetWskPropFromWskprops = func(pi Properties, path string) (*Wskprops, error) {
	var dep *Wskprops
	dep = pi.GetPropsFromWskprops(path)
	error := ValidateWskprops(dep)
	return dep, error
}
View Source
var ReadX509KeyPair = func(certFile, keyFile string) (tls.Certificate, error) {
	return tls.LoadX509KeyPair(certFile, keyFile)
}
View Source
var StatusCodes = []string{"success", "application error", "developer error", "internal error"}

Status codes to descriptions

View Source
var ValidateWskprops = func(wskprops *Wskprops) error {

	errStr := ""
	if len(wskprops.APIHost) == 0 {
		if wskprops.Source == WHISK_PROPERTY {
			errStr = wski18n.T("OpenWhisk API host is missing (Please configure WHISK_APIHOST in .wskprops under the system HOME directory.)")
		} else {
			errStr = wski18n.T("OpenWhisk API host is missing (Please configure whisk.api.host.proto, whisk.api.host.name and whisk.api.host.port in whisk.properties under the OPENWHISK_HOME directory.)")
		}
		return MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, DISPLAY_USAGE)
	} else {
		if len(wskprops.AuthKey) == 0 {
			if wskprops.Source == WHISK_PROPERTY {
				errStr = wski18n.T("Authentication key is missing (Please configure AUTH in .wskprops under the system HOME directory.)")
			} else {
				errStr = wski18n.T("Authentication key is missing (Please configure testing.auth as the path of the authentication key file in whisk.properties under the OPENWHISK_HOME directory.)")
			}
			return MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, DISPLAY_USAGE)
		} else {
			return nil
		}
	}
}

Functions

func BodyTruncator

func BodyTruncator(body io.ReadCloser) (string, io.ReadCloser, error)

bodyTruncator limits the size of Req/Resp Body for --verbose ONLY. It returns truncated Req/Resp Body, reloaded io.ReadCloser and any errors.

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 GetStatusCodeForMessage

func GetStatusCodeForMessage(msg string) int

func GetURLBase

func GetURLBase(host string, path string) (*url.URL, error)

func GetUrlBase

func GetUrlBase(host string) (*url.URL, error)

func GetValue

func GetValue(StoredValues map[string]string, key string, defaultvalue string) string

func IsDebug

func IsDebug() bool

func IsHttpRespSuccess

func IsHttpRespSuccess(r *http.Response) bool

func IsResponseResultSuccess

func IsResponseResultSuccess(data []byte) bool

func IsVerbose

func IsVerbose() bool

func ObfuscateText

func ObfuscateText(text string, replacements []ObfuscateSet) string

func PrintJSON

func PrintJSON(v interface{})

func PrintRequestInfo

func PrintRequestInfo(req *http.Request, secretToObfuscate ...ObfuscateSet) (*http.Request, error)

func PrintResponseInfo

func PrintResponseInfo(resp *http.Response, secretToObfuscate ...ObfuscateSet) (*http.Response, []byte, error)

func ReadProps

func ReadProps(path string) (map[string]string, error)

func SetDebug

func SetDebug(b bool)

func SetVerbose

func SetVerbose(b bool)

func Start

func Start(fn ActionFunction)

Start will start a loop reading in stdin and outputting in fd3 This is expected to be uses for implementing Go actions

Example
StartWithArgs(hello, []string{"{\"name\":\"Mike\"}", "err"})
Output:

name=Mike
{"message":"Hello, Mike!"}
name=Stranger
{"message":"Hello, Stranger!"}

func StartWithArgs

func StartWithArgs(action ActionFunction, args []string)

StartWithArgs will execute the function for each arg If there are no args it will start a read-write loop on the function Expected to be used as starting point for implementing Go Actions as whisk.StartWithArgs(function, os.Args[:1]) if args are 2 (command and one parameter) it will invoke the function once otherwise it will stat the function in a read-write loop

func TruncateStr

func TruncateStr(str string, maxlen int) string

TruncateStr() returns the string, truncated with ...in the middle if it exceeds the specified length

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 formatted message without any appended newline characters

Types

type Action

type Action struct {
	Namespace      string      `json:"namespace,omitempty"`
	Name           string      `json:"name,omitempty"`
	Version        string      `json:"version,omitempty"`
	Exec           *Exec       `json:"exec,omitempty"`
	Annotations    KeyValueArr `json:"annotations,omitempty"`
	DelAnnotations []string    `json:"delAnnotations,omitempty"`
	Parameters     KeyValueArr `json:"parameters,omitempty"`
	Limits         *Limits     `json:"limits,omitempty"`
	Error          string      `json:"error,omitempty"`
	Code           int         `json:"code,omitempty"`
	Publish        *bool       `json:"publish,omitempty"`
	Updated        int64       `json:"updated,omitempty"`
}

func (Action) ActionURL

func (action Action) ActionURL(apiHost string, apiPath string, apiVersion string, pkg string) (string, error)

Returns the URL of an action as a string. A valid API host, path and version must be passed. A package that contains the action must be passed as well. An empty string must be passed if the action is not packaged.

func (Action) Compare

func (action Action) Compare(sortable Sortable) bool

Compare(sortable) compares action to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Action. ***Method of type Sortable***

func (Action) ToHeaderString

func (action Action) ToHeaderString() string

ToHeaderString() returns the header for a list of actions

func (Action) ToSummaryRowString

func (action Action) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk action list`.

***Method of type Sortable***

func (Action) WebAction

func (action Action) WebAction() (webExportValue bool)

Determines if an action is a web action by examining the action's annotations. A value of true is returned if the action's annotations contains a "web-export" key and its associated value is a boolean value of "true". Otherwise, false is returned.

type ActionFunction

type ActionFunction func(event json.RawMessage) (json.RawMessage, error)

ActionFunction is the signature of an action in OpenWhisk

type ActionListOptions

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

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, fetchCode bool) (*Action, *http.Response, error)

func (*ActionService) Insert

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

func (*ActionService) Invoke

func (s *ActionService) Invoke(actionName string, payload interface{}, blocking bool, result bool) (map[string]interface{}, *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"`
	Name         string `json:"name"`
	Version      string `json:"version"`
	Subject      string `json:"subject"`
	ActivationID string `json:"activationId"`
	Cause        string `json:"cause,omitempty"`
	Start        int64  `json:"start"`    // 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
	Duration     int64  `json:"duration"` // Only available for actions
	StatusCode   int    `json:"statusCode"`
	Response     `json:"response"`
	Logs         []string    `json:"logs"`
	Annotations  KeyValueArr `json:"annotations"`
	Publish      *bool       `json:"publish,omitempty"`
}

func (Activation) Compare

func (activation Activation) Compare(sortable Sortable) bool

Compare(sortable) compares activation to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Activation. ***Method of type Sortable*** ***Currently, no method of sorting defined***

type ActivationFilteredRow

type ActivationFilteredRow struct {
	Row       Activation
	HeaderFmt string
	RowFmt    string
}

func (ActivationFilteredRow) Compare

func (activation ActivationFilteredRow) Compare(sortable Sortable) bool

Compare(sortable) compares activation to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Activation. ***Method of type Sortable*** ***Currently, no method of sorting defined***

func (ActivationFilteredRow) ToHeaderString

func (activation ActivationFilteredRow) ToHeaderString() string

ToHeaderString() returns the header for a list of activations

func (ActivationFilteredRow) ToSummaryRowString

func (activation ActivationFilteredRow) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk activation list`.

***Method of type Sortable***

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 Api

type Api struct {
	Namespace       string         `json:"namespace,omitempty"`
	ApiName         string         `json:"apiName,omitempty"`
	GatewayBasePath string         `json:"gatewayBasePath,omitempty"`
	GatewayRelPath  string         `json:"gatewayPath,omitempty"`
	GatewayMethod   string         `json:"gatewayMethod,omitempty"`
	Id              string         `json:"id,omitempty"`
	GatewayFullPath string         `json:"gatewayFullPath,omitempty"`
	Swagger         string         `json:"swagger,omitempty"`
	Action          *ApiAction     `json:"action,omitempty"`
	PathParameters  []ApiParameter `json:"pathParameters,omitempty"`
}

type ApiAction

type ApiAction struct {
	Name          string      `json:"name,omitempty"`
	Namespace     string      `json:"namespace,omitempty"`
	BackendMethod string      `json:"backendMethod,omitempty"`
	BackendUrl    string      `json:"backendUrl,omitempty"`
	Auth          string      `json:"authkey,omitempty"`
	SecureKey     interface{} `json:"secureKey,omitempty"`
}

type ApiCreateRequest

type ApiCreateRequest struct {
	ApiDoc *Api `json:"apidoc,omitempty"`
}

wsk api create : Request, Response

type ApiCreateRequestOptions

type ApiCreateRequestOptions ApiOptions

type ApiCreateResponse

type ApiCreateResponse RetApi

type ApiDeleteRequest

type ApiDeleteRequest struct {
	Api
}

wsk api delete : Request, Response

type ApiDeleteRequestOptions

type ApiDeleteRequestOptions ApiOptions

type ApiDeleteResponse

type ApiDeleteResponse struct{}

type ApiFilteredList

type ApiFilteredList struct {
	ActionName string
	ApiName    string
	BasePath   string
	RelPath    string
	Verb       string
	Url        string
}

Used for printing individual APIs in non-truncated form

func (ApiFilteredList) Compare

func (api ApiFilteredList) Compare(sortable Sortable) bool

Compare(sortable) compares api to sortable for the purpose of sorting. REQUIRED: sortable must also be of type ApiFilteredList. ***Method of type Sortable***

func (ApiFilteredList) ToHeaderString

func (api ApiFilteredList) ToHeaderString() string

ToHeaderString() returns the header for a list of apis

func (ApiFilteredList) ToSummaryRowString

func (api ApiFilteredList) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk api list` or `wsk api-experimental list`.

***Method of type Sortable***

type ApiFilteredRow

type ApiFilteredRow struct {
	ActionName string
	ApiName    string
	BasePath   string
	RelPath    string
	Verb       string
	Url        string
	FmtString  string
}

Used for printing individual APIs in truncated form

func (ApiFilteredRow) Compare

func (api ApiFilteredRow) Compare(sortable Sortable) bool

Compare(sortable) compares api to sortable for the purpose of sorting. REQUIRED: sortable must also be of type ApiFilteredRow. ***Method of type Sortable***

func (ApiFilteredRow) ToHeaderString

func (api ApiFilteredRow) ToHeaderString() string

ToHeaderString() returns the header for a list of apis

func (ApiFilteredRow) ToSummaryRowString

func (api ApiFilteredRow) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk api list -f` or `wsk api-experimental list -f`.

***Method of type Sortable***

type ApiGetRequest

type ApiGetRequest struct {
	Api
}

wsk api get : Request, Response

type ApiGetRequestOptions

type ApiGetRequestOptions ApiOptions

type ApiGetResponse

type ApiGetResponse RetApiArray

type ApiItem

type ApiItem struct {
	ApiId    string  `json:"id,omitempty"`
	QueryKey string  `json:"key,omitempty"`
	ApiValue *RetApi `json:"value,omitempty"`
}

type ApiListRequest

type ApiListRequest struct {
}

wsk api list : Request, Response

type ApiListRequestOptions

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

type ApiListResponse

type ApiListResponse RetApiArray

type ApiOptions

type ApiOptions struct {
	ActionName   string `url:"action,omitempty"`
	ApiBasePath  string `url:"basepath,omitempty"`
	ApiRelPath   string `url:"relpath,omitempty"`
	ApiVerb      string `url:"operation,omitempty"`
	ApiName      string `url:"apiname,omitempty"`
	SpaceGuid    string `url:"spaceguid,omitempty"`
	AccessToken  string `url:"accesstoken,omitempty"`
	ResponseType string `url:"responsetype,omitempty"`
}

type ApiParameter

type ApiParameter struct {
	Name             string                 `json:"name"`
	In               string                 `json:"in"`
	Description      string                 `json:"description,omitempty"`
	Required         bool                   `json:"required,omitempty"`
	Type             string                 `json:"type,omitempty"`
	Format           string                 `json:"format,omitempty"`
	AllowEmptyValue  bool                   `json:"allowEmptyValue,omitempty"`
	Items            map[string]interface{} `json:"items,omitempty"`
	CollectionFormat string                 `json:"collectionFormat,omitempty"`
	Default          interface{}            `json:"default,omitempty"`
	Maximum          int                    `json:"maximum,omitempty"`
	ExclusiveMaximum bool                   `json:"exclusiveMaximum,omitempty"`
	Minimum          int                    `json:"minimum,omitempty"`
	ExclusiveMinimum bool                   `json:"exclusiveMinimum,omitempty"`
	MaxLength        int                    `json:"maxLength,omitempty"`
	MinLength        int                    `json:"minLength,omitempty"`
	Pattern          string                 `json:"pattern,omitempty"`
	MaxItems         int                    `json:"maxItems,omitempty"`
	MinItems         int                    `json:"minItems,omitempty"`
	UniqueItems      bool                   `json:"uniqueItems,omitempty"`
	MultipleOf       int                    `json:"multipleOf,omitempty"`
	Enum             interface{}            `json:"enum,omitempty"`
	Ref              string                 `json:"$ref,omitempty"`
}

type ApiService

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

func (*ApiService) Delete

func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response, error)

func (*ApiService) Get

func (*ApiService) Insert

func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite bool) (*ApiCreateResponse, *http.Response, error)

func (*ApiService) List

func (s *ApiService) List(apiListOptions *ApiListRequestOptions) (*ApiListResponse, *http.Response, error)

type ApiSwagger

type ApiSwagger struct {
	SwaggerName string                     `json:"swagger,omitempty"`
	BasePath    string                     `json:"basePath,omitempty"`
	Info        *ApiSwaggerInfo            `json:"info,omitempty"`
	Paths       map[string]*ApiSwaggerPath `json:"paths,omitempty"`
	SecurityDef interface{}                `json:"securityDefinitions,omitempty"`
	Security    interface{}                `json:"security,omitempty"`
	XConfig     interface{}                `json:"x-ibm-configuration,omitempty"`
	XRateLimit  interface{}                `json:"x-ibm-rate-limit,omitempty"`
}

type ApiSwaggerInfo

type ApiSwaggerInfo struct {
	Title   string `json:"title,omitempty"`
	Version string `json:"version,omitempty"`
}

type ApiSwaggerOpXOpenWhisk

type ApiSwaggerOpXOpenWhisk struct {
	ActionName string `json:"action"`
	Namespace  string `json:"namespace"`
	Package    string `json:"package"`
	ApiUrl     string `json:"url"`
}

type ApiSwaggerOperation

type ApiSwaggerOperation struct {
	OperationId string                  `json:"operationId"`
	Parameters  []ApiParameter          `json:"parameters,omitempty"`
	Responses   interface{}             `json:"responses"`
	XOpenWhisk  *ApiSwaggerOpXOpenWhisk `json:"x-openwhisk,omitempty"`
}

type ApiSwaggerPath

type ApiSwaggerPath struct {
	Get        *ApiSwaggerOperation `json:"get,omitempty"`
	Put        *ApiSwaggerOperation `json:"put,omitempty"`
	Post       *ApiSwaggerOperation `json:"post,omitempty"`
	Delete     *ApiSwaggerOperation `json:"delete,omitempty"`
	Options    *ApiSwaggerOperation `json:"options,omitempty"`
	Head       *ApiSwaggerOperation `json:"head,omitempty"`
	Patch      *ApiSwaggerOperation `json:"patch,omitempty"`
	Parameters []ApiParameter       `json:"parameters,omitempty"`
}

func (*ApiSwaggerPath) MakeOperationMap

func (asp *ApiSwaggerPath) MakeOperationMap() map[string]*ApiSwaggerOperation

type ApiUserAuth

type ApiUserAuth struct {
	SpaceGuid   string `json:"spaceguid,omitempty"`
	AccessToken string `json:"accesstoken,omitempty"`
}

type AppErrorResult

type AppErrorResult struct {
	Error *interface{} `json:"error"`
}

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,omitempty"`
	Annotations KeyValueArr `json:"annotations,omitempty"`
	Parameters  KeyValueArr `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   []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    TriggerServiceInterface
	Actions     *ActionService
	Rules       *RuleService
	Activations *ActivationService
	Packages    *PackageService
	Namespaces  *NamespaceService
	Info        *InfoService
	Apis        *ApiService
	// contains filtered or unexported fields
}

func NewClient

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

NewClient creates a new whisk client with the provided http client and whisk configuration.

A new http.Transport will be created when client cert or TLS insecure options are set. If one use custom tranport and want to keep it intact, please opt out TLS related fields in configInput and construct TLS conguration in the custom transport.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout bool, secretToObfuscate ...ObfuscateSet) (*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) LoadX509KeyPair

func (c *Client) LoadX509KeyPair() error

func (*Client) NewRequest

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

func (*Client) NewRequestUrl

func (c *Client) NewRequestUrl(
	method string,
	urlRelResource *url.URL,
	body interface{},
	includeNamespaceInUrl bool,
	appendOpenWhiskPath bool,
	encodeBodyAs string,
	useAuthentication bool) (*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
includeNamespaceInUrl - when true "/namespaces/NAMESPACE" is included in the final URL; otherwise not included.
appendOpenWhiskPath - when true, the OpenWhisk URL format is generated
encodeBodyAs   - specifies body encoding (json or form data)
useAuthentication - when true, the basic Authorization is included with the configured authkey as the value

type ClientInterface

type ClientInterface interface {
	NewRequestUrl(method string, urlRelResource *url.URL, body interface{}, includeNamespaceInUrl bool, appendOpenWhiskPath bool, encodeBodyAs string, useAuthentication bool) (*http.Request, error)
	NewRequest(method, urlStr string, body interface{}, includeNamespaceInUrl bool) (*http.Request, error)
	Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout bool, secretToObfuscate ...ObfuscateSet) (*http.Response, error)
}

type Config

type Config struct {
	Namespace         string // NOTE :: Default is "_"
	Cert              string
	Key               string
	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
	UserAgent         string
	ApigwAccessToken  string
	ApigwTenantId     string
	AdditionalHeaders http.Header
}

func GetConfigFromWhiskProperties

func GetConfigFromWhiskProperties(pi Properties) (*Config, error)

func GetConfigFromWskprops

func GetConfigFromWskprops(pi Properties, path string) (*Config, error)

func GetDefaultConfig

func GetDefaultConfig() (*Config, error)

func GetDefaultConfigFromProperties

func GetDefaultConfigFromProperties(pi Properties) (*Config, error)

func GetWhiskPropertiesConfig

func GetWhiskPropertiesConfig() (*Config, error)

func GetWskpropsConfig

func GetWskpropsConfig(path string) (*Config, error)

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 `json:"-"`     // HTTP response that caused this error
	ErrMsg   *interface{}   `json:"error"` // error message string
	Code     *interface{}   `json:"code"`  // validation error code (tid)
}

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,omitempty"`
	Image      string   `json:"image,omitempty"`
	Init       string   `json:"init,omitempty"`
	Main       string   `json:"main,omitempty"`
	Components []string `json:"components,omitempty"` // List of fully qualified actions
	Binary     *bool    `json:"binary,omitempty"`
}

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"`
	Value interface{} `json:"value"`
}

type KeyValueArr

type KeyValueArr []KeyValue

func (KeyValueArr) AddOrReplace

func (keyValueArr KeyValueArr) AddOrReplace(kv *KeyValue) KeyValueArr

* Adds the specified KeyValue to the key value array. If the KeyValue's key * is already in the array, that entry is updated with the KeyValue's value. * * Returns a new key value array with the update

func (KeyValueArr) AppendKeyValueArr

func (keyValueArr KeyValueArr) AppendKeyValueArr(appKeyValueArr KeyValueArr) KeyValueArr

Appends items from appKeyValueArr to keyValueArr if the appKeyValueArr item does not exist in keyValueArr.

func (KeyValueArr) FindKeyValue

func (keyValueArr KeyValueArr) FindKeyValue(key string) int

func (KeyValueArr) GetValue

func (keyValueArr KeyValueArr) GetValue(key string) (res interface{})

Retrieves a value associated with a given key from a KeyValueArr. A key of type string must be passed to the method. An interface will be returned containing the found value. If a key could not be found, a nil value will be returned.

type Limits

type Limits struct {
	Timeout     *int `json:"timeout,omitempty"`
	Memory      *int `json:"memory,omitempty"`
	Logsize     *int `json:"logs,omitempty"`
	Concurrency *int `json:"concurrency,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"`
}

func (Namespace) Compare

func (namespace Namespace) Compare(sortable Sortable) bool

Compare(sortable) compares namespace to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Namespace. ***Method of type Sortable***

func (Namespace) ToHeaderString

func (namespace Namespace) ToHeaderString() string

ToHeaderString() returns the header for a list of namespaces

func (Namespace) ToSummaryRowString

func (namespace Namespace) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk namespace list`.

***Method of type Sortable***

type NamespaceService

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

func (*NamespaceService) List

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

get a list of available namespaces

type OSPackage

type OSPackage interface {
	Getenv(key string, defaultValue string) string
}

type OSPackageImp

type OSPackageImp struct{}

func (OSPackageImp) Getenv

func (osPackage OSPackageImp) Getenv(key string, defaultValue string) string

type ObfuscateSet

type ObfuscateSet struct {
	Regex       string
	Replacement string
}

type Package

type Package struct {
	Namespace   string      `json:"namespace,omitempty"`
	Name        string      `json:"name,omitempty"`
	Version     string      `json:"version,omitempty"`
	Publish     *bool       `json:"publish,omitempty"`
	Annotations KeyValueArr `json:"annotations,omitempty"`
	Parameters  KeyValueArr `json:"parameters,omitempty"`
	Binding     *Binding    `json:"binding,omitempty"`
	Actions     []Action    `json:"actions,omitempty"`
	Feeds       []Action    `json:"feeds,omitempty"`
	Updated     int64       `json:"updated,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) Compare

func (xPackage Package) Compare(sortable Sortable) bool

Compare(sortable) compares xPackage to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Package. ***Method of type Sortable***

func (*Package) GetName

func (p *Package) GetName() string

func (Package) ToHeaderString

func (pkg Package) ToHeaderString() string

ToHeaderString() returns the header for a list of actions

func (Package) ToSummaryRowString

func (xPackage Package) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk package list`.

***Method of type Sortable***

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 Printable

type Printable interface {
	ToHeaderString() string     // Prints header information of a Printable
	ToSummaryRowString() string // Prints summary info of one Printable
}

Printable items are anything that need to be printed for listing purposes.

type Properties

type Properties interface {
	GetPropsFromWskprops(string) *Wskprops
	GetPropsFromWhiskProperties() *Wskprops
}

func GetProperties

func GetProperties() Properties

type PropertiesImp

type PropertiesImp struct {
	OsPackage OSPackage
}

func (PropertiesImp) GetPropsFromWhiskProperties

func (pi PropertiesImp) GetPropsFromWhiskProperties() *Wskprops

func (PropertiesImp) GetPropsFromWskprops

func (pi PropertiesImp) GetPropsFromWskprops(path string) *Wskprops

type Response

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

type Result

type Result map[string]interface{}

type RetApi

type RetApi struct {
	Namespace string      `json:"namespace"`
	BaseUrl   string      `json:"gwApiUrl"`
	Activated bool        `json:"gwApiActivated"`
	TenantId  string      `json:"tenantId"`
	Swagger   *ApiSwagger `json:"apidoc,omitempty"`
}

type RetApiArray

type RetApiArray struct {
	Apis []ApiItem `json:"apis,omitempty"`
}

type Rule

type Rule struct {
	Namespace   string      `json:"namespace,omitempty"`
	Name        string      `json:"name,omitempty"`
	Version     string      `json:"version,omitempty"`
	Annotations KeyValueArr `json:"annotations,omitempty"`
	Status      string      `json:"status"`
	Trigger     interface{} `json:"trigger"`
	Action      interface{} `json:"action"`
	Publish     *bool       `json:"publish,omitempty"`
	Updated     int64       `json:"updated,omitempty"`
}

func (Rule) Compare

func (rule Rule) Compare(sortable Sortable) bool

Compare(sortable) compares rule to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Rule. ***Method of type Sortable***

func (Rule) ToHeaderString

func (rule Rule) ToHeaderString() string

ToHeaderString() returns the header for a list of rules

func (Rule) ToSummaryRowString

func (rule Rule) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk rule list`.

***Method of type Sortable***

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 Sortable

type Sortable interface {
	// Compare(sortable) compares an two sortables and returns true
	//      if the item calling the Compare method is less than toBeCompared.
	//      Sorts alphabetically by default, can have other parameters to sort by
	//      passed by sortByName.
	Compare(toBeCompared Sortable) bool
}

Sortable items are anything that needs to be sorted for listing purposes.

type Trigger

type Trigger struct {
	Namespace    string                 `json:"namespace,omitempty"`
	Name         string                 `json:"name,omityempty"`
	Version      string                 `json:"version,omitempty"`
	ActivationId string                 `json:"activationId,omitempty"`
	Annotations  KeyValueArr            `json:"annotations,omitempty"`
	Parameters   KeyValueArr            `json:"parameters,omitempty"`
	Limits       *Limits                `json:"limits,omitempty"`
	Publish      *bool                  `json:"publish,omitempty"`
	Rules        map[string]interface{} `json:"rules,omitempty"`
	Updated      int64                  `json:"updated,omitempty"`
}

func (Trigger) Compare

func (trigger Trigger) Compare(sortable Sortable) bool

Compare(sortable) compares trigger to sortable for the purpose of sorting. REQUIRED: sortable must also be of type Trigger. ***Method of type Sortable***

func (Trigger) ToHeaderString

func (trigger Trigger) ToHeaderString() string

ToHeaderString() returns the header for a list of triggers

func (Trigger) ToSummaryRowString

func (trigger Trigger) ToSummaryRowString() string

ToSummaryRowString() returns a compound string of required parameters for printing

from CLI command `wsk trigger list`.

***Method of type Sortable***

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) (*Trigger, *http.Response, error)

func (*TriggerService) Fire

func (s *TriggerService) Fire(triggerName string, payload interface{}) (*Trigger, *http.Response, error)

func (*TriggerService) Get

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

func (*TriggerService) Insert

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

func (*TriggerService) List

func (s *TriggerService) List(options *TriggerListOptions) ([]Trigger, *http.Response, error)

type TriggerServiceInterface

type TriggerServiceInterface interface {
	List(options *TriggerListOptions) ([]Trigger, *http.Response, error)
	Insert(trigger *Trigger, overwrite bool) (*Trigger, *http.Response, error)
	Get(triggerName string) (*Trigger, *http.Response, error)
	Delete(triggerName string) (*Trigger, *http.Response, error)
	Fire(triggerName string, payload interface{}) (*Trigger, *http.Response, error)
}

type WhiskError

type WhiskError struct {
	Msg *string `json:"msg"`
}

type WhiskErrorResponse

type WhiskErrorResponse struct {
	Response *WhiskResponse `json:"response"`
}

type WhiskResponse

type WhiskResponse struct {
	Result  map[string]interface{} `json:"result"`
	Success bool                   `json:"success"`
	Status  *interface{}           `json:"status"`
}

type WhiskResult

type WhiskResult struct {
}

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
	DisplayPrefix    bool  // When true, the CLI will prefix an error message with "error: "
	ApplicationError bool  // When true, the error is a result of an application failure
	TimedOut         bool  // When True, the error is a result of a timeout
}

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: "
bool    - TimedOut. If true, the error is a result of a timeout

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
bool        - TimedOut. If true, the error resulted from a timeout

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

type Wskprops

type Wskprops struct {
	APIGWSpaceSuid string
	APIGWTenantId  string
	APIHost        string
	Apiversion     string
	AuthAPIGWKey   string
	AuthKey        string
	Cert           string
	Key            string
	Namespace      string
	Source         string
}

func GetDefaultWskprops

func GetDefaultWskprops(source string) *Wskprops

Jump to

Keyboard shortcuts

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