{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Glacier.CompleteVaultLock
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation completes the vault locking process by transitioning the
-- vault lock from the @InProgress@ state to the @Locked@ state, which
-- causes the vault lock policy to become unchangeable. A vault lock is put
-- into the @InProgress@ state by calling InitiateVaultLock. You can obtain
-- the state of the vault lock by calling GetVaultLock. For more
-- information about the vault locking process,
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/vault-lock.html Amazon Glacier Vault Lock>.
--
-- This operation is idempotent. This request is always successful if the
-- vault lock is in the @Locked@ state and the provided lock ID matches the
-- lock ID originally used to lock the vault.
--
-- If an invalid lock ID is passed in the request when the vault lock is in
-- the @Locked@ state, the operation returns an @AccessDeniedException@
-- error. If an invalid lock ID is passed in the request when the vault
-- lock is in the @InProgress@ state, the operation throws an
-- @InvalidParameter@ error.
module Amazonka.Glacier.CompleteVaultLock
  ( -- * Creating a Request
    CompleteVaultLock (..),
    newCompleteVaultLock,

    -- * Request Lenses
    completeVaultLock_accountId,
    completeVaultLock_vaultName,
    completeVaultLock_lockId,

    -- * Destructuring the Response
    CompleteVaultLockResponse (..),
    newCompleteVaultLockResponse,
  )
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

-- | The input values for @CompleteVaultLock@.
--
-- /See:/ 'newCompleteVaultLock' smart constructor.
data CompleteVaultLock = CompleteVaultLock'
  { -- | The @AccountId@ value is the AWS account ID. This value must match the
    -- AWS account ID associated with the credentials used to sign the request.
    -- You can either specify an AWS account ID or optionally a single \'@-@\'
    -- (hyphen), in which case Amazon Glacier uses the AWS account ID
    -- associated with the credentials used to sign the request. If you specify
    -- your account ID, do not include any hyphens (\'-\') in the ID.
    CompleteVaultLock -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    CompleteVaultLock -> Text
vaultName :: Prelude.Text,
    -- | The @lockId@ value is the lock ID obtained from a InitiateVaultLock
    -- request.
    CompleteVaultLock -> Text
lockId :: Prelude.Text
  }
  deriving (CompleteVaultLock -> CompleteVaultLock -> Bool
(CompleteVaultLock -> CompleteVaultLock -> Bool)
-> (CompleteVaultLock -> CompleteVaultLock -> Bool)
-> Eq CompleteVaultLock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompleteVaultLock -> CompleteVaultLock -> Bool
$c/= :: CompleteVaultLock -> CompleteVaultLock -> Bool
== :: CompleteVaultLock -> CompleteVaultLock -> Bool
$c== :: CompleteVaultLock -> CompleteVaultLock -> Bool
Prelude.Eq, ReadPrec [CompleteVaultLock]
ReadPrec CompleteVaultLock
Int -> ReadS CompleteVaultLock
ReadS [CompleteVaultLock]
(Int -> ReadS CompleteVaultLock)
-> ReadS [CompleteVaultLock]
-> ReadPrec CompleteVaultLock
-> ReadPrec [CompleteVaultLock]
-> Read CompleteVaultLock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompleteVaultLock]
$creadListPrec :: ReadPrec [CompleteVaultLock]
readPrec :: ReadPrec CompleteVaultLock
$creadPrec :: ReadPrec CompleteVaultLock
readList :: ReadS [CompleteVaultLock]
$creadList :: ReadS [CompleteVaultLock]
readsPrec :: Int -> ReadS CompleteVaultLock
$creadsPrec :: Int -> ReadS CompleteVaultLock
Prelude.Read, Int -> CompleteVaultLock -> ShowS
[CompleteVaultLock] -> ShowS
CompleteVaultLock -> String
(Int -> CompleteVaultLock -> ShowS)
-> (CompleteVaultLock -> String)
-> ([CompleteVaultLock] -> ShowS)
-> Show CompleteVaultLock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompleteVaultLock] -> ShowS
$cshowList :: [CompleteVaultLock] -> ShowS
show :: CompleteVaultLock -> String
$cshow :: CompleteVaultLock -> String
showsPrec :: Int -> CompleteVaultLock -> ShowS
$cshowsPrec :: Int -> CompleteVaultLock -> ShowS
Prelude.Show, (forall x. CompleteVaultLock -> Rep CompleteVaultLock x)
-> (forall x. Rep CompleteVaultLock x -> CompleteVaultLock)
-> Generic CompleteVaultLock
forall x. Rep CompleteVaultLock x -> CompleteVaultLock
forall x. CompleteVaultLock -> Rep CompleteVaultLock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CompleteVaultLock x -> CompleteVaultLock
$cfrom :: forall x. CompleteVaultLock -> Rep CompleteVaultLock x
Prelude.Generic)

-- |
-- Create a value of 'CompleteVaultLock' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'accountId', 'completeVaultLock_accountId' - The @AccountId@ value is the AWS account ID. This value must match the
-- AWS account ID associated with the credentials used to sign the request.
-- You can either specify an AWS account ID or optionally a single \'@-@\'
-- (hyphen), in which case Amazon Glacier uses the AWS account ID
-- associated with the credentials used to sign the request. If you specify
-- your account ID, do not include any hyphens (\'-\') in the ID.
--
-- 'vaultName', 'completeVaultLock_vaultName' - The name of the vault.
--
-- 'lockId', 'completeVaultLock_lockId' - The @lockId@ value is the lock ID obtained from a InitiateVaultLock
-- request.
newCompleteVaultLock ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  -- | 'lockId'
  Prelude.Text ->
  CompleteVaultLock
newCompleteVaultLock :: Text -> Text -> Text -> CompleteVaultLock
newCompleteVaultLock Text
pAccountId_ Text
pVaultName_ Text
pLockId_ =
  CompleteVaultLock' :: Text -> Text -> Text -> CompleteVaultLock
CompleteVaultLock'
    { $sel:accountId:CompleteVaultLock' :: Text
accountId = Text
pAccountId_,
      $sel:vaultName:CompleteVaultLock' :: Text
vaultName = Text
pVaultName_,
      $sel:lockId:CompleteVaultLock' :: Text
lockId = Text
pLockId_
    }

-- | The @AccountId@ value is the AWS account ID. This value must match the
-- AWS account ID associated with the credentials used to sign the request.
-- You can either specify an AWS account ID or optionally a single \'@-@\'
-- (hyphen), in which case Amazon Glacier uses the AWS account ID
-- associated with the credentials used to sign the request. If you specify
-- your account ID, do not include any hyphens (\'-\') in the ID.
completeVaultLock_accountId :: Lens.Lens' CompleteVaultLock Prelude.Text
completeVaultLock_accountId :: (Text -> f Text) -> CompleteVaultLock -> f CompleteVaultLock
completeVaultLock_accountId = (CompleteVaultLock -> Text)
-> (CompleteVaultLock -> Text -> CompleteVaultLock)
-> Lens CompleteVaultLock CompleteVaultLock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompleteVaultLock' {Text
accountId :: Text
$sel:accountId:CompleteVaultLock' :: CompleteVaultLock -> Text
accountId} -> Text
accountId) (\s :: CompleteVaultLock
s@CompleteVaultLock' {} Text
a -> CompleteVaultLock
s {$sel:accountId:CompleteVaultLock' :: Text
accountId = Text
a} :: CompleteVaultLock)

-- | The name of the vault.
completeVaultLock_vaultName :: Lens.Lens' CompleteVaultLock Prelude.Text
completeVaultLock_vaultName :: (Text -> f Text) -> CompleteVaultLock -> f CompleteVaultLock
completeVaultLock_vaultName = (CompleteVaultLock -> Text)
-> (CompleteVaultLock -> Text -> CompleteVaultLock)
-> Lens CompleteVaultLock CompleteVaultLock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompleteVaultLock' {Text
vaultName :: Text
$sel:vaultName:CompleteVaultLock' :: CompleteVaultLock -> Text
vaultName} -> Text
vaultName) (\s :: CompleteVaultLock
s@CompleteVaultLock' {} Text
a -> CompleteVaultLock
s {$sel:vaultName:CompleteVaultLock' :: Text
vaultName = Text
a} :: CompleteVaultLock)

-- | The @lockId@ value is the lock ID obtained from a InitiateVaultLock
-- request.
completeVaultLock_lockId :: Lens.Lens' CompleteVaultLock Prelude.Text
completeVaultLock_lockId :: (Text -> f Text) -> CompleteVaultLock -> f CompleteVaultLock
completeVaultLock_lockId = (CompleteVaultLock -> Text)
-> (CompleteVaultLock -> Text -> CompleteVaultLock)
-> Lens CompleteVaultLock CompleteVaultLock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompleteVaultLock' {Text
lockId :: Text
$sel:lockId:CompleteVaultLock' :: CompleteVaultLock -> Text
lockId} -> Text
lockId) (\s :: CompleteVaultLock
s@CompleteVaultLock' {} Text
a -> CompleteVaultLock
s {$sel:lockId:CompleteVaultLock' :: Text
lockId = Text
a} :: CompleteVaultLock)

instance Core.AWSRequest CompleteVaultLock where
  type
    AWSResponse CompleteVaultLock =
      CompleteVaultLockResponse
  request :: CompleteVaultLock -> Request CompleteVaultLock
request =
    ByteString
-> Request CompleteVaultLock -> Request CompleteVaultLock
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
      (Request CompleteVaultLock -> Request CompleteVaultLock)
-> (CompleteVaultLock -> Request CompleteVaultLock)
-> CompleteVaultLock
-> Request CompleteVaultLock
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> CompleteVaultLock -> Request CompleteVaultLock
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CompleteVaultLock
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CompleteVaultLock)))
response =
    AWSResponse CompleteVaultLock
-> Logger
-> Service
-> Proxy CompleteVaultLock
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CompleteVaultLock)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse CompleteVaultLock
CompleteVaultLockResponse
CompleteVaultLockResponse'

instance Prelude.Hashable CompleteVaultLock

instance Prelude.NFData CompleteVaultLock

instance Core.ToHeaders CompleteVaultLock where
  toHeaders :: CompleteVaultLock -> [Header]
toHeaders = [Header] -> CompleteVaultLock -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON CompleteVaultLock where
  toJSON :: CompleteVaultLock -> Value
toJSON = Value -> CompleteVaultLock -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath CompleteVaultLock where
  toPath :: CompleteVaultLock -> ByteString
toPath CompleteVaultLock' {Text
lockId :: Text
vaultName :: Text
accountId :: Text
$sel:lockId:CompleteVaultLock' :: CompleteVaultLock -> Text
$sel:vaultName:CompleteVaultLock' :: CompleteVaultLock -> Text
$sel:accountId:CompleteVaultLock' :: CompleteVaultLock -> 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,
        ByteString
"/lock-policy/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
lockId
      ]

instance Core.ToQuery CompleteVaultLock where
  toQuery :: CompleteVaultLock -> QueryString
toQuery = QueryString -> CompleteVaultLock -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCompleteVaultLockResponse' smart constructor.
data CompleteVaultLockResponse = CompleteVaultLockResponse'
  {
  }
  deriving (CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool
(CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool)
-> (CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool)
-> Eq CompleteVaultLockResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool
$c/= :: CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool
== :: CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool
$c== :: CompleteVaultLockResponse -> CompleteVaultLockResponse -> Bool
Prelude.Eq, ReadPrec [CompleteVaultLockResponse]
ReadPrec CompleteVaultLockResponse
Int -> ReadS CompleteVaultLockResponse
ReadS [CompleteVaultLockResponse]
(Int -> ReadS CompleteVaultLockResponse)
-> ReadS [CompleteVaultLockResponse]
-> ReadPrec CompleteVaultLockResponse
-> ReadPrec [CompleteVaultLockResponse]
-> Read CompleteVaultLockResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompleteVaultLockResponse]
$creadListPrec :: ReadPrec [CompleteVaultLockResponse]
readPrec :: ReadPrec CompleteVaultLockResponse
$creadPrec :: ReadPrec CompleteVaultLockResponse
readList :: ReadS [CompleteVaultLockResponse]
$creadList :: ReadS [CompleteVaultLockResponse]
readsPrec :: Int -> ReadS CompleteVaultLockResponse
$creadsPrec :: Int -> ReadS CompleteVaultLockResponse
Prelude.Read, Int -> CompleteVaultLockResponse -> ShowS
[CompleteVaultLockResponse] -> ShowS
CompleteVaultLockResponse -> String
(Int -> CompleteVaultLockResponse -> ShowS)
-> (CompleteVaultLockResponse -> String)
-> ([CompleteVaultLockResponse] -> ShowS)
-> Show CompleteVaultLockResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompleteVaultLockResponse] -> ShowS
$cshowList :: [CompleteVaultLockResponse] -> ShowS
show :: CompleteVaultLockResponse -> String
$cshow :: CompleteVaultLockResponse -> String
showsPrec :: Int -> CompleteVaultLockResponse -> ShowS
$cshowsPrec :: Int -> CompleteVaultLockResponse -> ShowS
Prelude.Show, (forall x.
 CompleteVaultLockResponse -> Rep CompleteVaultLockResponse x)
-> (forall x.
    Rep CompleteVaultLockResponse x -> CompleteVaultLockResponse)
-> Generic CompleteVaultLockResponse
forall x.
Rep CompleteVaultLockResponse x -> CompleteVaultLockResponse
forall x.
CompleteVaultLockResponse -> Rep CompleteVaultLockResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CompleteVaultLockResponse x -> CompleteVaultLockResponse
$cfrom :: forall x.
CompleteVaultLockResponse -> Rep CompleteVaultLockResponse x
Prelude.Generic)

-- |
-- Create a value of 'CompleteVaultLockResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newCompleteVaultLockResponse ::
  CompleteVaultLockResponse
newCompleteVaultLockResponse :: CompleteVaultLockResponse
newCompleteVaultLockResponse =
  CompleteVaultLockResponse
CompleteVaultLockResponse'

instance Prelude.NFData CompleteVaultLockResponse