{-# 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.DirectoryService.Types.RegionsInfo
-- 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.DirectoryService.Types.RegionsInfo where

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

-- | Provides information about the Regions that are configured for
-- multi-Region replication.
--
-- /See:/ 'newRegionsInfo' smart constructor.
data RegionsInfo = RegionsInfo'
  { -- | The Region where the Managed Microsoft AD directory was originally
    -- created.
    RegionsInfo -> Maybe Text
primaryRegion :: Prelude.Maybe Prelude.Text,
    -- | Lists the Regions where the directory has been replicated, excluding the
    -- primary Region.
    RegionsInfo -> Maybe [Text]
additionalRegions :: Prelude.Maybe [Prelude.Text]
  }
  deriving (RegionsInfo -> RegionsInfo -> Bool
(RegionsInfo -> RegionsInfo -> Bool)
-> (RegionsInfo -> RegionsInfo -> Bool) -> Eq RegionsInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegionsInfo -> RegionsInfo -> Bool
$c/= :: RegionsInfo -> RegionsInfo -> Bool
== :: RegionsInfo -> RegionsInfo -> Bool
$c== :: RegionsInfo -> RegionsInfo -> Bool
Prelude.Eq, ReadPrec [RegionsInfo]
ReadPrec RegionsInfo
Int -> ReadS RegionsInfo
ReadS [RegionsInfo]
(Int -> ReadS RegionsInfo)
-> ReadS [RegionsInfo]
-> ReadPrec RegionsInfo
-> ReadPrec [RegionsInfo]
-> Read RegionsInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegionsInfo]
$creadListPrec :: ReadPrec [RegionsInfo]
readPrec :: ReadPrec RegionsInfo
$creadPrec :: ReadPrec RegionsInfo
readList :: ReadS [RegionsInfo]
$creadList :: ReadS [RegionsInfo]
readsPrec :: Int -> ReadS RegionsInfo
$creadsPrec :: Int -> ReadS RegionsInfo
Prelude.Read, Int -> RegionsInfo -> ShowS
[RegionsInfo] -> ShowS
RegionsInfo -> String
(Int -> RegionsInfo -> ShowS)
-> (RegionsInfo -> String)
-> ([RegionsInfo] -> ShowS)
-> Show RegionsInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegionsInfo] -> ShowS
$cshowList :: [RegionsInfo] -> ShowS
show :: RegionsInfo -> String
$cshow :: RegionsInfo -> String
showsPrec :: Int -> RegionsInfo -> ShowS
$cshowsPrec :: Int -> RegionsInfo -> ShowS
Prelude.Show, (forall x. RegionsInfo -> Rep RegionsInfo x)
-> (forall x. Rep RegionsInfo x -> RegionsInfo)
-> Generic RegionsInfo
forall x. Rep RegionsInfo x -> RegionsInfo
forall x. RegionsInfo -> Rep RegionsInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegionsInfo x -> RegionsInfo
$cfrom :: forall x. RegionsInfo -> Rep RegionsInfo x
Prelude.Generic)

-- |
-- Create a value of 'RegionsInfo' 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:
--
-- 'primaryRegion', 'regionsInfo_primaryRegion' - The Region where the Managed Microsoft AD directory was originally
-- created.
--
-- 'additionalRegions', 'regionsInfo_additionalRegions' - Lists the Regions where the directory has been replicated, excluding the
-- primary Region.
newRegionsInfo ::
  RegionsInfo
newRegionsInfo :: RegionsInfo
newRegionsInfo =
  RegionsInfo' :: Maybe Text -> Maybe [Text] -> RegionsInfo
RegionsInfo'
    { $sel:primaryRegion:RegionsInfo' :: Maybe Text
primaryRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:additionalRegions:RegionsInfo' :: Maybe [Text]
additionalRegions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Region where the Managed Microsoft AD directory was originally
-- created.
regionsInfo_primaryRegion :: Lens.Lens' RegionsInfo (Prelude.Maybe Prelude.Text)
regionsInfo_primaryRegion :: (Maybe Text -> f (Maybe Text)) -> RegionsInfo -> f RegionsInfo
regionsInfo_primaryRegion = (RegionsInfo -> Maybe Text)
-> (RegionsInfo -> Maybe Text -> RegionsInfo)
-> Lens RegionsInfo RegionsInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegionsInfo' {Maybe Text
primaryRegion :: Maybe Text
$sel:primaryRegion:RegionsInfo' :: RegionsInfo -> Maybe Text
primaryRegion} -> Maybe Text
primaryRegion) (\s :: RegionsInfo
s@RegionsInfo' {} Maybe Text
a -> RegionsInfo
s {$sel:primaryRegion:RegionsInfo' :: Maybe Text
primaryRegion = Maybe Text
a} :: RegionsInfo)

-- | Lists the Regions where the directory has been replicated, excluding the
-- primary Region.
regionsInfo_additionalRegions :: Lens.Lens' RegionsInfo (Prelude.Maybe [Prelude.Text])
regionsInfo_additionalRegions :: (Maybe [Text] -> f (Maybe [Text])) -> RegionsInfo -> f RegionsInfo
regionsInfo_additionalRegions = (RegionsInfo -> Maybe [Text])
-> (RegionsInfo -> Maybe [Text] -> RegionsInfo)
-> Lens RegionsInfo RegionsInfo (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegionsInfo' {Maybe [Text]
additionalRegions :: Maybe [Text]
$sel:additionalRegions:RegionsInfo' :: RegionsInfo -> Maybe [Text]
additionalRegions} -> Maybe [Text]
additionalRegions) (\s :: RegionsInfo
s@RegionsInfo' {} Maybe [Text]
a -> RegionsInfo
s {$sel:additionalRegions:RegionsInfo' :: Maybe [Text]
additionalRegions = Maybe [Text]
a} :: RegionsInfo) ((Maybe [Text] -> f (Maybe [Text]))
 -> RegionsInfo -> f RegionsInfo)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RegionsInfo
-> f RegionsInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON RegionsInfo where
  parseJSON :: Value -> Parser RegionsInfo
parseJSON =
    String
-> (Object -> Parser RegionsInfo) -> Value -> Parser RegionsInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RegionsInfo"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> RegionsInfo
RegionsInfo'
            (Maybe Text -> Maybe [Text] -> RegionsInfo)
-> Parser (Maybe Text) -> Parser (Maybe [Text] -> RegionsInfo)
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
"PrimaryRegion")
            Parser (Maybe [Text] -> RegionsInfo)
-> Parser (Maybe [Text]) -> Parser RegionsInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AdditionalRegions"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RegionsInfo

instance Prelude.NFData RegionsInfo