{-# 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.RDS.Types.SourceRegion
-- 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.RDS.Types.SourceRegion where

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

-- | Contains an Amazon Web Services Region name as the result of a
-- successful call to the @DescribeSourceRegions@ action.
--
-- /See:/ 'newSourceRegion' smart constructor.
data SourceRegion = SourceRegion'
  { -- | Whether the source Amazon Web Services Region supports replicating
    -- automated backups to the current Amazon Web Services Region.
    SourceRegion -> Maybe Bool
supportsDBInstanceAutomatedBackupsReplication :: Prelude.Maybe Prelude.Bool,
    -- | The status of the source Amazon Web Services Region.
    SourceRegion -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The name of the source Amazon Web Services Region.
    SourceRegion -> Maybe Text
regionName :: Prelude.Maybe Prelude.Text,
    -- | The endpoint for the source Amazon Web Services Region endpoint.
    SourceRegion -> Maybe Text
endpoint :: Prelude.Maybe Prelude.Text
  }
  deriving (SourceRegion -> SourceRegion -> Bool
(SourceRegion -> SourceRegion -> Bool)
-> (SourceRegion -> SourceRegion -> Bool) -> Eq SourceRegion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceRegion -> SourceRegion -> Bool
$c/= :: SourceRegion -> SourceRegion -> Bool
== :: SourceRegion -> SourceRegion -> Bool
$c== :: SourceRegion -> SourceRegion -> Bool
Prelude.Eq, ReadPrec [SourceRegion]
ReadPrec SourceRegion
Int -> ReadS SourceRegion
ReadS [SourceRegion]
(Int -> ReadS SourceRegion)
-> ReadS [SourceRegion]
-> ReadPrec SourceRegion
-> ReadPrec [SourceRegion]
-> Read SourceRegion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceRegion]
$creadListPrec :: ReadPrec [SourceRegion]
readPrec :: ReadPrec SourceRegion
$creadPrec :: ReadPrec SourceRegion
readList :: ReadS [SourceRegion]
$creadList :: ReadS [SourceRegion]
readsPrec :: Int -> ReadS SourceRegion
$creadsPrec :: Int -> ReadS SourceRegion
Prelude.Read, Int -> SourceRegion -> ShowS
[SourceRegion] -> ShowS
SourceRegion -> String
(Int -> SourceRegion -> ShowS)
-> (SourceRegion -> String)
-> ([SourceRegion] -> ShowS)
-> Show SourceRegion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceRegion] -> ShowS
$cshowList :: [SourceRegion] -> ShowS
show :: SourceRegion -> String
$cshow :: SourceRegion -> String
showsPrec :: Int -> SourceRegion -> ShowS
$cshowsPrec :: Int -> SourceRegion -> ShowS
Prelude.Show, (forall x. SourceRegion -> Rep SourceRegion x)
-> (forall x. Rep SourceRegion x -> SourceRegion)
-> Generic SourceRegion
forall x. Rep SourceRegion x -> SourceRegion
forall x. SourceRegion -> Rep SourceRegion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceRegion x -> SourceRegion
$cfrom :: forall x. SourceRegion -> Rep SourceRegion x
Prelude.Generic)

-- |
-- Create a value of 'SourceRegion' 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:
--
-- 'supportsDBInstanceAutomatedBackupsReplication', 'sourceRegion_supportsDBInstanceAutomatedBackupsReplication' - Whether the source Amazon Web Services Region supports replicating
-- automated backups to the current Amazon Web Services Region.
--
-- 'status', 'sourceRegion_status' - The status of the source Amazon Web Services Region.
--
-- 'regionName', 'sourceRegion_regionName' - The name of the source Amazon Web Services Region.
--
-- 'endpoint', 'sourceRegion_endpoint' - The endpoint for the source Amazon Web Services Region endpoint.
newSourceRegion ::
  SourceRegion
newSourceRegion :: SourceRegion
newSourceRegion =
  SourceRegion' :: Maybe Bool
-> Maybe Text -> Maybe Text -> Maybe Text -> SourceRegion
SourceRegion'
    { $sel:supportsDBInstanceAutomatedBackupsReplication:SourceRegion' :: Maybe Bool
supportsDBInstanceAutomatedBackupsReplication =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:status:SourceRegion' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regionName:SourceRegion' :: Maybe Text
regionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpoint:SourceRegion' :: Maybe Text
endpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the source Amazon Web Services Region supports replicating
-- automated backups to the current Amazon Web Services Region.
sourceRegion_supportsDBInstanceAutomatedBackupsReplication :: Lens.Lens' SourceRegion (Prelude.Maybe Prelude.Bool)
sourceRegion_supportsDBInstanceAutomatedBackupsReplication :: (Maybe Bool -> f (Maybe Bool)) -> SourceRegion -> f SourceRegion
sourceRegion_supportsDBInstanceAutomatedBackupsReplication = (SourceRegion -> Maybe Bool)
-> (SourceRegion -> Maybe Bool -> SourceRegion)
-> Lens SourceRegion SourceRegion (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRegion' {Maybe Bool
supportsDBInstanceAutomatedBackupsReplication :: Maybe Bool
$sel:supportsDBInstanceAutomatedBackupsReplication:SourceRegion' :: SourceRegion -> Maybe Bool
supportsDBInstanceAutomatedBackupsReplication} -> Maybe Bool
supportsDBInstanceAutomatedBackupsReplication) (\s :: SourceRegion
s@SourceRegion' {} Maybe Bool
a -> SourceRegion
s {$sel:supportsDBInstanceAutomatedBackupsReplication:SourceRegion' :: Maybe Bool
supportsDBInstanceAutomatedBackupsReplication = Maybe Bool
a} :: SourceRegion)

-- | The status of the source Amazon Web Services Region.
sourceRegion_status :: Lens.Lens' SourceRegion (Prelude.Maybe Prelude.Text)
sourceRegion_status :: (Maybe Text -> f (Maybe Text)) -> SourceRegion -> f SourceRegion
sourceRegion_status = (SourceRegion -> Maybe Text)
-> (SourceRegion -> Maybe Text -> SourceRegion)
-> Lens SourceRegion SourceRegion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRegion' {Maybe Text
status :: Maybe Text
$sel:status:SourceRegion' :: SourceRegion -> Maybe Text
status} -> Maybe Text
status) (\s :: SourceRegion
s@SourceRegion' {} Maybe Text
a -> SourceRegion
s {$sel:status:SourceRegion' :: Maybe Text
status = Maybe Text
a} :: SourceRegion)

-- | The name of the source Amazon Web Services Region.
sourceRegion_regionName :: Lens.Lens' SourceRegion (Prelude.Maybe Prelude.Text)
sourceRegion_regionName :: (Maybe Text -> f (Maybe Text)) -> SourceRegion -> f SourceRegion
sourceRegion_regionName = (SourceRegion -> Maybe Text)
-> (SourceRegion -> Maybe Text -> SourceRegion)
-> Lens SourceRegion SourceRegion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRegion' {Maybe Text
regionName :: Maybe Text
$sel:regionName:SourceRegion' :: SourceRegion -> Maybe Text
regionName} -> Maybe Text
regionName) (\s :: SourceRegion
s@SourceRegion' {} Maybe Text
a -> SourceRegion
s {$sel:regionName:SourceRegion' :: Maybe Text
regionName = Maybe Text
a} :: SourceRegion)

-- | The endpoint for the source Amazon Web Services Region endpoint.
sourceRegion_endpoint :: Lens.Lens' SourceRegion (Prelude.Maybe Prelude.Text)
sourceRegion_endpoint :: (Maybe Text -> f (Maybe Text)) -> SourceRegion -> f SourceRegion
sourceRegion_endpoint = (SourceRegion -> Maybe Text)
-> (SourceRegion -> Maybe Text -> SourceRegion)
-> Lens SourceRegion SourceRegion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceRegion' {Maybe Text
endpoint :: Maybe Text
$sel:endpoint:SourceRegion' :: SourceRegion -> Maybe Text
endpoint} -> Maybe Text
endpoint) (\s :: SourceRegion
s@SourceRegion' {} Maybe Text
a -> SourceRegion
s {$sel:endpoint:SourceRegion' :: Maybe Text
endpoint = Maybe Text
a} :: SourceRegion)

instance Core.FromXML SourceRegion where
  parseXML :: [Node] -> Either String SourceRegion
parseXML [Node]
x =
    Maybe Bool
-> Maybe Text -> Maybe Text -> Maybe Text -> SourceRegion
SourceRegion'
      (Maybe Bool
 -> Maybe Text -> Maybe Text -> Maybe Text -> SourceRegion)
-> Either String (Maybe Bool)
-> Either
     String (Maybe Text -> Maybe Text -> Maybe Text -> SourceRegion)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SupportsDBInstanceAutomatedBackupsReplication"
                  )
      Either
  String (Maybe Text -> Maybe Text -> Maybe Text -> SourceRegion)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> SourceRegion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either String (Maybe Text -> Maybe Text -> SourceRegion)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> SourceRegion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"RegionName")
      Either String (Maybe Text -> SourceRegion)
-> Either String (Maybe Text) -> Either String SourceRegion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Endpoint")

instance Prelude.Hashable SourceRegion

instance Prelude.NFData SourceRegion