github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/fgs/v2/function/results.go (about)

     1  package function
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  type Function struct {
     9  	Id                  string         `json:"-"`
    10  	FuncId              string         `json:"-"`
    11  	FuncUrn             string         `json:"func_urn"`
    12  	FuncName            string         `json:"func_name"`
    13  	DomainId            string         `json:"domain_id"`
    14  	Namespace           string         `json:"namespace"`
    15  	ProjectName         string         `json:"project_name"`
    16  	Package             string         `json:"package"`
    17  	Runtime             string         `json:"runtime"`
    18  	Timeout             int            `json:"timeout"`
    19  	Handler             string         `json:"handler"`
    20  	MemorySize          int            `json:"memory_size"`
    21  	Cpu                 int            `json:"cpu"`
    22  	CodeType            string         `json:"code_type"`
    23  	CodeUrl             string         `json:"code_url"`
    24  	CodeFileName        string         `json:"code_filename"`
    25  	CodeSize            int64          `json:"code_size"`
    26  	UserData            string         `json:"user_data"`
    27  	Digest              string         `json:"digest"`
    28  	Version             string         `json:"version"`
    29  	ImageName           string         `json:"image_name"`
    30  	Xrole               string         `json:"xrole"`
    31  	AppXrole            string         `json:"app_xrole"`
    32  	Description         string         `json:"description"`
    33  	VersionDescription  string         `json:"version_description"`
    34  	LastmodifiedUtc     int64          `json:"-"`
    35  	LastModified        string         `json:"last_modified"`
    36  	FuncCode            FunctionCode   `json:"func_code"`
    37  	FuncVpc             FuncVpc        `json:"func_vpc"`
    38  	MountConfig         MountConfig    `json:"mount_config,omitempty"`
    39  	Concurrency         int            `json:"-"`
    40  	DependList          []string       `json:"depend_list"`
    41  	StrategyConfig      StrategyConfig `json:"strategy_config"`
    42  	ExtendConfig        string         `json:"extend_config"`
    43  	Dependencies        []*Dependency  `json:"dependencies"`
    44  	InitializerTimeout  int            `json:"initializer_timeout,omitempty"`
    45  	InitializerHandler  string         `json:"initializer_handler,omitempty"`
    46  	EnterpriseProjectID string         `json:"enterprise_project_id"`
    47  }
    48  
    49  type FuncMount struct {
    50  	Id             string             `json:"id,omitempty"`
    51  	MountType      string             `json:"mount_type" required:"true"`
    52  	MountResource  string             `json:"mount_resource" required:"true"`
    53  	MountSharePath string             `json:"mount_share_path" required:"true"`
    54  	LocalMountPath string             `json:"local_mount_path" required:"true" description:"local file path in function runtime environment"`
    55  	UserGroupId    *int               `json:"-"`
    56  	UserId         *int               `json:"-"`
    57  	Status         string             `json:"status,omitempty"` //ACTIVE或DISABLED,和触发器类似。如果已经存在的配置不可用了processrouter不会挂载。
    58  	ProjectId      string             `json:"-"`
    59  	FuncVersions   []*FunctionVersion `json:"-"`
    60  	SaveType       int                `json:"-"` //仅仅在数据处理时用到,如果需要保存新的映射关系,则将其置为1,如要删除老的,将其置为2
    61  }
    62  
    63  //noinspection GoNameStartsWithPackageName
    64  type FunctionVersion struct {
    65  	Id                 string        `json:"-"`
    66  	FuncId             string        `json:"-"`
    67  	Runtime            string        `json:"runtime"`
    68  	Timeout            int           `json:"timeout"`
    69  	Handler            string        `json:"handler"`
    70  	MemorySize         int           `json:"memory_size"`
    71  	Cpu                int           `json:"cpu"`
    72  	CodeType           string        `json:"code_type"`
    73  	CodeUrl            string        `json:"code_url"`
    74  	CodeFileName       string        `json:"code_file_name"`
    75  	CodeSize           int64         `json:"code_size"`
    76  	UserData           string        `json:"user_data"`
    77  	ImageName          string        `json:"image_name"`
    78  	Digest             string        `json:"digest"`
    79  	Version            string        `json:"version"`
    80  	Xrole              string        `json:"xrole"`
    81  	AppXrole           string        `json:"app_xrole"`
    82  	Description        string        `json:"description"`
    83  	VersionDescription string        `json:"version_description"`
    84  	LastModified       int64         `json:"last_modified"`
    85  	Concurrency        int           `json:"concurrency"`
    86  	ExtendConfig       string        `json:"extend_config"`
    87  	Dependencies       []*Dependency `json:"dependencies"`
    88  	FuncBase           *FunctionBase `json:"func_base"`
    89  	FuncVpcId          string        `json:"-"`
    90  	FuncMounts         []*FuncMount
    91  	MountConfig        *MountConfig `json:"mount_config"`
    92  	Vpc                *FuncVpc     `json:"vpc"`
    93  	InitializerTimeout int
    94  	InitializerHandler string `description:"the function initializer handler"`
    95  }
    96  
    97  // dependency
    98  type Dependency struct {
    99  	Id           string             `json:"id"`
   100  	Owner        string             `json:"owner"`
   101  	Namespace    string             `json:"-"`
   102  	Link         string             `json:"link"`
   103  	Runtime      string             `json:"runtime"`
   104  	ETag         string             `json:"etag"`
   105  	Size         int64              `json:"size"`
   106  	Name         string             `json:"name"`
   107  	Description  string             `json:"description"`
   108  	FileName     string             `json:"file_name,omitempty"`
   109  	FuncVersions []*FunctionVersion `json:"-"`
   110  	SaveType     int                `json:"-"`
   111  }
   112  
   113  type MountUser struct {
   114  	UserId      int `json:"user_id" required:"true"`
   115  	UserGroupId int `json:"user_group_id" required:"true"`
   116  }
   117  
   118  type MountConfig struct {
   119  	MountUser  MountUser   `json:"mount_user" required:"true"`
   120  	FuncMounts []FuncMount `json:"func_mounts" required:"true"`
   121  }
   122  
   123  //noinspection GoNameStartsWithPackageName
   124  type FunctionCode struct {
   125  	File string `json:"file"`
   126  	Link string `json:"link"`
   127  }
   128  
   129  //noinspection GoNameStartsWithPackageName
   130  type FunctionBase struct {
   131  	Id          string `json:"-"`
   132  	FuncName    string `json:"func_name"`
   133  	DomainId    string `description:"domain id"`
   134  	Namespace   string `json:"namespace"`
   135  	ProjectName string `json:"project_name"`
   136  	Package     string `json:"package"`
   137  }
   138  
   139  type FuncVpc struct {
   140  	Id         string `json:"-"`
   141  	DomainId   string `json:"-" validate:"regexp=^[a-zA-Z0-9-]+$" description:"domain id"`
   142  	Namespace  string `json:"-"`
   143  	VpcName    string `json:"vpc_name,omitempty"`
   144  	VpcId      string `json:"vpc_id,omitempty"`
   145  	SubnetName string `json:"subnet_name,omitempty"`
   146  	SubnetId   string `json:"subnet_id,omitempty"`
   147  	Cidr       string `json:"cidr,omitempty"`
   148  	Gateway    string `json:"gateway,omitempty"`
   149  }
   150  
   151  type StrategyConfig struct {
   152  	Concurrency *int `json:"concurrency"`
   153  }
   154  
   155  type commonResult struct {
   156  	golangsdk.Result
   157  }
   158  
   159  type GetResult struct {
   160  	commonResult
   161  }
   162  
   163  type CreateResult struct {
   164  	commonResult
   165  }
   166  
   167  type DeleteResult struct {
   168  	golangsdk.ErrResult
   169  }
   170  
   171  type UpdateResult struct {
   172  	commonResult
   173  }
   174  
   175  type FunctionPage struct {
   176  	pagination.SinglePageBase
   177  }
   178  
   179  func (r commonResult) Extract() (*Function, error) {
   180  	var f Function
   181  	err := r.ExtractInto(&f)
   182  	return &f, err
   183  }
   184  
   185  //noinspection GoNameStartsWithPackageName
   186  type FunctionList struct {
   187  	Functions  []Function `json:"functions"`
   188  	NextMarker int        `json:"next_marker"`
   189  }
   190  
   191  func ExtractList(r pagination.Page) (FunctionList, error) {
   192  	var s FunctionList
   193  	err := (r.(FunctionPage)).ExtractInto(&s)
   194  	return s, err
   195  }
   196  
   197  func (r commonResult) ExtractInvoke() (interface{}, error) {
   198  	return r.Body, r.Err
   199  }
   200  
   201  type Versions struct {
   202  	Versions   []Function `json:"versions"`
   203  	NextMarker int        `json:"next_marker"`
   204  }
   205  
   206  func ExtractVersionlist(r pagination.Page) (Versions, error) {
   207  	var s Versions
   208  	err := (r.(FunctionPage)).ExtractInto(&s)
   209  	return s, err
   210  }
   211  
   212  type AliasResult struct {
   213  	Name         string `json:"name"`
   214  	Version      string `json:"version"`
   215  	Description  string `json:"description"`
   216  	LastModified string `json:"last_modified"`
   217  	AliasUrn     string `json:"alias_urn"`
   218  }
   219  
   220  func (r commonResult) ExtractAlias() (*AliasResult, error) {
   221  	var s AliasResult
   222  	err := r.ExtractInto(&s)
   223  	return &s, err
   224  }
   225  
   226  func ExtractAliasList(r pagination.Page) ([]AliasResult, error) {
   227  	var s []AliasResult
   228  	err := (r.(FunctionPage)).ExtractInto(&s)
   229  	return s, err
   230  }