{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.VaultAccessPolicy
-- 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)
module Amazonka.Glacier.Types.VaultAccessPolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'VaultAccessPolicy' 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:
--
-- 'policy', 'vaultAccessPolicy_policy' - The vault access policy.
newVaultAccessPolicy ::
  VaultAccessPolicy
newVaultAccessPolicy :: VaultAccessPolicy
newVaultAccessPolicy =
  VaultAccessPolicy' :: Maybe Text -> VaultAccessPolicy
VaultAccessPolicy' {$sel:policy:VaultAccessPolicy' :: Maybe Text
policy = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The vault access policy.
vaultAccessPolicy_policy :: Lens.Lens' VaultAccessPolicy (Prelude.Maybe Prelude.Text)
vaultAccessPolicy_policy :: (Maybe Text -> f (Maybe Text))
-> VaultAccessPolicy -> f VaultAccessPolicy
vaultAccessPolicy_policy = (VaultAccessPolicy -> Maybe Text)
-> (VaultAccessPolicy -> Maybe Text -> VaultAccessPolicy)
-> Lens
     VaultAccessPolicy VaultAccessPolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VaultAccessPolicy' {Maybe Text
policy :: Maybe Text
$sel:policy:VaultAccessPolicy' :: VaultAccessPolicy -> Maybe Text
policy} -> Maybe Text
policy) (\s :: VaultAccessPolicy
s@VaultAccessPolicy' {} Maybe Text
a -> VaultAccessPolicy
s {$sel:policy:VaultAccessPolicy' :: Maybe Text
policy = Maybe Text
a} :: VaultAccessPolicy)

instance Core.FromJSON VaultAccessPolicy where
  parseJSON :: Value -> Parser VaultAccessPolicy
parseJSON =
    String
-> (Object -> Parser VaultAccessPolicy)
-> Value
-> Parser VaultAccessPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VaultAccessPolicy"
      ( \Object
x ->
          Maybe Text -> VaultAccessPolicy
VaultAccessPolicy' (Maybe Text -> VaultAccessPolicy)
-> Parser (Maybe Text) -> Parser VaultAccessPolicy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Policy")
      )

instance Prelude.Hashable VaultAccessPolicy

instance Prelude.NFData VaultAccessPolicy

instance Core.ToJSON VaultAccessPolicy where
  toJSON :: VaultAccessPolicy -> Value
toJSON VaultAccessPolicy' {Maybe Text
policy :: Maybe Text
$sel:policy:VaultAccessPolicy' :: VaultAccessPolicy -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Policy" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
policy]
      )