{-# 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.MacieV2.DeleteInvitations
-- 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)
--
-- Deletes Amazon Macie membership invitations that were received from
-- specific accounts.
module Amazonka.MacieV2.DeleteInvitations
  ( -- * Creating a Request
    DeleteInvitations (..),
    newDeleteInvitations,

    -- * Request Lenses
    deleteInvitations_accountIds,

    -- * Destructuring the Response
    DeleteInvitationsResponse (..),
    newDeleteInvitationsResponse,

    -- * Response Lenses
    deleteInvitationsResponse_unprocessedAccounts,
    deleteInvitationsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteInvitations' smart constructor.
data DeleteInvitations = DeleteInvitations'
  { -- | An array that lists Amazon Web Services account IDs, one for each
    -- account that sent an invitation to delete.
    DeleteInvitations -> [Text]
accountIds :: [Prelude.Text]
  }
  deriving (DeleteInvitations -> DeleteInvitations -> Bool
(DeleteInvitations -> DeleteInvitations -> Bool)
-> (DeleteInvitations -> DeleteInvitations -> Bool)
-> Eq DeleteInvitations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInvitations -> DeleteInvitations -> Bool
$c/= :: DeleteInvitations -> DeleteInvitations -> Bool
== :: DeleteInvitations -> DeleteInvitations -> Bool
$c== :: DeleteInvitations -> DeleteInvitations -> Bool
Prelude.Eq, ReadPrec [DeleteInvitations]
ReadPrec DeleteInvitations
Int -> ReadS DeleteInvitations
ReadS [DeleteInvitations]
(Int -> ReadS DeleteInvitations)
-> ReadS [DeleteInvitations]
-> ReadPrec DeleteInvitations
-> ReadPrec [DeleteInvitations]
-> Read DeleteInvitations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInvitations]
$creadListPrec :: ReadPrec [DeleteInvitations]
readPrec :: ReadPrec DeleteInvitations
$creadPrec :: ReadPrec DeleteInvitations
readList :: ReadS [DeleteInvitations]
$creadList :: ReadS [DeleteInvitations]
readsPrec :: Int -> ReadS DeleteInvitations
$creadsPrec :: Int -> ReadS DeleteInvitations
Prelude.Read, Int -> DeleteInvitations -> ShowS
[DeleteInvitations] -> ShowS
DeleteInvitations -> String
(Int -> DeleteInvitations -> ShowS)
-> (DeleteInvitations -> String)
-> ([DeleteInvitations] -> ShowS)
-> Show DeleteInvitations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInvitations] -> ShowS
$cshowList :: [DeleteInvitations] -> ShowS
show :: DeleteInvitations -> String
$cshow :: DeleteInvitations -> String
showsPrec :: Int -> DeleteInvitations -> ShowS
$cshowsPrec :: Int -> DeleteInvitations -> ShowS
Prelude.Show, (forall x. DeleteInvitations -> Rep DeleteInvitations x)
-> (forall x. Rep DeleteInvitations x -> DeleteInvitations)
-> Generic DeleteInvitations
forall x. Rep DeleteInvitations x -> DeleteInvitations
forall x. DeleteInvitations -> Rep DeleteInvitations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteInvitations x -> DeleteInvitations
$cfrom :: forall x. DeleteInvitations -> Rep DeleteInvitations x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInvitations' 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', 'deleteInvitations_accountIds' - An array that lists Amazon Web Services account IDs, one for each
-- account that sent an invitation to delete.
newDeleteInvitations ::
  DeleteInvitations
newDeleteInvitations :: DeleteInvitations
newDeleteInvitations =
  DeleteInvitations' :: [Text] -> DeleteInvitations
DeleteInvitations' {$sel:accountIds:DeleteInvitations' :: [Text]
accountIds = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | An array that lists Amazon Web Services account IDs, one for each
-- account that sent an invitation to delete.
deleteInvitations_accountIds :: Lens.Lens' DeleteInvitations [Prelude.Text]
deleteInvitations_accountIds :: ([Text] -> f [Text]) -> DeleteInvitations -> f DeleteInvitations
deleteInvitations_accountIds = (DeleteInvitations -> [Text])
-> (DeleteInvitations -> [Text] -> DeleteInvitations)
-> Lens DeleteInvitations DeleteInvitations [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInvitations' {[Text]
accountIds :: [Text]
$sel:accountIds:DeleteInvitations' :: DeleteInvitations -> [Text]
accountIds} -> [Text]
accountIds) (\s :: DeleteInvitations
s@DeleteInvitations' {} [Text]
a -> DeleteInvitations
s {$sel:accountIds:DeleteInvitations' :: [Text]
accountIds = [Text]
a} :: DeleteInvitations) (([Text] -> f [Text]) -> DeleteInvitations -> f DeleteInvitations)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeleteInvitations
-> f DeleteInvitations
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 DeleteInvitations where
  type
    AWSResponse DeleteInvitations =
      DeleteInvitationsResponse
  request :: DeleteInvitations -> Request DeleteInvitations
request = Service -> DeleteInvitations -> Request DeleteInvitations
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteInvitations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInvitations)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteInvitations))
-> Logger
-> Service
-> Proxy DeleteInvitations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInvitations)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [UnprocessedAccount] -> Int -> DeleteInvitationsResponse
DeleteInvitationsResponse'
            (Maybe [UnprocessedAccount] -> Int -> DeleteInvitationsResponse)
-> Either String (Maybe [UnprocessedAccount])
-> Either String (Int -> DeleteInvitationsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [UnprocessedAccount]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"unprocessedAccounts"
                            Either String (Maybe (Maybe [UnprocessedAccount]))
-> Maybe [UnprocessedAccount]
-> Either String (Maybe [UnprocessedAccount])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UnprocessedAccount]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> DeleteInvitationsResponse)
-> Either String Int -> Either String DeleteInvitationsResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteInvitations

instance Prelude.NFData DeleteInvitations

instance Core.ToHeaders DeleteInvitations where
  toHeaders :: DeleteInvitations -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteInvitations -> 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 DeleteInvitations where
  toJSON :: DeleteInvitations -> Value
toJSON DeleteInvitations' {[Text]
accountIds :: [Text]
$sel:accountIds:DeleteInvitations' :: DeleteInvitations -> [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 DeleteInvitations where
  toPath :: DeleteInvitations -> ByteString
toPath = ByteString -> DeleteInvitations -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/invitations/delete"

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

-- | /See:/ 'newDeleteInvitationsResponse' smart constructor.
data DeleteInvitationsResponse = DeleteInvitationsResponse'
  { -- | An array of objects, one for each account whose invitation hasn\'t been
    -- deleted. Each object identifies the account and explains why the request
    -- hasn\'t been processed for that account.
    DeleteInvitationsResponse -> Maybe [UnprocessedAccount]
unprocessedAccounts :: Prelude.Maybe [UnprocessedAccount],
    -- | The response's http status code.
    DeleteInvitationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool
(DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool)
-> (DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool)
-> Eq DeleteInvitationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool
$c/= :: DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool
== :: DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool
$c== :: DeleteInvitationsResponse -> DeleteInvitationsResponse -> Bool
Prelude.Eq, ReadPrec [DeleteInvitationsResponse]
ReadPrec DeleteInvitationsResponse
Int -> ReadS DeleteInvitationsResponse
ReadS [DeleteInvitationsResponse]
(Int -> ReadS DeleteInvitationsResponse)
-> ReadS [DeleteInvitationsResponse]
-> ReadPrec DeleteInvitationsResponse
-> ReadPrec [DeleteInvitationsResponse]
-> Read DeleteInvitationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInvitationsResponse]
$creadListPrec :: ReadPrec [DeleteInvitationsResponse]
readPrec :: ReadPrec DeleteInvitationsResponse
$creadPrec :: ReadPrec DeleteInvitationsResponse
readList :: ReadS [DeleteInvitationsResponse]
$creadList :: ReadS [DeleteInvitationsResponse]
readsPrec :: Int -> ReadS DeleteInvitationsResponse
$creadsPrec :: Int -> ReadS DeleteInvitationsResponse
Prelude.Read, Int -> DeleteInvitationsResponse -> ShowS
[DeleteInvitationsResponse] -> ShowS
DeleteInvitationsResponse -> String
(Int -> DeleteInvitationsResponse -> ShowS)
-> (DeleteInvitationsResponse -> String)
-> ([DeleteInvitationsResponse] -> ShowS)
-> Show DeleteInvitationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInvitationsResponse] -> ShowS
$cshowList :: [DeleteInvitationsResponse] -> ShowS
show :: DeleteInvitationsResponse -> String
$cshow :: DeleteInvitationsResponse -> String
showsPrec :: Int -> DeleteInvitationsResponse -> ShowS
$cshowsPrec :: Int -> DeleteInvitationsResponse -> ShowS
Prelude.Show, (forall x.
 DeleteInvitationsResponse -> Rep DeleteInvitationsResponse x)
-> (forall x.
    Rep DeleteInvitationsResponse x -> DeleteInvitationsResponse)
-> Generic DeleteInvitationsResponse
forall x.
Rep DeleteInvitationsResponse x -> DeleteInvitationsResponse
forall x.
DeleteInvitationsResponse -> Rep DeleteInvitationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteInvitationsResponse x -> DeleteInvitationsResponse
$cfrom :: forall x.
DeleteInvitationsResponse -> Rep DeleteInvitationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInvitationsResponse' 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:
--
-- 'unprocessedAccounts', 'deleteInvitationsResponse_unprocessedAccounts' - An array of objects, one for each account whose invitation hasn\'t been
-- deleted. Each object identifies the account and explains why the request
-- hasn\'t been processed for that account.
--
-- 'httpStatus', 'deleteInvitationsResponse_httpStatus' - The response's http status code.
newDeleteInvitationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteInvitationsResponse
newDeleteInvitationsResponse :: Int -> DeleteInvitationsResponse
newDeleteInvitationsResponse Int
pHttpStatus_ =
  DeleteInvitationsResponse' :: Maybe [UnprocessedAccount] -> Int -> DeleteInvitationsResponse
DeleteInvitationsResponse'
    { $sel:unprocessedAccounts:DeleteInvitationsResponse' :: Maybe [UnprocessedAccount]
unprocessedAccounts =
        Maybe [UnprocessedAccount]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteInvitationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects, one for each account whose invitation hasn\'t been
-- deleted. Each object identifies the account and explains why the request
-- hasn\'t been processed for that account.
deleteInvitationsResponse_unprocessedAccounts :: Lens.Lens' DeleteInvitationsResponse (Prelude.Maybe [UnprocessedAccount])
deleteInvitationsResponse_unprocessedAccounts :: (Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
-> DeleteInvitationsResponse -> f DeleteInvitationsResponse
deleteInvitationsResponse_unprocessedAccounts = (DeleteInvitationsResponse -> Maybe [UnprocessedAccount])
-> (DeleteInvitationsResponse
    -> Maybe [UnprocessedAccount] -> DeleteInvitationsResponse)
-> Lens
     DeleteInvitationsResponse
     DeleteInvitationsResponse
     (Maybe [UnprocessedAccount])
     (Maybe [UnprocessedAccount])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInvitationsResponse' {Maybe [UnprocessedAccount]
unprocessedAccounts :: Maybe [UnprocessedAccount]
$sel:unprocessedAccounts:DeleteInvitationsResponse' :: DeleteInvitationsResponse -> Maybe [UnprocessedAccount]
unprocessedAccounts} -> Maybe [UnprocessedAccount]
unprocessedAccounts) (\s :: DeleteInvitationsResponse
s@DeleteInvitationsResponse' {} Maybe [UnprocessedAccount]
a -> DeleteInvitationsResponse
s {$sel:unprocessedAccounts:DeleteInvitationsResponse' :: Maybe [UnprocessedAccount]
unprocessedAccounts = Maybe [UnprocessedAccount]
a} :: DeleteInvitationsResponse) ((Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
 -> DeleteInvitationsResponse -> f DeleteInvitationsResponse)
-> ((Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
    -> Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
-> (Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
-> DeleteInvitationsResponse
-> f DeleteInvitationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [UnprocessedAccount]
  [UnprocessedAccount]
  [UnprocessedAccount]
  [UnprocessedAccount]
-> Iso
     (Maybe [UnprocessedAccount])
     (Maybe [UnprocessedAccount])
     (Maybe [UnprocessedAccount])
     (Maybe [UnprocessedAccount])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [UnprocessedAccount]
  [UnprocessedAccount]
  [UnprocessedAccount]
  [UnprocessedAccount]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteInvitationsResponse