github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/apigw/dedicated/v2/instances/results.go (about) 1 package instances 2 3 import ( 4 "encoding/json" 5 6 "github.com/chnsz/golangsdk" 7 "github.com/chnsz/golangsdk/pagination" 8 ) 9 10 type commonResult struct { 11 golangsdk.Result 12 } 13 14 // GetResult represents the result of a create operation. 15 type CreateResult struct { 16 commonResult 17 } 18 19 type CreateResp struct { 20 Id string `json:"instance_id"` 21 Message string `json:"message"` 22 } 23 24 // Call its Extract method to interpret it as a Instance Id. 25 func (r CreateResult) Extract() (*CreateResp, error) { 26 var s CreateResp 27 err := r.ExtractInto(&s) 28 return &s, err 29 } 30 31 // GetResult represents the result of a Get operation. 32 type GetResult struct { 33 commonResult 34 } 35 36 // UpdateResult represents the result of a Update operation. 37 type UpdateResult struct { 38 commonResult 39 } 40 41 type Instance struct { 42 // Instance ID. 43 Id string `json:"id"` 44 // Project ID. 45 ProjectId string `json:"project_id"` 46 // Instance name. 47 Name string `json:"instance_name"` 48 // Instance status. The value are as following: 49 // Creating, CreateSuccess, CreateFail, Initing, Registering, Running, InitingFailed, RegisterFailed, Installing 50 // InstallFailed, Updating, UpdateFailed, Rollbacking, RollbackSuccess, RollbackFailed, Deleting, DeleteFailed 51 // Unregistering, UnRegisterFailed, CreateTimeout, InitTimeout, RegisterTimeout, InstallTimeout, UpdateTimeout 52 // RollbackTimeout, DeleteTimeout, UnregisterTimeout, Starting, Freezing, Frozen, Restarting, RestartFail 53 // Unhealthy, RestartTimeout 54 // The status 'Deleting' is not supported, it's a BUG. --2021/06/15 55 Status string `json:"status"` 56 // Instance status ID. 57 // 1:Creating, 2:CreateSuccess, 3:CreateFail, 4:Initing, 5:Registering, 6:Running, 7:InitingFailed 58 // 8:RegisterFailed, 10:Installing, 11:InstallFailed, 12:Updating, 13:UpdateFailed, 20:Rollbacking 59 // 21:RollbackSuccess, 22:RollbackFailed, 23:Deleting, 24:DeleteFailed, 25:Unregistering, 26:UnRegisterFailed 60 // 27:CreateTimeout, 28:InitTimeout, 29:RegisterTimeout, 30:InstallTimeout, 31:UpdateTimeout 61 // 32:RollbackTimeout, 33:DeleteTimeout, 34:UnregisterTimeout, 35:Starting, 36:Freezing, 37:Frozen, 38:Restarting 62 // 39:RestartFail, 40:Unhealthy, 41:RestartTimeout 63 // Ditto: Issue of status id 23 (Deleting). --2021/06/15 64 StatusId int `json:"instance_status"` 65 // Instance type. 66 Type string `json:"type"` 67 // Instance edition. 68 Edition string `json:"spec"` 69 // Time when the APIG dedicated instance is created, in Unix timestamp format. 70 CreateTimestamp int64 `json:"create_time"` 71 // Enterprise project ID. 72 EnterpriseProjectId string `json:"enterprise_project_id"` 73 // Billing mode of the APIG dedicated instance. 74 // 0:Pay per use 75 // 1:Pay per use 76 ChargeMode int `json:"charging_mode"` 77 // Yearly/Monthly subscription order ID. 78 CbcMetadata string `json:"cbc_metadata"` 79 // The type of load balancer used by the instance. 80 // The valid values are as follows: 81 // + lvs: Linux virtual server 82 // + elb: Elastic load balance 83 LoadbalancerProvider string `json:"loadbalancer_provider"` 84 // The operation locks of the CBC serivce. 85 CbcOperationLocks []CbcOperationLock `json:"cbc_operation_locks"` 86 // Description about the APIG dedicated instance. 87 Description string `json:"description"` 88 // VPC ID. 89 VpcId string `json:"vpc_id"` 90 // Subnet network ID. 91 SubnetId string `json:"subnet_id"` 92 // ID of the security group to which the APIG dedicated instance belongs to. 93 SecurityGroupId string `json:"security_group_id"` 94 // Start time of the maintenance time window in the format "xx:00:00". 95 MaintainBegin string `json:"maintain_begin"` 96 // End time of the maintenance time window in the format "xx:00:00". 97 MaintainEnd string `json:"maintain_end"` 98 // VPC ingress private address. 99 Ipv4VpcIngressAddress string `json:"ingress_ip"` 100 // VPC ingress private address (IPv6). 101 Ipv6VpcIngressAddress string `json:"ingress_ip_v6"` 102 // ID of the account to which the APIG dedicated instance belongs. 103 UserId string `json:"user_id"` 104 // EIP bound to the APIG dedicated instance. 105 Ipv4IngressEipAddress string `json:"eip_address"` 106 // EIP (IPv6). 107 Ipv6IngressEipAddress string `json:"eip_ipv6_address"` 108 // Public egress address (IPv6). 109 Ipv6EgressCidr string `json:"nat_eip_ipv6_cidr"` 110 // IP address for public outbound access. 111 Ipv4EgressAddress string `json:"nat_eip_address"` 112 // Outbound access bandwidth. 113 BandwidthSize int `json:"bandwidth_size"` 114 // Billing type of the public inbound access bandwidth. 115 BandwidthChargingMode string `json:"bandwidth_charging_mode"` 116 // AZs. 117 AvailableZoneIds string `json:"available_zone_ids"` 118 // Instance version. 119 Version string `json:"instance_version"` 120 // Supported features. 121 SupportedFeatures []string `json:"supported_features"` 122 // THe list of endpoint service. 123 EndpointServices []EndpointService `json:"endpoint_services"` 124 // The IP of the serivce node. 125 NodeIp NodeIp `json:"node_ips"` 126 // The ingress address list of public network. 127 PublicIps []IpDetail `json:"publicips"` 128 // The ingress address list of private network. 129 PrivateIps []IpDetail `json:"privateips"` 130 // Whether the gateway can be released. 131 // + true: The gateway can be released. 132 // + false: The gateway cannot be released. 133 IsReleasable bool `json:"is_releasable"` 134 // Billing mode of the public inbound access bandwidth. 135 IngressBandwidthChargingMode string `json:"ingress_bandwidth_charging_mode"` 136 } 137 138 // CbcOperationLock is the structure that represents the restricted operation lock for CBC service. 139 type CbcOperationLock struct { 140 // Restricted operation scenarios: 141 // + TO_PERIOD_LOCK: On-demand subcontracting period scene lock, which does not allow deletion, specification 142 // changes, on-demand subcontracting periods, etc. 143 // + SPEC_CHG_LOCK: Package cycle specification change scene lock, which does not allow deletion, specification 144 // change, etc. 145 LockScene string `json:"lock_scene"` 146 // The ID of the object that initiated the restriction operation. 147 LockSourceId string `json:"lock_source_id"` 148 } 149 150 type EndpointService struct { 151 // The service name of the endpoint node. 152 ServiceName string `json:"service_name"` 153 // The create time of the endpoint node. 154 CreatedAt string `json:"created_at"` 155 } 156 157 type NodeIp struct { 158 // The IP address list of the livedata node. 159 LiveData []string `json:"livedata"` 160 // The IP address list of the shubao node. 161 Shubao []string `json:"shubao"` 162 } 163 164 type IpDetail struct { 165 // IP address. 166 IpAddress string `json:"ip_address"` 167 // Bandwidth size. 168 BandwidthSize int `json:"bandwidth_size"` 169 } 170 171 // Call its Extract method to interpret it as a Instance. 172 func (r commonResult) Extract() (*Instance, error) { 173 var s Instance 174 err := r.ExtractInto(&s) 175 return &s, err 176 } 177 178 type BaseInstance struct { 179 // Instance ID. 180 Id string `json:"id"` 181 // Project ID 182 ProjectId string `json:"project_id"` 183 // Instance name. 184 Name string `json:"instance_name"` 185 // Instance status. The value are as following: 186 // Creating, CreateSuccess, CreateFail, Initing, Registering, Running, InitingFailed, RegisterFailed, Installing 187 // InstallFailed, Updating, UpdateFailed, Rollbacking, RollbackSuccess, RollbackFailed, Deleting, DeleteFailed 188 // Unregistering, UnRegisterFailed, CreateTimeout, InitTimeout, RegisterTimeout, InstallTimeout, UpdateTimeout 189 // RollbackTimeout, DeleteTimeout, UnregisterTimeout, Starting, Freezing, Frozen, Restarting, RestartFail 190 // Unhealthy, RestartTimeout 191 // Ditto: Issue of status 'Deleting'. --2021/06/15 192 Status string `json:"status"` 193 // Instance status ID. 194 // 1:Creating, 2:CreateSuccess, 3:CreateFail, 4:Initing, 5:Registering, 6:Running, 7:InitingFailed 195 // 8:RegisterFailed, 10:Installing, 11:InstallFailed, 12:Updating, 13:UpdateFailed, 20:Rollbacking 196 // 21:RollbackSuccess, 22:RollbackFailed, 23:Deleting, 24:DeleteFailed, 25:Unregistering, 26:UnRegisterFailed 197 // 27:CreateTimeout, 28:InitTimeout, 29:RegisterTimeout, 30:InstallTimeout, 31:UpdateTimeout 198 // 32:RollbackTimeout, 33:DeleteTimeout, 34:UnregisterTimeout, 35:Starting, 36:Freezing, 37:Frozen, 38:Restarting 199 // 39:RestartFail, 40:Unhealthy, 41:RestartTimeout 200 // Ditto: Issue of status id 23 (Deleting). --2021/06/15 201 StatusId int `json:"instance_status"` 202 // Instance type. 203 Type string `json:"type"` 204 // Instance edition. 205 Edition string `json:"spec"` 206 // Time when the APIG dedicated instance is created, in Unix timestamp format. 207 CreateTimestamp int64 `json:"create_time"` 208 // Enterprise project ID. 209 EnterpriseProjectId string `json:"enterprise_project_id"` 210 // EIP bound to the APIG dedicated instance. 211 Ipv4Address string `json:"eip_address"` 212 // Billing mode of the APIG dedicated instance. 213 // 0:Pay per use 214 // 1:Pay per use 215 ChargeMode int `json:"charging_mode"` 216 // Yearly/Monthly subscription order ID. 217 CbcMetadata string `json:"cbc_metadata"` 218 } 219 220 // InstancePage represents the result of a List operation. 221 type InstancePage struct { 222 pagination.SinglePageBase 223 } 224 225 // Call its Extract method to interpret it as a BaseInstance array. 226 func ExtractInstances(r pagination.Page) ([]BaseInstance, error) { 227 var s []BaseInstance 228 err := r.(InstancePage).Result.ExtractIntoSlicePtr(&s, "instances") 229 return s, err 230 } 231 232 // DeleteResult represents the result of a Delete operation. 233 type DeleteResult struct { 234 golangsdk.ErrResult 235 } 236 237 // EnableEgressResult represents the result of a EnableEgressAccess operation. 238 type EnableEgressResult struct { 239 golangsdk.Result 240 } 241 242 // UdpateEgressResult represents the result of a UpdateEgressBandwidth operation. 243 type UdpateEgressResult struct { 244 golangsdk.Result 245 } 246 247 type EgressResult struct { 248 golangsdk.Result 249 } 250 251 type Egress struct { 252 Id string `json:"id"` 253 CloudEipId string `json:"cloudEipId"` 254 CloudEipAddress string `json:"cloudEipAddress"` 255 InstanceId string `json:"instanceId"` 256 CloudBandwidthId string `json:"cloudBandwidthId"` 257 BandwidthName string `json:"bandwidthName"` 258 BandwidthSize int `json:"bandwidthSize"` 259 } 260 261 // Extract is a method to interpret the response body or json string as an Egress. 262 func (r UdpateEgressResult) Extract() (*Egress, error) { 263 var s Egress 264 if r.Err != nil { 265 return &s, r.Err 266 } 267 body, ok := r.Body.(string) 268 if ok { 269 err := json.Unmarshal([]byte(body), &s) 270 return &s, err 271 } 272 err := r.ExtractInto(&s) 273 return &s, err 274 } 275 276 // Extract is a method to interpret the response body as an Egress. 277 func (r EnableEgressResult) Extract() (*Egress, error) { 278 var s Egress 279 err := r.ExtractInto(&s) 280 return &s, err 281 } 282 283 // DisableEgressResult represents the result of a DisableEgressAccess operation. 284 type DisableEgressResult struct { 285 golangsdk.ErrResult 286 } 287 288 // EnableIngressResult represents the result of a EnableIngressAccess operation. 289 type EnableIngressResult struct { 290 commonResult 291 } 292 293 type Ingress struct { 294 Id string `json:"eip_id"` 295 EipAddress string `json:"eip_address"` 296 Status string `json:"eip_status"` 297 Ipv6Address string `json:"eip_ipv6_address"` 298 } 299 300 // Call its Extract method to interpret it as a Ingress. 301 func (r EnableIngressResult) Extract() (*Ingress, error) { 302 var s Ingress 303 err := r.ExtractInto(&s) 304 return &s, err 305 } 306 307 // DisableIngressResult represents the result of a DisableIngressAccess operation. 308 type DisableIngressResult struct { 309 golangsdk.ErrResult 310 } 311 312 // Feature represents the result of a feature configuration. 313 type Feature struct { 314 // Feature ID. 315 ID string `json:"id"` 316 // Feature name. 317 Name string `json:"name"` 318 // Whether to enable the feature. 319 Enable bool `json:"enable"` 320 // Parameter configuration. 321 Config string `json:"config"` 322 // Dedicated APIG instance ID. 323 InstanceId string `json:"instance_id"` 324 // Feature update time. 325 UpdatedAt string `json:"update_time"` 326 } 327 328 // FeaturePage is a single page maximum result representing a query by offset page. 329 type FeaturePage struct { 330 pagination.OffsetPageBase 331 } 332 333 // IsEmpty checks whether a FeaturePage struct is empty. 334 func (b FeaturePage) IsEmpty() (bool, error) { 335 arr, err := ExtractFeatures(b) 336 return len(arr) == 0, err 337 } 338 339 // ExtractFeatures is a method to extract the list of feature configuration details for APIG instance. 340 func ExtractFeatures(r pagination.Page) ([]Feature, error) { 341 var s []Feature 342 err := r.(FeaturePage).Result.ExtractIntoSlicePtr(&s, "features") 343 return s, err 344 } 345 346 type EnableElbIngressResp struct { 347 // ID of the APIG dedicated instance. 348 Instance_id string `json:"instance_id"` 349 // Task information of binding the ingress EIP. 350 Message string `json:"message"` 351 // Job ID of binding the ingress EIP. 352 JobId string `json:"job_id"` 353 }