Skip to content

Commit 814a0f4

Browse files
authored
fix: update policy attach to use right endpoint (#19)
1 parent 67bc4f4 commit 814a0f4

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

crates/s3/src/admin.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,6 @@ struct ServiceAccountInfo {
335335
expiration: Option<String>,
336336
}
337337

338-
/// Request body for set policy
339-
#[derive(Debug, Serialize)]
340-
#[serde(rename_all = "camelCase")]
341-
struct SetPolicyApiRequest {
342-
policy_name: String,
343-
entity_name: String,
344-
}
345-
346338
/// Request body for setting bucket quota
347339
#[derive(Debug, Serialize)]
348340
#[serde(rename_all = "camelCase")]
@@ -498,19 +490,15 @@ impl AdminApi for AdminClient {
498490
entity_name: &str,
499491
) -> Result<()> {
500492
let policy_name = policy_names.join(",");
501-
let entity_type_str = match entity_type {
502-
PolicyEntity::User => "user",
503-
PolicyEntity::Group => "group",
504-
};
493+
let is_group = entity_type == PolicyEntity::Group;
505494

506-
let body = serde_json::to_vec(&SetPolicyApiRequest {
507-
policy_name,
508-
entity_name: entity_name.to_string(),
509-
})
510-
.map_err(Error::Json)?;
495+
let query = [
496+
("policyName", policy_name.as_str()),
497+
("userOrGroup", entity_name),
498+
("isGroup", if is_group { "true" } else { "false" }),
499+
];
511500

512-
let query = [("entityType", entity_type_str)];
513-
self.request_no_response(Method::PUT, "/set-policy", Some(&query), Some(&body))
501+
self.request_no_response(Method::PUT, "/set-user-or-group-policy", Some(&query), None)
514502
.await
515503
}
516504

0 commit comments

Comments
 (0)