geo_input.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package compute
  15. import (
  16. "yunion.io/x/onecloud/pkg/apis"
  17. )
  18. type CloudregionResourceListInput struct {
  19. // 区域名称或ID
  20. CloudregionId []string `json:"cloudregion_id"`
  21. // swagger:ignore
  22. // Deprecated
  23. // description: this param will be deprecate at 3.0
  24. Cloudregion string `json:"cloudregion" yunion-deprecated-by:"cloudregion_id"`
  25. // swagger:ignore
  26. // Deprecated
  27. // description: this param will be deprecate at 3.0
  28. Region string `json:"region" yunion-deprecated-by:"cloudregion_id"`
  29. // swagger:ignore
  30. // Deprecated
  31. // description: this param will be deprecate at 3.0
  32. RegionId string `json:"region_id" yunion-deprecated-by:"cloudregion_id"`
  33. }
  34. type CloudregionResourceInput struct {
  35. // 区域名称或ID
  36. CloudregionId string `json:"cloudregion_id"`
  37. // swagger:ignore
  38. // Deprecated
  39. // description: this param will be deprecate at 3.0
  40. Cloudregion string `json:"cloudregion" yunion-deprecated-by:"cloudregion_id"`
  41. // swagger:ignore
  42. // Deprecated
  43. // description: this param will be deprecate at 3.0
  44. Region string `json:"region" yunion-deprecated-by:"cloudregion_id"`
  45. // swagger:ignore
  46. // Deprecated
  47. // description: this param will be deprecate at 3.0
  48. RegionId string `json:"region_id" yunion-deprecated-by:"cloudregion_id"`
  49. }
  50. type RegionalFilterListInput struct {
  51. // 过滤位于指定城市区域的资源
  52. City string `json:"city"`
  53. CloudregionResourceListInput
  54. // 按区域名称过滤
  55. OrderByRegion string `json:"order_by_region"`
  56. // 按城市过滤
  57. OrderByCity string `json:"order_by_city"`
  58. }
  59. type ZonalFilterListInput struct {
  60. RegionalFilterListInput
  61. ZonalFilterListBase
  62. }
  63. type ZonalFilterListBase struct {
  64. ZoneResourceInput
  65. // 过滤处于多个指定可用区内的资源
  66. ZoneIds []string `json:"zone_ids"`
  67. // Deprecated
  68. // swagger:ignore
  69. Zones []string `json:"zones" yunion-deprecated-by:"zone_ids"`
  70. // 按可用区名称排序
  71. // pattern:asc|desc
  72. OrderByZone string `json:"order_by_zone"`
  73. }
  74. func (input ZonalFilterListBase) ZoneList() []string {
  75. zones := make([]string, 0)
  76. if len(input.ZoneIds) > 0 {
  77. zones = append(zones, input.ZoneIds...)
  78. }
  79. if len(input.ZoneId) > 0 {
  80. zones = append(zones, input.ZoneId)
  81. }
  82. return zones
  83. }
  84. func (input ZonalFilterListBase) FirstZone() string {
  85. if len(input.ZoneId) > 0 {
  86. return input.ZoneId
  87. }
  88. if len(input.ZoneIds) > 0 {
  89. return input.ZoneIds[0]
  90. }
  91. return ""
  92. }
  93. type CloudregionListInput struct {
  94. apis.EnabledStatusStandaloneResourceListInput
  95. apis.ExternalizedResourceBaseListInput
  96. apis.DomainizedResourceListInput
  97. ManagedResourceListInput
  98. UsableResourceListInput
  99. UsableVpcResourceListInput
  100. CapabilityListInput
  101. // 过滤位于指定城市的区域
  102. City string `json:"city"`
  103. // 过滤提供特定服务的区域
  104. Service string `json:"service"`
  105. // 云环境
  106. Environment []string `json:"environment"`
  107. // 按可用区数量排序
  108. // pattern:asc|desc
  109. OrderByZoneCount string `json:"order_by_zone_count"`
  110. // 按vpc数量排序
  111. // pattern:asc|desc
  112. OrderByVpcCount string `json:"order_by_vpc_count"`
  113. // 按虚拟机数量排序
  114. // pattern:asc|desc
  115. OrderByGuestCount string `json:"order_by_guest_count"`
  116. }
  117. type ZoneListInput struct {
  118. apis.StatusStandaloneResourceListInput
  119. apis.ExternalizedResourceBaseListInput
  120. ManagedResourceListInput
  121. RegionalFilterListInput
  122. UsableResourceListInput
  123. UsableVpcResourceListInput
  124. // 过滤提供特定服务的可用区
  125. Service string `json:"service"`
  126. Location []string `json:"location"`
  127. Contacts []string `json:"contacts"`
  128. OrderByWires string `json:"order_by_wires"`
  129. OrderByHosts string `json:"order_by_hosts"`
  130. OrderByHostsEnabled string `json:"order_by_hosts_enabled"`
  131. OrderByBaremetals string `json:"order_by_baremetals"`
  132. OrderByBaremetalsEnabled string `json:"order_by_baremetals_enabled"`
  133. }
  134. type ZoneResourceInput struct {
  135. // 可用区ID或名称
  136. // example:zone1
  137. ZoneId string `json:"zone_id"`
  138. // swagger:ignore
  139. // Deprecated
  140. Zone string `json:"zone" yunion-deprecated-by:"zone_id"`
  141. }