github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/autoscaling/v1/configurations/results.go (about) 1 package configurations 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 //CreateResult is a struct that contains all the return parameters of creation 9 type CreateResult struct { 10 golangsdk.Result 11 } 12 13 func (r CreateResult) Extract() (string, error) { 14 var a struct { 15 ID string `json:"scaling_configuration_id"` 16 } 17 18 err := r.Result.ExtractInto(&a) 19 return a.ID, err 20 } 21 22 type GetResult struct { 23 golangsdk.Result 24 } 25 26 func (r GetResult) Extract() (Configuration, error) { 27 var a Configuration 28 err := r.Result.ExtractIntoStructPtr(&a, "scaling_configuration") 29 return a, err 30 } 31 32 type Configuration struct { 33 ID string `json:"scaling_configuration_id"` 34 Tenant string `json:"tenant"` 35 Name string `json:"scaling_configuration_name"` 36 InstanceConfig InstanceConfig `json:"instance_config"` 37 CreateTime string `json:"create_time"` 38 } 39 40 type InstanceConfig struct { 41 FlavorRef string `json:"flavorRef"` 42 ImageRef string `json:"imageRef"` 43 Disk []Disk `json:"disk"` 44 SSHKey string `json:"key_name"` 45 InstanceName string `json:"instance_name"` 46 InstanceID string `json:"instance_id"` 47 AdminPass string `json:"adminPass"` 48 Personality []Personality `json:"personality"` 49 PublicIp PublicIp `json:"public_ip"` 50 UserData string `json:"user_data"` 51 Metadata map[string]interface{} `json:"metadata"` 52 } 53 54 type Disk struct { 55 Size int `json:"size"` 56 VolumeType string `json:"volume_type"` 57 DiskType string `json:"disk_type"` 58 } 59 60 type Personality struct { 61 Path string `json:"path"` 62 Content string `json:"content"` 63 } 64 65 type PublicIp struct { 66 Eip Eip `json:"eip"` 67 } 68 69 type Eip struct { 70 Type string `json:"ip_type"` 71 Bandwidth Bandwidth `json:"bandwidth"` 72 } 73 74 type Bandwidth struct { 75 Size int `json:"size"` 76 ShareType string `json:"share_type"` 77 ChargingMode string `json:"charging_mode"` 78 } 79 80 type DeleteResult struct { 81 golangsdk.ErrResult 82 } 83 84 type ConfigurationPage struct { 85 pagination.SinglePageBase 86 } 87 88 // IsEmpty returns true if a ListResult contains no Volumes. 89 func (r ConfigurationPage) IsEmpty() (bool, error) { 90 configs, err := r.Extract() 91 return len(configs) == 0, err 92 } 93 94 func (r ConfigurationPage) Extract() ([]Configuration, error) { 95 var cs []Configuration 96 err := r.Result.ExtractIntoSlicePtr(&cs, "scaling_groups") 97 return cs, err 98 }