Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codegen/src/v1/aws_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ fn has_unconditional_builder(name: &str) -> bool {
matches!(
name,
"AnalyticsExportDestination"
| "CreateSessionOutput"
| "InventoryDestination"
| "RoutingRule"
| "MetadataTableConfiguration"
Expand Down
13 changes: 11 additions & 2 deletions codegen/src/v1/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ fn collect_types_needing_serde(rust_types: &RustTypes) -> BTreeSet<String> {
types_needing_serde
}

fn collect_types_needing_custom_default(rust_types: &RustTypes) -> BTreeSet<String> {
fn collect_types_needing_custom_default(rust_types: &RustTypes, ops: &Operations) -> BTreeSet<String> {
let mut types_needing_custom_default = BTreeSet::new();

// Start with Configuration types that can't derive Default
Expand All @@ -526,6 +526,15 @@ fn collect_types_needing_custom_default(rust_types: &RustTypes) -> BTreeSet<Stri
}
}

// Also include operation output types that can't derive Default
for op in ops.values() {
if let Some(rust::Type::Struct(ty)) = rust_types.get(&op.output)
&& !can_derive_default(ty, rust_types)
{
collect_struct_dependencies(&op.output, rust_types, &mut types_needing_custom_default);
}
}

types_needing_custom_default
}

Expand Down Expand Up @@ -603,7 +612,7 @@ pub fn codegen(rust_types: &RustTypes, ops: &Operations, patch: Option<Patch>) {
let types_needing_serde = collect_types_needing_serde(rust_types);

// Collect types that need custom Default implementations
let types_needing_custom_default = collect_types_needing_custom_default(rust_types);
let types_needing_custom_default = collect_types_needing_custom_default(rust_types, ops);

g([
"#![allow(clippy::empty_structs_with_brackets)]",
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/v1/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Operation {
pub type Operations = BTreeMap<String, Operation>;

// TODO: handle these operations
pub const SKIPPED_OPS: &[&str] = &["CreateSession", "ListDirectoryBuckets"];
pub const SKIPPED_OPS: &[&str] = &["ListDirectoryBuckets"];

pub fn collect_operations(model: &smithy::Model) -> Operations {
let mut operations: Operations = default();
Expand Down
52 changes: 52 additions & 0 deletions crates/s3s-aws/src/conv/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,58 @@ impl AwsConversion for s3s::dto::CreateMultipartUploadOutput {
}
}

impl AwsConversion for s3s::dto::CreateSessionInput {
type Target = aws_sdk_s3::operation::create_session::CreateSessionInput;
type Error = S3Error;

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
bucket: unwrap_from_aws(x.bucket, "bucket")?,
bucket_key_enabled: try_from_aws(x.bucket_key_enabled)?,
ssekms_encryption_context: try_from_aws(x.ssekms_encryption_context)?,
ssekms_key_id: try_from_aws(x.ssekms_key_id)?,
server_side_encryption: try_from_aws(x.server_side_encryption)?,
session_mode: try_from_aws(x.session_mode)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_bucket(Some(try_into_aws(x.bucket)?));
y = y.set_bucket_key_enabled(try_into_aws(x.bucket_key_enabled)?);
y = y.set_ssekms_encryption_context(try_into_aws(x.ssekms_encryption_context)?);
y = y.set_ssekms_key_id(try_into_aws(x.ssekms_key_id)?);
y = y.set_server_side_encryption(try_into_aws(x.server_side_encryption)?);
y = y.set_session_mode(try_into_aws(x.session_mode)?);
y.build().map_err(S3Error::internal_error)
}
}

impl AwsConversion for s3s::dto::CreateSessionOutput {
type Target = aws_sdk_s3::operation::create_session::CreateSessionOutput;
type Error = S3Error;

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
bucket_key_enabled: try_from_aws(x.bucket_key_enabled)?,
credentials: unwrap_from_aws(x.credentials, "credentials")?,
ssekms_encryption_context: try_from_aws(x.ssekms_encryption_context)?,
ssekms_key_id: try_from_aws(x.ssekms_key_id)?,
server_side_encryption: try_from_aws(x.server_side_encryption)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_bucket_key_enabled(try_into_aws(x.bucket_key_enabled)?);
y = y.set_credentials(Some(try_into_aws(x.credentials)?));
y = y.set_ssekms_encryption_context(try_into_aws(x.ssekms_encryption_context)?);
y = y.set_ssekms_key_id(try_into_aws(x.ssekms_key_id)?);
y = y.set_server_side_encryption(try_into_aws(x.server_side_encryption)?);
Ok(y.build())
}
}

impl AwsConversion for s3s::dto::DataRedundancy {
type Target = aws_sdk_s3::types::DataRedundancy;
type Error = S3Error;
Expand Down
52 changes: 52 additions & 0 deletions crates/s3s-aws/src/conv/generated_minio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,58 @@ impl AwsConversion for s3s::dto::CreateMultipartUploadOutput {
}
}

impl AwsConversion for s3s::dto::CreateSessionInput {
type Target = aws_sdk_s3::operation::create_session::CreateSessionInput;
type Error = S3Error;

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
bucket: unwrap_from_aws(x.bucket, "bucket")?,
bucket_key_enabled: try_from_aws(x.bucket_key_enabled)?,
ssekms_encryption_context: try_from_aws(x.ssekms_encryption_context)?,
ssekms_key_id: try_from_aws(x.ssekms_key_id)?,
server_side_encryption: try_from_aws(x.server_side_encryption)?,
session_mode: try_from_aws(x.session_mode)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_bucket(Some(try_into_aws(x.bucket)?));
y = y.set_bucket_key_enabled(try_into_aws(x.bucket_key_enabled)?);
y = y.set_ssekms_encryption_context(try_into_aws(x.ssekms_encryption_context)?);
y = y.set_ssekms_key_id(try_into_aws(x.ssekms_key_id)?);
y = y.set_server_side_encryption(try_into_aws(x.server_side_encryption)?);
y = y.set_session_mode(try_into_aws(x.session_mode)?);
y.build().map_err(S3Error::internal_error)
}
}

impl AwsConversion for s3s::dto::CreateSessionOutput {
type Target = aws_sdk_s3::operation::create_session::CreateSessionOutput;
type Error = S3Error;

fn try_from_aws(x: Self::Target) -> S3Result<Self> {
Ok(Self {
bucket_key_enabled: try_from_aws(x.bucket_key_enabled)?,
credentials: unwrap_from_aws(x.credentials, "credentials")?,
ssekms_encryption_context: try_from_aws(x.ssekms_encryption_context)?,
ssekms_key_id: try_from_aws(x.ssekms_key_id)?,
server_side_encryption: try_from_aws(x.server_side_encryption)?,
})
}

fn try_into_aws(x: Self) -> S3Result<Self::Target> {
let mut y = Self::Target::builder();
y = y.set_bucket_key_enabled(try_into_aws(x.bucket_key_enabled)?);
y = y.set_credentials(Some(try_into_aws(x.credentials)?));
y = y.set_ssekms_encryption_context(try_into_aws(x.ssekms_encryption_context)?);
y = y.set_ssekms_key_id(try_into_aws(x.ssekms_key_id)?);
y = y.set_server_side_encryption(try_into_aws(x.server_side_encryption)?);
Ok(y.build())
}
}

impl AwsConversion for s3s::dto::DataRedundancy {
type Target = aws_sdk_s3::types::DataRedundancy;
type Error = S3Error;
Expand Down
26 changes: 26 additions & 0 deletions crates/s3s-aws/src/proxy/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,32 @@ impl S3 for Proxy {
}
}

#[tracing::instrument(skip(self, req))]
async fn create_session(
&self,
req: S3Request<s3s::dto::CreateSessionInput>,
) -> S3Result<S3Response<s3s::dto::CreateSessionOutput>> {
let input = req.input;
debug!(?input);
let mut b = self.0.create_session();
b = b.set_bucket(Some(try_into_aws(input.bucket)?));
b = b.set_bucket_key_enabled(try_into_aws(input.bucket_key_enabled)?);
b = b.set_ssekms_encryption_context(try_into_aws(input.ssekms_encryption_context)?);
b = b.set_ssekms_key_id(try_into_aws(input.ssekms_key_id)?);
b = b.set_server_side_encryption(try_into_aws(input.server_side_encryption)?);
b = b.set_session_mode(try_into_aws(input.session_mode)?);
let result = b.send().await;
match result {
Ok(output) => {
let headers = super::meta::build_headers(&output)?;
let output = try_from_aws(output)?;
debug!(?output);
Ok(S3Response::with_headers(output, headers))
}
Err(e) => Err(wrap_sdk_error!(e)),
}
}

#[tracing::instrument(skip(self, req))]
async fn delete_bucket(
&self,
Expand Down
26 changes: 26 additions & 0 deletions crates/s3s-aws/src/proxy/generated_minio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,32 @@ impl S3 for Proxy {
}
}

#[tracing::instrument(skip(self, req))]
async fn create_session(
&self,
req: S3Request<s3s::dto::CreateSessionInput>,
) -> S3Result<S3Response<s3s::dto::CreateSessionOutput>> {
let input = req.input;
debug!(?input);
let mut b = self.0.create_session();
b = b.set_bucket(Some(try_into_aws(input.bucket)?));
b = b.set_bucket_key_enabled(try_into_aws(input.bucket_key_enabled)?);
b = b.set_ssekms_encryption_context(try_into_aws(input.ssekms_encryption_context)?);
b = b.set_ssekms_key_id(try_into_aws(input.ssekms_key_id)?);
b = b.set_server_side_encryption(try_into_aws(input.server_side_encryption)?);
b = b.set_session_mode(try_into_aws(input.session_mode)?);
let result = b.send().await;
match result {
Ok(output) => {
let headers = super::meta::build_headers(&output)?;
let output = try_from_aws(output)?;
debug!(?output);
Ok(S3Response::with_headers(output, headers))
}
Err(e) => Err(wrap_sdk_error!(e)),
}
}

#[tracing::instrument(skip(self, req))]
async fn delete_bucket(
&self,
Expand Down
7 changes: 7 additions & 0 deletions crates/s3s/src/access/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ pub trait S3Access: Send + Sync + 'static {
Ok(())
}

/// Checks whether the CreateSession request has accesses to the resources.
///
/// This method returns `Ok(())` by default.
async fn create_session(&self, _req: &mut S3Request<CreateSessionInput>) -> S3Result<()> {
Ok(())
}

/// Checks whether the DeleteBucket request has accesses to the resources.
///
/// This method returns `Ok(())` by default.
Expand Down
7 changes: 7 additions & 0 deletions crates/s3s/src/access/generated_minio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ pub trait S3Access: Send + Sync + 'static {
Ok(())
}

/// Checks whether the CreateSession request has accesses to the resources.
///
/// This method returns `Ok(())` by default.
async fn create_session(&self, _req: &mut S3Request<CreateSessionInput>) -> S3Result<()> {
Ok(())
}

/// Checks whether the DeleteBucket request has accesses to the resources.
///
/// This method returns `Ok(())` by default.
Expand Down
Loading