{-# 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.SecurityHub.DisassociateMembers
-- 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 specified member accounts from the associated
-- administrator account.
--
-- Can be used to disassociate both accounts that are managed using
-- Organizations and accounts that were invited manually.
module Amazonka.SecurityHub.DisassociateMembers
  ( -- * Creating a Request
    DisassociateMembers (..),
    newDisassociateMembers,

    -- * Request Lenses
    disassociateMembers_accountIds,

    -- * Destructuring the Response
    DisassociateMembersResponse (..),
    newDisassociateMembersResponse,

    -- * Response Lenses
    disassociateMembersResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DisassociateMembers' 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:
--
-- 'accountIds', 'disassociateMembers_accountIds' - The account IDs of the member accounts to disassociate from the
-- administrator account.
newDisassociateMembers ::
  DisassociateMembers
newDisassociateMembers :: DisassociateMembers
newDisassociateMembers =
  DisassociateMembers' :: [Text] -> DisassociateMembers
DisassociateMembers' {$sel:accountIds:DisassociateMembers' :: [Text]
accountIds = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The account IDs of the member accounts to disassociate from the
-- administrator account.
disassociateMembers_accountIds :: Lens.Lens' DisassociateMembers [Prelude.Text]
disassociateMembers_accountIds :: ([Text] -> f [Text])
-> DisassociateMembers -> f DisassociateMembers
disassociateMembers_accountIds = (DisassociateMembers -> [Text])
-> (DisassociateMembers -> [Text] -> DisassociateMembers)
-> Lens DisassociateMembers DisassociateMembers [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMembers' {[Text]
accountIds :: [Text]
$sel:accountIds:DisassociateMembers' :: DisassociateMembers -> [Text]
accountIds} -> [Text]
accountIds) (\s :: DisassociateMembers
s@DisassociateMembers' {} [Text]
a -> DisassociateMembers
s {$sel:accountIds:DisassociateMembers' :: [Text]
accountIds = [Text]
a} :: DisassociateMembers) (([Text] -> f [Text])
 -> DisassociateMembers -> f DisassociateMembers)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DisassociateMembers
-> f DisassociateMembers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DisassociateMembers

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

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

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

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

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

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

instance Prelude.NFData DisassociateMembersResponse