{-# 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.GamesParks.GetExtension
-- 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 details about a specified extension.
module Amazonka.GamesParks.GetExtension
  ( -- * Creating a Request
    GetExtension (..),
    newGetExtension,

    -- * Request Lenses
    getExtension_name,
    getExtension_namespace,

    -- * Destructuring the Response
    GetExtensionResponse (..),
    newGetExtensionResponse,

    -- * Response Lenses
    getExtensionResponse_extension,
    getExtensionResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'GetExtension' 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:
--
-- 'name', 'getExtension_name' - The name of the extension.
--
-- 'namespace', 'getExtension_namespace' - The namespace (qualifier) of the extension.
newGetExtension ::
  -- | 'name'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  GetExtension
newGetExtension :: Text -> Text -> GetExtension
newGetExtension Text
pName_ Text
pNamespace_ =
  GetExtension'
    { $sel:name:GetExtension' :: Text
name = Text
pName_,
      $sel:namespace:GetExtension' :: Text
namespace = Text
pNamespace_
    }

-- | The name of the extension.
getExtension_name :: Lens.Lens' GetExtension Prelude.Text
getExtension_name :: Lens' GetExtension Text
getExtension_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExtension' {Text
name :: Text
$sel:name:GetExtension' :: GetExtension -> Text
name} -> Text
name) (\s :: GetExtension
s@GetExtension' {} Text
a -> GetExtension
s {$sel:name:GetExtension' :: Text
name = Text
a} :: GetExtension)

-- | The namespace (qualifier) of the extension.
getExtension_namespace :: Lens.Lens' GetExtension Prelude.Text
getExtension_namespace :: Lens' GetExtension Text
getExtension_namespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExtension' {Text
namespace :: Text
$sel:namespace:GetExtension' :: GetExtension -> Text
namespace} -> Text
namespace) (\s :: GetExtension
s@GetExtension' {} Text
a -> GetExtension
s {$sel:namespace:GetExtension' :: Text
namespace = Text
a} :: GetExtension)

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

instance Prelude.NFData GetExtension where
  rnf :: GetExtension -> ()
rnf GetExtension' {Text
namespace :: Text
name :: Text
$sel:namespace:GetExtension' :: GetExtension -> Text
$sel:name:GetExtension' :: GetExtension -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
namespace

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

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

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

-- |
-- Create a value of 'GetExtensionResponse' 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:
--
-- 'extension', 'getExtensionResponse_extension' - Details about the extension.
--
-- 'httpStatus', 'getExtensionResponse_httpStatus' - The response's http status code.
newGetExtensionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetExtensionResponse
newGetExtensionResponse :: Int -> GetExtensionResponse
newGetExtensionResponse Int
pHttpStatus_ =
  GetExtensionResponse'
    { $sel:extension:GetExtensionResponse' :: Maybe ExtensionDetails
extension = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetExtensionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the extension.
getExtensionResponse_extension :: Lens.Lens' GetExtensionResponse (Prelude.Maybe ExtensionDetails)
getExtensionResponse_extension :: Lens' GetExtensionResponse (Maybe ExtensionDetails)
getExtensionResponse_extension = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExtensionResponse' {Maybe ExtensionDetails
extension :: Maybe ExtensionDetails
$sel:extension:GetExtensionResponse' :: GetExtensionResponse -> Maybe ExtensionDetails
extension} -> Maybe ExtensionDetails
extension) (\s :: GetExtensionResponse
s@GetExtensionResponse' {} Maybe ExtensionDetails
a -> GetExtensionResponse
s {$sel:extension:GetExtensionResponse' :: Maybe ExtensionDetails
extension = Maybe ExtensionDetails
a} :: GetExtensionResponse)

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

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