Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jan/upgrade to amazonka 2.0 rc1 #2

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 3 additions & 3 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ dependencies:
- base >= 4.7 && < 5
- aeson
- aeson-casing
- amazonka-core
- amazonka-kinesis
- amazonka-s3
- amazonka-core ^>= 2.0
- amazonka-kinesis ^>= 2.0
- amazonka-s3 ^>= 2.0
- bytestring
- case-insensitive
- containers
Expand Down
5 changes: 2 additions & 3 deletions src/AWSLambda/Events/APIGateway.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Control.Lens hiding ((.=))
import Data.Aeson
import Data.Aeson.Casing (aesonDrop, camelCase)
import Data.Aeson.TH (deriveFromJSON)
-- import Data.CaseInsensitive (CI (..))
import Data.Aeson.Embedded
import Data.Aeson.TextValue
import Data.Aeson.Types (Parser)
Expand All @@ -42,8 +41,8 @@ import qualified Data.Set as Set
import qualified Data.Text as Text
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import GHC.Generics (Generic)
import Network.AWS.Data.Base64
import Network.AWS.Data.Text
import Amazonka.Data.Base64
import Amazonka.Data.Text
import qualified Network.HTTP.Types as HTTP
import Text.Read

Expand Down
8 changes: 4 additions & 4 deletions src/AWSLambda/Events/KinesisEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import Data.Aeson (FromJSON (..), withObject, (.:))
import Data.Aeson.Casing (aesonDrop, camelCase)
import Data.Aeson.TH (deriveFromJSON)
import Data.Text (Text)
import Network.AWS.Data.Base64 (Base64 (..))
import qualified Network.AWS.Kinesis.Types as Kinesis
import qualified Network.AWS.Types as AWS
import Amazonka.Data.Base64 (Base64 (..))
import qualified Amazonka.Kinesis.Types as Kinesis
import qualified Amazonka.Types as AWS

import AWSLambda.Events.Records

Expand All @@ -33,7 +33,7 @@ instance FromJSON KinesisRecord where
_krKinesisSchemaVersion <- o .: "kinesisSchemaVersion"
dataBase64 <- o .: "data"
_krRecord <-
Kinesis.record <$> (o .: "sequenceNumber") <*> pure (unBase64 dataBase64) <*>
Kinesis.newRecord <$> (o .: "sequenceNumber") <*> pure (unBase64 dataBase64) <*>
(o .: "partitionKey")
return KinesisRecord {..}
$(makeLenses ''KinesisRecord)
Expand Down
59 changes: 39 additions & 20 deletions src/AWSLambda/Events/S3Event.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import Data.Aeson.Casing (aesonDrop, camelCase)
import Data.Aeson.TH (deriveFromJSON)
import Data.Text (Text)
import Data.Time.Clock (UTCTime)
import Network.AWS.S3 (BucketName, ETag, Event(..), ObjectKey, ObjectVersionId)
import qualified Network.AWS.Types as AWS
import Amazonka.S3 (BucketName, ETag, Event(..), ObjectKey, ObjectVersionId)
import qualified Amazonka.Types as AWS

import AWSLambda.Events.Records
import AWSLambda.Orphans ()
Expand Down Expand Up @@ -112,25 +112,44 @@ type S3Event = RecordsEvent S3EventNotification
-- | Is the event an object creation event
isCreateEvent :: S3EventNotification -> Bool
isCreateEvent e = case _senEventName e of
S3ObjectCreated -> True
S3ObjectCreatedCompleteMultipartUpload -> True
S3ObjectCreatedCopy -> True
S3ObjectCreatedPost -> True
S3ObjectCreatedPut -> True
S3ObjectRemoved -> False
S3ObjectRemovedDelete -> False
S3ObjectRemovedDeleteMarkerCreated -> False
S3ReducedRedundancyLostObject -> False
Event_S3_ObjectCreated_CompleteMultipartUpload -> True
Event_S3_ObjectCreated_Copy -> True
Event_S3_ObjectCreated_Post -> True
Event_S3_ObjectCreated_Put -> True
Event_S3_ObjectCreated__ -> True
Event_S3_ObjectRemoved_Delete -> False
Event_S3_ObjectRemoved_DeleteMarkerCreated -> False
Event_S3_ObjectRemoved__ -> False
Event_S3_ObjectRestore_Completed -> False
Event_S3_ObjectRestore_Post -> False
Event_S3_ObjectRestore__ -> False
Event_S3_ReducedRedundancyLostObject -> False
Event_S3_Replication_OperationFailedReplication -> False
Event_S3_Replication_OperationMissedThreshold -> False
Event_S3_Replication_OperationNotTracked -> False
Event_S3_Replication_OperationReplicatedAfterThreshold -> False
Event_S3_Replication__ -> False
Event' _ -> False


-- | Is the event an object removal event
isRemoveEvent :: S3EventNotification -> Bool
isRemoveEvent e = case _senEventName e of
S3ObjectCreated -> False
S3ObjectCreatedCompleteMultipartUpload -> False
S3ObjectCreatedCopy -> False
S3ObjectCreatedPost -> False
S3ObjectCreatedPut -> False
S3ObjectRemoved -> True
S3ObjectRemovedDelete -> True
S3ObjectRemovedDeleteMarkerCreated -> True
S3ReducedRedundancyLostObject -> False
Event_S3_ObjectCreated_CompleteMultipartUpload -> False
Event_S3_ObjectCreated_Copy -> False
Event_S3_ObjectCreated_Post -> False
Event_S3_ObjectCreated_Put -> False
Event_S3_ObjectCreated__ -> False
Event_S3_ObjectRemoved_Delete -> True
Event_S3_ObjectRemoved_DeleteMarkerCreated -> True
Event_S3_ObjectRemoved__ -> True
Event_S3_ObjectRestore_Completed -> False
Event_S3_ObjectRestore_Post -> False
Event_S3_ObjectRestore__ -> False
Event_S3_ReducedRedundancyLostObject -> False
Event_S3_Replication_OperationFailedReplication -> False
Event_S3_Replication_OperationMissedThreshold -> False
Event_S3_Replication_OperationNotTracked -> False
Event_S3_Replication_OperationReplicatedAfterThreshold -> False
Event_S3_Replication__ -> False
Event' _ -> False
4 changes: 2 additions & 2 deletions src/AWSLambda/Events/SNSEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import Data.HashMap.Strict (HashMap)
import Data.Text (Text)
import Data.Time.Clock (UTCTime)
import GHC.Generics (Generic)
import Network.AWS.Data.Base64
import Network.AWS.Data.Text (FromText)
import Amazonka.Data.Base64
import Amazonka.Data.Text (FromText)

import AWSLambda.Events.MessageAttribute
import AWSLambda.Events.Records
Expand Down
6 changes: 3 additions & 3 deletions src/AWSLambda/Events/SQSEvent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import Data.ByteString (ByteString)
import Data.HashMap.Strict (HashMap)
import Data.Text (Text)
import GHC.Generics (Generic)
import Network.AWS.Data.Base64
import Network.AWS.Data.Text (FromText)
import qualified Network.AWS.Types as AWS
import Amazonka.Data.Base64
import Amazonka.Data.Text (FromText)
import qualified Amazonka.Types as AWS

import AWSLambda.Events.MessageAttribute
import AWSLambda.Events.Records
Expand Down
15 changes: 2 additions & 13 deletions src/AWSLambda/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
module AWSLambda.Orphans where

import Data.Aeson
import Data.Monoid ((<>))
import qualified Data.Text as Text
import Network.AWS.Data.Text (fromText)
import qualified Network.AWS.S3 as S3
import Amazonka.Data.Text (fromText)
import qualified Amazonka.S3 as S3

#if !MIN_VERSION_amazonka_core(1,6,0)
deriving instance FromJSON S3.BucketName
Expand All @@ -21,12 +19,3 @@ deriving instance FromJSON S3.ObjectVersionId

instance FromJSON S3.ETag where
parseJSON = withText "ETag" $ either fail return . fromText

instance FromJSON S3.Event where
parseJSON = withText "Event" $ either fail return . fromText . addS3Prefix
where
s3Prefix = "s3:"
addS3Prefix s =
if s3Prefix `Text.isPrefixOf` s
then s
else s3Prefix <> s
9 changes: 4 additions & 5 deletions src/Data/Aeson/Embedded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ module Data.Aeson.Embedded where
import Control.Lens.TH
import Data.Aeson
import qualified Data.ByteString.Lazy as LBS
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Network.AWS.Data.Text (FromText (..), ToText (..), fromText,
takeText)
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Amazonka.Data.Text (FromText (..), ToText (..), fromText)

-- | Type for a JSON value embedded within a JSON string value
newtype Embedded a = Embedded { _unEmbed :: a } deriving (Eq, Show)

instance FromJSON a =>
FromText (Embedded a) where
parser =
fmap Embedded . either fail pure . eitherDecodeStrict . encodeUtf8 =<< takeText
fromText txt =
fmap Embedded . eitherDecodeStrict $ encodeUtf8 txt

instance FromJSON a =>
FromJSON (Embedded a) where
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Aeson/TextValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Data.Aeson.TextValue where
import Control.Lens.TH
import Data.Aeson
import Data.String
import Network.AWS.Data.Text (FromText (..), ToText (..), fromText)
import Amazonka.Data.Text (FromText (..), ToText (..), fromText)


newtype TextValue a = TextValue { _unTextValue :: a } deriving (Eq, Show, IsString)
Expand Down
15 changes: 12 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
resolver: lts-17.7
resolver: lts-18.8
packages:
- .
- example-project
- .
- example-project
nix:
packages:
- zlib.dev
- zlib.out
# Work around https://github.com/commercialhaskell/stack/issues/5290
save-hackage-creds: false
extra-deps:
- github: brendanhay/amazonka
commit: 098795f847df7239af64535c6b2b233f3fbd699c
subdirs:
- lib/amazonka
- lib/amazonka-core
- lib/services/amazonka-sts # amazonka library depends on this
- lib/services/amazonka-kinesis
- lib/services/amazonka-s3
75 changes: 70 additions & 5 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,75 @@
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
packages:
- completed:
size: 27716899
subdir: lib/amazonka
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
name: amazonka
version: '2.0'
sha256: f78c31484748a9df89305ef998dab30018eb94f855fbb01b35d0680f10a52f8e
pantry-tree:
size: 1318
sha256: 44fd392b7c986dd3417f70308741be397ca32b0d51f1ead3bc9d00505d5c8bcb
original:
subdir: lib/amazonka
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
- completed:
size: 27716899
subdir: lib/amazonka-core
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
name: amazonka-core
version: '2.0'
sha256: f78c31484748a9df89305ef998dab30018eb94f855fbb01b35d0680f10a52f8e
pantry-tree:
size: 3117
sha256: 7aacb4d572894018c2ee64ec3fcfeae802ad61a6b04b4da04e7477b72af3ca2c
original:
subdir: lib/amazonka-core
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
- completed:
size: 27716899
subdir: lib/services/amazonka-sts
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
name: amazonka-sts
version: '2.0'
sha256: f78c31484748a9df89305ef998dab30018eb94f855fbb01b35d0680f10a52f8e
pantry-tree:
size: 2932
sha256: b3356be0b7999b0d4f0300b5f9bb61bb77090067e50140335210e817d30f9309
original:
subdir: lib/services/amazonka-sts
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
- completed:
size: 27716899
subdir: lib/services/amazonka-kinesis
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
name: amazonka-kinesis
version: '2.0'
sha256: f78c31484748a9df89305ef998dab30018eb94f855fbb01b35d0680f10a52f8e
pantry-tree:
size: 9301
sha256: 562da1e73c6f965b47b4c9fe21337dba10fc96b85c05c1faaed36db08eb6cbf7
original:
subdir: lib/services/amazonka-kinesis
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
- completed:
size: 27716899
subdir: lib/services/amazonka-s3
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
name: amazonka-s3
version: '2.0'
sha256: f78c31484748a9df89305ef998dab30018eb94f855fbb01b35d0680f10a52f8e
pantry-tree:
size: 37929
sha256: dae7759fe4c713a7932dcee0a993902fd9910c4a51e1655245a86892608af43e
original:
subdir: lib/services/amazonka-s3
url: https://github.com/brendanhay/amazonka/archive/098795f847df7239af64535c6b2b233f3fbd699c.tar.gz
snapshots:
- completed:
size: 565715
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/7.yaml
sha256: 1b5e4124989399e60e7a7901f0cefd910beea546131fb07a13a7208c4cc8b7ee
original: lts-17.7
size: 587126
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/8.yaml
sha256: 93a107557e8691ed5ca17beaee41e68222b142c48868fc8c04a4181fb233477d
original: lts-18.8
6 changes: 3 additions & 3 deletions test/AWSLambda/Events/KinesisEventSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import AWSLambda.Events.Records
import Data.Aeson
import Data.ByteString.Lazy (ByteString)

import qualified Network.AWS.Kinesis.Types as Kinesis
import Network.AWS.Types (Region (..))
import qualified Amazonka.Kinesis.Types as Kinesis
import Amazonka.Types (Region (..))

import Text.RawString.QQ

Expand Down Expand Up @@ -52,7 +52,7 @@ sampleKinesisEvent =
{ _kerKinesis =
KinesisRecord
{ _krRecord =
Kinesis.record
Kinesis.newRecord
"49545115243490985018280067714973144582180062593244200961"
"Hello, this is a test 123."
"partitionKey-3"
Expand Down
10 changes: 5 additions & 5 deletions test/AWSLambda/Events/S3EventSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Data.ByteString.Lazy (ByteString)
import Data.Time.Calendar
import Data.Time.Clock

import Network.AWS.S3
import Amazonka.S3

import Text.RawString.QQ

Expand Down Expand Up @@ -57,7 +57,7 @@ sampleS3PutJSON = [r|
"x-amz-request-id": "EXAMPLE123456789"
},
"awsRegion": "us-east-1",
"eventName": "ObjectCreated:Put",
"eventName": "s3:ObjectCreated:Put",
"userIdentity": {
"principalId": "EXAMPLE"
},
Expand All @@ -73,7 +73,7 @@ sampleS3PutEvent =
{ _reRecords =
[ S3EventNotification
{ _senAwsRegion = NorthVirginia
, _senEventName = S3ObjectCreatedPut
, _senEventName = Event_S3_ObjectCreated_Put
, _senEventSource = "aws:s3"
, _senEventTime = UTCTime (fromGregorian 1970 1 1) (secondsToDiffTime 0)
, _senEventVersion = "2.0"
Expand Down Expand Up @@ -147,7 +147,7 @@ sampleS3DeleteJSON = [r|
"x-amz-request-id": "EXAMPLE123456789"
},
"awsRegion": "us-east-1",
"eventName": "ObjectRemoved:Delete",
"eventName": "s3:ObjectRemoved:Delete",
"userIdentity": {
"principalId": "EXAMPLE"
},
Expand All @@ -163,7 +163,7 @@ sampleS3DeleteEvent =
{ _reRecords =
[ S3EventNotification
{ _senAwsRegion = NorthVirginia
, _senEventName = S3ObjectRemovedDelete
, _senEventName = Event_S3_ObjectRemoved_Delete
, _senEventSource = "aws:s3"
, _senEventTime = UTCTime (fromGregorian 1970 1 1) (secondsToDiffTime 0)
, _senEventVersion = "2.0"
Expand Down
Loading