{-# 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.MacieV2.EnableOrganizationAdminAccount
-- 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)
--
-- Designates an account as the delegated Amazon Macie administrator
-- account for an Amazon Web Services organization.
module Amazonka.MacieV2.EnableOrganizationAdminAccount
  ( -- * Creating a Request
    EnableOrganizationAdminAccount (..),
    newEnableOrganizationAdminAccount,

    -- * Request Lenses
    enableOrganizationAdminAccount_clientToken,
    enableOrganizationAdminAccount_adminAccountId,

    -- * Destructuring the Response
    EnableOrganizationAdminAccountResponse (..),
    newEnableOrganizationAdminAccountResponse,

    -- * Response Lenses
    enableOrganizationAdminAccountResponse_httpStatus,
  )
where

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

-- | /See:/ 'newEnableOrganizationAdminAccount' smart constructor.
data EnableOrganizationAdminAccount = EnableOrganizationAdminAccount'
  { -- | A unique, case-sensitive token that you provide to ensure the
    -- idempotency of the request.
    EnableOrganizationAdminAccount -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services account ID for the account to designate as the
    -- delegated Amazon Macie administrator account for the organization.
    EnableOrganizationAdminAccount -> Text
adminAccountId :: Prelude.Text
  }
  deriving (EnableOrganizationAdminAccount
-> EnableOrganizationAdminAccount -> Bool
(EnableOrganizationAdminAccount
 -> EnableOrganizationAdminAccount -> Bool)
-> (EnableOrganizationAdminAccount
    -> EnableOrganizationAdminAccount -> Bool)
-> Eq EnableOrganizationAdminAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableOrganizationAdminAccount
-> EnableOrganizationAdminAccount -> Bool
$c/= :: EnableOrganizationAdminAccount
-> EnableOrganizationAdminAccount -> Bool
== :: EnableOrganizationAdminAccount
-> EnableOrganizationAdminAccount -> Bool
$c== :: EnableOrganizationAdminAccount
-> EnableOrganizationAdminAccount -> Bool
Prelude.Eq, ReadPrec [EnableOrganizationAdminAccount]
ReadPrec EnableOrganizationAdminAccount
Int -> ReadS EnableOrganizationAdminAccount
ReadS [EnableOrganizationAdminAccount]
(Int -> ReadS EnableOrganizationAdminAccount)
-> ReadS [EnableOrganizationAdminAccount]
-> ReadPrec EnableOrganizationAdminAccount
-> ReadPrec [EnableOrganizationAdminAccount]
-> Read EnableOrganizationAdminAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableOrganizationAdminAccount]
$creadListPrec :: ReadPrec [EnableOrganizationAdminAccount]
readPrec :: ReadPrec EnableOrganizationAdminAccount
$creadPrec :: ReadPrec EnableOrganizationAdminAccount
readList :: ReadS [EnableOrganizationAdminAccount]
$creadList :: ReadS [EnableOrganizationAdminAccount]
readsPrec :: Int -> ReadS EnableOrganizationAdminAccount
$creadsPrec :: Int -> ReadS EnableOrganizationAdminAccount
Prelude.Read, Int -> EnableOrganizationAdminAccount -> ShowS
[EnableOrganizationAdminAccount] -> ShowS
EnableOrganizationAdminAccount -> String
(Int -> EnableOrganizationAdminAccount -> ShowS)
-> (EnableOrganizationAdminAccount -> String)
-> ([EnableOrganizationAdminAccount] -> ShowS)
-> Show EnableOrganizationAdminAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableOrganizationAdminAccount] -> ShowS
$cshowList :: [EnableOrganizationAdminAccount] -> ShowS
show :: EnableOrganizationAdminAccount -> String
$cshow :: EnableOrganizationAdminAccount -> String
showsPrec :: Int -> EnableOrganizationAdminAccount -> ShowS
$cshowsPrec :: Int -> EnableOrganizationAdminAccount -> ShowS
Prelude.Show, (forall x.
 EnableOrganizationAdminAccount
 -> Rep EnableOrganizationAdminAccount x)
-> (forall x.
    Rep EnableOrganizationAdminAccount x
    -> EnableOrganizationAdminAccount)
-> Generic EnableOrganizationAdminAccount
forall x.
Rep EnableOrganizationAdminAccount x
-> EnableOrganizationAdminAccount
forall x.
EnableOrganizationAdminAccount
-> Rep EnableOrganizationAdminAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableOrganizationAdminAccount x
-> EnableOrganizationAdminAccount
$cfrom :: forall x.
EnableOrganizationAdminAccount
-> Rep EnableOrganizationAdminAccount x
Prelude.Generic)

-- |
-- Create a value of 'EnableOrganizationAdminAccount' 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:
--
-- 'clientToken', 'enableOrganizationAdminAccount_clientToken' - A unique, case-sensitive token that you provide to ensure the
-- idempotency of the request.
--
-- 'adminAccountId', 'enableOrganizationAdminAccount_adminAccountId' - The Amazon Web Services account ID for the account to designate as the
-- delegated Amazon Macie administrator account for the organization.
newEnableOrganizationAdminAccount ::
  -- | 'adminAccountId'
  Prelude.Text ->
  EnableOrganizationAdminAccount
newEnableOrganizationAdminAccount :: Text -> EnableOrganizationAdminAccount
newEnableOrganizationAdminAccount Text
pAdminAccountId_ =
  EnableOrganizationAdminAccount' :: Maybe Text -> Text -> EnableOrganizationAdminAccount
EnableOrganizationAdminAccount'
    { $sel:clientToken:EnableOrganizationAdminAccount' :: Maybe Text
clientToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:adminAccountId:EnableOrganizationAdminAccount' :: Text
adminAccountId = Text
pAdminAccountId_
    }

-- | A unique, case-sensitive token that you provide to ensure the
-- idempotency of the request.
enableOrganizationAdminAccount_clientToken :: Lens.Lens' EnableOrganizationAdminAccount (Prelude.Maybe Prelude.Text)
enableOrganizationAdminAccount_clientToken :: (Maybe Text -> f (Maybe Text))
-> EnableOrganizationAdminAccount
-> f EnableOrganizationAdminAccount
enableOrganizationAdminAccount_clientToken = (EnableOrganizationAdminAccount -> Maybe Text)
-> (EnableOrganizationAdminAccount
    -> Maybe Text -> EnableOrganizationAdminAccount)
-> Lens
     EnableOrganizationAdminAccount
     EnableOrganizationAdminAccount
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableOrganizationAdminAccount' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:EnableOrganizationAdminAccount' :: EnableOrganizationAdminAccount -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: EnableOrganizationAdminAccount
s@EnableOrganizationAdminAccount' {} Maybe Text
a -> EnableOrganizationAdminAccount
s {$sel:clientToken:EnableOrganizationAdminAccount' :: Maybe Text
clientToken = Maybe Text
a} :: EnableOrganizationAdminAccount)

-- | The Amazon Web Services account ID for the account to designate as the
-- delegated Amazon Macie administrator account for the organization.
enableOrganizationAdminAccount_adminAccountId :: Lens.Lens' EnableOrganizationAdminAccount Prelude.Text
enableOrganizationAdminAccount_adminAccountId :: (Text -> f Text)
-> EnableOrganizationAdminAccount
-> f EnableOrganizationAdminAccount
enableOrganizationAdminAccount_adminAccountId = (EnableOrganizationAdminAccount -> Text)
-> (EnableOrganizationAdminAccount
    -> Text -> EnableOrganizationAdminAccount)
-> Lens
     EnableOrganizationAdminAccount
     EnableOrganizationAdminAccount
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableOrganizationAdminAccount' {Text
adminAccountId :: Text
$sel:adminAccountId:EnableOrganizationAdminAccount' :: EnableOrganizationAdminAccount -> Text
adminAccountId} -> Text
adminAccountId) (\s :: EnableOrganizationAdminAccount
s@EnableOrganizationAdminAccount' {} Text
a -> EnableOrganizationAdminAccount
s {$sel:adminAccountId:EnableOrganizationAdminAccount' :: Text
adminAccountId = Text
a} :: EnableOrganizationAdminAccount)

instance
  Core.AWSRequest
    EnableOrganizationAdminAccount
  where
  type
    AWSResponse EnableOrganizationAdminAccount =
      EnableOrganizationAdminAccountResponse
  request :: EnableOrganizationAdminAccount
-> Request EnableOrganizationAdminAccount
request = Service
-> EnableOrganizationAdminAccount
-> Request EnableOrganizationAdminAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse EnableOrganizationAdminAccount)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse EnableOrganizationAdminAccount))
-> Logger
-> Service
-> Proxy EnableOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse EnableOrganizationAdminAccount)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> EnableOrganizationAdminAccountResponse
EnableOrganizationAdminAccountResponse'
            (Int -> EnableOrganizationAdminAccountResponse)
-> Either String Int
-> Either String EnableOrganizationAdminAccountResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    EnableOrganizationAdminAccount

instance
  Prelude.NFData
    EnableOrganizationAdminAccount

instance
  Core.ToHeaders
    EnableOrganizationAdminAccount
  where
  toHeaders :: EnableOrganizationAdminAccount -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> EnableOrganizationAdminAccount -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON EnableOrganizationAdminAccount where
  toJSON :: EnableOrganizationAdminAccount -> Value
toJSON EnableOrganizationAdminAccount' {Maybe Text
Text
adminAccountId :: Text
clientToken :: Maybe Text
$sel:adminAccountId:EnableOrganizationAdminAccount' :: EnableOrganizationAdminAccount -> Text
$sel:clientToken:EnableOrganizationAdminAccount' :: EnableOrganizationAdminAccount -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"adminAccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
adminAccountId)
          ]
      )

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

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

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

-- |
-- Create a value of 'EnableOrganizationAdminAccountResponse' 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:
--
-- 'httpStatus', 'enableOrganizationAdminAccountResponse_httpStatus' - The response's http status code.
newEnableOrganizationAdminAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  EnableOrganizationAdminAccountResponse
newEnableOrganizationAdminAccountResponse :: Int -> EnableOrganizationAdminAccountResponse
newEnableOrganizationAdminAccountResponse
  Int
pHttpStatus_ =
    EnableOrganizationAdminAccountResponse' :: Int -> EnableOrganizationAdminAccountResponse
EnableOrganizationAdminAccountResponse'
      { $sel:httpStatus:EnableOrganizationAdminAccountResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

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

instance
  Prelude.NFData
    EnableOrganizationAdminAccountResponse