github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/geminidb/v3/instances/results.go (about) 1 package instances 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type DataStore struct { 9 Type string `json:"type" required:"true"` 10 Version string `json:"version" required:"true"` 11 StorageEngine string `json:"storage_engine" required:"true"` 12 } 13 14 type Flavor struct { 15 Num string `json:"num"` 16 Size string `json:"size"` 17 Storage string `json:"storage"` 18 SpecCode string `json:"spec_code"` 19 } 20 21 type BackupStrategy struct { 22 StartTime string `json:"start_time"` 23 KeepDays int `json:"keep_days"` 24 } 25 26 type GeminiDBBase struct { 27 Id string `json:"id"` 28 Name string `json:"name"` 29 Status string `json:"status"` 30 Region string `json:"region"` 31 Mode string `json:"mode"` 32 Created string `json:"-"` 33 VpcId string `json:"vpc_id"` 34 SubnetId string `json:"subnet_id"` 35 SecurityGroupId string `json:"security_group_id"` 36 DataStore DataStore `json:"datastore"` 37 38 EnterpriseProjectId string `json:"enterprise_project_id"` 39 } 40 41 type CreateResponse struct { 42 GeminiDBBase 43 JobId string `json:"job_id"` 44 AvailabilityZone string `json:"availability_zone"` 45 Flavor []Flavor `json:"flavor"` 46 BackupStrategy BackupStrategyOpt `json:"backup_strategy"` 47 } 48 49 type GeminiDBInstance struct { 50 GeminiDBBase 51 Port string `json:"port"` 52 Engine string `json:"engine"` 53 Updated string `json:"-"` 54 DbUserName string `json:"db_user_name"` 55 PayMode string `json:"pay_mode"` 56 TimeZone string `json:"time_zone"` 57 MaintenanceWindow string `json:"maintenance_window"` 58 Actions []string `json:"actions"` 59 Groups []Groups `json:"groups"` 60 BackupStrategy BackupStrategy `json:"backup_strategy"` 61 62 DedicatedResourceId string `json:"dedicated_resource_id"` 63 } 64 65 type Groups struct { 66 Id string `json:"id"` 67 Status string `json:"status"` 68 Volume Volume `json:"volume"` 69 Nodes []Nodes `json:"nodes"` 70 } 71 72 type Volume struct { 73 Size string `json:"size"` 74 Used string `json:"used"` 75 } 76 77 type Nodes struct { 78 Id string `json:"id"` 79 Name string `json:"name"` 80 Status string `json:"status"` 81 PrivateIp string `json:"private_ip"` 82 SpecCode string `json:"spec_code"` 83 AvailabilityZone string `json:"availability_zone"` 84 SupportReduce bool `json:"support_reduce"` 85 } 86 87 type commonResult struct { 88 golangsdk.Result 89 } 90 91 type CreateResult struct { 92 commonResult 93 } 94 95 func (r CreateResult) Extract() (*CreateResponse, error) { 96 var response CreateResponse 97 err := r.ExtractInto(&response) 98 return &response, err 99 } 100 101 type DeleteResult struct { 102 commonResult 103 } 104 105 type DeleteResponse struct { 106 JobId string `json:"job_id"` 107 } 108 109 func (r DeleteResult) Extract() (*DeleteResponse, error) { 110 var response DeleteResponse 111 err := r.ExtractInto(&response) 112 return &response, err 113 } 114 115 type ExtendResult struct { 116 commonResult 117 } 118 119 type ExtendResponse struct { 120 JobId string `json:"job_id"` 121 OrderId string `json:"order_id"` 122 } 123 124 func (r ExtendResult) Extract() (*ExtendResponse, error) { 125 var response ExtendResponse 126 err := r.ExtractInto(&response) 127 return &response, err 128 } 129 130 type UpdateResult struct { 131 golangsdk.ErrResult 132 } 133 134 type ListGeminiDBResult struct { 135 commonResult 136 } 137 138 type ListGeminiDBResponse struct { 139 Instances []GeminiDBInstance `json:"instances"` 140 TotalCount int `json:"total_count"` 141 } 142 143 type GeminiDBPage struct { 144 pagination.SinglePageBase 145 } 146 147 func (r GeminiDBPage) IsEmpty() (bool, error) { 148 data, err := ExtractGeminiDBInstances(r) 149 if err != nil { 150 return false, err 151 } 152 return len(data.Instances) == 0, err 153 } 154 155 // ExtractGeminiDBInstances is a function that takes a ListResult and returns the services' information. 156 func ExtractGeminiDBInstances(r pagination.Page) (ListGeminiDBResponse, error) { 157 var s ListGeminiDBResponse 158 err := (r.(GeminiDBPage)).ExtractInto(&s) 159 return s, err 160 } 161 162 type DehResource struct { 163 Id string `json:"id"` 164 ResourceName string `json:"resource_name"` 165 EngineName string `json:"engine_name"` 166 AvailabilityZone string `json:"availability_zone"` 167 Architecture string `json:"architecture"` 168 Status string `json:"status"` 169 Capacity Capacity `json:"capacity"` 170 } 171 172 type Capacity struct { 173 Vcpus int `json:"vcpus"` 174 Ram int `json:"ram"` 175 Volume int64 `json:"volume"` 176 } 177 178 type ListDehResponse struct { 179 Resources []DehResource `json:"resources"` 180 TotalCount int `json:"total_count"` 181 } 182 183 type DehResourcePage struct { 184 pagination.SinglePageBase 185 } 186 187 func ExtractDehResources(r pagination.Page) (ListDehResponse, error) { 188 var s ListDehResponse 189 err := (r.(DehResourcePage)).ExtractInto(&s) 190 return s, err 191 }