github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/workspace/v2/desktops/results.go (about) 1 package desktops 2 3 import ( 4 "github.com/chnsz/golangsdk/openstack/common/tags" 5 "github.com/chnsz/golangsdk/pagination" 6 ) 7 8 // RequestResp is the structure that represents the API response of desktop methods request. 9 type RequestResp struct { 10 // Job ID. 11 JobId string `json:"job_id"` 12 } 13 14 // RequestResp is the structure that represents the API response of Create method request. 15 type CreateResp struct { 16 RequestResp 17 } 18 19 // NewVolumesResp is the structure that represents the API response of NewVolumes method request. 20 type NewVolumesResp struct { 21 RequestResp 22 } 23 24 // ExpandVolumesResp is the structure that represents the API response of ExpandVolumes method request. 25 type ExpandVolumesResp struct { 26 RequestResp 27 } 28 29 // UpdateResp is the structure that represents the API response of UpdateProduct method request. 30 type UpdateResp struct { 31 // Job list. 32 Jobs []Job `json:"jobs"` 33 } 34 35 // Job is an object to specified the operation detail of desktop. 36 type Job struct { 37 // Desktop ID. 38 DesktopId string `json:"desktop_id"` 39 // Job ID. 40 ID string `json:"job_id"` 41 } 42 43 // GetResp is the structure that represents the API response of Get method request. 44 type GetResp struct { 45 // Desktop details. 46 Desktop Desktop `json:"desktop"` 47 } 48 49 // Desktop is the structure that represents the desktop detail. 50 type Desktop struct { 51 // Desktop ID. 52 ID string `json:"desktop_id"` 53 // Desktop name. 54 Name string `json:"computer_name"` 55 // IP address list of desktop. 56 Addresses map[string][]AddressInfo `json:"addresses"` 57 // IP address list. 58 IpAddresses []string `json:"ip_addresses"` 59 // Desktop type. 60 Type string `json:"desktop_type"` 61 // Desktop metadata. 62 // + charging_mode: charging information, 1 means prePaid, 0 means postPaid. 63 // + image_name: image name. 64 // + metering.image_id: image ID. 65 // + metering.resourcespeccode: resource specification code. 66 // + metering.resourcetype: resource type. 67 // + os_bit: operation system bit: 32 or 64. 68 // + os_type: operation system type. 69 // + desktop_os_version: operation system version. 70 Metadata map[string]string `json:"metadata"` 71 // Product information. 72 Flavor FlavorInfo `json:"flavor"` 73 // Desktop status. 74 Status string `json:"status"` 75 // Task status of desktop. 76 // + scheduling: Creating and scheduling. 77 // + block_device_mapping: In the process of being created, the disk is being prepared. 78 // + networking: Creating, preparing for networking. 79 // + spawning: Creating, creating internally. 80 // + rebooting: rebooting. 81 // + reboot_pending: Rebooting, the reboot is being issued. 82 // + reboot_started: Rebooting, start internal reboot. 83 // + rebooting_hard: Forced rebooting. 84 // + reboot_pending_hard: A reboot is being issued during a forced reboot. 85 // + reboot_started_hard: During a forced reboot, the internal reboot is started. 86 // + rebuilding: rebuilding. 87 // + rebuild_block_device_mapping: Rebuilding, preparing disk. 88 // + rebuild_spawning: Rebuilding, rebuilding internally. 89 // + migrating: Live migration is in progress. 90 // + resize_prep: The specification is being adjusted and is in the preparation stage. 91 // + resize_migrating: Adjusting the specification, in the migrating stage. 92 // + resize_migrated: In adjusting the specification, the migration has been completed. 93 // + resize_finish: Resize specification, resize is being completed. 94 // + resize_reverting: In the resize specification, the resize is being rolled back. 95 // + powering-off: Stopping. 96 // + powering-on: Starting. 97 // + deleting: Deleting. 98 // + deleteFailed: Delete failed. 99 TaskStatus string `json:"task_status"` 100 // The time that the desktop was created. 101 CreatedAt string `json:"created"` 102 // Configuration of security groups 103 SecurityGroups []SecurityGroup `json:"security_groups"` 104 // The login status of the desktop. 105 // + UNREGISTER: Indicates the state when the desktop is not registered (after the desktop is started, it will be 106 // automatically registered). The unregistered state also appears after shutdown. 107 // + REGISTERED: After the desktop is registered, it is waiting for the user to connect. 108 // + CONNECTED: Indicates that the user has successfully logged in and is using the desktop. 109 // + DISCONNECTED: Indicates the state displayed after the session is disconnected from the desktop and the client, 110 // which may be caused by closing the client window or disconnecting the client from the desktop network. 111 LoginStatus string `json:"login_status"` 112 // User name. 113 UserName string `json:"user_name"` 114 // Product ID. 115 ProductId string `json:"product_id"` 116 // Configuration of root volume. 117 RootVolume VolumeResp `json:"root_volume"` 118 // Configuration of data volumes. 119 DataVolumes []VolumeResp `json:"data_volumes"` 120 // User group. 121 UserGroup string `json:"user_group"` 122 // Availability zone where the desktop is located. 123 AvailabilityZone string `json:"availability_zone"` 124 // Product information. 125 Product ProductInfo `json:"product"` 126 // OU name. 127 OuName string `json:"ou_name"` 128 // OS version. 129 OsVersion string `json:"os_version"` 130 // SID. 131 SID string `json:"sid"` 132 // Order ID. 133 OrderId string `json:"order_id"` 134 // The key/value pairs of the desktop. 135 Tags []tags.ResourceTag `json:"tags"` 136 // EnterpriseProject ID of desktop 137 EnterpriseProjectId string `json:"enterprise_project_id"` 138 } 139 140 // AddressInfo is an object to specified the IP address details of desktop. 141 type AddressInfo struct { 142 // IP address. 143 Address string `json:"addr"` 144 // IP address version. 145 // + 4: IPv4 146 // + 6: IPv6 147 Version string `json:"version"` 148 // MAC address. 149 MacAddress string `json:"OS-EXT-IPS-MAC:mac_addr"` 150 // IP address allocation method. 151 // + fixed private IP address. 152 // + floating Floating IP address. 153 Type string `json:"OS-EXT-IPS:type"` 154 } 155 156 // FlavorInfo is an object to specified the flavor details of desktop. 157 type FlavorInfo struct { 158 // Flavor ID. 159 ID string `json:"id"` 160 // Shortcut link information of relevant tags for the corresponding specifications of the desktop. 161 Links []FlavorLinkInfo `json:"links"` 162 } 163 164 // FlavorLinkInfo is an object to specified the shortcut link information. 165 type FlavorLinkInfo struct { 166 // Name of the shortcut link. 167 Rel string `json:"rel"` 168 // Address of the shortcut link. 169 Hrel string `json:"hrel"` 170 } 171 172 // VolumeResp is an object to specified the volume details of root volume or data volume. 173 type VolumeResp struct { 174 // Volume type. 175 Type string `json:"type"` 176 // Volume size. 177 Size int `json:"size"` 178 // The device name to which the volume is attached. 179 Device string `json:"device"` 180 // Unique ID of volume map. 181 ID string `json:"id"` 182 // volume ID. 183 VolumeId string `json:"volume_id"` 184 // The time that the volume was created. 185 CreatedAt string `json:"create_time"` 186 // Volume name. 187 Name string `json:"display_name"` 188 } 189 190 // ProductInfo is an object to specified the product details. 191 type ProductInfo struct { 192 // Product ID. 193 ID string `json:"product_id"` 194 // Flavor ID. 195 FlavorId string `json:"flavor_id"` 196 // Product type. 197 Type string `json:"type"` 198 // CPU number. 199 CPU string `json:"cpu"` 200 // Memory size. 201 Memory string `json:"memory"` 202 // Product description. 203 Description string `json:"description"` 204 // Charging info. 205 ChargingMode string `json:"charge_mode"` 206 } 207 208 // RebuildResp is the structure that represents the response of the Rebuild method. 209 type RebuildResp struct { 210 // Job ID. 211 JobId string `json:"job_id"` 212 // Error Code. 213 ErrorCode string `json:"error_code"` 214 // Error message. 215 ErrorMsg string `json:"error_msg"` 216 } 217 218 // EipPage is a single page maximum result representing a query by offset page. 219 type EipPage struct { 220 pagination.OffsetPageBase 221 } 222 223 // EipResp is the structure that represents the bind information between EIP and desktop. 224 type EipResp struct { 225 // EIP ID. 226 ID string `json:"id"` 227 // + bandwidth: billed by bandwidth 228 // + traffic: billed by traffic 229 // Defaults to bandwidth. 230 ChargeMode string `json:"eip_charge_mode"` 231 // address of EIP 232 Address string `json:"address"` 233 // bandwidth size of EIP 234 BandWidthSize int `json:"bandwidth_size"` 235 // creation time, in UTC format: yyyy-MM-ddTHH:mm:ss. 236 CreateAt string `json:"create_time"` 237 // Desktop id of binded. 238 AttachedDesktopId string `json:"attached_desktop_id"` 239 // Desktop name of binded. 240 AttachedDesktopName string `json:"attached_desktop_name"` 241 // EnterpriseProject ID of desktop 242 EnterpriseProjectId string `json:"enterprise_project_id"` 243 } 244 245 // ExtractEips is a method to extract the list of EIP information. 246 func ExtractEips(r pagination.Page) ([]EipResp, error) { 247 var s []EipResp 248 err := r.(EipPage).Result.ExtractIntoSlicePtr(&s, "eips") 249 return s, err 250 } 251 252 // NetworkResp is the structure that represents the queried desktop network detail. 253 type NetworkResp struct { 254 // Desktop name. 255 Name string `json:"computer_name"` 256 // Desktop id. 257 DesktopId string `json:"computer_id"` 258 // Error message. 259 Network []NetworkInfos `json:"network_infos"` 260 } 261 262 // NetworkInfos is the structure that represents the desktop network details. 263 type NetworkInfos struct { 264 // Configured VPC information. 265 Vpc VpcInfo `json:"vpc_info"` 266 // Configured subnet information. 267 Subnet SubnetInfo `json:"subnet_info"` 268 // Configured port information. 269 PortInfo PortObject `json:"port_info"` 270 // Configured Elastic IP information. 271 PublicIp PublicIpInfo `json:"public_ip_info"` 272 // Configured security groups information. 273 SecurityGroups []SecurityGroup `json:"security_groups"` 274 } 275 276 // VpcInfo is an object to specified the VPC detail of desktop. 277 type VpcInfo struct { 278 // The VPC ID to which the desktop belongs. 279 ID string `json:"id"` 280 // The VPC name to which the desktop belongs. 281 Name string `json:"name"` 282 // The VPC segment to which the desktop belongs. 283 Cidr string `json:"cidr"` 284 } 285 286 // SubnetInfo is an object to specified the subnet detail of desktop. 287 type SubnetInfo struct { 288 // The subnet ID to which the desktop belongs. 289 ID string `json:"id"` 290 // The subnet name to which the desktop belongs. 291 Name string `json:"name"` 292 // The subnet segment to which the desktop belongs. 293 Cidr string `json:"cidr"` 294 } 295 296 // PortObject is an object to specified the private IP detail of desktop. 297 type PortObject struct { 298 // ID of Private ip . 299 ID string `json:"id"` 300 // Address of Private ip. 301 Address string `json:"ip_address"` 302 } 303 304 // PublicIpInfo is an object to specified the elastic IP detail of desktop. 305 type PublicIpInfo struct { 306 // ID of elastic IP. 307 ID string `json:"id"` 308 // Address of elastic IP. 309 Address string `json:"public_ip_address"` 310 } 311 312 // UpdateNetworkResp is the structure that represents the response of the update network infomation method. 313 type UpdateNetworkResp struct { 314 // Job ID. 315 JobId string `json:"job_id"` 316 // Error Code. 317 ErrorCode string `json:"error_code"` 318 // Error message. 319 ErrorMsg string `json:"error_msg"` 320 } 321 322 // ActionResp is the structure that represents the response of the DoAction method. 323 type ActionResp struct { 324 // Job ID. 325 JobId string `json:"job_id"` 326 // The desktops list of the operation failed. 327 FailedOperationList []FailedOperationList `json:"failed_operation_list"` 328 } 329 330 // FailedOperationList is the structure that represents the desktops list of the operation failed. 331 type FailedOperationList struct { 332 // Desktop ID. 333 DesktopId string `json:"desktop_id"` 334 // Desktop name. 335 DesktopName string `json:"desktop_name"` 336 // Error Code. 337 ErrorCode string `json:"error_code"` 338 // Error message. 339 ErrorMsg string `json:"error_msg"` 340 }