github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/opengauss/v3/instances/results.go (about) 1 package instances 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/golangsdk/pagination" 6 ) 7 8 type GaussDBResponse struct { 9 Id string `json:"id"` 10 Status string `json:"status"` 11 } 12 13 type CreateResponse struct { 14 Instance GaussDBResponse `json:"instance"` 15 OrderId string `json:"order_id"` 16 } 17 18 type ChargeInfoResp struct { 19 ChargeMode string `json:"charge_mode"` 20 } 21 22 type UpdateResponse struct { 23 JobId string `json:"job_id"` 24 OrderId string `json:"order_id"` 25 } 26 27 type GaussDBInstance struct { 28 Id string `json:"id"` 29 Name string `json:"name"` 30 Status string `json:"status"` 31 Type string `json:"type"` 32 Port int `json:"port"` 33 VpcId string `json:"vpc_id"` 34 SubnetId string `json:"subnet_id"` 35 SecurityGroupId string `json:"security_group_id"` 36 TimeZone string `json:"time_zone"` 37 Region string `json:"region"` 38 FlavorRef string `json:"flavor_ref"` 39 DbUserName string `json:"db_user_name"` 40 DiskEncryptionId string `json:"disk_encryption_id"` 41 DsspoolId string `json:"dsspool_id"` 42 SwitchStrategy string `json:"switch_strategy"` 43 MaintenanceWindow string `json:"maintenance_window"` 44 PublicIps []string `json:"public_ips"` 45 PrivateIps []string `json:"private_ips"` 46 ReplicaNum int `json:"replica_num"` 47 48 Volume VolumeOpt `json:"volume"` 49 Ha HaOpt `json:"ha"` 50 Nodes []Nodes `json:"nodes"` 51 DataStore DataStoreOpt `json:"datastore"` 52 BackupStrategy BackupStrategyOpt `json:"backup_strategy"` 53 ChargeInfo ChargeInfoResp `json:"charge_info"` 54 55 EnterpriseProjectId string `json:"enterprise_project_id"` 56 } 57 58 type Nodes struct { 59 Id string `json:"id"` 60 Name string `json:"name"` 61 Status string `json:"status"` 62 Role string `json:"role"` 63 AvailabilityZone string `json:"availability_zone"` 64 } 65 66 type commonResult struct { 67 golangsdk.Result 68 } 69 70 type CreateResult struct { 71 commonResult 72 } 73 74 type UpdateResult struct { 75 commonResult 76 } 77 78 func (r CreateResult) Extract() (*CreateResponse, error) { 79 var response CreateResponse 80 err := r.ExtractInto(&response) 81 return &response, err 82 } 83 84 type DeleteResult struct { 85 commonResult 86 } 87 88 type DeleteResponse struct { 89 JobId string `json:"job_id"` 90 } 91 92 func (r DeleteResult) Extract() (*DeleteResponse, error) { 93 var response DeleteResponse 94 err := r.ExtractInto(&response) 95 return &response, err 96 } 97 98 type ListGaussDBResult struct { 99 commonResult 100 } 101 102 type ListGaussDBResponse struct { 103 Instances []GaussDBInstance `json:"instances"` 104 TotalCount int `json:"total_count"` 105 } 106 107 type GaussDBPage struct { 108 pagination.SinglePageBase 109 } 110 111 func (r GaussDBPage) IsEmpty() (bool, error) { 112 data, err := ExtractGaussDBInstances(r) 113 if err != nil { 114 return false, err 115 } 116 return len(data.Instances) == 0, err 117 } 118 119 // ExtractGaussDBInstances is a function that takes a ListResult and returns the services' information. 120 func ExtractGaussDBInstances(r pagination.Page) (ListGaussDBResponse, error) { 121 var s ListGaussDBResponse 122 err := (r.(GaussDBPage)).ExtractInto(&s) 123 return s, err 124 } 125 126 type RenameResponse struct { 127 Instance GaussDBResponse `json:"instance"` 128 JobId string `json:"job_id"` 129 } 130 131 type RenameResult struct { 132 commonResult 133 } 134 135 func (r RenameResult) Extract() (*RenameResponse, error) { 136 var response RenameResponse 137 err := r.ExtractInto(&response) 138 return &response, err 139 }