{-# 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.Organizations.RegisterDelegatedAdministrator
-- 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)
--
-- Enables the specified member account to administer the Organizations
-- features of the specified AWS service. It grants read-only access to AWS
-- Organizations service data. The account still requires IAM permissions
-- to access and administer the AWS service.
--
-- You can run this action only for AWS services that support this feature.
-- For a current list of services that support it, see the column /Supports
-- Delegated Administrator/ in the table at
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services_list.html AWS Services that you can use with AWS Organizations>
-- in the /AWS Organizations User Guide./
--
-- This operation can be called only from the organization\'s management
-- account.
module Amazonka.Organizations.RegisterDelegatedAdministrator
  ( -- * Creating a Request
    RegisterDelegatedAdministrator (..),
    newRegisterDelegatedAdministrator,

    -- * Request Lenses
    registerDelegatedAdministrator_accountId,
    registerDelegatedAdministrator_servicePrincipal,

    -- * Destructuring the Response
    RegisterDelegatedAdministratorResponse (..),
    newRegisterDelegatedAdministratorResponse,
  )
where

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

-- | /See:/ 'newRegisterDelegatedAdministrator' smart constructor.
data RegisterDelegatedAdministrator = RegisterDelegatedAdministrator'
  { -- | The account ID number of the member account in the organization to
    -- register as a delegated administrator.
    RegisterDelegatedAdministrator -> Text
accountId :: Prelude.Text,
    -- | The service principal of the AWS service for which you want to make the
    -- member account a delegated administrator.
    RegisterDelegatedAdministrator -> Text
servicePrincipal :: Prelude.Text
  }
  deriving (RegisterDelegatedAdministrator
-> RegisterDelegatedAdministrator -> Bool
(RegisterDelegatedAdministrator
 -> RegisterDelegatedAdministrator -> Bool)
-> (RegisterDelegatedAdministrator
    -> RegisterDelegatedAdministrator -> Bool)
-> Eq RegisterDelegatedAdministrator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterDelegatedAdministrator
-> RegisterDelegatedAdministrator -> Bool
$c/= :: RegisterDelegatedAdministrator
-> RegisterDelegatedAdministrator -> Bool
== :: RegisterDelegatedAdministrator
-> RegisterDelegatedAdministrator -> Bool
$c== :: RegisterDelegatedAdministrator
-> RegisterDelegatedAdministrator -> Bool
Prelude.Eq, ReadPrec [RegisterDelegatedAdministrator]
ReadPrec RegisterDelegatedAdministrator
Int -> ReadS RegisterDelegatedAdministrator
ReadS [RegisterDelegatedAdministrator]
(Int -> ReadS RegisterDelegatedAdministrator)
-> ReadS [RegisterDelegatedAdministrator]
-> ReadPrec RegisterDelegatedAdministrator
-> ReadPrec [RegisterDelegatedAdministrator]
-> Read RegisterDelegatedAdministrator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterDelegatedAdministrator]
$creadListPrec :: ReadPrec [RegisterDelegatedAdministrator]
readPrec :: ReadPrec RegisterDelegatedAdministrator
$creadPrec :: ReadPrec RegisterDelegatedAdministrator
readList :: ReadS [RegisterDelegatedAdministrator]
$creadList :: ReadS [RegisterDelegatedAdministrator]
readsPrec :: Int -> ReadS RegisterDelegatedAdministrator
$creadsPrec :: Int -> ReadS RegisterDelegatedAdministrator
Prelude.Read, Int -> RegisterDelegatedAdministrator -> ShowS
[RegisterDelegatedAdministrator] -> ShowS
RegisterDelegatedAdministrator -> String
(Int -> RegisterDelegatedAdministrator -> ShowS)
-> (RegisterDelegatedAdministrator -> String)
-> ([RegisterDelegatedAdministrator] -> ShowS)
-> Show RegisterDelegatedAdministrator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterDelegatedAdministrator] -> ShowS
$cshowList :: [RegisterDelegatedAdministrator] -> ShowS
show :: RegisterDelegatedAdministrator -> String
$cshow :: RegisterDelegatedAdministrator -> String
showsPrec :: Int -> RegisterDelegatedAdministrator -> ShowS
$cshowsPrec :: Int -> RegisterDelegatedAdministrator -> ShowS
Prelude.Show, (forall x.
 RegisterDelegatedAdministrator
 -> Rep RegisterDelegatedAdministrator x)
-> (forall x.
    Rep RegisterDelegatedAdministrator x
    -> RegisterDelegatedAdministrator)
-> Generic RegisterDelegatedAdministrator
forall x.
Rep RegisterDelegatedAdministrator x
-> RegisterDelegatedAdministrator
forall x.
RegisterDelegatedAdministrator
-> Rep RegisterDelegatedAdministrator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterDelegatedAdministrator x
-> RegisterDelegatedAdministrator
$cfrom :: forall x.
RegisterDelegatedAdministrator
-> Rep RegisterDelegatedAdministrator x
Prelude.Generic)

-- |
-- Create a value of 'RegisterDelegatedAdministrator' 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:
--
-- 'accountId', 'registerDelegatedAdministrator_accountId' - The account ID number of the member account in the organization to
-- register as a delegated administrator.
--
-- 'servicePrincipal', 'registerDelegatedAdministrator_servicePrincipal' - The service principal of the AWS service for which you want to make the
-- member account a delegated administrator.
newRegisterDelegatedAdministrator ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'servicePrincipal'
  Prelude.Text ->
  RegisterDelegatedAdministrator
newRegisterDelegatedAdministrator :: Text -> Text -> RegisterDelegatedAdministrator
newRegisterDelegatedAdministrator
  Text
pAccountId_
  Text
pServicePrincipal_ =
    RegisterDelegatedAdministrator' :: Text -> Text -> RegisterDelegatedAdministrator
RegisterDelegatedAdministrator'
      { $sel:accountId:RegisterDelegatedAdministrator' :: Text
accountId =
          Text
pAccountId_,
        $sel:servicePrincipal:RegisterDelegatedAdministrator' :: Text
servicePrincipal = Text
pServicePrincipal_
      }

-- | The account ID number of the member account in the organization to
-- register as a delegated administrator.
registerDelegatedAdministrator_accountId :: Lens.Lens' RegisterDelegatedAdministrator Prelude.Text
registerDelegatedAdministrator_accountId :: (Text -> f Text)
-> RegisterDelegatedAdministrator
-> f RegisterDelegatedAdministrator
registerDelegatedAdministrator_accountId = (RegisterDelegatedAdministrator -> Text)
-> (RegisterDelegatedAdministrator
    -> Text -> RegisterDelegatedAdministrator)
-> Lens
     RegisterDelegatedAdministrator
     RegisterDelegatedAdministrator
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDelegatedAdministrator' {Text
accountId :: Text
$sel:accountId:RegisterDelegatedAdministrator' :: RegisterDelegatedAdministrator -> Text
accountId} -> Text
accountId) (\s :: RegisterDelegatedAdministrator
s@RegisterDelegatedAdministrator' {} Text
a -> RegisterDelegatedAdministrator
s {$sel:accountId:RegisterDelegatedAdministrator' :: Text
accountId = Text
a} :: RegisterDelegatedAdministrator)

-- | The service principal of the AWS service for which you want to make the
-- member account a delegated administrator.
registerDelegatedAdministrator_servicePrincipal :: Lens.Lens' RegisterDelegatedAdministrator Prelude.Text
registerDelegatedAdministrator_servicePrincipal :: (Text -> f Text)
-> RegisterDelegatedAdministrator
-> f RegisterDelegatedAdministrator
registerDelegatedAdministrator_servicePrincipal = (RegisterDelegatedAdministrator -> Text)
-> (RegisterDelegatedAdministrator
    -> Text -> RegisterDelegatedAdministrator)
-> Lens
     RegisterDelegatedAdministrator
     RegisterDelegatedAdministrator
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDelegatedAdministrator' {Text
servicePrincipal :: Text
$sel:servicePrincipal:RegisterDelegatedAdministrator' :: RegisterDelegatedAdministrator -> Text
servicePrincipal} -> Text
servicePrincipal) (\s :: RegisterDelegatedAdministrator
s@RegisterDelegatedAdministrator' {} Text
a -> RegisterDelegatedAdministrator
s {$sel:servicePrincipal:RegisterDelegatedAdministrator' :: Text
servicePrincipal = Text
a} :: RegisterDelegatedAdministrator)

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

instance
  Prelude.Hashable
    RegisterDelegatedAdministrator

instance
  Prelude.NFData
    RegisterDelegatedAdministrator

instance
  Core.ToHeaders
    RegisterDelegatedAdministrator
  where
  toHeaders :: RegisterDelegatedAdministrator -> [Header]
toHeaders =
    [Header] -> RegisterDelegatedAdministrator -> [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
"AWSOrganizationsV20161128.RegisterDelegatedAdministrator" ::
                          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 RegisterDelegatedAdministrator where
  toJSON :: RegisterDelegatedAdministrator -> Value
toJSON RegisterDelegatedAdministrator' {Text
servicePrincipal :: Text
accountId :: Text
$sel:servicePrincipal:RegisterDelegatedAdministrator' :: RegisterDelegatedAdministrator -> Text
$sel:accountId:RegisterDelegatedAdministrator' :: RegisterDelegatedAdministrator -> 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
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ServicePrincipal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
servicePrincipal)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    RegisterDelegatedAdministratorResponse