Skip to content

Instantly share code, notes, and snippets.

@leepa leepa/s3.rs
Created Dec 5, 2018

Embed
What would you like to do?
Partial - this is the structure for S3 events
#[derive(Deserialize, Debug)]
struct S3Event {
#[serde(rename = "Records")]
#[allow(dead_code)]
records: Vec<S3EventRecord>,
}
#[derive(Deserialize, Debug)]
struct S3EventRecord {
#[serde(rename = "eventVersion")]
#[allow(dead_code)]
event_version: String,
#[serde(rename = "eventSource")]
#[allow(dead_code)]
event_source: String,
#[serde(rename = "awsRegion")]
#[allow(dead_code)]
aws_region: String,
#[serde(rename = "eventTime")]
#[allow(dead_code)]
event_time: DateTime<Utc>,
#[serde(rename = "eventName")]
#[allow(dead_code)]
event_name: String,
#[serde(rename = "userIdentity")]
#[allow(dead_code)]
user_identity: S3UserIdentity,
#[serde(rename = "requestParameters")]
#[allow(dead_code)]
request_parameters: S3RequestParameters,
#[serde(rename = "responseElements")]
#[allow(dead_code)]
response_elements: HashMap<String, String>,
#[serde(rename = "s3")]
#[allow(dead_code)]
s3: S3Entity,
}
#[derive(Deserialize, Debug)]
struct S3RequestParameters {
#[serde(rename = "sourceIPAddress")]
#[allow(dead_code)]
source_ip_address: String,
}
#[derive(Deserialize, Debug)]
struct S3UserIdentity {
#[serde(rename = "principalId")]
#[allow(dead_code)]
principal_id: String,
}
#[derive(Deserialize, Debug)]
struct S3Entity {
#[serde(rename = "s3SchemaVersion")]
#[allow(dead_code)]
schema_version: String,
#[serde(rename = "configurationId")]
#[allow(dead_code)]
configuration_id: String,
#[serde(rename = "bucket")]
#[allow(dead_code)]
bucket: S3Bucket,
#[serde(rename = "object")]
#[allow(dead_code)]
object: S3Object,
}
#[derive(Deserialize, Debug)]
struct S3Bucket {
#[serde(rename = "name")]
#[allow(dead_code)]
name: String,
#[serde(rename = "ownerIdentity")]
#[allow(dead_code)]
owner_identity: S3UserIdentity,
#[serde(rename = "arn")]
#[allow(dead_code)]
arn: String,
}
#[derive(Deserialize, Debug)]
struct S3Object {
#[serde(rename = "key")]
#[allow(dead_code)]
key: String,
#[serde(default)]
#[serde(rename = "size")]
#[allow(dead_code)]
size: i64,
#[serde(default)]
#[serde(rename = "urlDecodedKey")]
#[allow(dead_code)]
url_decoded_key: String,
#[serde(default)]
#[serde(rename = "versionId")]
#[allow(dead_code)]
version_id: String,
#[serde(default)]
#[serde(rename = "eTag")]
#[allow(dead_code)]
etag: String,
#[serde(rename = "sequencer")]
#[allow(dead_code)]
sequencer: String,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.