function

package
v0.0.0-...-63319d1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FGS      = "fgs"
	FUNCTION = "functions"
	CODE     = "code"
	CONFIG   = "config"
	VERSION  = "versions"
	ALIAS    = "aliases"
	INVOKE   = "invocations"
	ASINVOKE = "invocations-async"
)

Variables

This section is empty.

Functions

func CreateResourceTags

func CreateResourceTags(c *golangsdk.ServiceClient, functionUrn string, opts TagsActionOpts) error

CreateResourceTags is the method that used to add tags to function using given parameters.

func DeleteAsyncInvokeConfig

func DeleteAsyncInvokeConfig(c *golangsdk.ServiceClient, functionUrn string) error

DeleteAsyncInvokeConfig is the method that used to delete the asynchronous invocation.

func DeleteResourceTags

func DeleteResourceTags(c *golangsdk.ServiceClient, functionUrn string, opts TagsActionOpts) error

DeleteResourceTags is the method that used to delete tags from function using given parameters.

func List

func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager

functions list

func ListAlias

func ListAlias(c *golangsdk.ServiceClient, functionUrn string) pagination.Pager

Querying the Aliases of a Function's All Versions

func ListVersions

func ListVersions(c *golangsdk.ServiceClient, opts ListOptsBuilder, functionUrn string) pagination.Pager

Querying the Alias Information of a Function Version

Types

type AliasResult

type AliasResult struct {
	Name         string `json:"name"`
	Version      string `json:"version"`
	Description  string `json:"description"`
	LastModified string `json:"last_modified"`
	AliasUrn     string `json:"alias_urn"`
}

func ExtractAliasList

func ExtractAliasList(r pagination.Page) ([]AliasResult, error)

type AsyncInvokeConfig

type AsyncInvokeConfig struct {
	// Function URN.
	FunctionUrn string `json:"func_urn"`
	// Maximum validity period of a message. Value range: 60–86,400. Unit: second.
	MaxAsyncEventAgeInSeconds int `json:"max_async_event_age_in_seconds"`
	// Maximum number of retry attempts to be made if asynchronous invocation fails. Default value: 3. Value range: 0–8.
	MaxAsyncRetryAttempts int `json:"max_async_retry_attempts"`
	// Asynchronous invocation target.
	DestinationConfig DestinationConfig `json:"destination_config"`
	// Time when asynchronous execution notification was configured.
	CreatedAt string `json:"created_time"`
	// Time when the asynchronous execution notification settings were last modified.
	UpdatedAt string `json:"last_modified"`
	// Whether to enable asynchronous invocation status persistence.
	EnableAsyncStatusLog bool `json:"enable_async_status_log"`
}

AsyncInvokeConfig is the structure that represents the asynchronous invocation.

func GetAsyncInvokeConfig

func GetAsyncInvokeConfig(c *golangsdk.ServiceClient, functionUrn string) (*AsyncInvokeConfig, error)

GetAsyncInvokeConfig is the method that used to query the configuration details of the asynchronous invocation.

func UpdateAsyncInvokeConfig

func UpdateAsyncInvokeConfig(c *golangsdk.ServiceClient, functionUrn string,
	opts AsyncInvokeConfigOpts) (*AsyncInvokeConfig, error)

UpdateAsyncInvokeConfig is the method that used to enable or modify the asynchronous invocation.

type AsyncInvokeConfigOpts

type AsyncInvokeConfigOpts struct {
	// The maximum validity period of a message.
	MaxAsyncEventAgeInSeconds int `json:"max_async_event_age_in_seconds,omitempty"`
	// The maximum number of retry attempts to be made if asynchronous invocation fails.
	MaxAsyncRetryAttempts int `json:"max_async_retry_attempts,omitempty"`
	// Asynchronous invocation target.
	DestinationConfig DestinationConfig `json:"destination_config,omitempty"`
	// Whether to enable asynchronous invocation status persistence.
	EnableAsyncStatusLog *bool `json:"enable_async_status_log,omitempty"`
}

AsyncInvokeConfigOpts is the structure that used to modify the asynchronous invocation configuration.

type CreateAliasOpts

type CreateAliasOpts struct {
	Name    string `json:"name" required:"true"`
	Version string `json:"version" required:"true"`
}

Alias struct

func (CreateAliasOpts) ToCreateFunctionMap

func (opts CreateAliasOpts) ToCreateFunctionMap() (map[string]interface{}, error)

type CreateOpts

type CreateOpts struct {
	FuncName            string            `json:"func_name" required:"true"`
	MemorySize          int               `json:"memory_size" required:"true"`
	Package             string            `json:"package" required:"true"`
	Runtime             string            `json:"runtime" required:"true"`
	Timeout             int               `json:"timeout" required:"true"`
	AppXrole            string            `json:"app_xrole,omitempty"`
	CodeFilename        string            `json:"code_filename,omitempty"`
	CodeType            string            `json:"code_type,omitempty"`
	CodeUrl             string            `json:"code_url,omitempty"`
	CustomImage         *CustomImage      `json:"custom_image,omitempty"`
	Description         string            `json:"description,omitempty"`
	EncryptedUserData   string            `json:"encrypted_user_data,omitempty"`
	EnterpriseProjectID string            `json:"enterprise_project_id,omitempty"`
	FuncCode            *FunctionCodeOpts `json:"func_code,omitempty"`
	Handler             string            `json:"handler,omitempty"`
	Type                string            `json:"type,omitempty"`
	UserData            string            `json:"user_data,omitempty"`
	Xrole               string            `json:"xrole,omitempty"`
}

function struct

func (CreateOpts) ToCreateFunctionMap

func (opts CreateOpts) ToCreateFunctionMap() (map[string]interface{}, error)

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToCreateFunctionMap() (map[string]interface{}, error)
}

Create function

type CreateResult

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

func AsyncInvoke

func AsyncInvoke(c *golangsdk.ServiceClient, m map[string]interface{}, functionUrn string) (r CreateResult)

Executing a Function Asynchronously

func Create

func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

create funtion

func CreateAlias

func CreateAlias(c *golangsdk.ServiceClient, opts CreateOptsBuilder, functionUrn string) (r CreateResult)

Creating an Alias for a Function Version

func CreateVersion

func CreateVersion(c *golangsdk.ServiceClient, opts CreateOptsBuilder, functionUrn string) (r CreateResult)

Publishing a Function Version

func Invoke

func Invoke(c *golangsdk.ServiceClient, m map[string]interface{}, functionUrn string) (r CreateResult)

Executing a Function Synchronously

func (CreateResult) Extract

func (r CreateResult) Extract() (*Function, error)

func (CreateResult) ExtractAlias

func (r CreateResult) ExtractAlias() (*AliasResult, error)

func (CreateResult) ExtractInvoke

func (r CreateResult) ExtractInvoke() (interface{}, error)

type CreateVersionOpts

type CreateVersionOpts struct {
	Digest      string `json:"digest,omitempty"`
	Description string `json:"description,omitempty"`
	Version     string `json:"version,omitempty"`
}

verstion struct

func (CreateVersionOpts) ToCreateFunctionMap

func (opts CreateVersionOpts) ToCreateFunctionMap() (map[string]interface{}, error)

type CustomImage

type CustomImage struct {
	Enabled bool   `json:"enabled" required:"true"`
	Image   string `json:"image" required:"true"`
}

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

func Delete

func Delete(c *golangsdk.ServiceClient, functionUrn string) (r DeleteResult)

Deleting a Function or Function Version

func DeleteAlias

func DeleteAlias(c *golangsdk.ServiceClient, functionUrn, aliasName string) (r DeleteResult)

Deleting an Alias of a Function Version

type Dependency

type Dependency struct {
	Id           string             `json:"id"`
	Owner        string             `json:"owner"`
	Namespace    string             `json:"-"`
	Link         string             `json:"link"`
	Runtime      string             `json:"runtime"`
	ETag         string             `json:"etag"`
	Size         int64              `json:"size"`
	Name         string             `json:"name"`
	Description  string             `json:"description"`
	FileName     string             `json:"file_name,omitempty"`
	FuncVersions []*FunctionVersion `json:"-"`
	SaveType     int                `json:"-"`
}

dependency

type DestinationConfig

type DestinationConfig struct {
	// The target to be invoked when a function is successfully executed.
	OnSuccess DestinationConfigDetails `json:"on_success,omitempty"`
	// The target to be invoked when a function fails to be executed due to a  system error or an internal error.
	OnFailure DestinationConfigDetails `json:"on_failure,omitempty"`
}

DestinationConfig is the structure that represents the asynchronous invocation target.

type DestinationConfigDetails

type DestinationConfigDetails struct {
	// The object type.
	Destination string `json:"destination,omitempty"`
	// The parameters (in JSON format) corresponding to the target service.
	Param string `json:"param,omitempty"`
}

DestinationConfigDetails is the structure that represents the configuration details of the asynchronous invocation.

type FuncMount

type FuncMount struct {
	Id             string             `json:"id,omitempty"`
	MountType      string             `json:"mount_type" required:"true"`
	MountResource  string             `json:"mount_resource" required:"true"`
	MountSharePath string             `json:"mount_share_path" required:"true"`
	LocalMountPath string             `json:"local_mount_path" required:"true" description:"local file path in function runtime environment"`
	UserGroupId    *int               `json:"-"`
	UserId         *int               `json:"-"`
	Status         string             `json:"status,omitempty"` //ACTIVE或DISABLED,和触发器类似。如果已经存在的配置不可用了processrouter不会挂载。
	ProjectId      string             `json:"-"`
	FuncVersions   []*FunctionVersion `json:"-"`
	SaveType       int                `json:"-"` //仅仅在数据处理时用到,如果需要保存新的映射关系,则将其置为1,如要删除老的,将其置为2
}

type FuncVpc

type FuncVpc struct {
	Id         string `json:"-"`
	DomainId   string `json:"-" validate:"regexp=^[a-zA-Z0-9-]+$" description:"domain id"`
	Namespace  string `json:"-"`
	VpcName    string `json:"vpc_name,omitempty"`
	VpcId      string `json:"vpc_id,omitempty"`
	SubnetName string `json:"subnet_name,omitempty"`
	SubnetId   string `json:"subnet_id,omitempty"`
	Cidr       string `json:"cidr,omitempty"`
	Gateway    string `json:"gateway,omitempty"`
}

type Function

type Function struct {
	Id                  string         `json:"-"`
	FuncId              string         `json:"-"`
	FuncUrn             string         `json:"func_urn"`
	FuncName            string         `json:"func_name"`
	DomainId            string         `json:"domain_id"`
	Namespace           string         `json:"namespace"`
	ProjectName         string         `json:"project_name"`
	Package             string         `json:"package"`
	Runtime             string         `json:"runtime"`
	Timeout             int            `json:"timeout"`
	Handler             string         `json:"handler"`
	MemorySize          int            `json:"memory_size"`
	Cpu                 int            `json:"cpu"`
	CodeType            string         `json:"code_type"`
	CodeUrl             string         `json:"code_url"`
	CodeFileName        string         `json:"code_filename"`
	CodeSize            int64          `json:"code_size"`
	CustomImage         CustomImage    `json:"custom_image"`
	UserData            string         `json:"user_data"`
	EncryptedUserData   string         `json:"encrypted_user_data"`
	Digest              string         `json:"digest"`
	Version             string         `json:"version"`
	ImageName           string         `json:"image_name"`
	Xrole               string         `json:"xrole"`
	AppXrole            string         `json:"app_xrole"`
	Description         string         `json:"description"`
	VersionDescription  string         `json:"version_description"`
	LastmodifiedUtc     int64          `json:"-"`
	LastModified        string         `json:"last_modified"`
	FuncCode            FunctionCode   `json:"func_code"`
	FuncVpc             FuncVpc        `json:"func_vpc"`
	MountConfig         MountConfig    `json:"mount_config,omitempty"`
	Concurrency         int            `json:"-"`
	DependList          []string       `json:"depend_list"`
	StrategyConfig      StrategyConfig `json:"strategy_config"`
	ExtendConfig        string         `json:"extend_config"`
	Dependencies        []*Dependency  `json:"dependencies"`
	InitializerTimeout  int            `json:"initializer_timeout,omitempty"`
	InitializerHandler  string         `json:"initializer_handler,omitempty"`
	EnterpriseProjectID string         `json:"enterprise_project_id"`
	Type                string         `json:"type"`
}

func UpdateMaxInstanceNumber

func UpdateMaxInstanceNumber(c *golangsdk.ServiceClient, functionUrn string, num int) (*Function, error)

type FunctionBase

type FunctionBase struct {
	Id          string `json:"-"`
	FuncName    string `json:"func_name"`
	DomainId    string `description:"domain id"`
	Namespace   string `json:"namespace"`
	ProjectName string `json:"project_name"`
	Package     string `json:"package"`
}

noinspection GoNameStartsWithPackageName

type FunctionCode

type FunctionCode struct {
	File string `json:"file"`
	Link string `json:"link"`
}

noinspection GoNameStartsWithPackageName

type FunctionCodeOpts

type FunctionCodeOpts struct {
	File string `json:"file" required:"true"`
	Link string `json:"-"`
}

funcCode struct

type FunctionList

type FunctionList struct {
	Functions  []Function `json:"functions"`
	NextMarker int        `json:"next_marker"`
}

noinspection GoNameStartsWithPackageName

func ExtractList

func ExtractList(r pagination.Page) (FunctionList, error)

type FunctionPage

type FunctionPage struct {
	pagination.SinglePageBase
}

type FunctionVersion

type FunctionVersion struct {
	Id                 string        `json:"-"`
	FuncId             string        `json:"-"`
	Runtime            string        `json:"runtime"`
	Timeout            int           `json:"timeout"`
	Handler            string        `json:"handler"`
	MemorySize         int           `json:"memory_size"`
	Cpu                int           `json:"cpu"`
	CodeType           string        `json:"code_type"`
	CodeUrl            string        `json:"code_url"`
	CodeFileName       string        `json:"code_file_name"`
	CodeSize           int64         `json:"code_size"`
	UserData           string        `json:"user_data"`
	EncryptedUserData  string        `json:"encrypted_user_data"`
	ImageName          string        `json:"image_name"`
	Digest             string        `json:"digest"`
	Version            string        `json:"version"`
	Xrole              string        `json:"xrole"`
	AppXrole           string        `json:"app_xrole"`
	Description        string        `json:"description"`
	VersionDescription string        `json:"version_description"`
	LastModified       int64         `json:"last_modified"`
	Concurrency        int           `json:"concurrency"`
	ExtendConfig       string        `json:"extend_config"`
	Dependencies       []*Dependency `json:"dependencies"`
	FuncBase           *FunctionBase `json:"func_base"`
	FuncVpcId          string        `json:"-"`
	FuncMounts         []*FuncMount
	MountConfig        *MountConfig `json:"mount_config"`
	Vpc                *FuncVpc     `json:"vpc"`
	InitializerTimeout int
	InitializerHandler string `description:"the function initializer handler"`
}

noinspection GoNameStartsWithPackageName

type GetResult

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

func GetAlias

func GetAlias(c *golangsdk.ServiceClient, functionUrn, aliasName string) (r GetResult)

Querying the Alias Information of a Function Version

func GetCode

func GetCode(c *golangsdk.ServiceClient, functionUrn string) (r GetResult)

Querying the Code of a Function

func GetMetadata

func GetMetadata(c *golangsdk.ServiceClient, functionUrn string) (r GetResult)

Querying the Metadata Information of a Function

func (GetResult) Extract

func (r GetResult) Extract() (*Function, error)

func (GetResult) ExtractAlias

func (r GetResult) ExtractAlias() (*AliasResult, error)

func (GetResult) ExtractInvoke

func (r GetResult) ExtractInvoke() (interface{}, error)

type ListOpts

type ListOpts struct {
	Marker   string `q:"marker"`
	MaxItems string `q:"maxitems"`
}

functions list struct

func (ListOpts) ToMetricsListQuery

func (opts ListOpts) ToMetricsListQuery() (string, error)

type ListOptsBuilder

type ListOptsBuilder interface {
	ToMetricsListQuery() (string, error)
}

type MaxInstanceConfig

type MaxInstanceConfig struct {
	// The maximum number of instances of the function.
	Number *int `json:"max_instance_num,omitempty"`
}

MaxInstanceConfig is the structure used to update the max instance configuration for function.

type MountConfig

type MountConfig struct {
	MountUser  MountUser   `json:"mount_user" required:"true"`
	FuncMounts []FuncMount `json:"func_mounts" required:"true"`
}

type MountUser

type MountUser struct {
	UserId      int `json:"user_id" required:"true"`
	UserGroupId int `json:"user_group_id" required:"true"`
}

type StrategyConfig

type StrategyConfig struct {
	Concurrency *int `json:"concurrency"`
}

type TagsActionOpts

type TagsActionOpts struct {
	// The action name.
	Action string `json:"action,omitempty"`
	// Tag list.
	Tags []tags.ResourceTag `json:"tags,omitempty"`
	// System tag list.
	SysTags []tags.ResourceTag `json:"sys_tags,omitempty"`
}

TagsActionOpts is an structure that used to manage function tags.

type UpdateAliasOpts

type UpdateAliasOpts struct {
	Version     string `json:"version" required:"true"`
	Description string `json:"description,omitempty"`
}

Alias struct for update

func (UpdateAliasOpts) ToUpdateMap

func (opts UpdateAliasOpts) ToUpdateMap() (map[string]interface{}, error)

type UpdateCodeOpts

type UpdateCodeOpts struct {
	CodeType     string           `json:"code_type" required:"true"`
	CodeUrl      string           `json:"code_url,omitempty"`
	DependList   []string         `json:"depend_list,omitempty"`
	CodeFileName string           `json:"code_filename,omitempty"`
	FuncCode     FunctionCodeOpts `json:"func_code,omitempty"`
}

Function struct for update

func (UpdateCodeOpts) ToUpdateMap

func (opts UpdateCodeOpts) ToUpdateMap() (map[string]interface{}, error)

type UpdateMetadataOpts

type UpdateMetadataOpts struct {
	Handler            string       `json:"handler" required:"true"`
	MemorySize         int          `json:"memory_size" required:"true"`
	Timeout            int          `json:"timeout" required:"true"`
	Runtime            string       `json:"runtime" required:"true"`
	Package            string       `json:"package,omitempty"`
	FuncVpc            *FuncVpc     `json:"func_vpc,omitempty"`
	MountConfig        *MountConfig `json:"mount_config,omitempty"`
	CodeUrl            string       `json:"code_url,omitempty"`
	Description        string       `json:"description,omitempty"`
	UserData           string       `json:"user_data,omitempty"`
	EncryptedUserData  string       `json:"encrypted_user_data,omitempty"`
	Xrole              string       `json:"xrole,omitempty"`
	AppXrole           string       `json:"app_xrole,omitempty"`
	InitializerHandler string       `json:"initializer_handler,omitempty"`
	InitializerTimeout int          `json:"initializer_timeout,omitempty"`
	CustomImage        *CustomImage `json:"custom_image,omitempty"`
}

Metadata struct for update

func (UpdateMetadataOpts) ToUpdateMap

func (opts UpdateMetadataOpts) ToUpdateMap() (map[string]interface{}, error)

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToUpdateMap() (map[string]interface{}, error)
}

type UpdateResult

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

func UpdateAlias

func UpdateAlias(c *golangsdk.ServiceClient, functionUrn, aliasName string, opts UpdateOptsBuilder) (r UpdateResult)

Modifying the Alias Information of a Function Version

func UpdateCode

func UpdateCode(c *golangsdk.ServiceClient, functionUrn string, opts UpdateOptsBuilder) (r UpdateResult)

Modifying the Code of a Function

func UpdateMetadata

func UpdateMetadata(c *golangsdk.ServiceClient, functionUrn string, opts UpdateOptsBuilder) (r UpdateResult)

Modifying the Metadata Information of a Function

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Function, error)

func (UpdateResult) ExtractAlias

func (r UpdateResult) ExtractAlias() (*AliasResult, error)

func (UpdateResult) ExtractInvoke

func (r UpdateResult) ExtractInvoke() (interface{}, error)

type Versions

type Versions struct {
	Versions   []Function `json:"versions"`
	NextMarker int        `json:"next_marker"`
}

func ExtractVersionlist

func ExtractVersionlist(r pagination.Page) (Versions, error)

Jump to

Keyboard shortcuts

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