natgateways.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/jsonutils"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. "yunion.io/x/onecloud/pkg/mcclient/options"
  19. )
  20. type NatGatewayListOptions struct {
  21. options.BaseListOptions
  22. Vpc string `help:"vpc id or name"`
  23. Cloudregion string `help:"cloudreigon id or name"`
  24. }
  25. func (opts *NatGatewayListOptions) Params() (jsonutils.JSONObject, error) {
  26. return options.ListStructToParams(opts)
  27. }
  28. type NatGatewayIdOptions struct {
  29. ID string `help:"ID of Nat Gateway"`
  30. }
  31. func (opts *NatGatewayIdOptions) GetId() string {
  32. return opts.ID
  33. }
  34. func (opts *NatGatewayIdOptions) Params() (jsonutils.JSONObject, error) {
  35. return nil, nil
  36. }
  37. type NatGatewayDeleteOption struct {
  38. NatGatewayIdOptions
  39. Force bool
  40. }
  41. func (opts *NatGatewayDeleteOption) Params() (jsonutils.JSONObject, error) {
  42. return jsonutils.Marshal(map[string]bool{"force": opts.Force}), nil
  43. }
  44. type NatDTableListOptions struct {
  45. Natgateway string `help:"Natgateway name or id"`
  46. options.BaseListOptions
  47. }
  48. type NatSTableListOptions struct {
  49. Natgateway string `help:"Natgateway name or id"`
  50. Network string `help:"Network id or name"`
  51. options.BaseListOptions
  52. }
  53. type NatDDeleteShowOptions struct {
  54. ID string `help:"ID of the DNat"`
  55. }
  56. type NatSDeleteShowOptions struct {
  57. ID string `help:"ID of the SNat"`
  58. }
  59. type NatDCreateOptions struct {
  60. NAME string `help:"DNAT's name"`
  61. NATGATEWAYID string `help:"The nat gateway'id to which DNat belongs"`
  62. INTERNALIP string `help:"Internal IP"`
  63. INTERNALPORT string `help:"Internal Port"`
  64. EXTERNALIP string `help:"External IP"`
  65. EXTERNALIPID string `help:"External IP ID, can be empty except huawei Cloud"`
  66. EXTERNALPORT string `help:"External Port"`
  67. IPPROTOCOL string `help:"Transport Protocol(tcp|udp)"`
  68. }
  69. type NatSCreateOptions struct {
  70. NAME string `help:"SNAT's name"`
  71. NATGATEWAYID string `help:"The nat gateway'id to which SNat belongs"`
  72. IP string `help:"External IP"`
  73. EXTERNALIPID string `help:"External IP ID, can be empty except huawei Cloud"`
  74. SourceCIDR string `help:"Source CIDR"`
  75. NetworkID string `help:"Network id"`
  76. }
  77. type NatPostpaidExpireOptions struct {
  78. NatGatewayIdOptions
  79. apis.PostpaidExpireInput
  80. }
  81. func (opts *NatPostpaidExpireOptions) Params() (jsonutils.JSONObject, error) {
  82. return jsonutils.Marshal(opts.PostpaidExpireInput), nil
  83. }