| 1 | package ram |
| 2 | |
| 3 | type GroupRequest struct { |
| 4 | Group |
| 5 | } |
| 6 | |
| 7 | type GroupQueryRequest struct { |
| 8 | GroupName string |
| 9 | } |
| 10 | |
| 11 | type GroupUpdateRequest struct { |
| 12 | GroupName string |
| 13 | NewGroupName string |
| 14 | NewComments string |
| 15 | } |
| 16 | |
| 17 | type GroupListRequest struct { |
| 18 | Marker string |
| 19 | MaxItems int8 |
| 20 | } |
| 21 | |
| 22 | type UserRelateGroupRequest struct { |
| 23 | UserName string |
| 24 | GroupName string |
| 25 | } |
| 26 | |
| 27 | type GroupResponse struct { |
| 28 | RamCommonResponse |
| 29 | Group Group |
| 30 | } |
| 31 | |
| 32 | type GroupListResponse struct { |
| 33 | RamCommonResponse |
| 34 | IsTruncated bool |
| 35 | Marker string |
| 36 | Groups struct { |
| 37 | Group []Group |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func (client *RamClient) CreateGroup(req GroupRequest) (GroupResponse, error) { |
| 42 | var resp GroupResponse |
| 43 | err := client.Invoke("CreateGroup", req, &resp) |
| 44 | if err != nil { |
| 45 | return GroupResponse{}, err |
| 46 | } |
| 47 | return resp, nil |
| 48 | } |
| 49 | |
| 50 | func (client *RamClient) GetGroup(req GroupQueryRequest) (GroupResponse, error) { |
| 51 | var resp GroupResponse |
| 52 | err := client.Invoke("GetGroup", req, &resp) |
| 53 | if err != nil { |
| 54 | return GroupResponse{}, err |
| 55 | } |
| 56 | return resp, nil |
| 57 | } |
| 58 | |
| 59 | func (client *RamClient) UpdateGroup(req GroupUpdateRequest) (GroupResponse, error) { |
| 60 | var resp GroupResponse |
| 61 | err := client.Invoke("UpdateGroup", req, &resp) |
| 62 | if err != nil { |
| 63 | return GroupResponse{}, err |
| 64 | } |
| 65 | return resp, nil |
| 66 | } |
| 67 | |
| 68 | func (client *RamClient) ListGroup(req GroupListRequest) (GroupListResponse, error) { |
| 69 | var resp GroupListResponse |
| 70 | err := client.Invoke("ListGroups", req, &resp) |
| 71 | if err != nil { |
| 72 | return GroupListResponse{}, err |
| 73 | } |
| 74 | return resp, nil |
| 75 | } |
| 76 | |
| 77 | func (client *RamClient) DeleteGroup(req GroupQueryRequest) (RamCommonResponse, error) { |
| 78 | var resp RamCommonResponse |
| 79 | err := client.Invoke("DeleteGroup", req, &resp) |
| 80 | if err != nil { |
| 81 | return RamCommonResponse{}, err |
| 82 | } |
| 83 | return resp, nil |
| 84 | } |
| 85 | |
| 86 | func (client *RamClient) AddUserToGroup(req UserRelateGroupRequest) (RamCommonResponse, error) { |
| 87 | var resp RamCommonResponse |
| 88 | err := client.Invoke("AddUserToGroup", req, &resp) |
| 89 | if err != nil { |
| 90 | return RamCommonResponse{}, err |
| 91 | } |
| 92 | return resp, nil |
| 93 | } |
| 94 | |
| 95 | func (client *RamClient) RemoveUserFromGroup(req UserRelateGroupRequest) (RamCommonResponse, error) { |
| 96 | var resp RamCommonResponse |
| 97 | err := client.Invoke("RemoveUserFromGroup", req, &resp) |
| 98 | if err != nil { |
| 99 | return RamCommonResponse{}, err |
| 100 | } |
| 101 | return resp, nil |
| 102 | } |
| 103 | |
| 104 | func (client *RamClient) ListGroupsForUser(req UserQueryRequest) (GroupListResponse, error) { |
| 105 | var resp GroupListResponse |
| 106 | err := client.Invoke("ListGroupsForUser", req, &resp) |
| 107 | if err != nil { |
| 108 | return GroupListResponse{}, err |
| 109 | } |
| 110 | return resp, nil |
| 111 | } |
| 112 | |
| 113 | func (client *RamClient) ListUsersForGroup(req GroupQueryRequest) (ListUserResponse, error) { |
| 114 | var resp ListUserResponse |
| 115 | err := client.Invoke("ListUsersForGroup", req, &resp) |
| 116 | if err != nil { |
| 117 | return ListUserResponse{}, err |
| 118 | } |
| 119 | return resp, nil |
| 120 | } |