| 1 |
package ram |
| 2 |
|
| 3 |
type Type string |
| 4 |
|
| 5 |
const ( |
| 6 |
Custom Type = "Custom" |
| 7 |
System Type = "System" |
| 8 |
) |
| 9 |
|
| 10 |
type PolicyRequest struct { |
| 11 |
PolicyName string |
| 12 |
PolicyType Type |
| 13 |
Description string |
| 14 |
PolicyDocument string |
| 15 |
SetAsDefault string |
| 16 |
VersionId string |
| 17 |
} |
| 18 |
type PolicyListResponse struct { |
| 19 |
RamCommonResponse |
| 20 |
Policies struct { |
| 21 |
Policy []Policy |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
type PolicyResponse struct { |
| 26 |
RamCommonResponse |
| 27 |
Policy Policy |
| 28 |
} |
| 29 |
|
| 30 |
type PolicyQueryRequest struct { |
| 31 |
PolicyType Type |
| 32 |
Marker string |
| 33 |
MaxItems int8 |
| 34 |
} |
| 35 |
|
| 36 |
type PolicyQueryResponse struct { |
| 37 |
RamCommonResponse |
| 38 |
IsTruncated bool |
| 39 |
Marker string |
| 40 |
Policies struct { |
| 41 |
Policy []Policy |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
type PolicyVersionResponse struct { |
| 46 |
RamCommonResponse |
| 47 |
IsDefaultVersion bool |
| 48 |
VersionId string |
| 49 |
CreateDate string |
| 50 |
PolicyDocument string |
| 51 |
} |
| 52 |
|
| 53 |
type AttachPolicyRequest struct { |
| 54 |
PolicyRequest |
| 55 |
UserName string |
| 56 |
} |
| 57 |
|
| 58 |
type AttachPolicyToRoleRequest struct { |
| 59 |
PolicyRequest |
| 60 |
RoleName string |
| 61 |
} |
| 62 |
|
| 63 |
type PolicyVersionResponseNew struct { |
| 64 |
RamCommonResponse |
| 65 |
PolicyVersion struct { |
| 66 |
IsDefaultVersion bool |
| 67 |
VersionId string |
| 68 |
CreateDate string |
| 69 |
PolicyDocument string |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
type AttachPolicyToGroupRequest struct { |
| 74 |
PolicyRequest |
| 75 |
GroupName string |
| 76 |
} |
| 77 |
|
| 78 |
type PolicyVersionsResponse struct { |
| 79 |
RamCommonResponse |
| 80 |
PolicyVersions struct { |
| 81 |
PolicyVersion []PolicyVersion |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
type PolicyListEntitiesResponse struct { |
| 86 |
RamCommonResponse |
| 87 |
Groups struct { |
| 88 |
Group []Group |
| 89 |
} |
| 90 |
Users struct { |
| 91 |
User []User |
| 92 |
} |
| 93 |
Roles struct { |
| 94 |
Role []Role |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
func (client *RamClient) CreatePolicy(policyReq PolicyRequest) (PolicyResponse, error) { |
| 99 |
var resp PolicyResponse |
| 100 |
err := client.Invoke("CreatePolicy", policyReq, &resp) |
| 101 |
if err != nil { |
| 102 |
return PolicyResponse{}, err |
| 103 |
} |
| 104 |
return resp, nil |
| 105 |
} |
| 106 |
|
| 107 |
func (client *RamClient) GetPolicy(policyReq PolicyRequest) (PolicyResponse, error) { |
| 108 |
var resp PolicyResponse |
| 109 |
err := client.Invoke("GetPolicy", policyReq, &resp) |
| 110 |
if err != nil { |
| 111 |
return PolicyResponse{}, err |
| 112 |
} |
| 113 |
return resp, nil |
| 114 |
} |
| 115 |
|
| 116 |
func (client *RamClient) DeletePolicy(policyReq PolicyRequest) (RamCommonResponse, error) { |
| 117 |
var resp RamCommonResponse |
| 118 |
err := client.Invoke("DeletePolicy", policyReq, &resp) |
| 119 |
if err != nil { |
| 120 |
return RamCommonResponse{}, err |
| 121 |
} |
| 122 |
return resp, nil |
| 123 |
} |
| 124 |
|
| 125 |
func (client *RamClient) ListPolicies(policyQuery PolicyQueryRequest) (PolicyQueryResponse, error) { |
| 126 |
var resp PolicyQueryResponse |
| 127 |
err := client.Invoke("ListPolicies", policyQuery, &resp) |
| 128 |
if err != nil { |
| 129 |
return PolicyQueryResponse{}, err |
| 130 |
} |
| 131 |
return resp, nil |
| 132 |
} |
| 133 |
|
| 134 |
func (client *RamClient) CreatePolicyVersion(policyReq PolicyRequest) (PolicyVersionResponse, error) { |
| 135 |
var resp PolicyVersionResponse |
| 136 |
err := client.Invoke("CreatePolicyVersion", policyReq, &resp) |
| 137 |
if err != nil { |
| 138 |
return PolicyVersionResponse{}, err |
| 139 |
} |
| 140 |
return resp, nil |
| 141 |
} |
| 142 |
|
| 143 |
func (client *RamClient) GetPolicyVersion(policyReq PolicyRequest) (PolicyVersionResponse, error) { |
| 144 |
var resp PolicyVersionResponse |
| 145 |
err := client.Invoke("GetPolicyVersion", policyReq, &resp) |
| 146 |
if err != nil { |
| 147 |
return PolicyVersionResponse{}, err |
| 148 |
} |
| 149 |
return resp, nil |
| 150 |
} |
| 151 |
|
| 152 |
func (client *RamClient) GetPolicyVersionNew(policyReq PolicyRequest) (PolicyVersionResponseNew, error) { |
| 153 |
var resp PolicyVersionResponseNew |
| 154 |
err := client.Invoke("GetPolicyVersion", policyReq, &resp) |
| 155 |
if err != nil { |
| 156 |
return PolicyVersionResponseNew{}, err |
| 157 |
} |
| 158 |
return resp, nil |
| 159 |
} |
| 160 |
|
| 161 |
func (client *RamClient) DeletePolicyVersion(policyReq PolicyRequest) (RamCommonResponse, error) { |
| 162 |
var resp RamCommonResponse |
| 163 |
err := client.Invoke("DeletePolicyVersion", policyReq, &resp) |
| 164 |
if err != nil { |
| 165 |
return RamCommonResponse{}, err |
| 166 |
} |
| 167 |
return resp, nil |
| 168 |
} |
| 169 |
|
| 170 |
func (client *RamClient) ListPolicyVersions(policyReq PolicyRequest) (PolicyVersionResponse, error) { |
| 171 |
var resp PolicyVersionResponse |
| 172 |
err := client.Invoke("ListPolicyVersions", policyReq, &resp) |
| 173 |
if err != nil { |
| 174 |
return PolicyVersionResponse{}, err |
| 175 |
} |
| 176 |
return resp, nil |
| 177 |
} |
| 178 |
|
| 179 |
func (client *RamClient) ListPolicyVersionsNew(policyReq PolicyRequest) (PolicyVersionsResponse, error) { |
| 180 |
var resp PolicyVersionsResponse |
| 181 |
err := client.Invoke("ListPolicyVersions", policyReq, &resp) |
| 182 |
if err != nil { |
| 183 |
return PolicyVersionsResponse{}, err |
| 184 |
} |
| 185 |
return resp, nil |
| 186 |
} |
| 187 |
|
| 188 |
func (client *RamClient) SetDefaultPolicyVersion(policyReq PolicyRequest) (RamCommonResponse, error) { |
| 189 |
var resp RamCommonResponse |
| 190 |
err := client.Invoke("SetDefaultPolicyVersion", policyReq, &resp) |
| 191 |
if err != nil { |
| 192 |
return RamCommonResponse{}, err |
| 193 |
} |
| 194 |
return resp, nil |
| 195 |
} |
| 196 |
|
| 197 |
func (client *RamClient) AttachPolicyToUser(attachPolicyRequest AttachPolicyRequest) (RamCommonResponse, error) { |
| 198 |
var resp RamCommonResponse |
| 199 |
err := client.Invoke("AttachPolicyToUser", attachPolicyRequest, &resp) |
| 200 |
if err != nil { |
| 201 |
return RamCommonResponse{}, err |
| 202 |
} |
| 203 |
return resp, nil |
| 204 |
} |
| 205 |
|
| 206 |
func (client *RamClient) DetachPolicyFromUser(attachPolicyRequest AttachPolicyRequest) (RamCommonResponse, error) { |
| 207 |
var resp RamCommonResponse |
| 208 |
err := client.Invoke("DetachPolicyFromUser", attachPolicyRequest, &resp) |
| 209 |
if err != nil { |
| 210 |
return RamCommonResponse{}, err |
| 211 |
} |
| 212 |
return resp, nil |
| 213 |
} |
| 214 |
|
| 215 |
func (client *RamClient) ListEntitiesForPolicy(policyReq PolicyRequest) (PolicyListEntitiesResponse, error) { |
| 216 |
var resp PolicyListEntitiesResponse |
| 217 |
err := client.Invoke("ListEntitiesForPolicy", policyReq, &resp) |
| 218 |
if err != nil { |
| 219 |
return PolicyListEntitiesResponse{}, err |
| 220 |
} |
| 221 |
return resp, nil |
| 222 |
} |
| 223 |
|
| 224 |
func (client *RamClient) ListPoliciesForUser(userQuery UserQueryRequest) (PolicyListResponse, error) { |
| 225 |
var resp PolicyListResponse |
| 226 |
err := client.Invoke("ListPoliciesForUser", userQuery, &resp) |
| 227 |
if err != nil { |
| 228 |
return PolicyListResponse{}, err |
| 229 |
} |
| 230 |
return resp, nil |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
func (client *RamClient) AttachPolicyToRole(attachPolicyRequest AttachPolicyToRoleRequest) (RamCommonResponse, error) { |
| 237 |
var resp RamCommonResponse |
| 238 |
err := client.Invoke("AttachPolicyToRole", attachPolicyRequest, &resp) |
| 239 |
if err != nil { |
| 240 |
return RamCommonResponse{}, err |
| 241 |
} |
| 242 |
return resp, nil |
| 243 |
} |
| 244 |
|
| 245 |
func (client *RamClient) DetachPolicyFromRole(attachPolicyRequest AttachPolicyToRoleRequest) (RamCommonResponse, error) { |
| 246 |
var resp RamCommonResponse |
| 247 |
err := client.Invoke("DetachPolicyFromRole", attachPolicyRequest, &resp) |
| 248 |
if err != nil { |
| 249 |
return RamCommonResponse{}, err |
| 250 |
} |
| 251 |
return resp, nil |
| 252 |
} |
| 253 |
|
| 254 |
func (client *RamClient) ListPoliciesForRole(roleQuery RoleQueryRequest) (PolicyListResponse, error) { |
| 255 |
var resp PolicyListResponse |
| 256 |
err := client.Invoke("ListPoliciesForRole", roleQuery, &resp) |
| 257 |
if err != nil { |
| 258 |
return PolicyListResponse{}, err |
| 259 |
} |
| 260 |
return resp, nil |
| 261 |
} |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
func (client *RamClient) AttachPolicyToGroup(attachPolicyRequest AttachPolicyToGroupRequest) (RamCommonResponse, error) { |
| 267 |
var resp RamCommonResponse |
| 268 |
err := client.Invoke("AttachPolicyToGroup", attachPolicyRequest, &resp) |
| 269 |
if err != nil { |
| 270 |
return RamCommonResponse{}, err |
| 271 |
} |
| 272 |
return resp, nil |
| 273 |
} |
| 274 |
|
| 275 |
func (client *RamClient) DetachPolicyFromGroup(attachPolicyRequest AttachPolicyToGroupRequest) (RamCommonResponse, error) { |
| 276 |
var resp RamCommonResponse |
| 277 |
err := client.Invoke("DetachPolicyFromGroup", attachPolicyRequest, &resp) |
| 278 |
if err != nil { |
| 279 |
return RamCommonResponse{}, err |
| 280 |
} |
| 281 |
return resp, nil |
| 282 |
} |
| 283 |
|
| 284 |
func (client *RamClient) ListPoliciesForGroup(groupQuery GroupQueryRequest) (PolicyListResponse, error) { |
| 285 |
var resp PolicyListResponse |
| 286 |
err := client.Invoke("ListPoliciesForGroup", groupQuery, &resp) |
| 287 |
if err != nil { |
| 288 |
return PolicyListResponse{}, err |
| 289 |
} |
| 290 |
return resp, nil |
| 291 |
} |