model.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package base
  2. import (
  3. "net/http"
  4. "net/url"
  5. "time"
  6. )
  7. const (
  8. RegionCnNorth1 = "cn-north-1"
  9. RegionUsEast1 = "us-east-1"
  10. RegionApSingapore = "ap-singapore-1"
  11. timeFormatV4 = "20060102T150405Z"
  12. )
  13. type ServiceInfo struct {
  14. Timeout time.Duration
  15. Scheme string
  16. Host string
  17. Header http.Header
  18. Credentials Credentials
  19. }
  20. type ApiInfo struct {
  21. Method string
  22. Path string
  23. Query url.Values
  24. Form url.Values
  25. Timeout time.Duration
  26. Header http.Header
  27. }
  28. type Credentials struct {
  29. AccessKeyID string
  30. SecretAccessKey string
  31. Service string
  32. Region string
  33. SessionToken string
  34. }
  35. type metadata struct {
  36. algorithm string
  37. credentialScope string
  38. signedHeaders string
  39. date string
  40. region string
  41. service string
  42. }
  43. // 统一的JSON返回结果
  44. type CommonResponse struct {
  45. ResponseMetadata ResponseMetadata
  46. Result interface{} `json:"Result,omitempty"`
  47. }
  48. type BaseResp struct {
  49. Status string
  50. CreatedTime int64
  51. UpdatedTime int64
  52. }
  53. type ErrorObj struct {
  54. CodeN int
  55. Code string
  56. Message string
  57. }
  58. type ResponseMetadata struct {
  59. RequestId string
  60. Service string `json:",omitempty"`
  61. Region string `json:",omitempty"`
  62. Action string `json:",omitempty"`
  63. Version string `json:",omitempty"`
  64. Error *ErrorObj `json:",omitempty"`
  65. }
  66. type Policy struct {
  67. Statement []*Statement
  68. }
  69. const (
  70. StatementEffectAllow = "Allow"
  71. StatementEffectDeny = "Deny"
  72. )
  73. type Statement struct {
  74. Effect string
  75. Action []string
  76. Resource []string
  77. Condition string `json:",omitempty"`
  78. }
  79. type SecurityToken2 struct {
  80. AccessKeyID string
  81. SecretAccessKey string
  82. SessionToken string
  83. ExpiredTime string
  84. CurrentTime string
  85. }
  86. type InnerToken struct {
  87. LTAccessKeyId string
  88. AccessKeyId string
  89. SignedSecretAccessKey string
  90. ExpiredTime int64
  91. PolicyString string
  92. Signature string
  93. }