{-# 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.Inspector2.GetMember
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets member information for your organization.
module Amazonka.Inspector2.GetMember
  ( -- * Creating a Request
    GetMember (..),
    newGetMember,

    -- * Request Lenses
    getMember_accountId,

    -- * Destructuring the Response
    GetMemberResponse (..),
    newGetMemberResponse,

    -- * Response Lenses
    getMemberResponse_member,
    getMemberResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetMember' smart constructor.
data GetMember = GetMember'
  { -- | The Amazon Web Services account ID of the member account to retrieve
    -- information on.
    GetMember -> Text
accountId :: Prelude.Text
  }
  deriving (GetMember -> GetMember -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMember -> GetMember -> Bool
$c/= :: GetMember -> GetMember -> Bool
== :: GetMember -> GetMember -> Bool
$c== :: GetMember -> GetMember -> Bool
Prelude.Eq, ReadPrec [GetMember]
ReadPrec GetMember
Int -> ReadS GetMember
ReadS [GetMember]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMember]
$creadListPrec :: ReadPrec [GetMember]
readPrec :: ReadPrec GetMember
$creadPrec :: ReadPrec GetMember
readList :: ReadS [GetMember]
$creadList :: ReadS [GetMember]
readsPrec :: Int -> ReadS GetMember
$creadsPrec :: Int -> ReadS GetMember
Prelude.Read, Int -> GetMember -> ShowS
[GetMember] -> ShowS
GetMember -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMember] -> ShowS
$cshowList :: [GetMember] -> ShowS
show :: GetMember -> String
$cshow :: GetMember -> String
showsPrec :: Int -> GetMember -> ShowS
$cshowsPrec :: Int -> GetMember -> ShowS
Prelude.Show, forall x. Rep GetMember x -> GetMember
forall x. GetMember -> Rep GetMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMember x -> GetMember
$cfrom :: forall x. GetMember -> Rep GetMember x
Prelude.Generic)

-- |
-- Create a value of 'GetMember' 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:
--
-- 'accountId', 'getMember_accountId' - The Amazon Web Services account ID of the member account to retrieve
-- information on.
newGetMember ::
  -- | 'accountId'
  Prelude.Text ->
  GetMember
newGetMember :: Text -> GetMember
newGetMember Text
pAccountId_ =
  GetMember' {$sel:accountId:GetMember' :: Text
accountId = Text
pAccountId_}

-- | The Amazon Web Services account ID of the member account to retrieve
-- information on.
getMember_accountId :: Lens.Lens' GetMember Prelude.Text
getMember_accountId :: Lens' GetMember Text
getMember_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMember' {Text
accountId :: Text
$sel:accountId:GetMember' :: GetMember -> Text
accountId} -> Text
accountId) (\s :: GetMember
s@GetMember' {} Text
a -> GetMember
s {$sel:accountId:GetMember' :: Text
accountId = Text
a} :: GetMember)

instance Core.AWSRequest GetMember where
  type AWSResponse GetMember = GetMemberResponse
  request :: (Service -> Service) -> GetMember -> Request GetMember
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 GetMember
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMember)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Member -> Int -> GetMemberResponse
GetMemberResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"member")
            forall (f :: * -> *) a b. Applicative f => 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 GetMember where
  hashWithSalt :: Int -> GetMember -> Int
hashWithSalt Int
_salt GetMember' {Text
accountId :: Text
$sel:accountId:GetMember' :: GetMember -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId

instance Prelude.NFData GetMember where
  rnf :: GetMember -> ()
rnf GetMember' {Text
accountId :: Text
$sel:accountId:GetMember' :: GetMember -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
accountId

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

instance Data.ToPath GetMember where
  toPath :: GetMember -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/members/get"

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

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

-- |
-- Create a value of 'GetMemberResponse' 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:
--
-- 'member', 'getMemberResponse_member' - Details of the retrieved member account.
--
-- 'httpStatus', 'getMemberResponse_httpStatus' - The response's http status code.
newGetMemberResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetMemberResponse
newGetMemberResponse :: Int -> GetMemberResponse
newGetMemberResponse Int
pHttpStatus_ =
  GetMemberResponse'
    { $sel:member:GetMemberResponse' :: Maybe Member
member = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetMemberResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details of the retrieved member account.
getMemberResponse_member :: Lens.Lens' GetMemberResponse (Prelude.Maybe Member)
getMemberResponse_member :: Lens' GetMemberResponse (Maybe Member)
getMemberResponse_member = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMemberResponse' {Maybe Member
member :: Maybe Member
$sel:member:GetMemberResponse' :: GetMemberResponse -> Maybe Member
member} -> Maybe Member
member) (\s :: GetMemberResponse
s@GetMemberResponse' {} Maybe Member
a -> GetMemberResponse
s {$sel:member:GetMemberResponse' :: Maybe Member
member = Maybe Member
a} :: GetMemberResponse)

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

instance Prelude.NFData GetMemberResponse where
  rnf :: GetMemberResponse -> ()
rnf GetMemberResponse' {Int
Maybe Member
httpStatus :: Int
member :: Maybe Member
$sel:httpStatus:GetMemberResponse' :: GetMemberResponse -> Int
$sel:member:GetMemberResponse' :: GetMemberResponse -> Maybe Member
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Member
member
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus