{-# 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-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)
--
-- 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 Amazonka.FMS.Types
import qualified Amazonka.Lens as Lens
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
(AssociateAdminAccount -> AssociateAdminAccount -> Bool)
-> (AssociateAdminAccount -> AssociateAdminAccount -> Bool)
-> Eq AssociateAdminAccount
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]
(Int -> ReadS AssociateAdminAccount)
-> ReadS [AssociateAdminAccount]
-> ReadPrec AssociateAdminAccount
-> ReadPrec [AssociateAdminAccount]
-> Read 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
(Int -> AssociateAdminAccount -> ShowS)
-> (AssociateAdminAccount -> String)
-> ([AssociateAdminAccount] -> ShowS)
-> Show AssociateAdminAccount
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. AssociateAdminAccount -> Rep AssociateAdminAccount x)
-> (forall x. Rep AssociateAdminAccount x -> AssociateAdminAccount)
-> Generic AssociateAdminAccount
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' :: Text -> AssociateAdminAccount
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 :: (Text -> f Text)
-> AssociateAdminAccount -> f AssociateAdminAccount
associateAdminAccount_adminAccount = (AssociateAdminAccount -> Text)
-> (AssociateAdminAccount -> Text -> AssociateAdminAccount)
-> Lens AssociateAdminAccount AssociateAdminAccount Text Text
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 :: AssociateAdminAccount -> Request AssociateAdminAccount
request = Service -> AssociateAdminAccount -> Request AssociateAdminAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateAdminAccount)))
response =
    AWSResponse AssociateAdminAccount
-> Logger
-> Service
-> Proxy AssociateAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateAdminAccount)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse AssociateAdminAccount
AssociateAdminAccountResponse
AssociateAdminAccountResponse'

instance Prelude.Hashable AssociateAdminAccount

instance Prelude.NFData AssociateAdminAccount

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

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

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

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

-- | /See:/ 'newAssociateAdminAccountResponse' smart constructor.
data AssociateAdminAccountResponse = AssociateAdminAccountResponse'
  {
  }
  deriving (AssociateAdminAccountResponse
-> AssociateAdminAccountResponse -> Bool
(AssociateAdminAccountResponse
 -> AssociateAdminAccountResponse -> Bool)
-> (AssociateAdminAccountResponse
    -> AssociateAdminAccountResponse -> Bool)
-> Eq AssociateAdminAccountResponse
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]
(Int -> ReadS AssociateAdminAccountResponse)
-> ReadS [AssociateAdminAccountResponse]
-> ReadPrec AssociateAdminAccountResponse
-> ReadPrec [AssociateAdminAccountResponse]
-> Read 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
(Int -> AssociateAdminAccountResponse -> ShowS)
-> (AssociateAdminAccountResponse -> String)
-> ([AssociateAdminAccountResponse] -> ShowS)
-> Show AssociateAdminAccountResponse
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.
 AssociateAdminAccountResponse
 -> Rep AssociateAdminAccountResponse x)
-> (forall x.
    Rep AssociateAdminAccountResponse x
    -> AssociateAdminAccountResponse)
-> Generic AssociateAdminAccountResponse
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