iamapi_response.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package iamapi
  2. import (
  3. "encoding/xml"
  4. "fmt"
  5. "time"
  6. "github.com/aws/aws-sdk-go/service/iam"
  7. )
  8. type CommonResponse struct {
  9. ResponseMetadata struct {
  10. RequestId string `xml:"RequestId"`
  11. } `xml:"ResponseMetadata"`
  12. }
  13. type ListUsersResponse struct {
  14. CommonResponse
  15. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ ListUsersResponse"`
  16. ListUsersResult struct {
  17. Users []*iam.User `xml:"Users>member"`
  18. IsTruncated bool `xml:"IsTruncated"`
  19. } `xml:"ListUsersResult"`
  20. }
  21. type ListAccessKeysResponse struct {
  22. CommonResponse
  23. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ ListAccessKeysResponse"`
  24. ListAccessKeysResult struct {
  25. AccessKeyMetadata []*iam.AccessKeyMetadata `xml:"AccessKeyMetadata>member"`
  26. IsTruncated bool `xml:"IsTruncated"`
  27. } `xml:"ListAccessKeysResult"`
  28. }
  29. type DeleteAccessKeyResponse struct {
  30. CommonResponse
  31. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ DeleteAccessKeyResponse"`
  32. }
  33. type CreatePolicyResponse struct {
  34. CommonResponse
  35. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ CreatePolicyResponse"`
  36. CreatePolicyResult struct {
  37. Policy iam.Policy `xml:"Policy"`
  38. } `xml:"CreatePolicyResult"`
  39. }
  40. type CreateUserResponse struct {
  41. CommonResponse
  42. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ CreateUserResponse"`
  43. CreateUserResult struct {
  44. User iam.User `xml:"User"`
  45. } `xml:"CreateUserResult"`
  46. }
  47. type DeleteUserResponse struct {
  48. CommonResponse
  49. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ DeleteUserResponse"`
  50. }
  51. type GetUserResponse struct {
  52. CommonResponse
  53. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ GetUserResponse"`
  54. GetUserResult struct {
  55. User iam.User `xml:"User"`
  56. } `xml:"GetUserResult"`
  57. }
  58. type UpdateUserResponse struct {
  59. CommonResponse
  60. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ UpdateUserResponse"`
  61. }
  62. type CreateAccessKeyResponse struct {
  63. CommonResponse
  64. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ CreateAccessKeyResponse"`
  65. CreateAccessKeyResult struct {
  66. AccessKey iam.AccessKey `xml:"AccessKey"`
  67. } `xml:"CreateAccessKeyResult"`
  68. }
  69. type PutUserPolicyResponse struct {
  70. CommonResponse
  71. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ PutUserPolicyResponse"`
  72. }
  73. type GetUserPolicyResponse struct {
  74. CommonResponse
  75. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ GetUserPolicyResponse"`
  76. GetUserPolicyResult struct {
  77. UserName string `xml:"UserName"`
  78. PolicyName string `xml:"PolicyName"`
  79. PolicyDocument string `xml:"PolicyDocument"`
  80. } `xml:"GetUserPolicyResult"`
  81. }
  82. type ErrorResponse struct {
  83. CommonResponse
  84. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ ErrorResponse"`
  85. Error struct {
  86. iam.ErrorDetails
  87. Type string `xml:"Type"`
  88. } `xml:"Error"`
  89. }
  90. func (r *CommonResponse) SetRequestId() {
  91. r.ResponseMetadata.RequestId = fmt.Sprintf("%d", time.Now().UnixNano())
  92. }