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

    -- * Request Lenses
    declineInvitations_accountIds,

    -- * Destructuring the Response
    DeclineInvitationsResponse (..),
    newDeclineInvitationsResponse,

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

-- |
-- Create a value of 'DeclineInvitations' 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', 'declineInvitations_accountIds' - An array that lists Amazon Web Services account IDs, one for each
-- account that sent an invitation to decline.
newDeclineInvitations ::
  DeclineInvitations
newDeclineInvitations :: DeclineInvitations
newDeclineInvitations =
  DeclineInvitations' :: [Text] -> DeclineInvitations
DeclineInvitations' {$sel:accountIds:DeclineInvitations' :: [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 decline.
declineInvitations_accountIds :: Lens.Lens' DeclineInvitations [Prelude.Text]
declineInvitations_accountIds :: ([Text] -> f [Text]) -> DeclineInvitations -> f DeclineInvitations
declineInvitations_accountIds = (DeclineInvitations -> [Text])
-> (DeclineInvitations -> [Text] -> DeclineInvitations)
-> Lens DeclineInvitations DeclineInvitations [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeclineInvitations' {[Text]
accountIds :: [Text]
$sel:accountIds:DeclineInvitations' :: DeclineInvitations -> [Text]
accountIds} -> [Text]
accountIds) (\s :: DeclineInvitations
s@DeclineInvitations' {} [Text]
a -> DeclineInvitations
s {$sel:accountIds:DeclineInvitations' :: [Text]
accountIds = [Text]
a} :: DeclineInvitations) (([Text] -> f [Text])
 -> DeclineInvitations -> f DeclineInvitations)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeclineInvitations
-> f DeclineInvitations
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 DeclineInvitations where
  type
    AWSResponse DeclineInvitations =
      DeclineInvitationsResponse
  request :: DeclineInvitations -> Request DeclineInvitations
request = Service -> DeclineInvitations -> Request DeclineInvitations
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeclineInvitations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeclineInvitations)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeclineInvitations))
-> Logger
-> Service
-> Proxy DeclineInvitations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeclineInvitations)))
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 -> DeclineInvitationsResponse
DeclineInvitationsResponse'
            (Maybe [UnprocessedAccount] -> Int -> DeclineInvitationsResponse)
-> Either String (Maybe [UnprocessedAccount])
-> Either String (Int -> DeclineInvitationsResponse)
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 -> DeclineInvitationsResponse)
-> Either String Int -> Either String DeclineInvitationsResponse
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 DeclineInvitations

instance Prelude.NFData DeclineInvitations

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

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

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

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

-- | An array of objects, one for each account whose invitation hasn\'t been
-- declined. Each object identifies the account and explains why the
-- request hasn\'t been processed for that account.
declineInvitationsResponse_unprocessedAccounts :: Lens.Lens' DeclineInvitationsResponse (Prelude.Maybe [UnprocessedAccount])
declineInvitationsResponse_unprocessedAccounts :: (Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
-> DeclineInvitationsResponse -> f DeclineInvitationsResponse
declineInvitationsResponse_unprocessedAccounts = (DeclineInvitationsResponse -> Maybe [UnprocessedAccount])
-> (DeclineInvitationsResponse
    -> Maybe [UnprocessedAccount] -> DeclineInvitationsResponse)
-> Lens
     DeclineInvitationsResponse
     DeclineInvitationsResponse
     (Maybe [UnprocessedAccount])
     (Maybe [UnprocessedAccount])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeclineInvitationsResponse' {Maybe [UnprocessedAccount]
unprocessedAccounts :: Maybe [UnprocessedAccount]
$sel:unprocessedAccounts:DeclineInvitationsResponse' :: DeclineInvitationsResponse -> Maybe [UnprocessedAccount]
unprocessedAccounts} -> Maybe [UnprocessedAccount]
unprocessedAccounts) (\s :: DeclineInvitationsResponse
s@DeclineInvitationsResponse' {} Maybe [UnprocessedAccount]
a -> DeclineInvitationsResponse
s {$sel:unprocessedAccounts:DeclineInvitationsResponse' :: Maybe [UnprocessedAccount]
unprocessedAccounts = Maybe [UnprocessedAccount]
a} :: DeclineInvitationsResponse) ((Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
 -> DeclineInvitationsResponse -> f DeclineInvitationsResponse)
-> ((Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
    -> Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
-> (Maybe [UnprocessedAccount] -> f (Maybe [UnprocessedAccount]))
-> DeclineInvitationsResponse
-> f DeclineInvitationsResponse
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.
declineInvitationsResponse_httpStatus :: Lens.Lens' DeclineInvitationsResponse Prelude.Int
declineInvitationsResponse_httpStatus :: (Int -> f Int)
-> DeclineInvitationsResponse -> f DeclineInvitationsResponse
declineInvitationsResponse_httpStatus = (DeclineInvitationsResponse -> Int)
-> (DeclineInvitationsResponse
    -> Int -> DeclineInvitationsResponse)
-> Lens
     DeclineInvitationsResponse DeclineInvitationsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeclineInvitationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeclineInvitationsResponse' :: DeclineInvitationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeclineInvitationsResponse
s@DeclineInvitationsResponse' {} Int
a -> DeclineInvitationsResponse
s {$sel:httpStatus:DeclineInvitationsResponse' :: Int
httpStatus = Int
a} :: DeclineInvitationsResponse)

instance Prelude.NFData DeclineInvitationsResponse