{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateHomeRegionControl
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This API sets up the home region for the calling account only.
module Amazonka.MigrationHubConfig.CreateHomeRegionControl
  ( -- * Creating a Request
    CreateHomeRegionControl (..),
    newCreateHomeRegionControl,

    -- * Request Lenses
    createHomeRegionControl_dryRun,
    createHomeRegionControl_homeRegion,
    createHomeRegionControl_target,

    -- * Destructuring the Response
    CreateHomeRegionControlResponse (..),
    newCreateHomeRegionControlResponse,

    -- * Response Lenses
    createHomeRegionControlResponse_homeRegionControl,
    createHomeRegionControlResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateHomeRegionControl' smart constructor.
data CreateHomeRegionControl = CreateHomeRegionControl'
  { -- | Optional Boolean flag to indicate whether any effect should take place.
    -- It tests whether the caller has permission to make the call.
    CreateHomeRegionControl -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The name of the home region of the calling account.
    CreateHomeRegionControl -> Text
homeRegion :: Prelude.Text,
    -- | The account for which this command sets up a home region control. The
    -- @Target@ is always of type @ACCOUNT@.
    CreateHomeRegionControl -> Target
target :: Target
  }
  deriving (CreateHomeRegionControl -> CreateHomeRegionControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateHomeRegionControl -> CreateHomeRegionControl -> Bool
$c/= :: CreateHomeRegionControl -> CreateHomeRegionControl -> Bool
== :: CreateHomeRegionControl -> CreateHomeRegionControl -> Bool
$c== :: CreateHomeRegionControl -> CreateHomeRegionControl -> Bool
Prelude.Eq, ReadPrec [CreateHomeRegionControl]
ReadPrec CreateHomeRegionControl
Int -> ReadS CreateHomeRegionControl
ReadS [CreateHomeRegionControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateHomeRegionControl]
$creadListPrec :: ReadPrec [CreateHomeRegionControl]
readPrec :: ReadPrec CreateHomeRegionControl
$creadPrec :: ReadPrec CreateHomeRegionControl
readList :: ReadS [CreateHomeRegionControl]
$creadList :: ReadS [CreateHomeRegionControl]
readsPrec :: Int -> ReadS CreateHomeRegionControl
$creadsPrec :: Int -> ReadS CreateHomeRegionControl
Prelude.Read, Int -> CreateHomeRegionControl -> ShowS
[CreateHomeRegionControl] -> ShowS
CreateHomeRegionControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateHomeRegionControl] -> ShowS
$cshowList :: [CreateHomeRegionControl] -> ShowS
show :: CreateHomeRegionControl -> String
$cshow :: CreateHomeRegionControl -> String
showsPrec :: Int -> CreateHomeRegionControl -> ShowS
$cshowsPrec :: Int -> CreateHomeRegionControl -> ShowS
Prelude.Show, forall x. Rep CreateHomeRegionControl x -> CreateHomeRegionControl
forall x. CreateHomeRegionControl -> Rep CreateHomeRegionControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateHomeRegionControl x -> CreateHomeRegionControl
$cfrom :: forall x. CreateHomeRegionControl -> Rep CreateHomeRegionControl x
Prelude.Generic)

-- |
-- Create a value of 'CreateHomeRegionControl' 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:
--
-- 'dryRun', 'createHomeRegionControl_dryRun' - Optional Boolean flag to indicate whether any effect should take place.
-- It tests whether the caller has permission to make the call.
--
-- 'homeRegion', 'createHomeRegionControl_homeRegion' - The name of the home region of the calling account.
--
-- 'target', 'createHomeRegionControl_target' - The account for which this command sets up a home region control. The
-- @Target@ is always of type @ACCOUNT@.
newCreateHomeRegionControl ::
  -- | 'homeRegion'
  Prelude.Text ->
  -- | 'target'
  Target ->
  CreateHomeRegionControl
newCreateHomeRegionControl :: Text -> Target -> CreateHomeRegionControl
newCreateHomeRegionControl Text
pHomeRegion_ Target
pTarget_ =
  CreateHomeRegionControl'
    { $sel:dryRun:CreateHomeRegionControl' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:homeRegion:CreateHomeRegionControl' :: Text
homeRegion = Text
pHomeRegion_,
      $sel:target:CreateHomeRegionControl' :: Target
target = Target
pTarget_
    }

-- | Optional Boolean flag to indicate whether any effect should take place.
-- It tests whether the caller has permission to make the call.
createHomeRegionControl_dryRun :: Lens.Lens' CreateHomeRegionControl (Prelude.Maybe Prelude.Bool)
createHomeRegionControl_dryRun :: Lens' CreateHomeRegionControl (Maybe Bool)
createHomeRegionControl_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHomeRegionControl' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:CreateHomeRegionControl' :: CreateHomeRegionControl -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: CreateHomeRegionControl
s@CreateHomeRegionControl' {} Maybe Bool
a -> CreateHomeRegionControl
s {$sel:dryRun:CreateHomeRegionControl' :: Maybe Bool
dryRun = Maybe Bool
a} :: CreateHomeRegionControl)

-- | The name of the home region of the calling account.
createHomeRegionControl_homeRegion :: Lens.Lens' CreateHomeRegionControl Prelude.Text
createHomeRegionControl_homeRegion :: Lens' CreateHomeRegionControl Text
createHomeRegionControl_homeRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHomeRegionControl' {Text
homeRegion :: Text
$sel:homeRegion:CreateHomeRegionControl' :: CreateHomeRegionControl -> Text
homeRegion} -> Text
homeRegion) (\s :: CreateHomeRegionControl
s@CreateHomeRegionControl' {} Text
a -> CreateHomeRegionControl
s {$sel:homeRegion:CreateHomeRegionControl' :: Text
homeRegion = Text
a} :: CreateHomeRegionControl)

-- | The account for which this command sets up a home region control. The
-- @Target@ is always of type @ACCOUNT@.
createHomeRegionControl_target :: Lens.Lens' CreateHomeRegionControl Target
createHomeRegionControl_target :: Lens' CreateHomeRegionControl Target
createHomeRegionControl_target = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHomeRegionControl' {Target
target :: Target
$sel:target:CreateHomeRegionControl' :: CreateHomeRegionControl -> Target
target} -> Target
target) (\s :: CreateHomeRegionControl
s@CreateHomeRegionControl' {} Target
a -> CreateHomeRegionControl
s {$sel:target:CreateHomeRegionControl' :: Target
target = Target
a} :: CreateHomeRegionControl)

instance Core.AWSRequest CreateHomeRegionControl where
  type
    AWSResponse CreateHomeRegionControl =
      CreateHomeRegionControlResponse
  request :: (Service -> Service)
-> CreateHomeRegionControl -> Request CreateHomeRegionControl
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateHomeRegionControl
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateHomeRegionControl)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe HomeRegionControl -> Int -> CreateHomeRegionControlResponse
CreateHomeRegionControlResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"HomeRegionControl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateHomeRegionControl where
  hashWithSalt :: Int -> CreateHomeRegionControl -> Int
hashWithSalt Int
_salt CreateHomeRegionControl' {Maybe Bool
Text
Target
target :: Target
homeRegion :: Text
dryRun :: Maybe Bool
$sel:target:CreateHomeRegionControl' :: CreateHomeRegionControl -> Target
$sel:homeRegion:CreateHomeRegionControl' :: CreateHomeRegionControl -> Text
$sel:dryRun:CreateHomeRegionControl' :: CreateHomeRegionControl -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
homeRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Target
target

instance Prelude.NFData CreateHomeRegionControl where
  rnf :: CreateHomeRegionControl -> ()
rnf CreateHomeRegionControl' {Maybe Bool
Text
Target
target :: Target
homeRegion :: Text
dryRun :: Maybe Bool
$sel:target:CreateHomeRegionControl' :: CreateHomeRegionControl -> Target
$sel:homeRegion:CreateHomeRegionControl' :: CreateHomeRegionControl -> Text
$sel:dryRun:CreateHomeRegionControl' :: CreateHomeRegionControl -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
homeRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Target
target

instance Data.ToHeaders CreateHomeRegionControl where
  toHeaders :: CreateHomeRegionControl -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSMigrationHubMultiAccountService.CreateHomeRegionControl" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateHomeRegionControl where
  toJSON :: CreateHomeRegionControl -> Value
toJSON CreateHomeRegionControl' {Maybe Bool
Text
Target
target :: Target
homeRegion :: Text
dryRun :: Maybe Bool
$sel:target:CreateHomeRegionControl' :: CreateHomeRegionControl -> Target
$sel:homeRegion:CreateHomeRegionControl' :: CreateHomeRegionControl -> Text
$sel:dryRun:CreateHomeRegionControl' :: CreateHomeRegionControl -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DryRun" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
dryRun,
            forall a. a -> Maybe a
Prelude.Just (Key
"HomeRegion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
homeRegion),
            forall a. a -> Maybe a
Prelude.Just (Key
"Target" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Target
target)
          ]
      )

instance Data.ToPath CreateHomeRegionControl where
  toPath :: CreateHomeRegionControl -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery CreateHomeRegionControl where
  toQuery :: CreateHomeRegionControl -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateHomeRegionControlResponse' smart constructor.
data CreateHomeRegionControlResponse = CreateHomeRegionControlResponse'
  { -- | This object is the @HomeRegionControl@ object that\'s returned by a
    -- successful call to @CreateHomeRegionControl@.
    CreateHomeRegionControlResponse -> Maybe HomeRegionControl
homeRegionControl :: Prelude.Maybe HomeRegionControl,
    -- | The response's http status code.
    CreateHomeRegionControlResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateHomeRegionControlResponse
-> CreateHomeRegionControlResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateHomeRegionControlResponse
-> CreateHomeRegionControlResponse -> Bool
$c/= :: CreateHomeRegionControlResponse
-> CreateHomeRegionControlResponse -> Bool
== :: CreateHomeRegionControlResponse
-> CreateHomeRegionControlResponse -> Bool
$c== :: CreateHomeRegionControlResponse
-> CreateHomeRegionControlResponse -> Bool
Prelude.Eq, ReadPrec [CreateHomeRegionControlResponse]
ReadPrec CreateHomeRegionControlResponse
Int -> ReadS CreateHomeRegionControlResponse
ReadS [CreateHomeRegionControlResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateHomeRegionControlResponse]
$creadListPrec :: ReadPrec [CreateHomeRegionControlResponse]
readPrec :: ReadPrec CreateHomeRegionControlResponse
$creadPrec :: ReadPrec CreateHomeRegionControlResponse
readList :: ReadS [CreateHomeRegionControlResponse]
$creadList :: ReadS [CreateHomeRegionControlResponse]
readsPrec :: Int -> ReadS CreateHomeRegionControlResponse
$creadsPrec :: Int -> ReadS CreateHomeRegionControlResponse
Prelude.Read, Int -> CreateHomeRegionControlResponse -> ShowS
[CreateHomeRegionControlResponse] -> ShowS
CreateHomeRegionControlResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateHomeRegionControlResponse] -> ShowS
$cshowList :: [CreateHomeRegionControlResponse] -> ShowS
show :: CreateHomeRegionControlResponse -> String
$cshow :: CreateHomeRegionControlResponse -> String
showsPrec :: Int -> CreateHomeRegionControlResponse -> ShowS
$cshowsPrec :: Int -> CreateHomeRegionControlResponse -> ShowS
Prelude.Show, forall x.
Rep CreateHomeRegionControlResponse x
-> CreateHomeRegionControlResponse
forall x.
CreateHomeRegionControlResponse
-> Rep CreateHomeRegionControlResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateHomeRegionControlResponse x
-> CreateHomeRegionControlResponse
$cfrom :: forall x.
CreateHomeRegionControlResponse
-> Rep CreateHomeRegionControlResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateHomeRegionControlResponse' 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:
--
-- 'homeRegionControl', 'createHomeRegionControlResponse_homeRegionControl' - This object is the @HomeRegionControl@ object that\'s returned by a
-- successful call to @CreateHomeRegionControl@.
--
-- 'httpStatus', 'createHomeRegionControlResponse_httpStatus' - The response's http status code.
newCreateHomeRegionControlResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateHomeRegionControlResponse
newCreateHomeRegionControlResponse :: Int -> CreateHomeRegionControlResponse
newCreateHomeRegionControlResponse Int
pHttpStatus_ =
  CreateHomeRegionControlResponse'
    { $sel:homeRegionControl:CreateHomeRegionControlResponse' :: Maybe HomeRegionControl
homeRegionControl =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateHomeRegionControlResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | This object is the @HomeRegionControl@ object that\'s returned by a
-- successful call to @CreateHomeRegionControl@.
createHomeRegionControlResponse_homeRegionControl :: Lens.Lens' CreateHomeRegionControlResponse (Prelude.Maybe HomeRegionControl)
createHomeRegionControlResponse_homeRegionControl :: Lens' CreateHomeRegionControlResponse (Maybe HomeRegionControl)
createHomeRegionControlResponse_homeRegionControl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHomeRegionControlResponse' {Maybe HomeRegionControl
homeRegionControl :: Maybe HomeRegionControl
$sel:homeRegionControl:CreateHomeRegionControlResponse' :: CreateHomeRegionControlResponse -> Maybe HomeRegionControl
homeRegionControl} -> Maybe HomeRegionControl
homeRegionControl) (\s :: CreateHomeRegionControlResponse
s@CreateHomeRegionControlResponse' {} Maybe HomeRegionControl
a -> CreateHomeRegionControlResponse
s {$sel:homeRegionControl:CreateHomeRegionControlResponse' :: Maybe HomeRegionControl
homeRegionControl = Maybe HomeRegionControl
a} :: CreateHomeRegionControlResponse)

-- | The response's http status code.
createHomeRegionControlResponse_httpStatus :: Lens.Lens' CreateHomeRegionControlResponse Prelude.Int
createHomeRegionControlResponse_httpStatus :: Lens' CreateHomeRegionControlResponse Int
createHomeRegionControlResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHomeRegionControlResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateHomeRegionControlResponse' :: CreateHomeRegionControlResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateHomeRegionControlResponse
s@CreateHomeRegionControlResponse' {} Int
a -> CreateHomeRegionControlResponse
s {$sel:httpStatus:CreateHomeRegionControlResponse' :: Int
httpStatus = Int
a} :: CreateHomeRegionControlResponse)

instance
  Prelude.NFData
    CreateHomeRegionControlResponse
  where
  rnf :: CreateHomeRegionControlResponse -> ()
rnf CreateHomeRegionControlResponse' {Int
Maybe HomeRegionControl
httpStatus :: Int
homeRegionControl :: Maybe HomeRegionControl
$sel:httpStatus:CreateHomeRegionControlResponse' :: CreateHomeRegionControlResponse -> Int
$sel:homeRegionControl:CreateHomeRegionControlResponse' :: CreateHomeRegionControlResponse -> Maybe HomeRegionControl
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe HomeRegionControl
homeRegionControl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus