{-# 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.KMS.Types.MultiRegionKey
-- 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.KMS.Types.MultiRegionKey where

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

-- | Describes the primary or replica key in a multi-Region key.
--
-- /See:/ 'newMultiRegionKey' smart constructor.
data MultiRegionKey = MultiRegionKey'
  { -- | Displays the key ARN of a primary or replica key of a multi-Region key.
    MultiRegionKey -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Displays the Amazon Web Services Region of a primary or replica key in a
    -- multi-Region key.
    MultiRegionKey -> Maybe Text
region :: Prelude.Maybe Prelude.Text
  }
  deriving (MultiRegionKey -> MultiRegionKey -> Bool
(MultiRegionKey -> MultiRegionKey -> Bool)
-> (MultiRegionKey -> MultiRegionKey -> Bool) -> Eq MultiRegionKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MultiRegionKey -> MultiRegionKey -> Bool
$c/= :: MultiRegionKey -> MultiRegionKey -> Bool
== :: MultiRegionKey -> MultiRegionKey -> Bool
$c== :: MultiRegionKey -> MultiRegionKey -> Bool
Prelude.Eq, ReadPrec [MultiRegionKey]
ReadPrec MultiRegionKey
Int -> ReadS MultiRegionKey
ReadS [MultiRegionKey]
(Int -> ReadS MultiRegionKey)
-> ReadS [MultiRegionKey]
-> ReadPrec MultiRegionKey
-> ReadPrec [MultiRegionKey]
-> Read MultiRegionKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MultiRegionKey]
$creadListPrec :: ReadPrec [MultiRegionKey]
readPrec :: ReadPrec MultiRegionKey
$creadPrec :: ReadPrec MultiRegionKey
readList :: ReadS [MultiRegionKey]
$creadList :: ReadS [MultiRegionKey]
readsPrec :: Int -> ReadS MultiRegionKey
$creadsPrec :: Int -> ReadS MultiRegionKey
Prelude.Read, Int -> MultiRegionKey -> ShowS
[MultiRegionKey] -> ShowS
MultiRegionKey -> String
(Int -> MultiRegionKey -> ShowS)
-> (MultiRegionKey -> String)
-> ([MultiRegionKey] -> ShowS)
-> Show MultiRegionKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MultiRegionKey] -> ShowS
$cshowList :: [MultiRegionKey] -> ShowS
show :: MultiRegionKey -> String
$cshow :: MultiRegionKey -> String
showsPrec :: Int -> MultiRegionKey -> ShowS
$cshowsPrec :: Int -> MultiRegionKey -> ShowS
Prelude.Show, (forall x. MultiRegionKey -> Rep MultiRegionKey x)
-> (forall x. Rep MultiRegionKey x -> MultiRegionKey)
-> Generic MultiRegionKey
forall x. Rep MultiRegionKey x -> MultiRegionKey
forall x. MultiRegionKey -> Rep MultiRegionKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MultiRegionKey x -> MultiRegionKey
$cfrom :: forall x. MultiRegionKey -> Rep MultiRegionKey x
Prelude.Generic)

-- |
-- Create a value of 'MultiRegionKey' 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:
--
-- 'arn', 'multiRegionKey_arn' - Displays the key ARN of a primary or replica key of a multi-Region key.
--
-- 'region', 'multiRegionKey_region' - Displays the Amazon Web Services Region of a primary or replica key in a
-- multi-Region key.
newMultiRegionKey ::
  MultiRegionKey
newMultiRegionKey :: MultiRegionKey
newMultiRegionKey =
  MultiRegionKey' :: Maybe Text -> Maybe Text -> MultiRegionKey
MultiRegionKey'
    { $sel:arn:MultiRegionKey' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:MultiRegionKey' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Displays the key ARN of a primary or replica key of a multi-Region key.
multiRegionKey_arn :: Lens.Lens' MultiRegionKey (Prelude.Maybe Prelude.Text)
multiRegionKey_arn :: (Maybe Text -> f (Maybe Text))
-> MultiRegionKey -> f MultiRegionKey
multiRegionKey_arn = (MultiRegionKey -> Maybe Text)
-> (MultiRegionKey -> Maybe Text -> MultiRegionKey)
-> Lens MultiRegionKey MultiRegionKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultiRegionKey' {Maybe Text
arn :: Maybe Text
$sel:arn:MultiRegionKey' :: MultiRegionKey -> Maybe Text
arn} -> Maybe Text
arn) (\s :: MultiRegionKey
s@MultiRegionKey' {} Maybe Text
a -> MultiRegionKey
s {$sel:arn:MultiRegionKey' :: Maybe Text
arn = Maybe Text
a} :: MultiRegionKey)

-- | Displays the Amazon Web Services Region of a primary or replica key in a
-- multi-Region key.
multiRegionKey_region :: Lens.Lens' MultiRegionKey (Prelude.Maybe Prelude.Text)
multiRegionKey_region :: (Maybe Text -> f (Maybe Text))
-> MultiRegionKey -> f MultiRegionKey
multiRegionKey_region = (MultiRegionKey -> Maybe Text)
-> (MultiRegionKey -> Maybe Text -> MultiRegionKey)
-> Lens MultiRegionKey MultiRegionKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultiRegionKey' {Maybe Text
region :: Maybe Text
$sel:region:MultiRegionKey' :: MultiRegionKey -> Maybe Text
region} -> Maybe Text
region) (\s :: MultiRegionKey
s@MultiRegionKey' {} Maybe Text
a -> MultiRegionKey
s {$sel:region:MultiRegionKey' :: Maybe Text
region = Maybe Text
a} :: MultiRegionKey)

instance Core.FromJSON MultiRegionKey where
  parseJSON :: Value -> Parser MultiRegionKey
parseJSON =
    String
-> (Object -> Parser MultiRegionKey)
-> Value
-> Parser MultiRegionKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MultiRegionKey"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> MultiRegionKey
MultiRegionKey'
            (Maybe Text -> Maybe Text -> MultiRegionKey)
-> Parser (Maybe Text) -> Parser (Maybe Text -> MultiRegionKey)
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
"Arn") Parser (Maybe Text -> MultiRegionKey)
-> Parser (Maybe Text) -> Parser MultiRegionKey
forall (f :: * -> *) a b. Applicative f => 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
"Region")
      )

instance Prelude.Hashable MultiRegionKey

instance Prelude.NFData MultiRegionKey