loadbalancerbackendgroup.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. "reflect"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/pkg/gotypes"
  19. "yunion.io/x/onecloud/pkg/apis"
  20. )
  21. type LoadbalancerBackendGroupDetails struct {
  22. apis.StatusStandaloneResourceDetails
  23. LoadbalancerResourceInfo
  24. SLoadbalancerBackendGroup
  25. LoadbalancerHealthCheck string `json:"loadbalancer_health_check"`
  26. LbListenerCount int `json:"lb_listener_count"`
  27. IsDefault bool `json:"is_default"`
  28. ProjectId string `json:"tenant_id"`
  29. }
  30. type LoadbalancerBackendGroupResourceInfo struct {
  31. LoadbalancerResourceInfo
  32. // 负载均衡后端组名称
  33. BackendGroup string `json:"backend_group"`
  34. // 负载均衡ID
  35. LoadbalancerId string `json:"loadbalancer_id"`
  36. }
  37. type LoadbalancerBackendGroupResourceInput struct {
  38. // 负载均衡后端组ID或名称
  39. BackendGroupId string `json:"backend_group_id"`
  40. // swagger:ignore
  41. // Deprecated
  42. BackendGroup string `json:"backend_group" yunion-deprecated-by:"backend_group_id"`
  43. }
  44. type LoadbalancerBackendGroupFilterListInput struct {
  45. LoadbalancerFilterListInput
  46. LoadbalancerBackendGroupResourceInput
  47. // 以负载均衡后端组名称排序
  48. OrderByBackendGroup string `json:"order_by_backend_group"`
  49. }
  50. type LoadbalancerBackendGroupCreateInput struct {
  51. apis.StatusStandaloneResourceCreateInput
  52. //swagger:ignore
  53. Loadbalancer string `json:"loadbalancer" yunion-deprecated-by:"loadbalancer_id"`
  54. // 负载均衡ID
  55. LoadbalancerId string `json:"loadbalancer_id"`
  56. Scheduler string `json:"scheduler"`
  57. LoadbalancerHealthCheckId string `json:"loadbalancer_health_check_id"`
  58. Type string `json:"type"`
  59. Backends []struct {
  60. Index int `json:"index"`
  61. Weight int `json:"weight"`
  62. Port int `json:"port"`
  63. Id string `json:"id"`
  64. Name string `json:"name"`
  65. ExternalId string `json:"external_id"`
  66. BackendType string `json:"backend_type"`
  67. BackendRole string `json:"backend_role"`
  68. Address string `json:"address"`
  69. ZoneId string `json:"zone_id"`
  70. HostName string `json:"host_name"`
  71. } `json:"backends"`
  72. }
  73. type LoadbalancerBackendGroupListInput struct {
  74. apis.StatusStandaloneResourceListInput
  75. apis.ExternalizedResourceBaseListInput
  76. LoadbalancerFilterListInput
  77. // filter LoadbalancerBackendGroup with no reference
  78. NoRef *bool `json:"no_ref"`
  79. Type []string `json:"type"`
  80. }
  81. type ListenerRuleBackendGroup struct {
  82. // 后端服务器组组ID
  83. Id string `json:"id"`
  84. // swagger:ignore
  85. Name string `json:"name"`
  86. // swagger:ignore
  87. ExternalId string `json:"external_id"`
  88. }
  89. type ListenerRuleBackendGroups []ListenerRuleBackendGroup
  90. func (groups ListenerRuleBackendGroups) String() string {
  91. return jsonutils.Marshal(groups).String()
  92. }
  93. func (groups ListenerRuleBackendGroups) IsZero() bool {
  94. return len(groups) == 0
  95. }
  96. type ListenerRuleRedirectPool struct {
  97. RegionPools map[string]ListenerRuleBackendGroups `json:"region_pools"`
  98. CountryPools map[string]ListenerRuleBackendGroups `json:"country_pools"`
  99. }
  100. func (pool ListenerRuleRedirectPool) String() string {
  101. return jsonutils.Marshal(pool).String()
  102. }
  103. func (pool ListenerRuleRedirectPool) IsZero() bool {
  104. return len(pool.RegionPools) == 0 && len(pool.CountryPools) == 0
  105. }
  106. func init() {
  107. gotypes.RegisterSerializable(reflect.TypeOf(&ListenerRuleBackendGroups{}), func() gotypes.ISerializable {
  108. return &ListenerRuleBackendGroups{}
  109. })
  110. gotypes.RegisterSerializable(reflect.TypeOf(&ListenerRuleRedirectPool{}), func() gotypes.ISerializable {
  111. return &ListenerRuleRedirectPool{}
  112. })
  113. }