{-# 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.Inspector2.DisassociateMember
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates a member account from an Amazon Inspector delegated
-- administrator.
module Amazonka.Inspector2.DisassociateMember
  ( -- * Creating a Request
    DisassociateMember (..),
    newDisassociateMember,

    -- * Request Lenses
    disassociateMember_accountId,

    -- * Destructuring the Response
    DisassociateMemberResponse (..),
    newDisassociateMemberResponse,

    -- * Response Lenses
    disassociateMemberResponse_httpStatus,
    disassociateMemberResponse_accountId,
  )
where

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

-- | /See:/ 'newDisassociateMember' smart constructor.
data DisassociateMember = DisassociateMember'
  { -- | The Amazon Web Services account ID of the member account to
    -- disassociate.
    DisassociateMember -> Text
accountId :: Prelude.Text
  }
  deriving (DisassociateMember -> DisassociateMember -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateMember -> DisassociateMember -> Bool
$c/= :: DisassociateMember -> DisassociateMember -> Bool
== :: DisassociateMember -> DisassociateMember -> Bool
$c== :: DisassociateMember -> DisassociateMember -> Bool
Prelude.Eq, ReadPrec [DisassociateMember]
ReadPrec DisassociateMember
Int -> ReadS DisassociateMember
ReadS [DisassociateMember]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateMember]
$creadListPrec :: ReadPrec [DisassociateMember]
readPrec :: ReadPrec DisassociateMember
$creadPrec :: ReadPrec DisassociateMember
readList :: ReadS [DisassociateMember]
$creadList :: ReadS [DisassociateMember]
readsPrec :: Int -> ReadS DisassociateMember
$creadsPrec :: Int -> ReadS DisassociateMember
Prelude.Read, Int -> DisassociateMember -> ShowS
[DisassociateMember] -> ShowS
DisassociateMember -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateMember] -> ShowS
$cshowList :: [DisassociateMember] -> ShowS
show :: DisassociateMember -> String
$cshow :: DisassociateMember -> String
showsPrec :: Int -> DisassociateMember -> ShowS
$cshowsPrec :: Int -> DisassociateMember -> ShowS
Prelude.Show, forall x. Rep DisassociateMember x -> DisassociateMember
forall x. DisassociateMember -> Rep DisassociateMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateMember x -> DisassociateMember
$cfrom :: forall x. DisassociateMember -> Rep DisassociateMember x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateMember' 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', 'disassociateMember_accountId' - The Amazon Web Services account ID of the member account to
-- disassociate.
newDisassociateMember ::
  -- | 'accountId'
  Prelude.Text ->
  DisassociateMember
newDisassociateMember :: Text -> DisassociateMember
newDisassociateMember Text
pAccountId_ =
  DisassociateMember' {$sel:accountId:DisassociateMember' :: Text
accountId = Text
pAccountId_}

-- | The Amazon Web Services account ID of the member account to
-- disassociate.
disassociateMember_accountId :: Lens.Lens' DisassociateMember Prelude.Text
disassociateMember_accountId :: Lens' DisassociateMember Text
disassociateMember_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMember' {Text
accountId :: Text
$sel:accountId:DisassociateMember' :: DisassociateMember -> Text
accountId} -> Text
accountId) (\s :: DisassociateMember
s@DisassociateMember' {} Text
a -> DisassociateMember
s {$sel:accountId:DisassociateMember' :: Text
accountId = Text
a} :: DisassociateMember)

instance Core.AWSRequest DisassociateMember where
  type
    AWSResponse DisassociateMember =
      DisassociateMemberResponse
  request :: (Service -> Service)
-> DisassociateMember -> Request DisassociateMember
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 DisassociateMember
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateMember)))
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 ->
          Int -> Text -> DisassociateMemberResponse
DisassociateMemberResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"accountId")
      )

instance Prelude.Hashable DisassociateMember where
  hashWithSalt :: Int -> DisassociateMember -> Int
hashWithSalt Int
_salt DisassociateMember' {Text
accountId :: Text
$sel:accountId:DisassociateMember' :: DisassociateMember -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId

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

instance Data.ToHeaders DisassociateMember where
  toHeaders :: DisassociateMember -> 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 DisassociateMember where
  toJSON :: DisassociateMember -> Value
toJSON DisassociateMember' {Text
accountId :: Text
$sel:accountId:DisassociateMember' :: DisassociateMember -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"accountId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
accountId)]
      )

instance Data.ToPath DisassociateMember where
  toPath :: DisassociateMember -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/members/disassociate"

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

-- | /See:/ 'newDisassociateMemberResponse' smart constructor.
data DisassociateMemberResponse = DisassociateMemberResponse'
  { -- | The response's http status code.
    DisassociateMemberResponse -> Int
httpStatus :: Prelude.Int,
    -- | The Amazon Web Services account ID of the successfully disassociated
    -- member.
    DisassociateMemberResponse -> Text
accountId :: Prelude.Text
  }
  deriving (DisassociateMemberResponse -> DisassociateMemberResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateMemberResponse -> DisassociateMemberResponse -> Bool
$c/= :: DisassociateMemberResponse -> DisassociateMemberResponse -> Bool
== :: DisassociateMemberResponse -> DisassociateMemberResponse -> Bool
$c== :: DisassociateMemberResponse -> DisassociateMemberResponse -> Bool
Prelude.Eq, ReadPrec [DisassociateMemberResponse]
ReadPrec DisassociateMemberResponse
Int -> ReadS DisassociateMemberResponse
ReadS [DisassociateMemberResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateMemberResponse]
$creadListPrec :: ReadPrec [DisassociateMemberResponse]
readPrec :: ReadPrec DisassociateMemberResponse
$creadPrec :: ReadPrec DisassociateMemberResponse
readList :: ReadS [DisassociateMemberResponse]
$creadList :: ReadS [DisassociateMemberResponse]
readsPrec :: Int -> ReadS DisassociateMemberResponse
$creadsPrec :: Int -> ReadS DisassociateMemberResponse
Prelude.Read, Int -> DisassociateMemberResponse -> ShowS
[DisassociateMemberResponse] -> ShowS
DisassociateMemberResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateMemberResponse] -> ShowS
$cshowList :: [DisassociateMemberResponse] -> ShowS
show :: DisassociateMemberResponse -> String
$cshow :: DisassociateMemberResponse -> String
showsPrec :: Int -> DisassociateMemberResponse -> ShowS
$cshowsPrec :: Int -> DisassociateMemberResponse -> ShowS
Prelude.Show, forall x.
Rep DisassociateMemberResponse x -> DisassociateMemberResponse
forall x.
DisassociateMemberResponse -> Rep DisassociateMemberResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateMemberResponse x -> DisassociateMemberResponse
$cfrom :: forall x.
DisassociateMemberResponse -> Rep DisassociateMemberResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateMemberResponse' 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', 'disassociateMemberResponse_httpStatus' - The response's http status code.
--
-- 'accountId', 'disassociateMemberResponse_accountId' - The Amazon Web Services account ID of the successfully disassociated
-- member.
newDisassociateMemberResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'accountId'
  Prelude.Text ->
  DisassociateMemberResponse
newDisassociateMemberResponse :: Int -> Text -> DisassociateMemberResponse
newDisassociateMemberResponse
  Int
pHttpStatus_
  Text
pAccountId_ =
    DisassociateMemberResponse'
      { $sel:httpStatus:DisassociateMemberResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:accountId:DisassociateMemberResponse' :: Text
accountId = Text
pAccountId_
      }

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

-- | The Amazon Web Services account ID of the successfully disassociated
-- member.
disassociateMemberResponse_accountId :: Lens.Lens' DisassociateMemberResponse Prelude.Text
disassociateMemberResponse_accountId :: Lens' DisassociateMemberResponse Text
disassociateMemberResponse_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMemberResponse' {Text
accountId :: Text
$sel:accountId:DisassociateMemberResponse' :: DisassociateMemberResponse -> Text
accountId} -> Text
accountId) (\s :: DisassociateMemberResponse
s@DisassociateMemberResponse' {} Text
a -> DisassociateMemberResponse
s {$sel:accountId:DisassociateMemberResponse' :: Text
accountId = Text
a} :: DisassociateMemberResponse)

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