{-# 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.AcceptInvitation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Accepts an Amazon Macie membership invitation that was received from a
-- specific account.
module Amazonka.MacieV2.AcceptInvitation
  ( -- * Creating a Request
    AcceptInvitation (..),
    newAcceptInvitation,

    -- * Request Lenses
    acceptInvitation_administratorAccountId,
    acceptInvitation_masterAccount,
    acceptInvitation_invitationId,

    -- * Destructuring the Response
    AcceptInvitationResponse (..),
    newAcceptInvitationResponse,

    -- * Response Lenses
    acceptInvitationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newAcceptInvitation' smart constructor.
data AcceptInvitation = AcceptInvitation'
  { -- | The Amazon Web Services account ID for the account that sent the
    -- invitation.
    AcceptInvitation -> Maybe Text
administratorAccountId :: Prelude.Maybe Prelude.Text,
    -- | (Deprecated) The Amazon Web Services account ID for the account that
    -- sent the invitation. This property has been replaced by the
    -- administratorAccountId property and is retained only for backward
    -- compatibility.
    AcceptInvitation -> Maybe Text
masterAccount :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the invitation to accept.
    AcceptInvitation -> Text
invitationId :: Prelude.Text
  }
  deriving (AcceptInvitation -> AcceptInvitation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptInvitation -> AcceptInvitation -> Bool
$c/= :: AcceptInvitation -> AcceptInvitation -> Bool
== :: AcceptInvitation -> AcceptInvitation -> Bool
$c== :: AcceptInvitation -> AcceptInvitation -> Bool
Prelude.Eq, ReadPrec [AcceptInvitation]
ReadPrec AcceptInvitation
Int -> ReadS AcceptInvitation
ReadS [AcceptInvitation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptInvitation]
$creadListPrec :: ReadPrec [AcceptInvitation]
readPrec :: ReadPrec AcceptInvitation
$creadPrec :: ReadPrec AcceptInvitation
readList :: ReadS [AcceptInvitation]
$creadList :: ReadS [AcceptInvitation]
readsPrec :: Int -> ReadS AcceptInvitation
$creadsPrec :: Int -> ReadS AcceptInvitation
Prelude.Read, Int -> AcceptInvitation -> ShowS
[AcceptInvitation] -> ShowS
AcceptInvitation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptInvitation] -> ShowS
$cshowList :: [AcceptInvitation] -> ShowS
show :: AcceptInvitation -> String
$cshow :: AcceptInvitation -> String
showsPrec :: Int -> AcceptInvitation -> ShowS
$cshowsPrec :: Int -> AcceptInvitation -> ShowS
Prelude.Show, forall x. Rep AcceptInvitation x -> AcceptInvitation
forall x. AcceptInvitation -> Rep AcceptInvitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceptInvitation x -> AcceptInvitation
$cfrom :: forall x. AcceptInvitation -> Rep AcceptInvitation x
Prelude.Generic)

-- |
-- Create a value of 'AcceptInvitation' 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:
--
-- 'administratorAccountId', 'acceptInvitation_administratorAccountId' - The Amazon Web Services account ID for the account that sent the
-- invitation.
--
-- 'masterAccount', 'acceptInvitation_masterAccount' - (Deprecated) The Amazon Web Services account ID for the account that
-- sent the invitation. This property has been replaced by the
-- administratorAccountId property and is retained only for backward
-- compatibility.
--
-- 'invitationId', 'acceptInvitation_invitationId' - The unique identifier for the invitation to accept.
newAcceptInvitation ::
  -- | 'invitationId'
  Prelude.Text ->
  AcceptInvitation
newAcceptInvitation :: Text -> AcceptInvitation
newAcceptInvitation Text
pInvitationId_ =
  AcceptInvitation'
    { $sel:administratorAccountId:AcceptInvitation' :: Maybe Text
administratorAccountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:masterAccount:AcceptInvitation' :: Maybe Text
masterAccount = forall a. Maybe a
Prelude.Nothing,
      $sel:invitationId:AcceptInvitation' :: Text
invitationId = Text
pInvitationId_
    }

-- | The Amazon Web Services account ID for the account that sent the
-- invitation.
acceptInvitation_administratorAccountId :: Lens.Lens' AcceptInvitation (Prelude.Maybe Prelude.Text)
acceptInvitation_administratorAccountId :: Lens' AcceptInvitation (Maybe Text)
acceptInvitation_administratorAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptInvitation' {Maybe Text
administratorAccountId :: Maybe Text
$sel:administratorAccountId:AcceptInvitation' :: AcceptInvitation -> Maybe Text
administratorAccountId} -> Maybe Text
administratorAccountId) (\s :: AcceptInvitation
s@AcceptInvitation' {} Maybe Text
a -> AcceptInvitation
s {$sel:administratorAccountId:AcceptInvitation' :: Maybe Text
administratorAccountId = Maybe Text
a} :: AcceptInvitation)

-- | (Deprecated) The Amazon Web Services account ID for the account that
-- sent the invitation. This property has been replaced by the
-- administratorAccountId property and is retained only for backward
-- compatibility.
acceptInvitation_masterAccount :: Lens.Lens' AcceptInvitation (Prelude.Maybe Prelude.Text)
acceptInvitation_masterAccount :: Lens' AcceptInvitation (Maybe Text)
acceptInvitation_masterAccount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptInvitation' {Maybe Text
masterAccount :: Maybe Text
$sel:masterAccount:AcceptInvitation' :: AcceptInvitation -> Maybe Text
masterAccount} -> Maybe Text
masterAccount) (\s :: AcceptInvitation
s@AcceptInvitation' {} Maybe Text
a -> AcceptInvitation
s {$sel:masterAccount:AcceptInvitation' :: Maybe Text
masterAccount = Maybe Text
a} :: AcceptInvitation)

-- | The unique identifier for the invitation to accept.
acceptInvitation_invitationId :: Lens.Lens' AcceptInvitation Prelude.Text
acceptInvitation_invitationId :: Lens' AcceptInvitation Text
acceptInvitation_invitationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptInvitation' {Text
invitationId :: Text
$sel:invitationId:AcceptInvitation' :: AcceptInvitation -> Text
invitationId} -> Text
invitationId) (\s :: AcceptInvitation
s@AcceptInvitation' {} Text
a -> AcceptInvitation
s {$sel:invitationId:AcceptInvitation' :: Text
invitationId = Text
a} :: AcceptInvitation)

instance Core.AWSRequest AcceptInvitation where
  type
    AWSResponse AcceptInvitation =
      AcceptInvitationResponse
  request :: (Service -> Service)
-> AcceptInvitation -> Request AcceptInvitation
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 AcceptInvitation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptInvitation)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AcceptInvitationResponse
AcceptInvitationResponse'
            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))
      )

instance Prelude.Hashable AcceptInvitation where
  hashWithSalt :: Int -> AcceptInvitation -> Int
hashWithSalt Int
_salt AcceptInvitation' {Maybe Text
Text
invitationId :: Text
masterAccount :: Maybe Text
administratorAccountId :: Maybe Text
$sel:invitationId:AcceptInvitation' :: AcceptInvitation -> Text
$sel:masterAccount:AcceptInvitation' :: AcceptInvitation -> Maybe Text
$sel:administratorAccountId:AcceptInvitation' :: AcceptInvitation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
administratorAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
masterAccount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
invitationId

instance Prelude.NFData AcceptInvitation where
  rnf :: AcceptInvitation -> ()
rnf AcceptInvitation' {Maybe Text
Text
invitationId :: Text
masterAccount :: Maybe Text
administratorAccountId :: Maybe Text
$sel:invitationId:AcceptInvitation' :: AcceptInvitation -> Text
$sel:masterAccount:AcceptInvitation' :: AcceptInvitation -> Maybe Text
$sel:administratorAccountId:AcceptInvitation' :: AcceptInvitation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
administratorAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
masterAccount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
invitationId

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

instance Data.ToPath AcceptInvitation where
  toPath :: AcceptInvitation -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/invitations/accept"

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

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

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

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

instance Prelude.NFData AcceptInvitationResponse where
  rnf :: AcceptInvitationResponse -> ()
rnf AcceptInvitationResponse' {Int
httpStatus :: Int
$sel:httpStatus:AcceptInvitationResponse' :: AcceptInvitationResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus