{-# 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.MigrationHubConfig.Types.HomeRegionControl
-- 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.MigrationHubConfig.Types.HomeRegionControl where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MigrationHubConfig.Types.Target
import qualified Amazonka.Prelude as Prelude

-- | A home region control is an object that specifies the home region for an
-- account, with some additional information. It contains a target (always
-- of type @ACCOUNT@), an ID, and a time at which the home region was set.
--
-- /See:/ 'newHomeRegionControl' smart constructor.
data HomeRegionControl = HomeRegionControl'
  { -- | A timestamp representing the time when the customer called
    -- @CreateHomeregionControl@ and set the home region for the account.
    HomeRegionControl -> Maybe POSIX
requestedTime :: Prelude.Maybe Core.POSIX,
    -- | The AWS Region that\'s been set as home region. For example,
    -- \"us-west-2\" or \"eu-central-1\" are valid home regions.
    HomeRegionControl -> Maybe Text
homeRegion :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier that\'s generated for each home region control.
    -- It\'s always a string that begins with \"hrc-\" followed by 12 lowercase
    -- letters and numbers.
    HomeRegionControl -> Maybe Text
controlId :: Prelude.Maybe Prelude.Text,
    -- | The target parameter specifies the identifier to which the home region
    -- is applied, which is always an @ACCOUNT@. It applies the home region to
    -- the current @ACCOUNT@.
    HomeRegionControl -> Maybe Target
target :: Prelude.Maybe Target
  }
  deriving (HomeRegionControl -> HomeRegionControl -> Bool
(HomeRegionControl -> HomeRegionControl -> Bool)
-> (HomeRegionControl -> HomeRegionControl -> Bool)
-> Eq HomeRegionControl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HomeRegionControl -> HomeRegionControl -> Bool
$c/= :: HomeRegionControl -> HomeRegionControl -> Bool
== :: HomeRegionControl -> HomeRegionControl -> Bool
$c== :: HomeRegionControl -> HomeRegionControl -> Bool
Prelude.Eq, ReadPrec [HomeRegionControl]
ReadPrec HomeRegionControl
Int -> ReadS HomeRegionControl
ReadS [HomeRegionControl]
(Int -> ReadS HomeRegionControl)
-> ReadS [HomeRegionControl]
-> ReadPrec HomeRegionControl
-> ReadPrec [HomeRegionControl]
-> Read HomeRegionControl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HomeRegionControl]
$creadListPrec :: ReadPrec [HomeRegionControl]
readPrec :: ReadPrec HomeRegionControl
$creadPrec :: ReadPrec HomeRegionControl
readList :: ReadS [HomeRegionControl]
$creadList :: ReadS [HomeRegionControl]
readsPrec :: Int -> ReadS HomeRegionControl
$creadsPrec :: Int -> ReadS HomeRegionControl
Prelude.Read, Int -> HomeRegionControl -> ShowS
[HomeRegionControl] -> ShowS
HomeRegionControl -> String
(Int -> HomeRegionControl -> ShowS)
-> (HomeRegionControl -> String)
-> ([HomeRegionControl] -> ShowS)
-> Show HomeRegionControl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HomeRegionControl] -> ShowS
$cshowList :: [HomeRegionControl] -> ShowS
show :: HomeRegionControl -> String
$cshow :: HomeRegionControl -> String
showsPrec :: Int -> HomeRegionControl -> ShowS
$cshowsPrec :: Int -> HomeRegionControl -> ShowS
Prelude.Show, (forall x. HomeRegionControl -> Rep HomeRegionControl x)
-> (forall x. Rep HomeRegionControl x -> HomeRegionControl)
-> Generic HomeRegionControl
forall x. Rep HomeRegionControl x -> HomeRegionControl
forall x. HomeRegionControl -> Rep HomeRegionControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HomeRegionControl x -> HomeRegionControl
$cfrom :: forall x. HomeRegionControl -> Rep HomeRegionControl x
Prelude.Generic)

-- |
-- Create a value of 'HomeRegionControl' 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:
--
-- 'requestedTime', 'homeRegionControl_requestedTime' - A timestamp representing the time when the customer called
-- @CreateHomeregionControl@ and set the home region for the account.
--
-- 'homeRegion', 'homeRegionControl_homeRegion' - The AWS Region that\'s been set as home region. For example,
-- \"us-west-2\" or \"eu-central-1\" are valid home regions.
--
-- 'controlId', 'homeRegionControl_controlId' - A unique identifier that\'s generated for each home region control.
-- It\'s always a string that begins with \"hrc-\" followed by 12 lowercase
-- letters and numbers.
--
-- 'target', 'homeRegionControl_target' - The target parameter specifies the identifier to which the home region
-- is applied, which is always an @ACCOUNT@. It applies the home region to
-- the current @ACCOUNT@.
newHomeRegionControl ::
  HomeRegionControl
newHomeRegionControl :: HomeRegionControl
newHomeRegionControl =
  HomeRegionControl' :: Maybe POSIX
-> Maybe Text -> Maybe Text -> Maybe Target -> HomeRegionControl
HomeRegionControl'
    { $sel:requestedTime:HomeRegionControl' :: Maybe POSIX
requestedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:homeRegion:HomeRegionControl' :: Maybe Text
homeRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:controlId:HomeRegionControl' :: Maybe Text
controlId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:target:HomeRegionControl' :: Maybe Target
target = Maybe Target
forall a. Maybe a
Prelude.Nothing
    }

-- | A timestamp representing the time when the customer called
-- @CreateHomeregionControl@ and set the home region for the account.
homeRegionControl_requestedTime :: Lens.Lens' HomeRegionControl (Prelude.Maybe Prelude.UTCTime)
homeRegionControl_requestedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> HomeRegionControl -> f HomeRegionControl
homeRegionControl_requestedTime = (HomeRegionControl -> Maybe POSIX)
-> (HomeRegionControl -> Maybe POSIX -> HomeRegionControl)
-> Lens
     HomeRegionControl HomeRegionControl (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HomeRegionControl' {Maybe POSIX
requestedTime :: Maybe POSIX
$sel:requestedTime:HomeRegionControl' :: HomeRegionControl -> Maybe POSIX
requestedTime} -> Maybe POSIX
requestedTime) (\s :: HomeRegionControl
s@HomeRegionControl' {} Maybe POSIX
a -> HomeRegionControl
s {$sel:requestedTime:HomeRegionControl' :: Maybe POSIX
requestedTime = Maybe POSIX
a} :: HomeRegionControl) ((Maybe POSIX -> f (Maybe POSIX))
 -> HomeRegionControl -> f HomeRegionControl)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> HomeRegionControl
-> f HomeRegionControl
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The AWS Region that\'s been set as home region. For example,
-- \"us-west-2\" or \"eu-central-1\" are valid home regions.
homeRegionControl_homeRegion :: Lens.Lens' HomeRegionControl (Prelude.Maybe Prelude.Text)
homeRegionControl_homeRegion :: (Maybe Text -> f (Maybe Text))
-> HomeRegionControl -> f HomeRegionControl
homeRegionControl_homeRegion = (HomeRegionControl -> Maybe Text)
-> (HomeRegionControl -> Maybe Text -> HomeRegionControl)
-> Lens
     HomeRegionControl HomeRegionControl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HomeRegionControl' {Maybe Text
homeRegion :: Maybe Text
$sel:homeRegion:HomeRegionControl' :: HomeRegionControl -> Maybe Text
homeRegion} -> Maybe Text
homeRegion) (\s :: HomeRegionControl
s@HomeRegionControl' {} Maybe Text
a -> HomeRegionControl
s {$sel:homeRegion:HomeRegionControl' :: Maybe Text
homeRegion = Maybe Text
a} :: HomeRegionControl)

-- | A unique identifier that\'s generated for each home region control.
-- It\'s always a string that begins with \"hrc-\" followed by 12 lowercase
-- letters and numbers.
homeRegionControl_controlId :: Lens.Lens' HomeRegionControl (Prelude.Maybe Prelude.Text)
homeRegionControl_controlId :: (Maybe Text -> f (Maybe Text))
-> HomeRegionControl -> f HomeRegionControl
homeRegionControl_controlId = (HomeRegionControl -> Maybe Text)
-> (HomeRegionControl -> Maybe Text -> HomeRegionControl)
-> Lens
     HomeRegionControl HomeRegionControl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HomeRegionControl' {Maybe Text
controlId :: Maybe Text
$sel:controlId:HomeRegionControl' :: HomeRegionControl -> Maybe Text
controlId} -> Maybe Text
controlId) (\s :: HomeRegionControl
s@HomeRegionControl' {} Maybe Text
a -> HomeRegionControl
s {$sel:controlId:HomeRegionControl' :: Maybe Text
controlId = Maybe Text
a} :: HomeRegionControl)

-- | The target parameter specifies the identifier to which the home region
-- is applied, which is always an @ACCOUNT@. It applies the home region to
-- the current @ACCOUNT@.
homeRegionControl_target :: Lens.Lens' HomeRegionControl (Prelude.Maybe Target)
homeRegionControl_target :: (Maybe Target -> f (Maybe Target))
-> HomeRegionControl -> f HomeRegionControl
homeRegionControl_target = (HomeRegionControl -> Maybe Target)
-> (HomeRegionControl -> Maybe Target -> HomeRegionControl)
-> Lens
     HomeRegionControl HomeRegionControl (Maybe Target) (Maybe Target)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HomeRegionControl' {Maybe Target
target :: Maybe Target
$sel:target:HomeRegionControl' :: HomeRegionControl -> Maybe Target
target} -> Maybe Target
target) (\s :: HomeRegionControl
s@HomeRegionControl' {} Maybe Target
a -> HomeRegionControl
s {$sel:target:HomeRegionControl' :: Maybe Target
target = Maybe Target
a} :: HomeRegionControl)

instance Core.FromJSON HomeRegionControl where
  parseJSON :: Value -> Parser HomeRegionControl
parseJSON =
    String
-> (Object -> Parser HomeRegionControl)
-> Value
-> Parser HomeRegionControl
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HomeRegionControl"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe Text -> Maybe Target -> HomeRegionControl
HomeRegionControl'
            (Maybe POSIX
 -> Maybe Text -> Maybe Text -> Maybe Target -> HomeRegionControl)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Target -> HomeRegionControl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequestedTime")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Target -> HomeRegionControl)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Target -> HomeRegionControl)
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
"HomeRegion")
            Parser (Maybe Text -> Maybe Target -> HomeRegionControl)
-> Parser (Maybe Text)
-> Parser (Maybe Target -> HomeRegionControl)
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
"ControlId")
            Parser (Maybe Target -> HomeRegionControl)
-> Parser (Maybe Target) -> Parser HomeRegionControl
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Target)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Target")
      )

instance Prelude.Hashable HomeRegionControl

instance Prelude.NFData HomeRegionControl