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
18 changes: 13 additions & 5 deletions examples/advanced-sqs-partial-batch-failures/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,17 @@ where
}
},
)
.map(|id| BatchItemFailure { item_identifier: id })
.map(|id| {
let mut failure_item = BatchItemFailure::default();
failure_item.item_identifier = id;
failure_item
})
.collect();

Ok(SqsBatchResponse {
batch_item_failures: failure_items,
Ok({
let mut response = SqsBatchResponse::default();
response.batch_item_failures = failure_items;
response
})
}

Expand Down Expand Up @@ -140,8 +146,10 @@ mod test {
.unwrap();

let lambda_event = LambdaEvent {
payload: SqsEventObj {
records: vec![msg_to_fail, msg_to_succeed],
payload: {
let mut event_object = SqsEventObj::default();
event_object.records = vec![msg_to_fail, msg_to_succeed];
event_object
},
context: Context::default(),
};
Expand Down
42 changes: 23 additions & 19 deletions examples/basic-s3-object-lambda-thumbnail/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,28 @@ mod tests {
}

fn get_s3_event() -> S3ObjectLambdaEvent {
S3ObjectLambdaEvent {
x_amz_request_id: ("ID".to_string()),
head_object_context: (Some(HeadObjectContext::default())),
list_objects_context: (Some(ListObjectsContext::default())),
get_object_context: (Some(GetObjectContext {
input_s3_url: ("S3_URL".to_string()),
output_route: ("O_ROUTE".to_string()),
output_token: ("O_TOKEN".to_string()),
})),
list_objects_v2_context: (Some(ListObjectsV2Context::default())),
protocol_version: ("VERSION".to_string()),
user_identity: (UserIdentity::default()),
user_request: (UserRequest::default()),
configuration: (Configuration {
access_point_arn: ("APRN".to_string()),
supporting_access_point_arn: ("SAPRN".to_string()),
payload: (json!(null)),
}),
}
let mut event = S3ObjectLambdaEvent::default();
event.x_amz_request_id = "ID".to_string();
event.head_object_context = Some(HeadObjectContext::default());
event.list_objects_context = Some(ListObjectsContext::default());
event.get_object_context = Some({
let mut context = GetObjectContext::default();
context.input_s3_url = "S3_URL".to_string();
context.output_route = "O_ROUTE".to_string();
context.output_token = "O_TOKEN".to_string();
context
});
event.list_objects_v2_context = Some(ListObjectsV2Context::default());
event.protocol_version = "VERSION".to_string();
event.user_identity = UserIdentity::default();
event.user_request = UserRequest::default();
event.configuration = {
let mut configuration = Configuration::default();
configuration.access_point_arn = "APRN".to_string();
configuration.supporting_access_point_arn = "SAPRN".to_string();
configuration.payload = json!(null);
configuration
};
event
}
}
81 changes: 44 additions & 37 deletions examples/basic-s3-thumbnail/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,46 +185,53 @@ mod tests {
}

fn get_s3_event(event_name: &str, bucket_name: &str, object_key: &str) -> S3Event {
S3Event {
records: (vec![get_s3_event_record(event_name, bucket_name, object_key)]),
}
let mut event = S3Event::default();
event.records = vec![get_s3_event_record(event_name, bucket_name, object_key)];
event
}

fn get_s3_event_record(event_name: &str, bucket_name: &str, object_key: &str) -> S3EventRecord {
let s3_entity = S3Entity {
schema_version: (Some(String::default())),
configuration_id: (Some(String::default())),
bucket: (S3Bucket {
name: (Some(bucket_name.to_string())),
owner_identity: Some(S3UserIdentity {
principal_id: (Some(String::default())),
}),
arn: (Some(String::default())),
}),
object: (S3Object {
key: (Some(object_key.to_string())),
size: (Some(1)),
url_decoded_key: (Some(String::default())),
version_id: (Some(String::default())),
e_tag: (Some(String::default())),
sequencer: (Some(String::default())),
}),
let mut s3_bucket = S3Bucket::default();
s3_bucket.name = (Some(bucket_name.to_string()));
s3_bucket.owner_identity = {
let mut s3_user_identity = S3UserIdentity::default();
s3_user_identity.principal_id = Some(String::default());
Some(s3_user_identity)
};

S3EventRecord {
event_version: (Some(String::default())),
event_source: (Some(String::default())),
aws_region: (Some(String::default())),
event_time: (chrono::DateTime::default()),
event_name: (Some(event_name.to_string())),
principal_id: (S3UserIdentity {
principal_id: (Some("X".to_string())),
}),
request_parameters: (S3RequestParameters {
source_ip_address: (Some(String::default())),
}),
response_elements: (HashMap::new()),
s3: (s3_entity),
}
s3_bucket.arn = Some(String::default());

let mut s3_object = S3Object::default();
s3_object.key = Some(object_key.to_string());
s3_object.size = Some(1);
s3_object.url_decoded_key = Some(String::default());
s3_object.version_id = Some(String::default());
s3_object.e_tag = Some(String::default());
s3_object.sequencer = Some(String::default());

let mut s3_entity = S3Entity::default();
s3_entity.schema_version = Some(String::default());
s3_entity.configuration_id = Some(String::default());
s3_entity.bucket = s3_bucket;
s3_entity.object = s3_object;

let mut s3_event_record = S3EventRecord::default();
s3_event_record.event_version = Some(String::default());
s3_event_record.event_source = Some(String::default());
s3_event_record.aws_region = Some(String::default());
s3_event_record.event_time = chrono::DateTime::default();
s3_event_record.event_name = Some(event_name.to_string());
s3_event_record.principal_id = {
let mut s3_user_identity = S3UserIdentity::default();
s3_user_identity.principal_id = Some("X".to_string());
s3_user_identity
};
s3_event_record.request_parameters = {
let mut s3_request_parameters = S3RequestParameters::default();
s3_request_parameters.source_ip_address = Some(String::default());
s3_request_parameters
};
s3_event_record.response_elements = HashMap::new();
s3_event_record.s3 = s3_entity;
s3_event_record
}
}
1 change: 1 addition & 0 deletions lambda-events/src/encodings/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use std::{borrow::Cow, mem::take, ops::Deref, pin::Pin, task::Poll};
///
/// For more information about API Gateway's body types,
/// refer to [this documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html).
#[non_exhaustive]
#[derive(Debug, Default, Eq, PartialEq)]
pub enum Body {
/// An empty body
Expand Down
1 change: 1 addition & 0 deletions lambda-events/src/encodings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub use self::http::*;
pub type Error = Box<dyn std::error::Error + Send + Sync>;

/// Binary data encoded in base64.
#[non_exhaustive]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct Base64Data(
#[serde(deserialize_with = "deserialize_base64")]
Expand Down
4 changes: 4 additions & 0 deletions lambda-events/src/encodings/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use serde::{
use std::ops::{Deref, DerefMut};

/// Timestamp with millisecond precision.
#[non_exhaustive]
#[derive(Clone, Default, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct MillisecondTimestamp(
#[serde(deserialize_with = "deserialize_milliseconds")]
Expand All @@ -29,6 +30,7 @@ impl DerefMut for MillisecondTimestamp {
}

/// Timestamp with second precision.
#[non_exhaustive]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct SecondTimestamp(
#[serde(deserialize_with = "deserialize_seconds")]
Expand All @@ -51,6 +53,7 @@ impl DerefMut for SecondTimestamp {
}

/// Duration with second precision.
#[non_exhaustive]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct SecondDuration(
#[serde(deserialize_with = "deserialize_duration_seconds")]
Expand All @@ -73,6 +76,7 @@ impl DerefMut for SecondDuration {
}

/// Duration with minute precision.
#[non_exhaustive]
#[derive(Clone, Default, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct MinuteDuration(
#[serde(deserialize_with = "deserialize_duration_minutes")]
Expand Down
3 changes: 3 additions & 0 deletions lambda-events/src/event/activemq/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;

use crate::custom_serde::deserialize_lambda_map;

#[non_exhaustive]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActiveMqEvent {
Expand All @@ -22,6 +23,7 @@ pub struct ActiveMqEvent {
pub other: serde_json::Map<String, Value>,
}

#[non_exhaustive]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActiveMqMessage {
Expand Down Expand Up @@ -59,6 +61,7 @@ pub struct ActiveMqMessage {
pub other: serde_json::Map<String, Value>,
}

#[non_exhaustive]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActiveMqDestination {
Expand Down
3 changes: 3 additions & 0 deletions lambda-events/src/event/alb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;

/// `AlbTargetGroupRequest` contains data originating from the ALB Lambda target group integration
#[non_exhaustive]
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AlbTargetGroupRequest {
Expand Down Expand Up @@ -44,6 +45,7 @@ pub struct AlbTargetGroupRequest {
}

/// `AlbTargetGroupRequestContext` contains the information to identify the load balancer invoking the lambda
#[non_exhaustive]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AlbTargetGroupRequestContext {
Expand All @@ -58,6 +60,7 @@ pub struct AlbTargetGroupRequestContext {
}

/// `ElbContext` contains the information to identify the ARN invoking the lambda
#[non_exhaustive]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ElbContext {
Expand Down
Loading
Loading