{-# 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.DisassociateFromMasterAccount
-- 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)
--
-- Disassociates the current GuardDuty member account from its
-- administrator account.
module Amazonka.GuardDuty.DisassociateFromMasterAccount
  ( -- * Creating a Request
    DisassociateFromMasterAccount (..),
    newDisassociateFromMasterAccount,

    -- * Request Lenses
    disassociateFromMasterAccount_detectorId,

    -- * Destructuring the Response
    DisassociateFromMasterAccountResponse (..),
    newDisassociateFromMasterAccountResponse,

    -- * Response Lenses
    disassociateFromMasterAccountResponse_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:/ 'newDisassociateFromMasterAccount' smart constructor.
data DisassociateFromMasterAccount = DisassociateFromMasterAccount'
  { -- | The unique ID of the detector of the GuardDuty member account.
    DisassociateFromMasterAccount -> Text
detectorId :: Prelude.Text
  }
  deriving (DisassociateFromMasterAccount
-> DisassociateFromMasterAccount -> Bool
(DisassociateFromMasterAccount
 -> DisassociateFromMasterAccount -> Bool)
-> (DisassociateFromMasterAccount
    -> DisassociateFromMasterAccount -> Bool)
-> Eq DisassociateFromMasterAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateFromMasterAccount
-> DisassociateFromMasterAccount -> Bool
$c/= :: DisassociateFromMasterAccount
-> DisassociateFromMasterAccount -> Bool
== :: DisassociateFromMasterAccount
-> DisassociateFromMasterAccount -> Bool
$c== :: DisassociateFromMasterAccount
-> DisassociateFromMasterAccount -> Bool
Prelude.Eq, ReadPrec [DisassociateFromMasterAccount]
ReadPrec DisassociateFromMasterAccount
Int -> ReadS DisassociateFromMasterAccount
ReadS [DisassociateFromMasterAccount]
(Int -> ReadS DisassociateFromMasterAccount)
-> ReadS [DisassociateFromMasterAccount]
-> ReadPrec DisassociateFromMasterAccount
-> ReadPrec [DisassociateFromMasterAccount]
-> Read DisassociateFromMasterAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateFromMasterAccount]
$creadListPrec :: ReadPrec [DisassociateFromMasterAccount]
readPrec :: ReadPrec DisassociateFromMasterAccount
$creadPrec :: ReadPrec DisassociateFromMasterAccount
readList :: ReadS [DisassociateFromMasterAccount]
$creadList :: ReadS [DisassociateFromMasterAccount]
readsPrec :: Int -> ReadS DisassociateFromMasterAccount
$creadsPrec :: Int -> ReadS DisassociateFromMasterAccount
Prelude.Read, Int -> DisassociateFromMasterAccount -> ShowS
[DisassociateFromMasterAccount] -> ShowS
DisassociateFromMasterAccount -> String
(Int -> DisassociateFromMasterAccount -> ShowS)
-> (DisassociateFromMasterAccount -> String)
-> ([DisassociateFromMasterAccount] -> ShowS)
-> Show DisassociateFromMasterAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateFromMasterAccount] -> ShowS
$cshowList :: [DisassociateFromMasterAccount] -> ShowS
show :: DisassociateFromMasterAccount -> String
$cshow :: DisassociateFromMasterAccount -> String
showsPrec :: Int -> DisassociateFromMasterAccount -> ShowS
$cshowsPrec :: Int -> DisassociateFromMasterAccount -> ShowS
Prelude.Show, (forall x.
 DisassociateFromMasterAccount
 -> Rep DisassociateFromMasterAccount x)
-> (forall x.
    Rep DisassociateFromMasterAccount x
    -> DisassociateFromMasterAccount)
-> Generic DisassociateFromMasterAccount
forall x.
Rep DisassociateFromMasterAccount x
-> DisassociateFromMasterAccount
forall x.
DisassociateFromMasterAccount
-> Rep DisassociateFromMasterAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateFromMasterAccount x
-> DisassociateFromMasterAccount
$cfrom :: forall x.
DisassociateFromMasterAccount
-> Rep DisassociateFromMasterAccount x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateFromMasterAccount' 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:
--
-- 'detectorId', 'disassociateFromMasterAccount_detectorId' - The unique ID of the detector of the GuardDuty member account.
newDisassociateFromMasterAccount ::
  -- | 'detectorId'
  Prelude.Text ->
  DisassociateFromMasterAccount
newDisassociateFromMasterAccount :: Text -> DisassociateFromMasterAccount
newDisassociateFromMasterAccount Text
pDetectorId_ =
  DisassociateFromMasterAccount' :: Text -> DisassociateFromMasterAccount
DisassociateFromMasterAccount'
    { $sel:detectorId:DisassociateFromMasterAccount' :: Text
detectorId =
        Text
pDetectorId_
    }

-- | The unique ID of the detector of the GuardDuty member account.
disassociateFromMasterAccount_detectorId :: Lens.Lens' DisassociateFromMasterAccount Prelude.Text
disassociateFromMasterAccount_detectorId :: (Text -> f Text)
-> DisassociateFromMasterAccount -> f DisassociateFromMasterAccount
disassociateFromMasterAccount_detectorId = (DisassociateFromMasterAccount -> Text)
-> (DisassociateFromMasterAccount
    -> Text -> DisassociateFromMasterAccount)
-> Lens
     DisassociateFromMasterAccount
     DisassociateFromMasterAccount
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateFromMasterAccount' {Text
detectorId :: Text
$sel:detectorId:DisassociateFromMasterAccount' :: DisassociateFromMasterAccount -> Text
detectorId} -> Text
detectorId) (\s :: DisassociateFromMasterAccount
s@DisassociateFromMasterAccount' {} Text
a -> DisassociateFromMasterAccount
s {$sel:detectorId:DisassociateFromMasterAccount' :: Text
detectorId = Text
a} :: DisassociateFromMasterAccount)

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

instance Prelude.NFData DisassociateFromMasterAccount

instance Core.ToHeaders DisassociateFromMasterAccount where
  toHeaders :: DisassociateFromMasterAccount -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateFromMasterAccount -> 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 DisassociateFromMasterAccount where
  toJSON :: DisassociateFromMasterAccount -> Value
toJSON = Value -> DisassociateFromMasterAccount -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath DisassociateFromMasterAccount where
  toPath :: DisassociateFromMasterAccount -> ByteString
toPath DisassociateFromMasterAccount' {Text
detectorId :: Text
$sel:detectorId:DisassociateFromMasterAccount' :: DisassociateFromMasterAccount -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/detector/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
detectorId,
        ByteString
"/master/disassociate"
      ]

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

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

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

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

instance
  Prelude.NFData
    DisassociateFromMasterAccountResponse