You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
1.6 KiB

  1. package param
  2. import "gitlab.ecloud.com/ecloud/ecloudsdkcore/utils"
  3. type Params struct {
  4. Action string `json:"action,omitempty"`
  5. Protocol string `json:"protocol,omitempty"`
  6. Uri string `json:"uri,omitempty"`
  7. GatewayUri string `json:"gatewayUri,omitempty"`
  8. Request interface{} `json:"request,omitempty"`
  9. Method string `json:"method,omitempty"`
  10. AuthType int32 `json:"authType,omitempty"`
  11. ContentType string `json:"contentType,omitempty"`
  12. }
  13. func (p *Params) String() string {
  14. return utils.Beautify(p)
  15. }
  16. func (p *Params) GoString() string {
  17. return p.String()
  18. }
  19. func (p *Params) ToJsonString() string {
  20. return utils.ToJsonString(p)
  21. }
  22. type Builder struct {
  23. params *Params
  24. }
  25. func NewParamsBuilder() *Builder {
  26. params := &Params{}
  27. b := &Builder{params: params}
  28. return b
  29. }
  30. func (b *Builder) Action(action string) *Builder {
  31. b.params.Action = action
  32. return b
  33. }
  34. func (b *Builder) Protocol(protocol string) *Builder {
  35. b.params.Protocol = protocol
  36. return b
  37. }
  38. func (b *Builder) Uri(uri string) *Builder {
  39. b.params.Uri = uri
  40. return b
  41. }
  42. func (b *Builder) GatewayUri(gatewayUri string) *Builder {
  43. b.params.GatewayUri = gatewayUri
  44. return b
  45. }
  46. func (b *Builder) Request(request interface{}) *Builder {
  47. b.params.Request = request
  48. return b
  49. }
  50. func (b *Builder) Method(method string) *Builder {
  51. b.params.Method = method
  52. return b
  53. }
  54. func (b *Builder) AuthType(authType int32) *Builder {
  55. b.params.AuthType = authType
  56. return b
  57. }
  58. func (b *Builder) ContentType(contentType string) *Builder {
  59. b.params.ContentType = contentType
  60. return b
  61. }
  62. func (b *Builder) Build() *Params {
  63. return b.params
  64. }