{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MigrationHubConfig.Types.HomeRegionControl where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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 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 timestamp representing the time when the customer called
    -- @CreateHomeregionControl@ and set the home region for the account.
    HomeRegionControl -> Maybe POSIX
requestedTime :: Prelude.Maybe Data.POSIX,
    -- | 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
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]
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
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. 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:
--
-- '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.
--
-- '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.
--
-- 'requestedTime', 'homeRegionControl_requestedTime' - A timestamp representing the time when the customer called
-- @CreateHomeregionControl@ and set the home region for the account.
--
-- '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'
    { $sel:controlId:HomeRegionControl' :: Maybe Text
controlId = forall a. Maybe a
Prelude.Nothing,
      $sel:homeRegion:HomeRegionControl' :: Maybe Text
homeRegion = forall a. Maybe a
Prelude.Nothing,
      $sel:requestedTime:HomeRegionControl' :: Maybe POSIX
requestedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:target:HomeRegionControl' :: Maybe Target
target = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' HomeRegionControl (Maybe Text)
homeRegionControl_controlId = 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 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 :: Lens' HomeRegionControl (Maybe Text)
homeRegionControl_homeRegion = 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 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 :: Lens' HomeRegionControl (Maybe UTCTime)
homeRegionControl_requestedTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable HomeRegionControl where
  hashWithSalt :: Int -> HomeRegionControl -> Int
hashWithSalt Int
_salt HomeRegionControl' {Maybe Text
Maybe POSIX
Maybe Target
target :: Maybe Target
requestedTime :: Maybe POSIX
homeRegion :: Maybe Text
controlId :: Maybe Text
$sel:target:HomeRegionControl' :: HomeRegionControl -> Maybe Target
$sel:requestedTime:HomeRegionControl' :: HomeRegionControl -> Maybe POSIX
$sel:homeRegion:HomeRegionControl' :: HomeRegionControl -> Maybe Text
$sel:controlId:HomeRegionControl' :: HomeRegionControl -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
controlId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
homeRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
requestedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Target
target

instance Prelude.NFData HomeRegionControl where
  rnf :: HomeRegionControl -> ()
rnf HomeRegionControl' {Maybe Text
Maybe POSIX
Maybe Target
target :: Maybe Target
requestedTime :: Maybe POSIX
homeRegion :: Maybe Text
controlId :: Maybe Text
$sel:target:HomeRegionControl' :: HomeRegionControl -> Maybe Target
$sel:requestedTime:HomeRegionControl' :: HomeRegionControl -> Maybe POSIX
$sel:homeRegion:HomeRegionControl' :: HomeRegionControl -> Maybe Text
$sel:controlId:HomeRegionControl' :: HomeRegionControl -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
controlId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
homeRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
requestedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Target
target