{-# 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.MediaStore.CreateContainer
(
CreateContainer (..),
newCreateContainer,
createContainer_tags,
createContainer_containerName,
CreateContainerResponse (..),
newCreateContainerResponse,
createContainerResponse_httpStatus,
createContainerResponse_container,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaStore.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateContainer = CreateContainer'
{
CreateContainer -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
CreateContainer -> Text
containerName :: Prelude.Text
}
deriving (CreateContainer -> CreateContainer -> Bool
(CreateContainer -> CreateContainer -> Bool)
-> (CreateContainer -> CreateContainer -> Bool)
-> Eq CreateContainer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContainer -> CreateContainer -> Bool
$c/= :: CreateContainer -> CreateContainer -> Bool
== :: CreateContainer -> CreateContainer -> Bool
$c== :: CreateContainer -> CreateContainer -> Bool
Prelude.Eq, ReadPrec [CreateContainer]
ReadPrec CreateContainer
Int -> ReadS CreateContainer
ReadS [CreateContainer]
(Int -> ReadS CreateContainer)
-> ReadS [CreateContainer]
-> ReadPrec CreateContainer
-> ReadPrec [CreateContainer]
-> Read CreateContainer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContainer]
$creadListPrec :: ReadPrec [CreateContainer]
readPrec :: ReadPrec CreateContainer
$creadPrec :: ReadPrec CreateContainer
readList :: ReadS [CreateContainer]
$creadList :: ReadS [CreateContainer]
readsPrec :: Int -> ReadS CreateContainer
$creadsPrec :: Int -> ReadS CreateContainer
Prelude.Read, Int -> CreateContainer -> ShowS
[CreateContainer] -> ShowS
CreateContainer -> String
(Int -> CreateContainer -> ShowS)
-> (CreateContainer -> String)
-> ([CreateContainer] -> ShowS)
-> Show CreateContainer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContainer] -> ShowS
$cshowList :: [CreateContainer] -> ShowS
show :: CreateContainer -> String
$cshow :: CreateContainer -> String
showsPrec :: Int -> CreateContainer -> ShowS
$cshowsPrec :: Int -> CreateContainer -> ShowS
Prelude.Show, (forall x. CreateContainer -> Rep CreateContainer x)
-> (forall x. Rep CreateContainer x -> CreateContainer)
-> Generic CreateContainer
forall x. Rep CreateContainer x -> CreateContainer
forall x. CreateContainer -> Rep CreateContainer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContainer x -> CreateContainer
$cfrom :: forall x. CreateContainer -> Rep CreateContainer x
Prelude.Generic)
newCreateContainer ::
Prelude.Text ->
CreateContainer
newCreateContainer :: Text -> CreateContainer
newCreateContainer Text
pContainerName_ =
CreateContainer' :: Maybe (NonEmpty Tag) -> Text -> CreateContainer
CreateContainer'
{ $sel:tags:CreateContainer' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
$sel:containerName:CreateContainer' :: Text
containerName = Text
pContainerName_
}
createContainer_tags :: Lens.Lens' CreateContainer (Prelude.Maybe (Prelude.NonEmpty Tag))
createContainer_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateContainer -> f CreateContainer
createContainer_tags = (CreateContainer -> Maybe (NonEmpty Tag))
-> (CreateContainer -> Maybe (NonEmpty Tag) -> CreateContainer)
-> Lens
CreateContainer
CreateContainer
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContainer' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateContainer' :: CreateContainer -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateContainer
s@CreateContainer' {} Maybe (NonEmpty Tag)
a -> CreateContainer
s {$sel:tags:CreateContainer' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateContainer) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateContainer -> f CreateContainer)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateContainer
-> f CreateContainer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
(Maybe (NonEmpty Tag))
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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createContainer_containerName :: Lens.Lens' CreateContainer Prelude.Text
createContainer_containerName :: (Text -> f Text) -> CreateContainer -> f CreateContainer
createContainer_containerName = (CreateContainer -> Text)
-> (CreateContainer -> Text -> CreateContainer)
-> Lens CreateContainer CreateContainer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContainer' {Text
containerName :: Text
$sel:containerName:CreateContainer' :: CreateContainer -> Text
containerName} -> Text
containerName) (\s :: CreateContainer
s@CreateContainer' {} Text
a -> CreateContainer
s {$sel:containerName:CreateContainer' :: Text
containerName = Text
a} :: CreateContainer)
instance Core.AWSRequest CreateContainer where
type
AWSResponse CreateContainer =
CreateContainerResponse
request :: CreateContainer -> Request CreateContainer
request = Service -> CreateContainer -> Request CreateContainer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateContainer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContainer)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateContainer))
-> Logger
-> Service
-> Proxy CreateContainer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContainer)))
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 ->
Int -> Container -> CreateContainerResponse
CreateContainerResponse'
(Int -> Container -> CreateContainerResponse)
-> Either String Int
-> Either String (Container -> CreateContainerResponse)
forall (f :: * -> *) a b. Functor 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))
Either String (Container -> CreateContainerResponse)
-> Either String Container -> Either String CreateContainerResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Container
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Container")
)
instance Prelude.Hashable CreateContainer
instance Prelude.NFData CreateContainer
instance Core.ToHeaders CreateContainer where
toHeaders :: CreateContainer -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateContainer -> 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
"MediaStore_20170901.CreateContainer" ::
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 CreateContainer where
toJSON :: CreateContainer -> Value
toJSON CreateContainer' {Maybe (NonEmpty Tag)
Text
containerName :: Text
tags :: Maybe (NonEmpty Tag)
$sel:containerName:CreateContainer' :: CreateContainer -> Text
$sel:tags:CreateContainer' :: CreateContainer -> Maybe (NonEmpty Tag)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ContainerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName)
]
)
instance Core.ToPath CreateContainer where
toPath :: CreateContainer -> ByteString
toPath = ByteString -> CreateContainer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateContainer where
toQuery :: CreateContainer -> QueryString
toQuery = QueryString -> CreateContainer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateContainerResponse = CreateContainerResponse'
{
CreateContainerResponse -> Int
httpStatus :: Prelude.Int,
CreateContainerResponse -> Container
container :: Container
}
deriving (CreateContainerResponse -> CreateContainerResponse -> Bool
(CreateContainerResponse -> CreateContainerResponse -> Bool)
-> (CreateContainerResponse -> CreateContainerResponse -> Bool)
-> Eq CreateContainerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContainerResponse -> CreateContainerResponse -> Bool
$c/= :: CreateContainerResponse -> CreateContainerResponse -> Bool
== :: CreateContainerResponse -> CreateContainerResponse -> Bool
$c== :: CreateContainerResponse -> CreateContainerResponse -> Bool
Prelude.Eq, ReadPrec [CreateContainerResponse]
ReadPrec CreateContainerResponse
Int -> ReadS CreateContainerResponse
ReadS [CreateContainerResponse]
(Int -> ReadS CreateContainerResponse)
-> ReadS [CreateContainerResponse]
-> ReadPrec CreateContainerResponse
-> ReadPrec [CreateContainerResponse]
-> Read CreateContainerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContainerResponse]
$creadListPrec :: ReadPrec [CreateContainerResponse]
readPrec :: ReadPrec CreateContainerResponse
$creadPrec :: ReadPrec CreateContainerResponse
readList :: ReadS [CreateContainerResponse]
$creadList :: ReadS [CreateContainerResponse]
readsPrec :: Int -> ReadS CreateContainerResponse
$creadsPrec :: Int -> ReadS CreateContainerResponse
Prelude.Read, Int -> CreateContainerResponse -> ShowS
[CreateContainerResponse] -> ShowS
CreateContainerResponse -> String
(Int -> CreateContainerResponse -> ShowS)
-> (CreateContainerResponse -> String)
-> ([CreateContainerResponse] -> ShowS)
-> Show CreateContainerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContainerResponse] -> ShowS
$cshowList :: [CreateContainerResponse] -> ShowS
show :: CreateContainerResponse -> String
$cshow :: CreateContainerResponse -> String
showsPrec :: Int -> CreateContainerResponse -> ShowS
$cshowsPrec :: Int -> CreateContainerResponse -> ShowS
Prelude.Show, (forall x.
CreateContainerResponse -> Rep CreateContainerResponse x)
-> (forall x.
Rep CreateContainerResponse x -> CreateContainerResponse)
-> Generic CreateContainerResponse
forall x. Rep CreateContainerResponse x -> CreateContainerResponse
forall x. CreateContainerResponse -> Rep CreateContainerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContainerResponse x -> CreateContainerResponse
$cfrom :: forall x. CreateContainerResponse -> Rep CreateContainerResponse x
Prelude.Generic)
newCreateContainerResponse ::
Prelude.Int ->
Container ->
CreateContainerResponse
newCreateContainerResponse :: Int -> Container -> CreateContainerResponse
newCreateContainerResponse Int
pHttpStatus_ Container
pContainer_ =
CreateContainerResponse' :: Int -> Container -> CreateContainerResponse
CreateContainerResponse'
{ $sel:httpStatus:CreateContainerResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:container:CreateContainerResponse' :: Container
container = Container
pContainer_
}
createContainerResponse_httpStatus :: Lens.Lens' CreateContainerResponse Prelude.Int
createContainerResponse_httpStatus :: (Int -> f Int)
-> CreateContainerResponse -> f CreateContainerResponse
createContainerResponse_httpStatus = (CreateContainerResponse -> Int)
-> (CreateContainerResponse -> Int -> CreateContainerResponse)
-> Lens CreateContainerResponse CreateContainerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContainerResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateContainerResponse' :: CreateContainerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateContainerResponse
s@CreateContainerResponse' {} Int
a -> CreateContainerResponse
s {$sel:httpStatus:CreateContainerResponse' :: Int
httpStatus = Int
a} :: CreateContainerResponse)
createContainerResponse_container :: Lens.Lens' CreateContainerResponse Container
createContainerResponse_container :: (Container -> f Container)
-> CreateContainerResponse -> f CreateContainerResponse
createContainerResponse_container = (CreateContainerResponse -> Container)
-> (CreateContainerResponse
-> Container -> CreateContainerResponse)
-> Lens
CreateContainerResponse CreateContainerResponse Container Container
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContainerResponse' {Container
container :: Container
$sel:container:CreateContainerResponse' :: CreateContainerResponse -> Container
container} -> Container
container) (\s :: CreateContainerResponse
s@CreateContainerResponse' {} Container
a -> CreateContainerResponse
s {$sel:container:CreateContainerResponse' :: Container
container = Container
a} :: CreateContainerResponse)
instance Prelude.NFData CreateContainerResponse