{-# 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.GetTrustAnchor
-- 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 trust anchor.
--
-- __Required permissions:__ @rolesanywhere:GetTrustAnchor@.
module Amazonka.RolesAnywhere.GetTrustAnchor
  ( -- * Creating a Request
    GetTrustAnchor (..),
    newGetTrustAnchor,

    -- * Request Lenses
    getTrustAnchor_trustAnchorId,

    -- * Destructuring the Response
    TrustAnchorDetailResponse (..),
    newTrustAnchorDetailResponse,

    -- * Response Lenses
    trustAnchorDetailResponse_trustAnchor,
  )
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:/ 'newGetTrustAnchor' smart constructor.
data GetTrustAnchor = GetTrustAnchor'
  { -- | The unique identifier of the trust anchor.
    GetTrustAnchor -> Text
trustAnchorId :: Prelude.Text
  }
  deriving (GetTrustAnchor -> GetTrustAnchor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTrustAnchor -> GetTrustAnchor -> Bool
$c/= :: GetTrustAnchor -> GetTrustAnchor -> Bool
== :: GetTrustAnchor -> GetTrustAnchor -> Bool
$c== :: GetTrustAnchor -> GetTrustAnchor -> Bool
Prelude.Eq, ReadPrec [GetTrustAnchor]
ReadPrec GetTrustAnchor
Int -> ReadS GetTrustAnchor
ReadS [GetTrustAnchor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTrustAnchor]
$creadListPrec :: ReadPrec [GetTrustAnchor]
readPrec :: ReadPrec GetTrustAnchor
$creadPrec :: ReadPrec GetTrustAnchor
readList :: ReadS [GetTrustAnchor]
$creadList :: ReadS [GetTrustAnchor]
readsPrec :: Int -> ReadS GetTrustAnchor
$creadsPrec :: Int -> ReadS GetTrustAnchor
Prelude.Read, Int -> GetTrustAnchor -> ShowS
[GetTrustAnchor] -> ShowS
GetTrustAnchor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTrustAnchor] -> ShowS
$cshowList :: [GetTrustAnchor] -> ShowS
show :: GetTrustAnchor -> String
$cshow :: GetTrustAnchor -> String
showsPrec :: Int -> GetTrustAnchor -> ShowS
$cshowsPrec :: Int -> GetTrustAnchor -> ShowS
Prelude.Show, forall x. Rep GetTrustAnchor x -> GetTrustAnchor
forall x. GetTrustAnchor -> Rep GetTrustAnchor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTrustAnchor x -> GetTrustAnchor
$cfrom :: forall x. GetTrustAnchor -> Rep GetTrustAnchor x
Prelude.Generic)

-- |
-- Create a value of 'GetTrustAnchor' 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:
--
-- 'trustAnchorId', 'getTrustAnchor_trustAnchorId' - The unique identifier of the trust anchor.
newGetTrustAnchor ::
  -- | 'trustAnchorId'
  Prelude.Text ->
  GetTrustAnchor
newGetTrustAnchor :: Text -> GetTrustAnchor
newGetTrustAnchor Text
pTrustAnchorId_ =
  GetTrustAnchor' {$sel:trustAnchorId:GetTrustAnchor' :: Text
trustAnchorId = Text
pTrustAnchorId_}

-- | The unique identifier of the trust anchor.
getTrustAnchor_trustAnchorId :: Lens.Lens' GetTrustAnchor Prelude.Text
getTrustAnchor_trustAnchorId :: Lens' GetTrustAnchor Text
getTrustAnchor_trustAnchorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrustAnchor' {Text
trustAnchorId :: Text
$sel:trustAnchorId:GetTrustAnchor' :: GetTrustAnchor -> Text
trustAnchorId} -> Text
trustAnchorId) (\s :: GetTrustAnchor
s@GetTrustAnchor' {} Text
a -> GetTrustAnchor
s {$sel:trustAnchorId:GetTrustAnchor' :: Text
trustAnchorId = Text
a} :: GetTrustAnchor)

instance Core.AWSRequest GetTrustAnchor where
  type
    AWSResponse GetTrustAnchor =
      TrustAnchorDetailResponse
  request :: (Service -> Service) -> GetTrustAnchor -> Request GetTrustAnchor
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 GetTrustAnchor
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetTrustAnchor)))
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 GetTrustAnchor where
  hashWithSalt :: Int -> GetTrustAnchor -> Int
hashWithSalt Int
_salt GetTrustAnchor' {Text
trustAnchorId :: Text
$sel:trustAnchorId:GetTrustAnchor' :: GetTrustAnchor -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trustAnchorId

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

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

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