{-# 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.RolesAnywhere.GetProfile
-- 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 a profile.
--
-- __Required permissions:__ @rolesanywhere:GetProfile@.
module Amazonka.RolesAnywhere.GetProfile
  ( -- * Creating a Request
    GetProfile (..),
    newGetProfile,

    -- * Request Lenses
    getProfile_profileId,

    -- * Destructuring the Response
    ProfileDetailResponse (..),
    newProfileDetailResponse,

    -- * Response Lenses
    profileDetailResponse_profile,
  )
where

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

-- | /See:/ 'newGetProfile' smart constructor.
data GetProfile = GetProfile'
  { -- | The unique identifier of the profile.
    GetProfile -> Text
profileId :: Prelude.Text
  }
  deriving (GetProfile -> GetProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetProfile -> GetProfile -> Bool
$c/= :: GetProfile -> GetProfile -> Bool
== :: GetProfile -> GetProfile -> Bool
$c== :: GetProfile -> GetProfile -> Bool
Prelude.Eq, ReadPrec [GetProfile]
ReadPrec GetProfile
Int -> ReadS GetProfile
ReadS [GetProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetProfile]
$creadListPrec :: ReadPrec [GetProfile]
readPrec :: ReadPrec GetProfile
$creadPrec :: ReadPrec GetProfile
readList :: ReadS [GetProfile]
$creadList :: ReadS [GetProfile]
readsPrec :: Int -> ReadS GetProfile
$creadsPrec :: Int -> ReadS GetProfile
Prelude.Read, Int -> GetProfile -> ShowS
[GetProfile] -> ShowS
GetProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetProfile] -> ShowS
$cshowList :: [GetProfile] -> ShowS
show :: GetProfile -> String
$cshow :: GetProfile -> String
showsPrec :: Int -> GetProfile -> ShowS
$cshowsPrec :: Int -> GetProfile -> ShowS
Prelude.Show, forall x. Rep GetProfile x -> GetProfile
forall x. GetProfile -> Rep GetProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetProfile x -> GetProfile
$cfrom :: forall x. GetProfile -> Rep GetProfile x
Prelude.Generic)

-- |
-- Create a value of 'GetProfile' 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:
--
-- 'profileId', 'getProfile_profileId' - The unique identifier of the profile.
newGetProfile ::
  -- | 'profileId'
  Prelude.Text ->
  GetProfile
newGetProfile :: Text -> GetProfile
newGetProfile Text
pProfileId_ =
  GetProfile' {$sel:profileId:GetProfile' :: Text
profileId = Text
pProfileId_}

-- | The unique identifier of the profile.
getProfile_profileId :: Lens.Lens' GetProfile Prelude.Text
getProfile_profileId :: Lens' GetProfile Text
getProfile_profileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProfile' {Text
profileId :: Text
$sel:profileId:GetProfile' :: GetProfile -> Text
profileId} -> Text
profileId) (\s :: GetProfile
s@GetProfile' {} Text
a -> GetProfile
s {$sel:profileId:GetProfile' :: Text
profileId = Text
a} :: GetProfile)

instance Core.AWSRequest GetProfile where
  type AWSResponse GetProfile = ProfileDetailResponse
  request :: (Service -> Service) -> GetProfile -> Request GetProfile
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetProfile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetProfile)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GetProfile where
  hashWithSalt :: Int -> GetProfile -> Int
hashWithSalt Int
_salt GetProfile' {Text
profileId :: Text
$sel:profileId:GetProfile' :: GetProfile -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
profileId

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

instance Data.ToHeaders GetProfile where
  toHeaders :: GetProfile -> 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.ToPath GetProfile where
  toPath :: GetProfile -> ByteString
toPath GetProfile' {Text
profileId :: Text
$sel:profileId:GetProfile' :: GetProfile -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/profile/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
profileId]

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