{-# 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.FMS.AssociateAdminAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets the Firewall Manager administrator account. The account must be a
-- member of the organization in Organizations whose resources you want to
-- protect. Firewall Manager sets the permissions that allow the account to
-- administer your Firewall Manager policies.
--
-- The account that you associate with Firewall Manager is called the
-- Firewall Manager administrator account.
module Amazonka.FMS.AssociateAdminAccount
  ( -- * Creating a Request
    AssociateAdminAccount (..),
    newAssociateAdminAccount,

    -- * Request Lenses
    associateAdminAccount_adminAccount,

    -- * Destructuring the Response
    AssociateAdminAccountResponse (..),
    newAssociateAdminAccountResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAssociateAdminAccount' smart constructor.
data AssociateAdminAccount = AssociateAdminAccount'
  { -- | The Amazon Web Services account ID to associate with Firewall Manager as
    -- the Firewall Manager administrator account. This must be an
    -- Organizations member account. For more information about Organizations,
    -- see
    -- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts.html Managing the Amazon Web Services Accounts in Your Organization>.
    AssociateAdminAccount -> Text
adminAccount :: Prelude.Text
  }
  deriving (AssociateAdminAccount -> AssociateAdminAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAdminAccount -> AssociateAdminAccount -> Bool
$c/= :: AssociateAdminAccount -> AssociateAdminAccount -> Bool
== :: AssociateAdminAccount -> AssociateAdminAccount -> Bool
$c== :: AssociateAdminAccount -> AssociateAdminAccount -> Bool
Prelude.Eq, ReadPrec [AssociateAdminAccount]
ReadPrec AssociateAdminAccount
Int -> ReadS AssociateAdminAccount
ReadS [AssociateAdminAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAdminAccount]
$creadListPrec :: ReadPrec [AssociateAdminAccount]
readPrec :: ReadPrec AssociateAdminAccount
$creadPrec :: ReadPrec AssociateAdminAccount
readList :: ReadS [AssociateAdminAccount]
$creadList :: ReadS [AssociateAdminAccount]
readsPrec :: Int -> ReadS AssociateAdminAccount
$creadsPrec :: Int -> ReadS AssociateAdminAccount
Prelude.Read, Int -> AssociateAdminAccount -> ShowS
[AssociateAdminAccount] -> ShowS
AssociateAdminAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAdminAccount] -> ShowS
$cshowList :: [AssociateAdminAccount] -> ShowS
show :: AssociateAdminAccount -> String
$cshow :: AssociateAdminAccount -> String
showsPrec :: Int -> AssociateAdminAccount -> ShowS
$cshowsPrec :: Int -> AssociateAdminAccount -> ShowS
Prelude.Show, forall x. Rep AssociateAdminAccount x -> AssociateAdminAccount
forall x. AssociateAdminAccount -> Rep AssociateAdminAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateAdminAccount x -> AssociateAdminAccount
$cfrom :: forall x. AssociateAdminAccount -> Rep AssociateAdminAccount x
Prelude.Generic)

-- |
-- Create a value of 'AssociateAdminAccount' 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:
--
-- 'adminAccount', 'associateAdminAccount_adminAccount' - The Amazon Web Services account ID to associate with Firewall Manager as
-- the Firewall Manager administrator account. This must be an
-- Organizations member account. For more information about Organizations,
-- see
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts.html Managing the Amazon Web Services Accounts in Your Organization>.
newAssociateAdminAccount ::
  -- | 'adminAccount'
  Prelude.Text ->
  AssociateAdminAccount
newAssociateAdminAccount :: Text -> AssociateAdminAccount
newAssociateAdminAccount Text
pAdminAccount_ =
  AssociateAdminAccount'
    { $sel:adminAccount:AssociateAdminAccount' :: Text
adminAccount =
        Text
pAdminAccount_
    }

-- | The Amazon Web Services account ID to associate with Firewall Manager as
-- the Firewall Manager administrator account. This must be an
-- Organizations member account. For more information about Organizations,
-- see
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts.html Managing the Amazon Web Services Accounts in Your Organization>.
associateAdminAccount_adminAccount :: Lens.Lens' AssociateAdminAccount Prelude.Text
associateAdminAccount_adminAccount :: Lens' AssociateAdminAccount Text
associateAdminAccount_adminAccount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAdminAccount' {Text
adminAccount :: Text
$sel:adminAccount:AssociateAdminAccount' :: AssociateAdminAccount -> Text
adminAccount} -> Text
adminAccount) (\s :: AssociateAdminAccount
s@AssociateAdminAccount' {} Text
a -> AssociateAdminAccount
s {$sel:adminAccount:AssociateAdminAccount' :: Text
adminAccount = Text
a} :: AssociateAdminAccount)

instance Core.AWSRequest AssociateAdminAccount where
  type
    AWSResponse AssociateAdminAccount =
      AssociateAdminAccountResponse
  request :: (Service -> Service)
-> AssociateAdminAccount -> Request AssociateAdminAccount
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 AssociateAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateAdminAccount)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AssociateAdminAccountResponse
AssociateAdminAccountResponse'

instance Prelude.Hashable AssociateAdminAccount where
  hashWithSalt :: Int -> AssociateAdminAccount -> Int
hashWithSalt Int
_salt AssociateAdminAccount' {Text
adminAccount :: Text
$sel:adminAccount:AssociateAdminAccount' :: AssociateAdminAccount -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
adminAccount

instance Prelude.NFData AssociateAdminAccount where
  rnf :: AssociateAdminAccount -> ()
rnf AssociateAdminAccount' {Text
adminAccount :: Text
$sel:adminAccount:AssociateAdminAccount' :: AssociateAdminAccount -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
adminAccount

instance Data.ToHeaders AssociateAdminAccount where
  toHeaders :: AssociateAdminAccount -> [Header]
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 -> [Header]
Data.=# ( ByteString
"AWSFMS_20180101.AssociateAdminAccount" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON AssociateAdminAccount where
  toJSON :: AssociateAdminAccount -> Value
toJSON AssociateAdminAccount' {Text
adminAccount :: Text
$sel:adminAccount:AssociateAdminAccount' :: AssociateAdminAccount -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"AdminAccount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
adminAccount)]
      )

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

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

-- | /See:/ 'newAssociateAdminAccountResponse' smart constructor.
data AssociateAdminAccountResponse = AssociateAdminAccountResponse'
  {
  }
  deriving (AssociateAdminAccountResponse
-> AssociateAdminAccountResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAdminAccountResponse
-> AssociateAdminAccountResponse -> Bool
$c/= :: AssociateAdminAccountResponse
-> AssociateAdminAccountResponse -> Bool
== :: AssociateAdminAccountResponse
-> AssociateAdminAccountResponse -> Bool
$c== :: AssociateAdminAccountResponse
-> AssociateAdminAccountResponse -> Bool
Prelude.Eq, ReadPrec [AssociateAdminAccountResponse]
ReadPrec AssociateAdminAccountResponse
Int -> ReadS AssociateAdminAccountResponse
ReadS [AssociateAdminAccountResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAdminAccountResponse]
$creadListPrec :: ReadPrec [AssociateAdminAccountResponse]
readPrec :: ReadPrec AssociateAdminAccountResponse
$creadPrec :: ReadPrec AssociateAdminAccountResponse
readList :: ReadS [AssociateAdminAccountResponse]
$creadList :: ReadS [AssociateAdminAccountResponse]
readsPrec :: Int -> ReadS AssociateAdminAccountResponse
$creadsPrec :: Int -> ReadS AssociateAdminAccountResponse
Prelude.Read, Int -> AssociateAdminAccountResponse -> ShowS
[AssociateAdminAccountResponse] -> ShowS
AssociateAdminAccountResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAdminAccountResponse] -> ShowS
$cshowList :: [AssociateAdminAccountResponse] -> ShowS
show :: AssociateAdminAccountResponse -> String
$cshow :: AssociateAdminAccountResponse -> String
showsPrec :: Int -> AssociateAdminAccountResponse -> ShowS
$cshowsPrec :: Int -> AssociateAdminAccountResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateAdminAccountResponse x
-> AssociateAdminAccountResponse
forall x.
AssociateAdminAccountResponse
-> Rep AssociateAdminAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateAdminAccountResponse x
-> AssociateAdminAccountResponse
$cfrom :: forall x.
AssociateAdminAccountResponse
-> Rep AssociateAdminAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateAdminAccountResponse' 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.
newAssociateAdminAccountResponse ::
  AssociateAdminAccountResponse
newAssociateAdminAccountResponse :: AssociateAdminAccountResponse
newAssociateAdminAccountResponse =
  AssociateAdminAccountResponse
AssociateAdminAccountResponse'

instance Prelude.NFData AssociateAdminAccountResponse where
  rnf :: AssociateAdminAccountResponse -> ()
rnf AssociateAdminAccountResponse
_ = ()