use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::enumeration::{CannedType, GranteeType, PermissionType};
pub trait RequestInfoTrait {
fn request_id(&self) -> &str;
fn id2(&self) -> &str;
fn status_code(&self) -> isize;
fn header(&self) -> &HashMap<String, String>;
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct RequestInfo {
pub(crate) request_id: String,
pub(crate) id2: String,
pub(crate) status_code: isize,
pub(crate) header: HashMap<String, String>,
}
impl RequestInfo {
pub fn request_id(&self) -> &str {
&self.request_id
}
pub fn id2(&self) -> &str {
&self.id2
}
pub fn status_code(&self) -> isize {
self.status_code
}
pub fn header(&self) -> &HashMap<String, String> {
&self.header
}
}
impl RequestInfoTrait for RequestInfo {
fn request_id(&self) -> &str {
&self.request_id
}
fn id2(&self) -> &str {
&self.id2
}
fn status_code(&self) -> isize {
self.status_code
}
fn header(&self) -> &HashMap<String, String> {
&self.header
}
}
pub type Meta = HashMap<String, String>;
#[derive(Debug, Clone, PartialEq, Default, Deserialize, Serialize)]
pub struct Owner {
#[serde(default)]
#[serde(rename = "ID")]
pub(crate) id: String,
}
impl Owner {
pub fn new(id: impl Into<String>) -> Self {
Self {
id: id.into(),
}
}
pub fn id(&self) -> &str {
&self.id
}
pub fn set_id(&mut self, id: impl Into<String>) {
self.id = id.into();
}
}
#[derive(Debug, Clone, PartialEq, Default, Deserialize, Serialize)]
pub struct Grant {
#[serde(default)]
#[serde(rename = "Grantee")]
pub(crate) grantee: Grantee,
#[serde(default)]
#[serde(rename = "Permission")]
pub(crate) permission: PermissionType,
}
impl Grant {
pub fn new(grantee: impl Into<Grantee>, permission: impl Into<PermissionType>) -> Self {
Self {
grantee: grantee.into(),
permission: permission.into(),
}
}
pub fn grantee(&self) -> &Grantee {
&self.grantee
}
pub fn permission(&self) -> &PermissionType {
&self.permission
}
pub fn set_grantee(&mut self, grantee: impl Into<Grantee>) {
self.grantee = grantee.into();
}
pub fn set_permission(&mut self, permission: impl Into<PermissionType>) {
self.permission = permission.into();
}
}
#[derive(Debug, Clone, PartialEq, Default, Deserialize, Serialize)]
pub struct Grantee {
#[serde(default)]
#[serde(rename = "ID")]
#[serde(skip_serializing_if = "String::is_empty")]
pub(crate) id: String,
#[serde(default)]
#[serde(rename = "Type")]
pub(crate) grantee_type: GranteeType,
#[serde(default)]
#[serde(rename = "Canned")]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) canned: Option<CannedType>,
}
impl Grantee {
pub fn new(grantee_type: impl Into<GranteeType>) -> Self {
Self {
id: "".to_string(),
grantee_type: grantee_type.into(),
canned: None,
}
}
pub fn new_with_id(grantee_type: impl Into<GranteeType>, id: impl Into<String>) -> Self {
Self {
id: id.into(),
grantee_type: grantee_type.into(),
canned: None,
}
}
pub fn new_with_canned(grantee_type: impl Into<GranteeType>, canned: impl Into<Option<CannedType>>) -> Self {
Self {
id: "".to_string(),
grantee_type: grantee_type.into(),
canned: canned.into(),
}
}
pub fn id(&self) -> &str {
&self.id
}
pub fn grantee_type(&self) -> &GranteeType {
&self.grantee_type
}
pub fn canned(&self) -> &Option<CannedType> {
&self.canned
}
pub fn set_id(&mut self, id: impl Into<String>) {
self.id = id.into();
}
pub fn set_grantee_type(&mut self, grantee_type: impl Into<GranteeType>) {
self.grantee_type = grantee_type.into();
}
pub fn set_canned(&mut self, canned: impl Into<Option<CannedType>>) {
self.canned = canned.into();
}
}
#[derive(Debug, Clone, PartialEq, Default, Deserialize)]
pub struct ListedCommonPrefix {
#[serde(default)]
#[serde(rename = "Prefix")]
pub(crate) prefix: String,
}
impl ListedCommonPrefix {
pub fn prefix(&self) -> &str {
&self.prefix
}
}
#[derive(Debug, Clone, PartialEq, Default, Deserialize)]
pub(crate) struct TempCopyResult {
#[serde(default)]
#[serde(rename = "ETag")]
pub(crate) etag: String,
#[serde(default)]
#[serde(rename = "LastModified")]
pub(crate) last_modified: String,
#[serde(default)]
#[serde(rename = "Code")]
pub(crate) code: String,
#[serde(default)]
#[serde(rename = "Message")]
pub(crate) message: String,
#[serde(default)]
#[serde(rename = "HostId")]
pub(crate) host_id: String,
#[serde(default)]
#[serde(rename = "Resource")]
pub(crate) resource: String,
#[serde(default)]
#[serde(rename = "EC")]
pub(crate) ec: String,
}