github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/fgs/v2/reserved/Update.go (about) 1 package reserved 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 ) 8 9 type UpdateOpts struct { 10 FuncUrn string `json:"-"` 11 Count *int `json:"count" required:"true"` 12 IdleMode *bool `json:"idle_mode"` 13 TacticsConfig *TacticsConfig `json:"tactics_config"` 14 } 15 16 type TacticsConfig struct { 17 CronConfigs []CronConfig `json:"cron_configs"` 18 } 19 type CronConfig struct { 20 Name string `json:"name,omitempty"` 21 Cron string `json:"cron,omitempty"` 22 Count int `json:"count,omitempty"` 23 StartTime int `json:"start_time,omitempty"` 24 ExpiredTime int `json:"expired_time,omitempty"` 25 } 26 27 func Update(client *golangsdk.ServiceClient, opts UpdateOpts) (*FuncReservedRespUpdate, error) { 28 b, err := build.RequestBody(opts, "") 29 if err != nil { 30 return nil, err 31 } 32 33 raw, err := client.Put(client.ServiceURL("fgs", "functions", opts.FuncUrn, "reservedinstances"), b, nil, &golangsdk.RequestOpts{ 34 OkCodes: []int{200}, 35 }) 36 if err != nil { 37 return nil, err 38 } 39 40 var res FuncReservedRespUpdate 41 return &res, extract.Into(raw.Body, &res) 42 } 43 44 type FuncReservedRespUpdate struct { 45 TacticsConfig *TacticsConfig `json:"tactics_config"` 46 IdleMode bool `json:"idle_mode"` 47 Count int `json:"count"` 48 }