{-# 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.AuditManager.RegisterOrganizationAdminAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enables an Amazon Web Services account within the organization as the
-- delegated administrator for Audit Manager.
module Amazonka.AuditManager.RegisterOrganizationAdminAccount
  ( -- * Creating a Request
    RegisterOrganizationAdminAccount (..),
    newRegisterOrganizationAdminAccount,

    -- * Request Lenses
    registerOrganizationAdminAccount_adminAccountId,

    -- * Destructuring the Response
    RegisterOrganizationAdminAccountResponse (..),
    newRegisterOrganizationAdminAccountResponse,

    -- * Response Lenses
    registerOrganizationAdminAccountResponse_adminAccountId,
    registerOrganizationAdminAccountResponse_organizationId,
    registerOrganizationAdminAccountResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'RegisterOrganizationAdminAccount' 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:
--
-- 'adminAccountId', 'registerOrganizationAdminAccount_adminAccountId' - The identifier for the delegated administrator account.
newRegisterOrganizationAdminAccount ::
  -- | 'adminAccountId'
  Prelude.Text ->
  RegisterOrganizationAdminAccount
newRegisterOrganizationAdminAccount :: Text -> RegisterOrganizationAdminAccount
newRegisterOrganizationAdminAccount Text
pAdminAccountId_ =
  RegisterOrganizationAdminAccount'
    { $sel:adminAccountId:RegisterOrganizationAdminAccount' :: Text
adminAccountId =
        Text
pAdminAccountId_
    }

-- | The identifier for the delegated administrator account.
registerOrganizationAdminAccount_adminAccountId :: Lens.Lens' RegisterOrganizationAdminAccount Prelude.Text
registerOrganizationAdminAccount_adminAccountId :: Lens' RegisterOrganizationAdminAccount Text
registerOrganizationAdminAccount_adminAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterOrganizationAdminAccount' {Text
adminAccountId :: Text
$sel:adminAccountId:RegisterOrganizationAdminAccount' :: RegisterOrganizationAdminAccount -> Text
adminAccountId} -> Text
adminAccountId) (\s :: RegisterOrganizationAdminAccount
s@RegisterOrganizationAdminAccount' {} Text
a -> RegisterOrganizationAdminAccount
s {$sel:adminAccountId:RegisterOrganizationAdminAccount' :: Text
adminAccountId = Text
a} :: RegisterOrganizationAdminAccount)

instance
  Core.AWSRequest
    RegisterOrganizationAdminAccount
  where
  type
    AWSResponse RegisterOrganizationAdminAccount =
      RegisterOrganizationAdminAccountResponse
  request :: (Service -> Service)
-> RegisterOrganizationAdminAccount
-> Request RegisterOrganizationAdminAccount
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 RegisterOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse RegisterOrganizationAdminAccount)))
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 Text
-> Maybe Text -> Int -> RegisterOrganizationAdminAccountResponse
RegisterOrganizationAdminAccountResponse'
            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
"adminAccountId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"organizationId")
            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
    RegisterOrganizationAdminAccount
  where
  hashWithSalt :: Int -> RegisterOrganizationAdminAccount -> Int
hashWithSalt
    Int
_salt
    RegisterOrganizationAdminAccount' {Text
adminAccountId :: Text
$sel:adminAccountId:RegisterOrganizationAdminAccount' :: RegisterOrganizationAdminAccount -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
adminAccountId

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

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

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

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

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

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

-- |
-- Create a value of 'RegisterOrganizationAdminAccountResponse' 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:
--
-- 'adminAccountId', 'registerOrganizationAdminAccountResponse_adminAccountId' - The identifier for the delegated administrator account.
--
-- 'organizationId', 'registerOrganizationAdminAccountResponse_organizationId' - The identifier for the organization.
--
-- 'httpStatus', 'registerOrganizationAdminAccountResponse_httpStatus' - The response's http status code.
newRegisterOrganizationAdminAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RegisterOrganizationAdminAccountResponse
newRegisterOrganizationAdminAccountResponse :: Int -> RegisterOrganizationAdminAccountResponse
newRegisterOrganizationAdminAccountResponse
  Int
pHttpStatus_ =
    RegisterOrganizationAdminAccountResponse'
      { $sel:adminAccountId:RegisterOrganizationAdminAccountResponse' :: Maybe Text
adminAccountId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:organizationId:RegisterOrganizationAdminAccountResponse' :: Maybe Text
organizationId = forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:RegisterOrganizationAdminAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The identifier for the delegated administrator account.
registerOrganizationAdminAccountResponse_adminAccountId :: Lens.Lens' RegisterOrganizationAdminAccountResponse (Prelude.Maybe Prelude.Text)
registerOrganizationAdminAccountResponse_adminAccountId :: Lens' RegisterOrganizationAdminAccountResponse (Maybe Text)
registerOrganizationAdminAccountResponse_adminAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterOrganizationAdminAccountResponse' {Maybe Text
adminAccountId :: Maybe Text
$sel:adminAccountId:RegisterOrganizationAdminAccountResponse' :: RegisterOrganizationAdminAccountResponse -> Maybe Text
adminAccountId} -> Maybe Text
adminAccountId) (\s :: RegisterOrganizationAdminAccountResponse
s@RegisterOrganizationAdminAccountResponse' {} Maybe Text
a -> RegisterOrganizationAdminAccountResponse
s {$sel:adminAccountId:RegisterOrganizationAdminAccountResponse' :: Maybe Text
adminAccountId = Maybe Text
a} :: RegisterOrganizationAdminAccountResponse)

-- | The identifier for the organization.
registerOrganizationAdminAccountResponse_organizationId :: Lens.Lens' RegisterOrganizationAdminAccountResponse (Prelude.Maybe Prelude.Text)
registerOrganizationAdminAccountResponse_organizationId :: Lens' RegisterOrganizationAdminAccountResponse (Maybe Text)
registerOrganizationAdminAccountResponse_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterOrganizationAdminAccountResponse' {Maybe Text
organizationId :: Maybe Text
$sel:organizationId:RegisterOrganizationAdminAccountResponse' :: RegisterOrganizationAdminAccountResponse -> Maybe Text
organizationId} -> Maybe Text
organizationId) (\s :: RegisterOrganizationAdminAccountResponse
s@RegisterOrganizationAdminAccountResponse' {} Maybe Text
a -> RegisterOrganizationAdminAccountResponse
s {$sel:organizationId:RegisterOrganizationAdminAccountResponse' :: Maybe Text
organizationId = Maybe Text
a} :: RegisterOrganizationAdminAccountResponse)

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

instance
  Prelude.NFData
    RegisterOrganizationAdminAccountResponse
  where
  rnf :: RegisterOrganizationAdminAccountResponse -> ()
rnf RegisterOrganizationAdminAccountResponse' {Int
Maybe Text
httpStatus :: Int
organizationId :: Maybe Text
adminAccountId :: Maybe Text
$sel:httpStatus:RegisterOrganizationAdminAccountResponse' :: RegisterOrganizationAdminAccountResponse -> Int
$sel:organizationId:RegisterOrganizationAdminAccountResponse' :: RegisterOrganizationAdminAccountResponse -> Maybe Text
$sel:adminAccountId:RegisterOrganizationAdminAccountResponse' :: RegisterOrganizationAdminAccountResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
adminAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus