{-# 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.IVS.GetPlaybackKeyPair
-- 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 specified playback authorization key pair and returns the @arn@
-- and @fingerprint@. The @privateKey@ held by the caller can be used to
-- generate viewer authorization tokens, to grant viewers access to private
-- channels. For more information, see
-- <https://docs.aws.amazon.com/ivs/latest/userguide/private-channels.html Setting Up Private Channels>
-- in the /Amazon IVS User Guide/.
module Amazonka.IVS.GetPlaybackKeyPair
  ( -- * Creating a Request
    GetPlaybackKeyPair (..),
    newGetPlaybackKeyPair,

    -- * Request Lenses
    getPlaybackKeyPair_arn,

    -- * Destructuring the Response
    GetPlaybackKeyPairResponse (..),
    newGetPlaybackKeyPairResponse,

    -- * Response Lenses
    getPlaybackKeyPairResponse_keyPair,
    getPlaybackKeyPairResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetPlaybackKeyPair' smart constructor.
data GetPlaybackKeyPair = GetPlaybackKeyPair'
  { -- | ARN of the key pair to be returned.
    GetPlaybackKeyPair -> Text
arn :: Prelude.Text
  }
  deriving (GetPlaybackKeyPair -> GetPlaybackKeyPair -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPlaybackKeyPair -> GetPlaybackKeyPair -> Bool
$c/= :: GetPlaybackKeyPair -> GetPlaybackKeyPair -> Bool
== :: GetPlaybackKeyPair -> GetPlaybackKeyPair -> Bool
$c== :: GetPlaybackKeyPair -> GetPlaybackKeyPair -> Bool
Prelude.Eq, ReadPrec [GetPlaybackKeyPair]
ReadPrec GetPlaybackKeyPair
Int -> ReadS GetPlaybackKeyPair
ReadS [GetPlaybackKeyPair]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPlaybackKeyPair]
$creadListPrec :: ReadPrec [GetPlaybackKeyPair]
readPrec :: ReadPrec GetPlaybackKeyPair
$creadPrec :: ReadPrec GetPlaybackKeyPair
readList :: ReadS [GetPlaybackKeyPair]
$creadList :: ReadS [GetPlaybackKeyPair]
readsPrec :: Int -> ReadS GetPlaybackKeyPair
$creadsPrec :: Int -> ReadS GetPlaybackKeyPair
Prelude.Read, Int -> GetPlaybackKeyPair -> ShowS
[GetPlaybackKeyPair] -> ShowS
GetPlaybackKeyPair -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPlaybackKeyPair] -> ShowS
$cshowList :: [GetPlaybackKeyPair] -> ShowS
show :: GetPlaybackKeyPair -> String
$cshow :: GetPlaybackKeyPair -> String
showsPrec :: Int -> GetPlaybackKeyPair -> ShowS
$cshowsPrec :: Int -> GetPlaybackKeyPair -> ShowS
Prelude.Show, forall x. Rep GetPlaybackKeyPair x -> GetPlaybackKeyPair
forall x. GetPlaybackKeyPair -> Rep GetPlaybackKeyPair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPlaybackKeyPair x -> GetPlaybackKeyPair
$cfrom :: forall x. GetPlaybackKeyPair -> Rep GetPlaybackKeyPair x
Prelude.Generic)

-- |
-- Create a value of 'GetPlaybackKeyPair' 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:
--
-- 'arn', 'getPlaybackKeyPair_arn' - ARN of the key pair to be returned.
newGetPlaybackKeyPair ::
  -- | 'arn'
  Prelude.Text ->
  GetPlaybackKeyPair
newGetPlaybackKeyPair :: Text -> GetPlaybackKeyPair
newGetPlaybackKeyPair Text
pArn_ =
  GetPlaybackKeyPair' {$sel:arn:GetPlaybackKeyPair' :: Text
arn = Text
pArn_}

-- | ARN of the key pair to be returned.
getPlaybackKeyPair_arn :: Lens.Lens' GetPlaybackKeyPair Prelude.Text
getPlaybackKeyPair_arn :: Lens' GetPlaybackKeyPair Text
getPlaybackKeyPair_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPlaybackKeyPair' {Text
arn :: Text
$sel:arn:GetPlaybackKeyPair' :: GetPlaybackKeyPair -> Text
arn} -> Text
arn) (\s :: GetPlaybackKeyPair
s@GetPlaybackKeyPair' {} Text
a -> GetPlaybackKeyPair
s {$sel:arn:GetPlaybackKeyPair' :: Text
arn = Text
a} :: GetPlaybackKeyPair)

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

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

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

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

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

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

-- |
-- Create a value of 'GetPlaybackKeyPairResponse' 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:
--
-- 'keyPair', 'getPlaybackKeyPairResponse_keyPair' -
--
-- 'httpStatus', 'getPlaybackKeyPairResponse_httpStatus' - The response's http status code.
newGetPlaybackKeyPairResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPlaybackKeyPairResponse
newGetPlaybackKeyPairResponse :: Int -> GetPlaybackKeyPairResponse
newGetPlaybackKeyPairResponse Int
pHttpStatus_ =
  GetPlaybackKeyPairResponse'
    { $sel:keyPair:GetPlaybackKeyPairResponse' :: Maybe PlaybackKeyPair
keyPair =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPlaybackKeyPairResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

getPlaybackKeyPairResponse_keyPair :: Lens.Lens' GetPlaybackKeyPairResponse (Prelude.Maybe PlaybackKeyPair)
getPlaybackKeyPairResponse_keyPair :: Lens' GetPlaybackKeyPairResponse (Maybe PlaybackKeyPair)
getPlaybackKeyPairResponse_keyPair = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPlaybackKeyPairResponse' {Maybe PlaybackKeyPair
keyPair :: Maybe PlaybackKeyPair
$sel:keyPair:GetPlaybackKeyPairResponse' :: GetPlaybackKeyPairResponse -> Maybe PlaybackKeyPair
keyPair} -> Maybe PlaybackKeyPair
keyPair) (\s :: GetPlaybackKeyPairResponse
s@GetPlaybackKeyPairResponse' {} Maybe PlaybackKeyPair
a -> GetPlaybackKeyPairResponse
s {$sel:keyPair:GetPlaybackKeyPairResponse' :: Maybe PlaybackKeyPair
keyPair = Maybe PlaybackKeyPair
a} :: GetPlaybackKeyPairResponse)

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

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