{-# 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.InitiateVaultLock
(
InitiateVaultLock (..),
newInitiateVaultLock,
initiateVaultLock_policy,
initiateVaultLock_accountId,
initiateVaultLock_vaultName,
InitiateVaultLockResponse (..),
newInitiateVaultLockResponse,
initiateVaultLockResponse_lockId,
initiateVaultLockResponse_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 InitiateVaultLock = InitiateVaultLock'
{
InitiateVaultLock -> Maybe VaultLockPolicy
policy :: Prelude.Maybe VaultLockPolicy,
InitiateVaultLock -> Text
accountId :: Prelude.Text,
InitiateVaultLock -> Text
vaultName :: Prelude.Text
}
deriving (InitiateVaultLock -> InitiateVaultLock -> Bool
(InitiateVaultLock -> InitiateVaultLock -> Bool)
-> (InitiateVaultLock -> InitiateVaultLock -> Bool)
-> Eq InitiateVaultLock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitiateVaultLock -> InitiateVaultLock -> Bool
$c/= :: InitiateVaultLock -> InitiateVaultLock -> Bool
== :: InitiateVaultLock -> InitiateVaultLock -> Bool
$c== :: InitiateVaultLock -> InitiateVaultLock -> Bool
Prelude.Eq, ReadPrec [InitiateVaultLock]
ReadPrec InitiateVaultLock
Int -> ReadS InitiateVaultLock
ReadS [InitiateVaultLock]
(Int -> ReadS InitiateVaultLock)
-> ReadS [InitiateVaultLock]
-> ReadPrec InitiateVaultLock
-> ReadPrec [InitiateVaultLock]
-> Read InitiateVaultLock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitiateVaultLock]
$creadListPrec :: ReadPrec [InitiateVaultLock]
readPrec :: ReadPrec InitiateVaultLock
$creadPrec :: ReadPrec InitiateVaultLock
readList :: ReadS [InitiateVaultLock]
$creadList :: ReadS [InitiateVaultLock]
readsPrec :: Int -> ReadS InitiateVaultLock
$creadsPrec :: Int -> ReadS InitiateVaultLock
Prelude.Read, Int -> InitiateVaultLock -> ShowS
[InitiateVaultLock] -> ShowS
InitiateVaultLock -> String
(Int -> InitiateVaultLock -> ShowS)
-> (InitiateVaultLock -> String)
-> ([InitiateVaultLock] -> ShowS)
-> Show InitiateVaultLock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateVaultLock] -> ShowS
$cshowList :: [InitiateVaultLock] -> ShowS
show :: InitiateVaultLock -> String
$cshow :: InitiateVaultLock -> String
showsPrec :: Int -> InitiateVaultLock -> ShowS
$cshowsPrec :: Int -> InitiateVaultLock -> ShowS
Prelude.Show, (forall x. InitiateVaultLock -> Rep InitiateVaultLock x)
-> (forall x. Rep InitiateVaultLock x -> InitiateVaultLock)
-> Generic InitiateVaultLock
forall x. Rep InitiateVaultLock x -> InitiateVaultLock
forall x. InitiateVaultLock -> Rep InitiateVaultLock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InitiateVaultLock x -> InitiateVaultLock
$cfrom :: forall x. InitiateVaultLock -> Rep InitiateVaultLock x
Prelude.Generic)
newInitiateVaultLock ::
Prelude.Text ->
Prelude.Text ->
InitiateVaultLock
newInitiateVaultLock :: Text -> Text -> InitiateVaultLock
newInitiateVaultLock Text
pAccountId_ Text
pVaultName_ =
InitiateVaultLock' :: Maybe VaultLockPolicy -> Text -> Text -> InitiateVaultLock
InitiateVaultLock'
{ $sel:policy:InitiateVaultLock' :: Maybe VaultLockPolicy
policy = Maybe VaultLockPolicy
forall a. Maybe a
Prelude.Nothing,
$sel:accountId:InitiateVaultLock' :: Text
accountId = Text
pAccountId_,
$sel:vaultName:InitiateVaultLock' :: Text
vaultName = Text
pVaultName_
}
initiateVaultLock_policy :: Lens.Lens' InitiateVaultLock (Prelude.Maybe VaultLockPolicy)
initiateVaultLock_policy :: (Maybe VaultLockPolicy -> f (Maybe VaultLockPolicy))
-> InitiateVaultLock -> f InitiateVaultLock
initiateVaultLock_policy = (InitiateVaultLock -> Maybe VaultLockPolicy)
-> (InitiateVaultLock
-> Maybe VaultLockPolicy -> InitiateVaultLock)
-> Lens
InitiateVaultLock
InitiateVaultLock
(Maybe VaultLockPolicy)
(Maybe VaultLockPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateVaultLock' {Maybe VaultLockPolicy
policy :: Maybe VaultLockPolicy
$sel:policy:InitiateVaultLock' :: InitiateVaultLock -> Maybe VaultLockPolicy
policy} -> Maybe VaultLockPolicy
policy) (\s :: InitiateVaultLock
s@InitiateVaultLock' {} Maybe VaultLockPolicy
a -> InitiateVaultLock
s {$sel:policy:InitiateVaultLock' :: Maybe VaultLockPolicy
policy = Maybe VaultLockPolicy
a} :: InitiateVaultLock)
initiateVaultLock_accountId :: Lens.Lens' InitiateVaultLock Prelude.Text
initiateVaultLock_accountId :: (Text -> f Text) -> InitiateVaultLock -> f InitiateVaultLock
initiateVaultLock_accountId = (InitiateVaultLock -> Text)
-> (InitiateVaultLock -> Text -> InitiateVaultLock)
-> Lens InitiateVaultLock InitiateVaultLock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateVaultLock' {Text
accountId :: Text
$sel:accountId:InitiateVaultLock' :: InitiateVaultLock -> Text
accountId} -> Text
accountId) (\s :: InitiateVaultLock
s@InitiateVaultLock' {} Text
a -> InitiateVaultLock
s {$sel:accountId:InitiateVaultLock' :: Text
accountId = Text
a} :: InitiateVaultLock)
initiateVaultLock_vaultName :: Lens.Lens' InitiateVaultLock Prelude.Text
initiateVaultLock_vaultName :: (Text -> f Text) -> InitiateVaultLock -> f InitiateVaultLock
initiateVaultLock_vaultName = (InitiateVaultLock -> Text)
-> (InitiateVaultLock -> Text -> InitiateVaultLock)
-> Lens InitiateVaultLock InitiateVaultLock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateVaultLock' {Text
vaultName :: Text
$sel:vaultName:InitiateVaultLock' :: InitiateVaultLock -> Text
vaultName} -> Text
vaultName) (\s :: InitiateVaultLock
s@InitiateVaultLock' {} Text
a -> InitiateVaultLock
s {$sel:vaultName:InitiateVaultLock' :: Text
vaultName = Text
a} :: InitiateVaultLock)
instance Core.AWSRequest InitiateVaultLock where
type
AWSResponse InitiateVaultLock =
InitiateVaultLockResponse
request :: InitiateVaultLock -> Request InitiateVaultLock
request =
ByteString
-> Request InitiateVaultLock -> Request InitiateVaultLock
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
(Request InitiateVaultLock -> Request InitiateVaultLock)
-> (InitiateVaultLock -> Request InitiateVaultLock)
-> InitiateVaultLock
-> Request InitiateVaultLock
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> InitiateVaultLock -> Request InitiateVaultLock
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy InitiateVaultLock
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InitiateVaultLock)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse InitiateVaultLock))
-> Logger
-> Service
-> Proxy InitiateVaultLock
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InitiateVaultLock)))
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 -> InitiateVaultLockResponse
InitiateVaultLockResponse'
(Maybe Text -> Int -> InitiateVaultLockResponse)
-> Either String (Maybe Text)
-> Either String (Int -> InitiateVaultLockResponse)
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
"x-amz-lock-id")
Either String (Int -> InitiateVaultLockResponse)
-> Either String Int -> Either String InitiateVaultLockResponse
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 InitiateVaultLock
instance Prelude.NFData InitiateVaultLock
instance Core.ToHeaders InitiateVaultLock where
toHeaders :: InitiateVaultLock -> ResponseHeaders
toHeaders = ResponseHeaders -> InitiateVaultLock -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON InitiateVaultLock where
toJSON :: InitiateVaultLock -> Value
toJSON InitiateVaultLock' {Maybe VaultLockPolicy
Text
vaultName :: Text
accountId :: Text
policy :: Maybe VaultLockPolicy
$sel:vaultName:InitiateVaultLock' :: InitiateVaultLock -> Text
$sel:accountId:InitiateVaultLock' :: InitiateVaultLock -> Text
$sel:policy:InitiateVaultLock' :: InitiateVaultLock -> Maybe VaultLockPolicy
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Text
"policy" Text -> VaultLockPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VaultLockPolicy -> Pair) -> Maybe VaultLockPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VaultLockPolicy
policy]
)
instance Core.ToPath InitiateVaultLock where
toPath :: InitiateVaultLock -> ByteString
toPath InitiateVaultLock' {Maybe VaultLockPolicy
Text
vaultName :: Text
accountId :: Text
policy :: Maybe VaultLockPolicy
$sel:vaultName:InitiateVaultLock' :: InitiateVaultLock -> Text
$sel:accountId:InitiateVaultLock' :: InitiateVaultLock -> Text
$sel:policy:InitiateVaultLock' :: InitiateVaultLock -> Maybe VaultLockPolicy
..} =
[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,
ByteString
"/lock-policy"
]
instance Core.ToQuery InitiateVaultLock where
toQuery :: InitiateVaultLock -> QueryString
toQuery = QueryString -> InitiateVaultLock -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data InitiateVaultLockResponse = InitiateVaultLockResponse'
{
InitiateVaultLockResponse -> Maybe Text
lockId :: Prelude.Maybe Prelude.Text,
InitiateVaultLockResponse -> Int
httpStatus :: Prelude.Int
}
deriving (InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool
(InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool)
-> (InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool)
-> Eq InitiateVaultLockResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool
$c/= :: InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool
== :: InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool
$c== :: InitiateVaultLockResponse -> InitiateVaultLockResponse -> Bool
Prelude.Eq, ReadPrec [InitiateVaultLockResponse]
ReadPrec InitiateVaultLockResponse
Int -> ReadS InitiateVaultLockResponse
ReadS [InitiateVaultLockResponse]
(Int -> ReadS InitiateVaultLockResponse)
-> ReadS [InitiateVaultLockResponse]
-> ReadPrec InitiateVaultLockResponse
-> ReadPrec [InitiateVaultLockResponse]
-> Read InitiateVaultLockResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitiateVaultLockResponse]
$creadListPrec :: ReadPrec [InitiateVaultLockResponse]
readPrec :: ReadPrec InitiateVaultLockResponse
$creadPrec :: ReadPrec InitiateVaultLockResponse
readList :: ReadS [InitiateVaultLockResponse]
$creadList :: ReadS [InitiateVaultLockResponse]
readsPrec :: Int -> ReadS InitiateVaultLockResponse
$creadsPrec :: Int -> ReadS InitiateVaultLockResponse
Prelude.Read, Int -> InitiateVaultLockResponse -> ShowS
[InitiateVaultLockResponse] -> ShowS
InitiateVaultLockResponse -> String
(Int -> InitiateVaultLockResponse -> ShowS)
-> (InitiateVaultLockResponse -> String)
-> ([InitiateVaultLockResponse] -> ShowS)
-> Show InitiateVaultLockResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateVaultLockResponse] -> ShowS
$cshowList :: [InitiateVaultLockResponse] -> ShowS
show :: InitiateVaultLockResponse -> String
$cshow :: InitiateVaultLockResponse -> String
showsPrec :: Int -> InitiateVaultLockResponse -> ShowS
$cshowsPrec :: Int -> InitiateVaultLockResponse -> ShowS
Prelude.Show, (forall x.
InitiateVaultLockResponse -> Rep InitiateVaultLockResponse x)
-> (forall x.
Rep InitiateVaultLockResponse x -> InitiateVaultLockResponse)
-> Generic InitiateVaultLockResponse
forall x.
Rep InitiateVaultLockResponse x -> InitiateVaultLockResponse
forall x.
InitiateVaultLockResponse -> Rep InitiateVaultLockResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InitiateVaultLockResponse x -> InitiateVaultLockResponse
$cfrom :: forall x.
InitiateVaultLockResponse -> Rep InitiateVaultLockResponse x
Prelude.Generic)
newInitiateVaultLockResponse ::
Prelude.Int ->
InitiateVaultLockResponse
newInitiateVaultLockResponse :: Int -> InitiateVaultLockResponse
newInitiateVaultLockResponse Int
pHttpStatus_ =
InitiateVaultLockResponse' :: Maybe Text -> Int -> InitiateVaultLockResponse
InitiateVaultLockResponse'
{ $sel:lockId:InitiateVaultLockResponse' :: Maybe Text
lockId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:InitiateVaultLockResponse' :: Int
httpStatus = Int
pHttpStatus_
}
initiateVaultLockResponse_lockId :: Lens.Lens' InitiateVaultLockResponse (Prelude.Maybe Prelude.Text)
initiateVaultLockResponse_lockId :: (Maybe Text -> f (Maybe Text))
-> InitiateVaultLockResponse -> f InitiateVaultLockResponse
initiateVaultLockResponse_lockId = (InitiateVaultLockResponse -> Maybe Text)
-> (InitiateVaultLockResponse
-> Maybe Text -> InitiateVaultLockResponse)
-> Lens
InitiateVaultLockResponse
InitiateVaultLockResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateVaultLockResponse' {Maybe Text
lockId :: Maybe Text
$sel:lockId:InitiateVaultLockResponse' :: InitiateVaultLockResponse -> Maybe Text
lockId} -> Maybe Text
lockId) (\s :: InitiateVaultLockResponse
s@InitiateVaultLockResponse' {} Maybe Text
a -> InitiateVaultLockResponse
s {$sel:lockId:InitiateVaultLockResponse' :: Maybe Text
lockId = Maybe Text
a} :: InitiateVaultLockResponse)
initiateVaultLockResponse_httpStatus :: Lens.Lens' InitiateVaultLockResponse Prelude.Int
initiateVaultLockResponse_httpStatus :: (Int -> f Int)
-> InitiateVaultLockResponse -> f InitiateVaultLockResponse
initiateVaultLockResponse_httpStatus = (InitiateVaultLockResponse -> Int)
-> (InitiateVaultLockResponse -> Int -> InitiateVaultLockResponse)
-> Lens InitiateVaultLockResponse InitiateVaultLockResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateVaultLockResponse' {Int
httpStatus :: Int
$sel:httpStatus:InitiateVaultLockResponse' :: InitiateVaultLockResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: InitiateVaultLockResponse
s@InitiateVaultLockResponse' {} Int
a -> InitiateVaultLockResponse
s {$sel:httpStatus:InitiateVaultLockResponse' :: Int
httpStatus = Int
a} :: InitiateVaultLockResponse)
instance Prelude.NFData InitiateVaultLockResponse