{-# 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.WorkSpacesWeb.GetTrustStoreCertificate
-- 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 the trust store certificate.
module Amazonka.WorkSpacesWeb.GetTrustStoreCertificate
  ( -- * Creating a Request
    GetTrustStoreCertificate (..),
    newGetTrustStoreCertificate,

    -- * Request Lenses
    getTrustStoreCertificate_thumbprint,
    getTrustStoreCertificate_trustStoreArn,

    -- * Destructuring the Response
    GetTrustStoreCertificateResponse (..),
    newGetTrustStoreCertificateResponse,

    -- * Response Lenses
    getTrustStoreCertificateResponse_certificate,
    getTrustStoreCertificateResponse_trustStoreArn,
    getTrustStoreCertificateResponse_httpStatus,
  )
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.WorkSpacesWeb.Types

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

-- |
-- Create a value of 'GetTrustStoreCertificate' 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:
--
-- 'thumbprint', 'getTrustStoreCertificate_thumbprint' - The thumbprint of the trust store certificate.
--
-- 'trustStoreArn', 'getTrustStoreCertificate_trustStoreArn' - The ARN of the trust store certificate.
newGetTrustStoreCertificate ::
  -- | 'thumbprint'
  Prelude.Text ->
  -- | 'trustStoreArn'
  Prelude.Text ->
  GetTrustStoreCertificate
newGetTrustStoreCertificate :: Text -> Text -> GetTrustStoreCertificate
newGetTrustStoreCertificate
  Text
pThumbprint_
  Text
pTrustStoreArn_ =
    GetTrustStoreCertificate'
      { $sel:thumbprint:GetTrustStoreCertificate' :: Text
thumbprint =
          Text
pThumbprint_,
        $sel:trustStoreArn:GetTrustStoreCertificate' :: Text
trustStoreArn = Text
pTrustStoreArn_
      }

-- | The thumbprint of the trust store certificate.
getTrustStoreCertificate_thumbprint :: Lens.Lens' GetTrustStoreCertificate Prelude.Text
getTrustStoreCertificate_thumbprint :: Lens' GetTrustStoreCertificate Text
getTrustStoreCertificate_thumbprint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrustStoreCertificate' {Text
thumbprint :: Text
$sel:thumbprint:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
thumbprint} -> Text
thumbprint) (\s :: GetTrustStoreCertificate
s@GetTrustStoreCertificate' {} Text
a -> GetTrustStoreCertificate
s {$sel:thumbprint:GetTrustStoreCertificate' :: Text
thumbprint = Text
a} :: GetTrustStoreCertificate)

-- | The ARN of the trust store certificate.
getTrustStoreCertificate_trustStoreArn :: Lens.Lens' GetTrustStoreCertificate Prelude.Text
getTrustStoreCertificate_trustStoreArn :: Lens' GetTrustStoreCertificate Text
getTrustStoreCertificate_trustStoreArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrustStoreCertificate' {Text
trustStoreArn :: Text
$sel:trustStoreArn:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
trustStoreArn} -> Text
trustStoreArn) (\s :: GetTrustStoreCertificate
s@GetTrustStoreCertificate' {} Text
a -> GetTrustStoreCertificate
s {$sel:trustStoreArn:GetTrustStoreCertificate' :: Text
trustStoreArn = Text
a} :: GetTrustStoreCertificate)

instance Core.AWSRequest GetTrustStoreCertificate where
  type
    AWSResponse GetTrustStoreCertificate =
      GetTrustStoreCertificateResponse
  request :: (Service -> Service)
-> GetTrustStoreCertificate -> Request GetTrustStoreCertificate
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 GetTrustStoreCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTrustStoreCertificate)))
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 Certificate
-> Maybe Text -> Int -> GetTrustStoreCertificateResponse
GetTrustStoreCertificateResponse'
            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
"certificate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"trustStoreArn")
            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 GetTrustStoreCertificate where
  hashWithSalt :: Int -> GetTrustStoreCertificate -> Int
hashWithSalt Int
_salt GetTrustStoreCertificate' {Text
trustStoreArn :: Text
thumbprint :: Text
$sel:trustStoreArn:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
$sel:thumbprint:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thumbprint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trustStoreArn

instance Prelude.NFData GetTrustStoreCertificate where
  rnf :: GetTrustStoreCertificate -> ()
rnf GetTrustStoreCertificate' {Text
trustStoreArn :: Text
thumbprint :: Text
$sel:trustStoreArn:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
$sel:thumbprint:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
thumbprint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trustStoreArn

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

instance Data.ToQuery GetTrustStoreCertificate where
  toQuery :: GetTrustStoreCertificate -> QueryString
toQuery GetTrustStoreCertificate' {Text
trustStoreArn :: Text
thumbprint :: Text
$sel:trustStoreArn:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
$sel:thumbprint:GetTrustStoreCertificate' :: GetTrustStoreCertificate -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"thumbprint" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
thumbprint]

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

-- |
-- Create a value of 'GetTrustStoreCertificateResponse' 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:
--
-- 'certificate', 'getTrustStoreCertificateResponse_certificate' - The certificate of the trust store certificate.
--
-- 'trustStoreArn', 'getTrustStoreCertificateResponse_trustStoreArn' - The ARN of the trust store certificate.
--
-- 'httpStatus', 'getTrustStoreCertificateResponse_httpStatus' - The response's http status code.
newGetTrustStoreCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTrustStoreCertificateResponse
newGetTrustStoreCertificateResponse :: Int -> GetTrustStoreCertificateResponse
newGetTrustStoreCertificateResponse Int
pHttpStatus_ =
  GetTrustStoreCertificateResponse'
    { $sel:certificate:GetTrustStoreCertificateResponse' :: Maybe Certificate
certificate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:trustStoreArn:GetTrustStoreCertificateResponse' :: Maybe Text
trustStoreArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTrustStoreCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The certificate of the trust store certificate.
getTrustStoreCertificateResponse_certificate :: Lens.Lens' GetTrustStoreCertificateResponse (Prelude.Maybe Certificate)
getTrustStoreCertificateResponse_certificate :: Lens' GetTrustStoreCertificateResponse (Maybe Certificate)
getTrustStoreCertificateResponse_certificate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrustStoreCertificateResponse' {Maybe Certificate
certificate :: Maybe Certificate
$sel:certificate:GetTrustStoreCertificateResponse' :: GetTrustStoreCertificateResponse -> Maybe Certificate
certificate} -> Maybe Certificate
certificate) (\s :: GetTrustStoreCertificateResponse
s@GetTrustStoreCertificateResponse' {} Maybe Certificate
a -> GetTrustStoreCertificateResponse
s {$sel:certificate:GetTrustStoreCertificateResponse' :: Maybe Certificate
certificate = Maybe Certificate
a} :: GetTrustStoreCertificateResponse)

-- | The ARN of the trust store certificate.
getTrustStoreCertificateResponse_trustStoreArn :: Lens.Lens' GetTrustStoreCertificateResponse (Prelude.Maybe Prelude.Text)
getTrustStoreCertificateResponse_trustStoreArn :: Lens' GetTrustStoreCertificateResponse (Maybe Text)
getTrustStoreCertificateResponse_trustStoreArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrustStoreCertificateResponse' {Maybe Text
trustStoreArn :: Maybe Text
$sel:trustStoreArn:GetTrustStoreCertificateResponse' :: GetTrustStoreCertificateResponse -> Maybe Text
trustStoreArn} -> Maybe Text
trustStoreArn) (\s :: GetTrustStoreCertificateResponse
s@GetTrustStoreCertificateResponse' {} Maybe Text
a -> GetTrustStoreCertificateResponse
s {$sel:trustStoreArn:GetTrustStoreCertificateResponse' :: Maybe Text
trustStoreArn = Maybe Text
a} :: GetTrustStoreCertificateResponse)

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

instance
  Prelude.NFData
    GetTrustStoreCertificateResponse
  where
  rnf :: GetTrustStoreCertificateResponse -> ()
rnf GetTrustStoreCertificateResponse' {Int
Maybe Text
Maybe Certificate
httpStatus :: Int
trustStoreArn :: Maybe Text
certificate :: Maybe Certificate
$sel:httpStatus:GetTrustStoreCertificateResponse' :: GetTrustStoreCertificateResponse -> Int
$sel:trustStoreArn:GetTrustStoreCertificateResponse' :: GetTrustStoreCertificateResponse -> Maybe Text
$sel:certificate:GetTrustStoreCertificateResponse' :: GetTrustStoreCertificateResponse -> Maybe Certificate
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Certificate
certificate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
trustStoreArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus