Skip to content

Commit 95cf205

Browse files
committed
remove S3 SDK deps
1 parent 6648ac9 commit 95cf205

File tree

3 files changed

+221
-8
lines changed

3 files changed

+221
-8
lines changed

Libraries/src/Amazon.Lambda.S3Events/Amazon.Lambda.S3Events.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="AWSSDK.S3" Version="3.7.0" />
16+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1717
</ItemGroup>
1818

1919
</Project>

Libraries/src/Amazon.Lambda.S3Events/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Amazon.Lambda.S3Events
22

3-
This package contains classes that can be used as input types for Lambda functions that process Amazon Simple Storage Service (Amazon S3) events.
4-
5-
This package has a dependency on the [AWS SDK for .NET package AWSSDK.S3](https://www.nuget.org/packages/AWSSDK.S3/) in order to use the `Amazon.S3.Util.S3EventNotification` type.
3+
This package contains classes that can be used as input types for Lambda functions that process Amazon Simple Storage Service (Amazon S3) events.
64

75
# Serialization
86

97
If you are using this package with Amazon Lambda but are not also using `Amazon.Lambda.Serialization.Json`, be aware that two properties require custom serialization. These properties are both part of the `Amazon.S3.Util.S3EventNotification+ResponseElementsEntity` class.
108
1. `XAmzRequestId` should be treated as `x-amz-request-id`
119
2. `XAmzId2` should be treated as `x-amz-id-2`
1210

13-
A Newtonsoft.Json `IContractResolver` implementation which handles this custom serialization is located in [Amazon.Lambda.Serialization.Json\AwsResolver.cs](../Amazon.Lambda.Serialization.Json/AwsResolver.cs), consult this source for more information.
11+
A Newtonsoft.Json `IContractResolver` implementation which handles this custom serialization is located in [Amazon.Lambda.Serialization.Json\AwsResolver.cs](../Amazon.Lambda.Serialization.Json/AwsResolver.cs), consult this source for more information.
1412

1513
# Sample Function
1614

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,226 @@
11
namespace Amazon.Lambda.S3Events
22
{
3-
using Amazon.S3.Util;
3+
using System;
4+
using System.Collections.Generic;
5+
6+
using Newtonsoft.Json;
47

58
/// <summary>
69
/// AWS S3 event
710
/// http://docs.aws.amazon.com/lambda/latest/dg/with-s3.html
811
/// http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-s3-put
12+
13+
914
/// </summary>
10-
public class S3Event : S3EventNotification { }
11-
}
15+
public class S3Event
16+
{
17+
18+
/// <summary>
19+
/// Gets and sets the records for the S3 event notification
20+
/// </summary>
21+
public List<S3EventNotificationRecord> Records { get; set; }
22+
23+
/// <summary>
24+
/// The class holds the user identity properties.
25+
/// </summary>
26+
public class UserIdentityEntity
27+
{
28+
/// <summary>
29+
/// Gets and sets the PrincipalId property.
30+
/// </summary>
31+
public string PrincipalId { get; set; }
32+
}
33+
34+
/// <summary>
35+
/// This class contains the identity information for an S3 bucket.
36+
/// </summary>
37+
public class S3BucketEntity
38+
{
39+
/// <summary>
40+
/// Gets and sets the name of the bucket.
41+
/// </summary>
42+
public string Name { get; set; }
43+
44+
/// <summary>
45+
/// Gets and sets the bucket owner id.
46+
/// </summary>
47+
public UserIdentityEntity OwnerIdentity { get; set; }
48+
49+
/// <summary>
50+
/// Gets and sets the S3 bucket arn.
51+
/// </summary>
52+
public string Arn { get; set; }
53+
}
54+
55+
/// <summary>
56+
/// This class contains the information for an object in S3.
57+
/// </summary>
58+
public class S3ObjectEntity
59+
{
60+
/// <summary>
61+
/// Gets and sets the key for the object stored in S3.
62+
/// </summary>
63+
public string Key { get; set; }
64+
65+
/// <summary>
66+
/// Gets and sets the size of the object in S3.
67+
/// </summary>
68+
public long Size { get; set; }
69+
70+
/// <summary>
71+
/// Gets and sets the etag of the object. This can be used to determine if the object has changed.
72+
/// </summary>
73+
public string ETag { get; set; }
74+
75+
/// <summary>
76+
/// Gets and sets the version id of the object in S3.
77+
/// </summary>
78+
public string VersionId { get; set; }
79+
80+
/// <summary>
81+
/// Gets and sets the sequencer a string representation of a hexadecimal value used to determine event sequence, only used with PUTs and DELETEs.
82+
/// </summary>
83+
public string Sequencer { get; set; }
84+
}
85+
86+
/// <summary>
87+
/// Gets and sets the meta information describing S3.
88+
/// </summary>
89+
public class S3Entity
90+
{
91+
/// <summary>
92+
/// Gets and sets the ConfigurationId. This ID can be found in the bucket notification configuration.
93+
/// </summary>
94+
public string ConfigurationId { get; set; }
95+
96+
/// <summary>
97+
/// Gets and sets the Bucket property.
98+
/// </summary>
99+
public S3BucketEntity Bucket { get; set; }
100+
101+
/// <summary>
102+
/// Gets and sets the Object property.
103+
/// </summary>
104+
public S3ObjectEntity Object { get; set; }
105+
106+
/// <summary>
107+
/// Gets and sets the S3SchemaVersion property.
108+
/// </summary>
109+
public string S3SchemaVersion { get; set; }
110+
}
111+
112+
/// <summary>
113+
/// The class holds the request parameters
114+
/// </summary>
115+
public class RequestParametersEntity
116+
{
117+
/// <summary>
118+
/// Gets and sets the SourceIPAddress. This is the ip address where the request came from.
119+
/// </summary>
120+
public string SourceIPAddress { get; set; }
121+
}
122+
123+
/// <summary>
124+
/// This class holds the response elements.
125+
/// </summary>
126+
public class ResponseElementsEntity
127+
{
128+
/// <summary>
129+
/// Gets and sets the XAmzId2 Property. This is the Amazon S3 host that processed the request.
130+
/// </summary>
131+
132+
[JsonProperty("x-amz-id-2")]
133+
public string XAmzId2 { get; set; }
134+
135+
/// <summary>
136+
/// Gets and sets the XAmzRequestId. This is the Amazon S3 generated request ID.
137+
/// </summary>
138+
[JsonProperty("x-amz-request-id")]
139+
public string XAmzRequestId { get; set; }
140+
}
141+
142+
/// <summary>
143+
/// The class holds the glacier event data elements.
144+
/// </summary>
145+
public class S3GlacierEventDataEntity
146+
{
147+
/// <summary>
148+
/// Gets and sets the RestoreEventData property.
149+
/// </summary>
150+
public S3RestoreEventDataEntity RestoreEventData { get; set; }
151+
}
152+
153+
/// <summary>
154+
/// The class holds the restore event data elements.
155+
/// </summary>
156+
public class S3RestoreEventDataEntity
157+
{
158+
/// <summary>
159+
/// Gets and sets the LifecycleRestorationExpiryTime the time when the object restoration will be expired.
160+
/// </summary>
161+
public DateTime LifecycleRestorationExpiryTime { get; set; }
162+
163+
/// <summary>
164+
/// Gets and sets the LifecycleRestoreStorageClass the source storage class for restore.
165+
/// </summary>
166+
public string LifecycleRestoreStorageClass { get; set; }
167+
}
168+
169+
/// <summary>
170+
/// The class holds the event notification.
171+
/// </summary>
172+
public class S3EventNotificationRecord
173+
{
174+
/// <summary>
175+
/// Gets and sets the AwsRegion property.
176+
/// </summary>
177+
public string AwsRegion { get; set; }
178+
179+
/// <summary>
180+
/// Gets and sets the EventName property. This identities what type of event occurred.
181+
/// For example for an object just put in S3 this will be set to EventType.ObjectCreatedPut.
182+
/// </summary>
183+
public string EventName { get; set; }
184+
185+
/// <summary>
186+
/// Gets and sets the EventSource property.
187+
/// </summary>
188+
public string EventSource { get; set; }
189+
190+
/// <summary>
191+
/// Gets and sets the EventTime property. The time when S3 finished processing the request.
192+
/// </summary>
193+
public DateTime EventTime { get; set; }
194+
195+
/// <summary>
196+
/// Gets and sets the EventVersion property.
197+
/// </summary>
198+
public string EventVersion { get; set; }
199+
200+
/// <summary>
201+
/// Gets and sets the RequestParameters property.
202+
/// </summary>
203+
public RequestParametersEntity RequestParameters { get; set; }
204+
205+
/// <summary>
206+
/// Gets and sets the ResponseElements property.
207+
/// </summary>
208+
public ResponseElementsEntity ResponseElements { get; set; }
209+
210+
/// <summary>
211+
/// Gets and sets the S3 property.
212+
/// </summary>
213+
public S3Entity S3 { get; set; }
214+
215+
/// <summary>
216+
/// Gets and sets the UserIdentity property.
217+
/// </summary>
218+
public UserIdentityEntity UserIdentity { get; set; }
219+
220+
/// <summary>
221+
/// Get and sets the GlacierEventData property.
222+
/// </summary>
223+
public S3GlacierEventDataEntity GlacierEventData { get; set; }
224+
}
225+
}
226+
}

0 commit comments

Comments
 (0)