{-# 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.Macie.AssociateMemberAccount
-- 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)
--
-- Associates a specified AWS account with Amazon Macie Classic as a member
-- account.
module Amazonka.Macie.AssociateMemberAccount
  ( -- * Creating a Request
    AssociateMemberAccount (..),
    newAssociateMemberAccount,

    -- * Request Lenses
    associateMemberAccount_memberAccountId,

    -- * Destructuring the Response
    AssociateMemberAccountResponse (..),
    newAssociateMemberAccountResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Macie.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAssociateMemberAccount' smart constructor.
data AssociateMemberAccount = AssociateMemberAccount'
  { -- | The ID of the AWS account that you want to associate with Amazon Macie
    -- Classic as a member account.
    AssociateMemberAccount -> Text
memberAccountId :: Prelude.Text
  }
  deriving (AssociateMemberAccount -> AssociateMemberAccount -> Bool
(AssociateMemberAccount -> AssociateMemberAccount -> Bool)
-> (AssociateMemberAccount -> AssociateMemberAccount -> Bool)
-> Eq AssociateMemberAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateMemberAccount -> AssociateMemberAccount -> Bool
$c/= :: AssociateMemberAccount -> AssociateMemberAccount -> Bool
== :: AssociateMemberAccount -> AssociateMemberAccount -> Bool
$c== :: AssociateMemberAccount -> AssociateMemberAccount -> Bool
Prelude.Eq, ReadPrec [AssociateMemberAccount]
ReadPrec AssociateMemberAccount
Int -> ReadS AssociateMemberAccount
ReadS [AssociateMemberAccount]
(Int -> ReadS AssociateMemberAccount)
-> ReadS [AssociateMemberAccount]
-> ReadPrec AssociateMemberAccount
-> ReadPrec [AssociateMemberAccount]
-> Read AssociateMemberAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateMemberAccount]
$creadListPrec :: ReadPrec [AssociateMemberAccount]
readPrec :: ReadPrec AssociateMemberAccount
$creadPrec :: ReadPrec AssociateMemberAccount
readList :: ReadS [AssociateMemberAccount]
$creadList :: ReadS [AssociateMemberAccount]
readsPrec :: Int -> ReadS AssociateMemberAccount
$creadsPrec :: Int -> ReadS AssociateMemberAccount
Prelude.Read, Int -> AssociateMemberAccount -> ShowS
[AssociateMemberAccount] -> ShowS
AssociateMemberAccount -> String
(Int -> AssociateMemberAccount -> ShowS)
-> (AssociateMemberAccount -> String)
-> ([AssociateMemberAccount] -> ShowS)
-> Show AssociateMemberAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateMemberAccount] -> ShowS
$cshowList :: [AssociateMemberAccount] -> ShowS
show :: AssociateMemberAccount -> String
$cshow :: AssociateMemberAccount -> String
showsPrec :: Int -> AssociateMemberAccount -> ShowS
$cshowsPrec :: Int -> AssociateMemberAccount -> ShowS
Prelude.Show, (forall x. AssociateMemberAccount -> Rep AssociateMemberAccount x)
-> (forall x.
    Rep AssociateMemberAccount x -> AssociateMemberAccount)
-> Generic AssociateMemberAccount
forall x. Rep AssociateMemberAccount x -> AssociateMemberAccount
forall x. AssociateMemberAccount -> Rep AssociateMemberAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateMemberAccount x -> AssociateMemberAccount
$cfrom :: forall x. AssociateMemberAccount -> Rep AssociateMemberAccount x
Prelude.Generic)

-- |
-- Create a value of 'AssociateMemberAccount' 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:
--
-- 'memberAccountId', 'associateMemberAccount_memberAccountId' - The ID of the AWS account that you want to associate with Amazon Macie
-- Classic as a member account.
newAssociateMemberAccount ::
  -- | 'memberAccountId'
  Prelude.Text ->
  AssociateMemberAccount
newAssociateMemberAccount :: Text -> AssociateMemberAccount
newAssociateMemberAccount Text
pMemberAccountId_ =
  AssociateMemberAccount' :: Text -> AssociateMemberAccount
AssociateMemberAccount'
    { $sel:memberAccountId:AssociateMemberAccount' :: Text
memberAccountId =
        Text
pMemberAccountId_
    }

-- | The ID of the AWS account that you want to associate with Amazon Macie
-- Classic as a member account.
associateMemberAccount_memberAccountId :: Lens.Lens' AssociateMemberAccount Prelude.Text
associateMemberAccount_memberAccountId :: (Text -> f Text)
-> AssociateMemberAccount -> f AssociateMemberAccount
associateMemberAccount_memberAccountId = (AssociateMemberAccount -> Text)
-> (AssociateMemberAccount -> Text -> AssociateMemberAccount)
-> Lens AssociateMemberAccount AssociateMemberAccount Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateMemberAccount' {Text
memberAccountId :: Text
$sel:memberAccountId:AssociateMemberAccount' :: AssociateMemberAccount -> Text
memberAccountId} -> Text
memberAccountId) (\s :: AssociateMemberAccount
s@AssociateMemberAccount' {} Text
a -> AssociateMemberAccount
s {$sel:memberAccountId:AssociateMemberAccount' :: Text
memberAccountId = Text
a} :: AssociateMemberAccount)

instance Core.AWSRequest AssociateMemberAccount where
  type
    AWSResponse AssociateMemberAccount =
      AssociateMemberAccountResponse
  request :: AssociateMemberAccount -> Request AssociateMemberAccount
request = Service -> AssociateMemberAccount -> Request AssociateMemberAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateMemberAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateMemberAccount)))
response =
    AWSResponse AssociateMemberAccount
-> Logger
-> Service
-> Proxy AssociateMemberAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateMemberAccount)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse AssociateMemberAccount
AssociateMemberAccountResponse
AssociateMemberAccountResponse'

instance Prelude.Hashable AssociateMemberAccount

instance Prelude.NFData AssociateMemberAccount

instance Core.ToHeaders AssociateMemberAccount where
  toHeaders :: AssociateMemberAccount -> [Header]
toHeaders =
    [Header] -> AssociateMemberAccount -> [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
"MacieService.AssociateMemberAccount" ::
                          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 AssociateMemberAccount where
  toJSON :: AssociateMemberAccount -> Value
toJSON AssociateMemberAccount' {Text
memberAccountId :: Text
$sel:memberAccountId:AssociateMemberAccount' :: AssociateMemberAccount -> 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
"memberAccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
memberAccountId)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    AssociateMemberAccountResponse