{-# 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.GuardDuty.DisableOrganizationAdminAccount
-- 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)
--
-- Disables an AWS account within the Organization as the GuardDuty
-- delegated administrator.
module Amazonka.GuardDuty.DisableOrganizationAdminAccount
  ( -- * Creating a Request
    DisableOrganizationAdminAccount (..),
    newDisableOrganizationAdminAccount,

    -- * Request Lenses
    disableOrganizationAdminAccount_adminAccountId,

    -- * Destructuring the Response
    DisableOrganizationAdminAccountResponse (..),
    newDisableOrganizationAdminAccountResponse,

    -- * Response Lenses
    disableOrganizationAdminAccountResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.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:/ 'newDisableOrganizationAdminAccount' smart constructor.
data DisableOrganizationAdminAccount = DisableOrganizationAdminAccount'
  { -- | The AWS Account ID for the organizations account to be disabled as a
    -- GuardDuty delegated administrator.
    DisableOrganizationAdminAccount -> Text
adminAccountId :: Prelude.Text
  }
  deriving (DisableOrganizationAdminAccount
-> DisableOrganizationAdminAccount -> Bool
(DisableOrganizationAdminAccount
 -> DisableOrganizationAdminAccount -> Bool)
-> (DisableOrganizationAdminAccount
    -> DisableOrganizationAdminAccount -> Bool)
-> Eq DisableOrganizationAdminAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableOrganizationAdminAccount
-> DisableOrganizationAdminAccount -> Bool
$c/= :: DisableOrganizationAdminAccount
-> DisableOrganizationAdminAccount -> Bool
== :: DisableOrganizationAdminAccount
-> DisableOrganizationAdminAccount -> Bool
$c== :: DisableOrganizationAdminAccount
-> DisableOrganizationAdminAccount -> Bool
Prelude.Eq, ReadPrec [DisableOrganizationAdminAccount]
ReadPrec DisableOrganizationAdminAccount
Int -> ReadS DisableOrganizationAdminAccount
ReadS [DisableOrganizationAdminAccount]
(Int -> ReadS DisableOrganizationAdminAccount)
-> ReadS [DisableOrganizationAdminAccount]
-> ReadPrec DisableOrganizationAdminAccount
-> ReadPrec [DisableOrganizationAdminAccount]
-> Read DisableOrganizationAdminAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableOrganizationAdminAccount]
$creadListPrec :: ReadPrec [DisableOrganizationAdminAccount]
readPrec :: ReadPrec DisableOrganizationAdminAccount
$creadPrec :: ReadPrec DisableOrganizationAdminAccount
readList :: ReadS [DisableOrganizationAdminAccount]
$creadList :: ReadS [DisableOrganizationAdminAccount]
readsPrec :: Int -> ReadS DisableOrganizationAdminAccount
$creadsPrec :: Int -> ReadS DisableOrganizationAdminAccount
Prelude.Read, Int -> DisableOrganizationAdminAccount -> ShowS
[DisableOrganizationAdminAccount] -> ShowS
DisableOrganizationAdminAccount -> String
(Int -> DisableOrganizationAdminAccount -> ShowS)
-> (DisableOrganizationAdminAccount -> String)
-> ([DisableOrganizationAdminAccount] -> ShowS)
-> Show DisableOrganizationAdminAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableOrganizationAdminAccount] -> ShowS
$cshowList :: [DisableOrganizationAdminAccount] -> ShowS
show :: DisableOrganizationAdminAccount -> String
$cshow :: DisableOrganizationAdminAccount -> String
showsPrec :: Int -> DisableOrganizationAdminAccount -> ShowS
$cshowsPrec :: Int -> DisableOrganizationAdminAccount -> ShowS
Prelude.Show, (forall x.
 DisableOrganizationAdminAccount
 -> Rep DisableOrganizationAdminAccount x)
-> (forall x.
    Rep DisableOrganizationAdminAccount x
    -> DisableOrganizationAdminAccount)
-> Generic DisableOrganizationAdminAccount
forall x.
Rep DisableOrganizationAdminAccount x
-> DisableOrganizationAdminAccount
forall x.
DisableOrganizationAdminAccount
-> Rep DisableOrganizationAdminAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableOrganizationAdminAccount x
-> DisableOrganizationAdminAccount
$cfrom :: forall x.
DisableOrganizationAdminAccount
-> Rep DisableOrganizationAdminAccount x
Prelude.Generic)

-- |
-- Create a value of 'DisableOrganizationAdminAccount' 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', 'disableOrganizationAdminAccount_adminAccountId' - The AWS Account ID for the organizations account to be disabled as a
-- GuardDuty delegated administrator.
newDisableOrganizationAdminAccount ::
  -- | 'adminAccountId'
  Prelude.Text ->
  DisableOrganizationAdminAccount
newDisableOrganizationAdminAccount :: Text -> DisableOrganizationAdminAccount
newDisableOrganizationAdminAccount Text
pAdminAccountId_ =
  DisableOrganizationAdminAccount' :: Text -> DisableOrganizationAdminAccount
DisableOrganizationAdminAccount'
    { $sel:adminAccountId:DisableOrganizationAdminAccount' :: Text
adminAccountId =
        Text
pAdminAccountId_
    }

-- | The AWS Account ID for the organizations account to be disabled as a
-- GuardDuty delegated administrator.
disableOrganizationAdminAccount_adminAccountId :: Lens.Lens' DisableOrganizationAdminAccount Prelude.Text
disableOrganizationAdminAccount_adminAccountId :: (Text -> f Text)
-> DisableOrganizationAdminAccount
-> f DisableOrganizationAdminAccount
disableOrganizationAdminAccount_adminAccountId = (DisableOrganizationAdminAccount -> Text)
-> (DisableOrganizationAdminAccount
    -> Text -> DisableOrganizationAdminAccount)
-> Lens
     DisableOrganizationAdminAccount
     DisableOrganizationAdminAccount
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableOrganizationAdminAccount' {Text
adminAccountId :: Text
$sel:adminAccountId:DisableOrganizationAdminAccount' :: DisableOrganizationAdminAccount -> Text
adminAccountId} -> Text
adminAccountId) (\s :: DisableOrganizationAdminAccount
s@DisableOrganizationAdminAccount' {} Text
a -> DisableOrganizationAdminAccount
s {$sel:adminAccountId:DisableOrganizationAdminAccount' :: Text
adminAccountId = Text
a} :: DisableOrganizationAdminAccount)

instance
  Core.AWSRequest
    DisableOrganizationAdminAccount
  where
  type
    AWSResponse DisableOrganizationAdminAccount =
      DisableOrganizationAdminAccountResponse
  request :: DisableOrganizationAdminAccount
-> Request DisableOrganizationAdminAccount
request = Service
-> DisableOrganizationAdminAccount
-> Request DisableOrganizationAdminAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DisableOrganizationAdminAccount)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DisableOrganizationAdminAccount))
-> Logger
-> Service
-> Proxy DisableOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DisableOrganizationAdminAccount)))
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 -> DisableOrganizationAdminAccountResponse
DisableOrganizationAdminAccountResponse'
            (Int -> DisableOrganizationAdminAccountResponse)
-> Either String Int
-> Either String DisableOrganizationAdminAccountResponse
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
    DisableOrganizationAdminAccount

instance
  Prelude.NFData
    DisableOrganizationAdminAccount

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

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

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

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

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

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

instance
  Prelude.NFData
    DisableOrganizationAdminAccountResponse