{-# 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.Glacier.CreateVault
(
CreateVault (..),
newCreateVault,
createVault_accountId,
createVault_vaultName,
CreateVaultResponse (..),
newCreateVaultResponse,
createVaultResponse_location,
createVaultResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateVault = CreateVault'
{
CreateVault -> Text
accountId :: Prelude.Text,
CreateVault -> Text
vaultName :: Prelude.Text
}
deriving (CreateVault -> CreateVault -> Bool
(CreateVault -> CreateVault -> Bool)
-> (CreateVault -> CreateVault -> Bool) -> Eq CreateVault
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateVault -> CreateVault -> Bool
$c/= :: CreateVault -> CreateVault -> Bool
== :: CreateVault -> CreateVault -> Bool
$c== :: CreateVault -> CreateVault -> Bool
Prelude.Eq, ReadPrec [CreateVault]
ReadPrec CreateVault
Int -> ReadS CreateVault
ReadS [CreateVault]
(Int -> ReadS CreateVault)
-> ReadS [CreateVault]
-> ReadPrec CreateVault
-> ReadPrec [CreateVault]
-> Read CreateVault
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateVault]
$creadListPrec :: ReadPrec [CreateVault]
readPrec :: ReadPrec CreateVault
$creadPrec :: ReadPrec CreateVault
readList :: ReadS [CreateVault]
$creadList :: ReadS [CreateVault]
readsPrec :: Int -> ReadS CreateVault
$creadsPrec :: Int -> ReadS CreateVault
Prelude.Read, Int -> CreateVault -> ShowS
[CreateVault] -> ShowS
CreateVault -> String
(Int -> CreateVault -> ShowS)
-> (CreateVault -> String)
-> ([CreateVault] -> ShowS)
-> Show CreateVault
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateVault] -> ShowS
$cshowList :: [CreateVault] -> ShowS
show :: CreateVault -> String
$cshow :: CreateVault -> String
showsPrec :: Int -> CreateVault -> ShowS
$cshowsPrec :: Int -> CreateVault -> ShowS
Prelude.Show, (forall x. CreateVault -> Rep CreateVault x)
-> (forall x. Rep CreateVault x -> CreateVault)
-> Generic CreateVault
forall x. Rep CreateVault x -> CreateVault
forall x. CreateVault -> Rep CreateVault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateVault x -> CreateVault
$cfrom :: forall x. CreateVault -> Rep CreateVault x
Prelude.Generic)
newCreateVault ::
Prelude.Text ->
Prelude.Text ->
CreateVault
newCreateVault :: Text -> Text -> CreateVault
newCreateVault Text
pAccountId_ Text
pVaultName_ =
CreateVault' :: Text -> Text -> CreateVault
CreateVault'
{ $sel:accountId:CreateVault' :: Text
accountId = Text
pAccountId_,
$sel:vaultName:CreateVault' :: Text
vaultName = Text
pVaultName_
}
createVault_accountId :: Lens.Lens' CreateVault Prelude.Text
createVault_accountId :: (Text -> f Text) -> CreateVault -> f CreateVault
createVault_accountId = (CreateVault -> Text)
-> (CreateVault -> Text -> CreateVault)
-> Lens CreateVault CreateVault Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVault' {Text
accountId :: Text
$sel:accountId:CreateVault' :: CreateVault -> Text
accountId} -> Text
accountId) (\s :: CreateVault
s@CreateVault' {} Text
a -> CreateVault
s {$sel:accountId:CreateVault' :: Text
accountId = Text
a} :: CreateVault)
createVault_vaultName :: Lens.Lens' CreateVault Prelude.Text
createVault_vaultName :: (Text -> f Text) -> CreateVault -> f CreateVault
createVault_vaultName = (CreateVault -> Text)
-> (CreateVault -> Text -> CreateVault)
-> Lens CreateVault CreateVault Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVault' {Text
vaultName :: Text
$sel:vaultName:CreateVault' :: CreateVault -> Text
vaultName} -> Text
vaultName) (\s :: CreateVault
s@CreateVault' {} Text
a -> CreateVault
s {$sel:vaultName:CreateVault' :: Text
vaultName = Text
a} :: CreateVault)
instance Core.AWSRequest CreateVault where
type AWSResponse CreateVault = CreateVaultResponse
request :: CreateVault -> Request CreateVault
request =
ByteString -> Request CreateVault -> Request CreateVault
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
(Request CreateVault -> Request CreateVault)
-> (CreateVault -> Request CreateVault)
-> CreateVault
-> Request CreateVault
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> CreateVault -> Request CreateVault
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVault)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreateVault))
-> Logger
-> Service
-> Proxy CreateVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVault)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Maybe Text -> Int -> CreateVaultResponse
CreateVaultResponse'
(Maybe Text -> Int -> CreateVaultResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateVaultResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Location")
Either String (Int -> CreateVaultResponse)
-> Either String Int -> Either String CreateVaultResponse
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 CreateVault
instance Prelude.NFData CreateVault
instance Core.ToHeaders CreateVault where
toHeaders :: CreateVault -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateVault -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateVault where
toJSON :: CreateVault -> Value
toJSON = Value -> CreateVault -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)
instance Core.ToPath CreateVault where
toPath :: CreateVault -> ByteString
toPath CreateVault' {Text
vaultName :: Text
accountId :: Text
$sel:vaultName:CreateVault' :: CreateVault -> Text
$sel:accountId:CreateVault' :: CreateVault -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
ByteString
"/vaults/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
vaultName
]
instance Core.ToQuery CreateVault where
toQuery :: CreateVault -> QueryString
toQuery = QueryString -> CreateVault -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateVaultResponse = CreateVaultResponse'
{
CreateVaultResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
CreateVaultResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateVaultResponse -> CreateVaultResponse -> Bool
(CreateVaultResponse -> CreateVaultResponse -> Bool)
-> (CreateVaultResponse -> CreateVaultResponse -> Bool)
-> Eq CreateVaultResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateVaultResponse -> CreateVaultResponse -> Bool
$c/= :: CreateVaultResponse -> CreateVaultResponse -> Bool
== :: CreateVaultResponse -> CreateVaultResponse -> Bool
$c== :: CreateVaultResponse -> CreateVaultResponse -> Bool
Prelude.Eq, ReadPrec [CreateVaultResponse]
ReadPrec CreateVaultResponse
Int -> ReadS CreateVaultResponse
ReadS [CreateVaultResponse]
(Int -> ReadS CreateVaultResponse)
-> ReadS [CreateVaultResponse]
-> ReadPrec CreateVaultResponse
-> ReadPrec [CreateVaultResponse]
-> Read CreateVaultResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateVaultResponse]
$creadListPrec :: ReadPrec [CreateVaultResponse]
readPrec :: ReadPrec CreateVaultResponse
$creadPrec :: ReadPrec CreateVaultResponse
readList :: ReadS [CreateVaultResponse]
$creadList :: ReadS [CreateVaultResponse]
readsPrec :: Int -> ReadS CreateVaultResponse
$creadsPrec :: Int -> ReadS CreateVaultResponse
Prelude.Read, Int -> CreateVaultResponse -> ShowS
[CreateVaultResponse] -> ShowS
CreateVaultResponse -> String
(Int -> CreateVaultResponse -> ShowS)
-> (CreateVaultResponse -> String)
-> ([CreateVaultResponse] -> ShowS)
-> Show CreateVaultResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateVaultResponse] -> ShowS
$cshowList :: [CreateVaultResponse] -> ShowS
show :: CreateVaultResponse -> String
$cshow :: CreateVaultResponse -> String
showsPrec :: Int -> CreateVaultResponse -> ShowS
$cshowsPrec :: Int -> CreateVaultResponse -> ShowS
Prelude.Show, (forall x. CreateVaultResponse -> Rep CreateVaultResponse x)
-> (forall x. Rep CreateVaultResponse x -> CreateVaultResponse)
-> Generic CreateVaultResponse
forall x. Rep CreateVaultResponse x -> CreateVaultResponse
forall x. CreateVaultResponse -> Rep CreateVaultResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateVaultResponse x -> CreateVaultResponse
$cfrom :: forall x. CreateVaultResponse -> Rep CreateVaultResponse x
Prelude.Generic)
newCreateVaultResponse ::
Prelude.Int ->
CreateVaultResponse
newCreateVaultResponse :: Int -> CreateVaultResponse
newCreateVaultResponse Int
pHttpStatus_ =
CreateVaultResponse' :: Maybe Text -> Int -> CreateVaultResponse
CreateVaultResponse'
{ $sel:location:CreateVaultResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateVaultResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createVaultResponse_location :: Lens.Lens' CreateVaultResponse (Prelude.Maybe Prelude.Text)
createVaultResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateVaultResponse -> f CreateVaultResponse
createVaultResponse_location = (CreateVaultResponse -> Maybe Text)
-> (CreateVaultResponse -> Maybe Text -> CreateVaultResponse)
-> Lens
CreateVaultResponse CreateVaultResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVaultResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateVaultResponse' :: CreateVaultResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateVaultResponse
s@CreateVaultResponse' {} Maybe Text
a -> CreateVaultResponse
s {$sel:location:CreateVaultResponse' :: Maybe Text
location = Maybe Text
a} :: CreateVaultResponse)
createVaultResponse_httpStatus :: Lens.Lens' CreateVaultResponse Prelude.Int
createVaultResponse_httpStatus :: (Int -> f Int) -> CreateVaultResponse -> f CreateVaultResponse
createVaultResponse_httpStatus = (CreateVaultResponse -> Int)
-> (CreateVaultResponse -> Int -> CreateVaultResponse)
-> Lens CreateVaultResponse CreateVaultResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVaultResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateVaultResponse' :: CreateVaultResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateVaultResponse
s@CreateVaultResponse' {} Int
a -> CreateVaultResponse
s {$sel:httpStatus:CreateVaultResponse' :: Int
httpStatus = Int
a} :: CreateVaultResponse)
instance Prelude.NFData CreateVaultResponse