{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.Rekognition.CreateCollection
(
CreateCollection (..),
newCreateCollection,
createCollection_tags,
createCollection_collectionId,
CreateCollectionResponse (..),
newCreateCollectionResponse,
createCollectionResponse_faceModelVersion,
createCollectionResponse_collectionArn,
createCollectionResponse_statusCode,
createCollectionResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateCollection = CreateCollection'
{
CreateCollection -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateCollection -> Text
collectionId :: Prelude.Text
}
deriving (CreateCollection -> CreateCollection -> Bool
(CreateCollection -> CreateCollection -> Bool)
-> (CreateCollection -> CreateCollection -> Bool)
-> Eq CreateCollection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCollection -> CreateCollection -> Bool
$c/= :: CreateCollection -> CreateCollection -> Bool
== :: CreateCollection -> CreateCollection -> Bool
$c== :: CreateCollection -> CreateCollection -> Bool
Prelude.Eq, ReadPrec [CreateCollection]
ReadPrec CreateCollection
Int -> ReadS CreateCollection
ReadS [CreateCollection]
(Int -> ReadS CreateCollection)
-> ReadS [CreateCollection]
-> ReadPrec CreateCollection
-> ReadPrec [CreateCollection]
-> Read CreateCollection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCollection]
$creadListPrec :: ReadPrec [CreateCollection]
readPrec :: ReadPrec CreateCollection
$creadPrec :: ReadPrec CreateCollection
readList :: ReadS [CreateCollection]
$creadList :: ReadS [CreateCollection]
readsPrec :: Int -> ReadS CreateCollection
$creadsPrec :: Int -> ReadS CreateCollection
Prelude.Read, Int -> CreateCollection -> ShowS
[CreateCollection] -> ShowS
CreateCollection -> String
(Int -> CreateCollection -> ShowS)
-> (CreateCollection -> String)
-> ([CreateCollection] -> ShowS)
-> Show CreateCollection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCollection] -> ShowS
$cshowList :: [CreateCollection] -> ShowS
show :: CreateCollection -> String
$cshow :: CreateCollection -> String
showsPrec :: Int -> CreateCollection -> ShowS
$cshowsPrec :: Int -> CreateCollection -> ShowS
Prelude.Show, (forall x. CreateCollection -> Rep CreateCollection x)
-> (forall x. Rep CreateCollection x -> CreateCollection)
-> Generic CreateCollection
forall x. Rep CreateCollection x -> CreateCollection
forall x. CreateCollection -> Rep CreateCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCollection x -> CreateCollection
$cfrom :: forall x. CreateCollection -> Rep CreateCollection x
Prelude.Generic)
newCreateCollection ::
Prelude.Text ->
CreateCollection
newCreateCollection :: Text -> CreateCollection
newCreateCollection Text
pCollectionId_ =
CreateCollection' :: Maybe (HashMap Text Text) -> Text -> CreateCollection
CreateCollection'
{ $sel:tags:CreateCollection' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:collectionId:CreateCollection' :: Text
collectionId = Text
pCollectionId_
}
createCollection_tags :: Lens.Lens' CreateCollection (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createCollection_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateCollection -> f CreateCollection
createCollection_tags = (CreateCollection -> Maybe (HashMap Text Text))
-> (CreateCollection
-> Maybe (HashMap Text Text) -> CreateCollection)
-> Lens
CreateCollection
CreateCollection
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCollection' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateCollection' :: CreateCollection -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateCollection
s@CreateCollection' {} Maybe (HashMap Text Text)
a -> CreateCollection
s {$sel:tags:CreateCollection' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateCollection) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateCollection -> f CreateCollection)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateCollection
-> f CreateCollection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createCollection_collectionId :: Lens.Lens' CreateCollection Prelude.Text
createCollection_collectionId :: (Text -> f Text) -> CreateCollection -> f CreateCollection
createCollection_collectionId = (CreateCollection -> Text)
-> (CreateCollection -> Text -> CreateCollection)
-> Lens CreateCollection CreateCollection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCollection' {Text
collectionId :: Text
$sel:collectionId:CreateCollection' :: CreateCollection -> Text
collectionId} -> Text
collectionId) (\s :: CreateCollection
s@CreateCollection' {} Text
a -> CreateCollection
s {$sel:collectionId:CreateCollection' :: Text
collectionId = Text
a} :: CreateCollection)
instance Core.AWSRequest CreateCollection where
type
AWSResponse CreateCollection =
CreateCollectionResponse
request :: CreateCollection -> Request CreateCollection
request = Service -> CreateCollection -> Request CreateCollection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateCollection
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCollection)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateCollection))
-> Logger
-> Service
-> Proxy CreateCollection
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCollection)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text
-> Maybe Text -> Maybe Natural -> Int -> CreateCollectionResponse
CreateCollectionResponse'
(Maybe Text
-> Maybe Text -> Maybe Natural -> Int -> CreateCollectionResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe Text -> Maybe Natural -> Int -> CreateCollectionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FaceModelVersion")
Either
String
(Maybe Text -> Maybe Natural -> Int -> CreateCollectionResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Natural -> Int -> CreateCollectionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CollectionArn")
Either String (Maybe Natural -> Int -> CreateCollectionResponse)
-> Either String (Maybe Natural)
-> Either String (Int -> CreateCollectionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StatusCode")
Either String (Int -> CreateCollectionResponse)
-> Either String Int -> Either String CreateCollectionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateCollection
instance Prelude.NFData CreateCollection
instance Core.ToHeaders CreateCollection where
toHeaders :: CreateCollection -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateCollection -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"RekognitionService.CreateCollection" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateCollection where
toJSON :: CreateCollection -> Value
toJSON CreateCollection' {Maybe (HashMap Text Text)
Text
collectionId :: Text
tags :: Maybe (HashMap Text Text)
$sel:collectionId:CreateCollection' :: CreateCollection -> Text
$sel:tags:CreateCollection' :: CreateCollection -> Maybe (HashMap Text Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"CollectionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
collectionId)
]
)
instance Core.ToPath CreateCollection where
toPath :: CreateCollection -> ByteString
toPath = ByteString -> CreateCollection -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateCollection where
toQuery :: CreateCollection -> QueryString
toQuery = QueryString -> CreateCollection -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateCollectionResponse = CreateCollectionResponse'
{
CreateCollectionResponse -> Maybe Text
faceModelVersion :: Prelude.Maybe Prelude.Text,
CreateCollectionResponse -> Maybe Text
collectionArn :: Prelude.Maybe Prelude.Text,
CreateCollectionResponse -> Maybe Natural
statusCode :: Prelude.Maybe Prelude.Natural,
CreateCollectionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateCollectionResponse -> CreateCollectionResponse -> Bool
(CreateCollectionResponse -> CreateCollectionResponse -> Bool)
-> (CreateCollectionResponse -> CreateCollectionResponse -> Bool)
-> Eq CreateCollectionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCollectionResponse -> CreateCollectionResponse -> Bool
$c/= :: CreateCollectionResponse -> CreateCollectionResponse -> Bool
== :: CreateCollectionResponse -> CreateCollectionResponse -> Bool
$c== :: CreateCollectionResponse -> CreateCollectionResponse -> Bool
Prelude.Eq, ReadPrec [CreateCollectionResponse]
ReadPrec CreateCollectionResponse
Int -> ReadS CreateCollectionResponse
ReadS [CreateCollectionResponse]
(Int -> ReadS CreateCollectionResponse)
-> ReadS [CreateCollectionResponse]
-> ReadPrec CreateCollectionResponse
-> ReadPrec [CreateCollectionResponse]
-> Read CreateCollectionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCollectionResponse]
$creadListPrec :: ReadPrec [CreateCollectionResponse]
readPrec :: ReadPrec CreateCollectionResponse
$creadPrec :: ReadPrec CreateCollectionResponse
readList :: ReadS [CreateCollectionResponse]
$creadList :: ReadS [CreateCollectionResponse]
readsPrec :: Int -> ReadS CreateCollectionResponse
$creadsPrec :: Int -> ReadS CreateCollectionResponse
Prelude.Read, Int -> CreateCollectionResponse -> ShowS
[CreateCollectionResponse] -> ShowS
CreateCollectionResponse -> String
(Int -> CreateCollectionResponse -> ShowS)
-> (CreateCollectionResponse -> String)
-> ([CreateCollectionResponse] -> ShowS)
-> Show CreateCollectionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCollectionResponse] -> ShowS
$cshowList :: [CreateCollectionResponse] -> ShowS
show :: CreateCollectionResponse -> String
$cshow :: CreateCollectionResponse -> String
showsPrec :: Int -> CreateCollectionResponse -> ShowS
$cshowsPrec :: Int -> CreateCollectionResponse -> ShowS
Prelude.Show, (forall x.
CreateCollectionResponse -> Rep CreateCollectionResponse x)
-> (forall x.
Rep CreateCollectionResponse x -> CreateCollectionResponse)
-> Generic CreateCollectionResponse
forall x.
Rep CreateCollectionResponse x -> CreateCollectionResponse
forall x.
CreateCollectionResponse -> Rep CreateCollectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateCollectionResponse x -> CreateCollectionResponse
$cfrom :: forall x.
CreateCollectionResponse -> Rep CreateCollectionResponse x
Prelude.Generic)
newCreateCollectionResponse ::
Prelude.Int ->
CreateCollectionResponse
newCreateCollectionResponse :: Int -> CreateCollectionResponse
newCreateCollectionResponse Int
pHttpStatus_ =
CreateCollectionResponse' :: Maybe Text
-> Maybe Text -> Maybe Natural -> Int -> CreateCollectionResponse
CreateCollectionResponse'
{ $sel:faceModelVersion:CreateCollectionResponse' :: Maybe Text
faceModelVersion =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:collectionArn:CreateCollectionResponse' :: Maybe Text
collectionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:statusCode:CreateCollectionResponse' :: Maybe Natural
statusCode = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateCollectionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createCollectionResponse_faceModelVersion :: Lens.Lens' CreateCollectionResponse (Prelude.Maybe Prelude.Text)
createCollectionResponse_faceModelVersion :: (Maybe Text -> f (Maybe Text))
-> CreateCollectionResponse -> f CreateCollectionResponse
createCollectionResponse_faceModelVersion = (CreateCollectionResponse -> Maybe Text)
-> (CreateCollectionResponse
-> Maybe Text -> CreateCollectionResponse)
-> Lens
CreateCollectionResponse
CreateCollectionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCollectionResponse' {Maybe Text
faceModelVersion :: Maybe Text
$sel:faceModelVersion:CreateCollectionResponse' :: CreateCollectionResponse -> Maybe Text
faceModelVersion} -> Maybe Text
faceModelVersion) (\s :: CreateCollectionResponse
s@CreateCollectionResponse' {} Maybe Text
a -> CreateCollectionResponse
s {$sel:faceModelVersion:CreateCollectionResponse' :: Maybe Text
faceModelVersion = Maybe Text
a} :: CreateCollectionResponse)
createCollectionResponse_collectionArn :: Lens.Lens' CreateCollectionResponse (Prelude.Maybe Prelude.Text)
createCollectionResponse_collectionArn :: (Maybe Text -> f (Maybe Text))
-> CreateCollectionResponse -> f CreateCollectionResponse
createCollectionResponse_collectionArn = (CreateCollectionResponse -> Maybe Text)
-> (CreateCollectionResponse
-> Maybe Text -> CreateCollectionResponse)
-> Lens
CreateCollectionResponse
CreateCollectionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCollectionResponse' {Maybe Text
collectionArn :: Maybe Text
$sel:collectionArn:CreateCollectionResponse' :: CreateCollectionResponse -> Maybe Text
collectionArn} -> Maybe Text
collectionArn) (\s :: CreateCollectionResponse
s@CreateCollectionResponse' {} Maybe Text
a -> CreateCollectionResponse
s {$sel:collectionArn:CreateCollectionResponse' :: Maybe Text
collectionArn = Maybe Text
a} :: CreateCollectionResponse)
createCollectionResponse_statusCode :: Lens.Lens' CreateCollectionResponse (Prelude.Maybe Prelude.Natural)
createCollectionResponse_statusCode :: (Maybe Natural -> f (Maybe Natural))
-> CreateCollectionResponse -> f CreateCollectionResponse
createCollectionResponse_statusCode = (CreateCollectionResponse -> Maybe Natural)
-> (CreateCollectionResponse
-> Maybe Natural -> CreateCollectionResponse)
-> Lens
CreateCollectionResponse
CreateCollectionResponse
(Maybe Natural)
(Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCollectionResponse' {Maybe Natural
statusCode :: Maybe Natural
$sel:statusCode:CreateCollectionResponse' :: CreateCollectionResponse -> Maybe Natural
statusCode} -> Maybe Natural
statusCode) (\s :: CreateCollectionResponse
s@CreateCollectionResponse' {} Maybe Natural
a -> CreateCollectionResponse
s {$sel:statusCode:CreateCollectionResponse' :: Maybe Natural
statusCode = Maybe Natural
a} :: CreateCollectionResponse)
createCollectionResponse_httpStatus :: Lens.Lens' CreateCollectionResponse Prelude.Int
createCollectionResponse_httpStatus :: (Int -> f Int)
-> CreateCollectionResponse -> f CreateCollectionResponse
createCollectionResponse_httpStatus = (CreateCollectionResponse -> Int)
-> (CreateCollectionResponse -> Int -> CreateCollectionResponse)
-> Lens CreateCollectionResponse CreateCollectionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCollectionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCollectionResponse' :: CreateCollectionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCollectionResponse
s@CreateCollectionResponse' {} Int
a -> CreateCollectionResponse
s {$sel:httpStatus:CreateCollectionResponse' :: Int
httpStatus = Int
a} :: CreateCollectionResponse)
instance Prelude.NFData CreateCollectionResponse