{-# 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.AcceptAdministratorInvitation
-- 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)
--
-- Accepts the invitation to be a member account and be monitored by the
-- Security Hub administrator account that the invitation was sent from.
--
-- This operation is only used by member accounts that are not added
-- through Organizations.
--
-- When the member account accepts the invitation, permission is granted to
-- the administrator account to view findings generated in the member
-- account.
module Amazonka.SecurityHub.AcceptAdministratorInvitation
  ( -- * Creating a Request
    AcceptAdministratorInvitation (..),
    newAcceptAdministratorInvitation,

    -- * Request Lenses
    acceptAdministratorInvitation_administratorId,
    acceptAdministratorInvitation_invitationId,

    -- * Destructuring the Response
    AcceptAdministratorInvitationResponse (..),
    newAcceptAdministratorInvitationResponse,

    -- * Response Lenses
    acceptAdministratorInvitationResponse_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:/ 'newAcceptAdministratorInvitation' smart constructor.
data AcceptAdministratorInvitation = AcceptAdministratorInvitation'
  { -- | The account ID of the Security Hub administrator account that sent the
    -- invitation.
    AcceptAdministratorInvitation -> Text
administratorId :: Prelude.Text,
    -- | The identifier of the invitation sent from the Security Hub
    -- administrator account.
    AcceptAdministratorInvitation -> Text
invitationId :: Prelude.Text
  }
  deriving (AcceptAdministratorInvitation
-> AcceptAdministratorInvitation -> Bool
(AcceptAdministratorInvitation
 -> AcceptAdministratorInvitation -> Bool)
-> (AcceptAdministratorInvitation
    -> AcceptAdministratorInvitation -> Bool)
-> Eq AcceptAdministratorInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptAdministratorInvitation
-> AcceptAdministratorInvitation -> Bool
$c/= :: AcceptAdministratorInvitation
-> AcceptAdministratorInvitation -> Bool
== :: AcceptAdministratorInvitation
-> AcceptAdministratorInvitation -> Bool
$c== :: AcceptAdministratorInvitation
-> AcceptAdministratorInvitation -> Bool
Prelude.Eq, ReadPrec [AcceptAdministratorInvitation]
ReadPrec AcceptAdministratorInvitation
Int -> ReadS AcceptAdministratorInvitation
ReadS [AcceptAdministratorInvitation]
(Int -> ReadS AcceptAdministratorInvitation)
-> ReadS [AcceptAdministratorInvitation]
-> ReadPrec AcceptAdministratorInvitation
-> ReadPrec [AcceptAdministratorInvitation]
-> Read AcceptAdministratorInvitation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptAdministratorInvitation]
$creadListPrec :: ReadPrec [AcceptAdministratorInvitation]
readPrec :: ReadPrec AcceptAdministratorInvitation
$creadPrec :: ReadPrec AcceptAdministratorInvitation
readList :: ReadS [AcceptAdministratorInvitation]
$creadList :: ReadS [AcceptAdministratorInvitation]
readsPrec :: Int -> ReadS AcceptAdministratorInvitation
$creadsPrec :: Int -> ReadS AcceptAdministratorInvitation
Prelude.Read, Int -> AcceptAdministratorInvitation -> ShowS
[AcceptAdministratorInvitation] -> ShowS
AcceptAdministratorInvitation -> String
(Int -> AcceptAdministratorInvitation -> ShowS)
-> (AcceptAdministratorInvitation -> String)
-> ([AcceptAdministratorInvitation] -> ShowS)
-> Show AcceptAdministratorInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptAdministratorInvitation] -> ShowS
$cshowList :: [AcceptAdministratorInvitation] -> ShowS
show :: AcceptAdministratorInvitation -> String
$cshow :: AcceptAdministratorInvitation -> String
showsPrec :: Int -> AcceptAdministratorInvitation -> ShowS
$cshowsPrec :: Int -> AcceptAdministratorInvitation -> ShowS
Prelude.Show, (forall x.
 AcceptAdministratorInvitation
 -> Rep AcceptAdministratorInvitation x)
-> (forall x.
    Rep AcceptAdministratorInvitation x
    -> AcceptAdministratorInvitation)
-> Generic AcceptAdministratorInvitation
forall x.
Rep AcceptAdministratorInvitation x
-> AcceptAdministratorInvitation
forall x.
AcceptAdministratorInvitation
-> Rep AcceptAdministratorInvitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AcceptAdministratorInvitation x
-> AcceptAdministratorInvitation
$cfrom :: forall x.
AcceptAdministratorInvitation
-> Rep AcceptAdministratorInvitation x
Prelude.Generic)

-- |
-- Create a value of 'AcceptAdministratorInvitation' 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:
--
-- 'administratorId', 'acceptAdministratorInvitation_administratorId' - The account ID of the Security Hub administrator account that sent the
-- invitation.
--
-- 'invitationId', 'acceptAdministratorInvitation_invitationId' - The identifier of the invitation sent from the Security Hub
-- administrator account.
newAcceptAdministratorInvitation ::
  -- | 'administratorId'
  Prelude.Text ->
  -- | 'invitationId'
  Prelude.Text ->
  AcceptAdministratorInvitation
newAcceptAdministratorInvitation :: Text -> Text -> AcceptAdministratorInvitation
newAcceptAdministratorInvitation
  Text
pAdministratorId_
  Text
pInvitationId_ =
    AcceptAdministratorInvitation' :: Text -> Text -> AcceptAdministratorInvitation
AcceptAdministratorInvitation'
      { $sel:administratorId:AcceptAdministratorInvitation' :: Text
administratorId =
          Text
pAdministratorId_,
        $sel:invitationId:AcceptAdministratorInvitation' :: Text
invitationId = Text
pInvitationId_
      }

-- | The account ID of the Security Hub administrator account that sent the
-- invitation.
acceptAdministratorInvitation_administratorId :: Lens.Lens' AcceptAdministratorInvitation Prelude.Text
acceptAdministratorInvitation_administratorId :: (Text -> f Text)
-> AcceptAdministratorInvitation -> f AcceptAdministratorInvitation
acceptAdministratorInvitation_administratorId = (AcceptAdministratorInvitation -> Text)
-> (AcceptAdministratorInvitation
    -> Text -> AcceptAdministratorInvitation)
-> Lens
     AcceptAdministratorInvitation
     AcceptAdministratorInvitation
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptAdministratorInvitation' {Text
administratorId :: Text
$sel:administratorId:AcceptAdministratorInvitation' :: AcceptAdministratorInvitation -> Text
administratorId} -> Text
administratorId) (\s :: AcceptAdministratorInvitation
s@AcceptAdministratorInvitation' {} Text
a -> AcceptAdministratorInvitation
s {$sel:administratorId:AcceptAdministratorInvitation' :: Text
administratorId = Text
a} :: AcceptAdministratorInvitation)

-- | The identifier of the invitation sent from the Security Hub
-- administrator account.
acceptAdministratorInvitation_invitationId :: Lens.Lens' AcceptAdministratorInvitation Prelude.Text
acceptAdministratorInvitation_invitationId :: (Text -> f Text)
-> AcceptAdministratorInvitation -> f AcceptAdministratorInvitation
acceptAdministratorInvitation_invitationId = (AcceptAdministratorInvitation -> Text)
-> (AcceptAdministratorInvitation
    -> Text -> AcceptAdministratorInvitation)
-> Lens
     AcceptAdministratorInvitation
     AcceptAdministratorInvitation
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptAdministratorInvitation' {Text
invitationId :: Text
$sel:invitationId:AcceptAdministratorInvitation' :: AcceptAdministratorInvitation -> Text
invitationId} -> Text
invitationId) (\s :: AcceptAdministratorInvitation
s@AcceptAdministratorInvitation' {} Text
a -> AcceptAdministratorInvitation
s {$sel:invitationId:AcceptAdministratorInvitation' :: Text
invitationId = Text
a} :: AcceptAdministratorInvitation)

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

instance Prelude.NFData AcceptAdministratorInvitation

instance Core.ToHeaders AcceptAdministratorInvitation where
  toHeaders :: AcceptAdministratorInvitation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AcceptAdministratorInvitation -> 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 AcceptAdministratorInvitation where
  toJSON :: AcceptAdministratorInvitation -> Value
toJSON AcceptAdministratorInvitation' {Text
invitationId :: Text
administratorId :: Text
$sel:invitationId:AcceptAdministratorInvitation' :: AcceptAdministratorInvitation -> Text
$sel:administratorId:AcceptAdministratorInvitation' :: AcceptAdministratorInvitation -> 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
"AdministratorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
administratorId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InvitationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
invitationId)
          ]
      )

instance Core.ToPath AcceptAdministratorInvitation where
  toPath :: AcceptAdministratorInvitation -> ByteString
toPath = ByteString -> AcceptAdministratorInvitation -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/administrator"

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

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

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

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

instance
  Prelude.NFData
    AcceptAdministratorInvitationResponse