natgateway.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. "time"
  17. "yunion.io/x/cloudmux/pkg/apis/compute"
  18. "yunion.io/x/jsonutils"
  19. "yunion.io/x/onecloud/pkg/apis"
  20. billing_api "yunion.io/x/onecloud/pkg/apis/billing"
  21. )
  22. const (
  23. NAT_STAUTS_AVAILABLE = compute.NAT_STAUTS_AVAILABLE // 可用
  24. NAT_STATUS_ALLOCATE = compute.NAT_STATUS_ALLOCATE // 创建中
  25. NAT_STATUS_DEPLOYING = compute.NAT_STATUS_DEPLOYING // 配置中
  26. NAT_STATUS_UNKNOWN = compute.NAT_STATUS_UNKNOWN // 未知状态
  27. NAT_STATUS_CREATE_FAILED = compute.NAT_STATUS_CREATE_FAILED // 创建失败
  28. NAT_STATUS_DELETED = "deleted" // 删除
  29. NAT_STATUS_DELETING = compute.NAT_STATUS_DELETING // 删除中
  30. NAT_STATUS_DELETE_FAILED = "delete_failed" // 删除失败
  31. NAT_STATUS_SET_AUTO_RENEW = "set_auto_renew" // 设置自动续费中
  32. NAT_STATUS_SET_AUTO_RENEW_FAILED = "set_auto_renew_failed" // 设置自动续费失败
  33. NAT_STATUS_RENEWING = "renewing" // 续费中
  34. NAT_STATUS_RENEW_FAILED = "renew_failed" // 续费失败
  35. )
  36. type NatGetewayListInput struct {
  37. apis.StatusInfrasResourceBaseListInput
  38. apis.ExternalizedResourceBaseListInput
  39. apis.DeletePreventableResourceBaseListInput
  40. VpcFilterListInput
  41. }
  42. type NatEntryListInput struct {
  43. apis.StatusInfrasResourceBaseListInput
  44. apis.ExternalizedResourceBaseListInput
  45. NatGatewayFilterListInput
  46. }
  47. type NatDEntryListInput struct {
  48. NatEntryListInput
  49. ExternalIP []string `json:"external_ip"`
  50. ExternalPort []int `json:"external_port"`
  51. InternalIP []string `json:"internal_ip"`
  52. InternalPort []int `json:"internal_port"`
  53. IpProtocol []string `json:"ip_protocol"`
  54. }
  55. type NatSEntryListInput struct {
  56. NatEntryListInput
  57. NetworkFilterListBase
  58. IP []string `json:"ip"`
  59. SourceCIDR []string `json:"source_cidr"`
  60. }
  61. type NatGatewayResourceInfo struct {
  62. // NAT网关名称
  63. Natgateway string `json:"natgateway"`
  64. // 归属VPC ID
  65. VpcId string `json:"vpc_id"`
  66. VpcResourceInfo
  67. }
  68. type NatGatewayResourceInput struct {
  69. // NAT网关ID or Name
  70. NatgatewayId string `json:"natgateway_id"`
  71. // swagger:ignore
  72. // Deprecated
  73. Natgateway string `json:"natgateway" yunion-deprecated-by:"natgateway_id"`
  74. }
  75. type NatGatewayFilterListInput struct {
  76. NatGatewayResourceInput
  77. // 以NAT网关名字排序
  78. OrderByNatgateway string `json:"order_by_natgateway"`
  79. VpcFilterListInput
  80. }
  81. type NatEntryDetails struct {
  82. apis.StatusInfrasResourceBaseDetails
  83. NatGatewayResourceInfo
  84. }
  85. type NatGatewaySyncstatusInput struct {
  86. }
  87. type NatgatewayCreateInput struct {
  88. apis.StatusInfrasResourceBaseCreateInput
  89. // 包年包月时间周期
  90. Duration string `json:"duration"`
  91. // 是否自动续费(仅包年包月时生效)
  92. // default: false
  93. AutoRenew bool `json:"auto_renew"`
  94. // 到期释放时间
  95. ReleaseAt time.Time `json:"release_at"`
  96. // 计费方式
  97. // enum: ["postpaid", "prepaid"]
  98. BillingType billing_api.TBillingType `json:"billing_type"`
  99. // swagger:ignore
  100. BillingCycle string `json:"billing_cycle"`
  101. NetworkId string `json:"network_id"`
  102. // swagger:ignore
  103. VpcId string `json:"vpc_id"`
  104. // 绑定已有弹性公网IP,要求EIP必须和Vpc在同一区域
  105. Eip string `json:"eip"`
  106. // 绑定新建弹性公网IP
  107. EipBw int `json:"eip_bw,omitzero"`
  108. // 弹性公网IP计费类型
  109. // enum: ["bandwidth", "traffic"]
  110. // default: traffic
  111. EipChargeType billing_api.TNetChargeType `json:"eip_charge_type,omitempty"`
  112. EipBgpType string `json:"eip_bgp_type"`
  113. EipAutoDellocate bool `json:"eip_auto_dellocate"`
  114. }
  115. func (opts *NatgatewayCreateInput) Params() (jsonutils.JSONObject, error) {
  116. return jsonutils.Marshal(opts), nil
  117. }
  118. type NatgatewayDeleteInput struct {
  119. Force bool `json:"force"`
  120. }