{-# 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.Detective.DisassociateMembership
-- 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)
--
-- Removes the member account from the specified behavior graph. This
-- operation can only be called by a member account that has the @ENABLED@
-- status.
module Amazonka.Detective.DisassociateMembership
  ( -- * Creating a Request
    DisassociateMembership (..),
    newDisassociateMembership,

    -- * Request Lenses
    disassociateMembership_graphArn,

    -- * Destructuring the Response
    DisassociateMembershipResponse (..),
    newDisassociateMembershipResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Detective.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:/ 'newDisassociateMembership' smart constructor.
data DisassociateMembership = DisassociateMembership'
  { -- | The ARN of the behavior graph to remove the member account from.
    --
    -- The member account\'s member status in the behavior graph must be
    -- @ENABLED@.
    DisassociateMembership -> Text
graphArn :: Prelude.Text
  }
  deriving (DisassociateMembership -> DisassociateMembership -> Bool
(DisassociateMembership -> DisassociateMembership -> Bool)
-> (DisassociateMembership -> DisassociateMembership -> Bool)
-> Eq DisassociateMembership
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateMembership -> DisassociateMembership -> Bool
$c/= :: DisassociateMembership -> DisassociateMembership -> Bool
== :: DisassociateMembership -> DisassociateMembership -> Bool
$c== :: DisassociateMembership -> DisassociateMembership -> Bool
Prelude.Eq, ReadPrec [DisassociateMembership]
ReadPrec DisassociateMembership
Int -> ReadS DisassociateMembership
ReadS [DisassociateMembership]
(Int -> ReadS DisassociateMembership)
-> ReadS [DisassociateMembership]
-> ReadPrec DisassociateMembership
-> ReadPrec [DisassociateMembership]
-> Read DisassociateMembership
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateMembership]
$creadListPrec :: ReadPrec [DisassociateMembership]
readPrec :: ReadPrec DisassociateMembership
$creadPrec :: ReadPrec DisassociateMembership
readList :: ReadS [DisassociateMembership]
$creadList :: ReadS [DisassociateMembership]
readsPrec :: Int -> ReadS DisassociateMembership
$creadsPrec :: Int -> ReadS DisassociateMembership
Prelude.Read, Int -> DisassociateMembership -> ShowS
[DisassociateMembership] -> ShowS
DisassociateMembership -> String
(Int -> DisassociateMembership -> ShowS)
-> (DisassociateMembership -> String)
-> ([DisassociateMembership] -> ShowS)
-> Show DisassociateMembership
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateMembership] -> ShowS
$cshowList :: [DisassociateMembership] -> ShowS
show :: DisassociateMembership -> String
$cshow :: DisassociateMembership -> String
showsPrec :: Int -> DisassociateMembership -> ShowS
$cshowsPrec :: Int -> DisassociateMembership -> ShowS
Prelude.Show, (forall x. DisassociateMembership -> Rep DisassociateMembership x)
-> (forall x.
    Rep DisassociateMembership x -> DisassociateMembership)
-> Generic DisassociateMembership
forall x. Rep DisassociateMembership x -> DisassociateMembership
forall x. DisassociateMembership -> Rep DisassociateMembership x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateMembership x -> DisassociateMembership
$cfrom :: forall x. DisassociateMembership -> Rep DisassociateMembership x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateMembership' 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:
--
-- 'graphArn', 'disassociateMembership_graphArn' - The ARN of the behavior graph to remove the member account from.
--
-- The member account\'s member status in the behavior graph must be
-- @ENABLED@.
newDisassociateMembership ::
  -- | 'graphArn'
  Prelude.Text ->
  DisassociateMembership
newDisassociateMembership :: Text -> DisassociateMembership
newDisassociateMembership Text
pGraphArn_ =
  DisassociateMembership' :: Text -> DisassociateMembership
DisassociateMembership' {$sel:graphArn:DisassociateMembership' :: Text
graphArn = Text
pGraphArn_}

-- | The ARN of the behavior graph to remove the member account from.
--
-- The member account\'s member status in the behavior graph must be
-- @ENABLED@.
disassociateMembership_graphArn :: Lens.Lens' DisassociateMembership Prelude.Text
disassociateMembership_graphArn :: (Text -> f Text)
-> DisassociateMembership -> f DisassociateMembership
disassociateMembership_graphArn = (DisassociateMembership -> Text)
-> (DisassociateMembership -> Text -> DisassociateMembership)
-> Lens DisassociateMembership DisassociateMembership Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMembership' {Text
graphArn :: Text
$sel:graphArn:DisassociateMembership' :: DisassociateMembership -> Text
graphArn} -> Text
graphArn) (\s :: DisassociateMembership
s@DisassociateMembership' {} Text
a -> DisassociateMembership
s {$sel:graphArn:DisassociateMembership' :: Text
graphArn = Text
a} :: DisassociateMembership)

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

instance Prelude.Hashable DisassociateMembership

instance Prelude.NFData DisassociateMembership

instance Core.ToHeaders DisassociateMembership where
  toHeaders :: DisassociateMembership -> [Header]
toHeaders =
    [Header] -> DisassociateMembership -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 DisassociateMembership where
  toJSON :: DisassociateMembership -> Value
toJSON DisassociateMembership' {Text
graphArn :: Text
$sel:graphArn:DisassociateMembership' :: DisassociateMembership -> 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
"GraphArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
graphArn)]
      )

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

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

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

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

instance
  Prelude.NFData
    DisassociateMembershipResponse