iamapi_response.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 CreateAccessKeyResponse struct {
  59. CommonResponse
  60. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ CreateAccessKeyResponse"`
  61. CreateAccessKeyResult struct {
  62. AccessKey iam.AccessKey `xml:"AccessKey"`
  63. } `xml:"CreateAccessKeyResult"`
  64. }
  65. type PutUserPolicyResponse struct {
  66. CommonResponse
  67. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ PutUserPolicyResponse"`
  68. }
  69. type GetUserPolicyResponse struct {
  70. CommonResponse
  71. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ GetUserPolicyResponse"`
  72. GetUserPolicyResult struct {
  73. UserName string `xml:"UserName"`
  74. PolicyName string `xml:"PolicyName"`
  75. PolicyDocument string `xml:"PolicyDocument"`
  76. } `xml:"GetUserPolicyResult"`
  77. }
  78. type ErrorResponse struct {
  79. CommonResponse
  80. XMLName xml.Name `xml:"https://iam.amazonaws.com/doc/2010-05-08/ ErrorResponse"`
  81. Error struct {
  82. iam.ErrorDetails
  83. Type string `xml:"Type"`
  84. } `xml:"Error"`
  85. }
  86. func (r *CommonResponse) SetRequestId() {
  87. r.ResponseMetadata.RequestId = fmt.Sprintf("%d", time.Now().UnixNano())
  88. }