{-# 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.Lambda.GetLayerVersion
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information about a version of an
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html Lambda layer>,
-- with a link to download the layer archive that\'s valid for 10 minutes.
module Amazonka.Lambda.GetLayerVersion
  ( -- * Creating a Request
    GetLayerVersion (..),
    newGetLayerVersion,

    -- * Request Lenses
    getLayerVersion_layerName,
    getLayerVersion_versionNumber,

    -- * Destructuring the Response
    GetLayerVersionResponse (..),
    newGetLayerVersionResponse,

    -- * Response Lenses
    getLayerVersionResponse_layerVersionArn,
    getLayerVersionResponse_content,
    getLayerVersionResponse_createdDate,
    getLayerVersionResponse_version,
    getLayerVersionResponse_licenseInfo,
    getLayerVersionResponse_compatibleArchitectures,
    getLayerVersionResponse_layerArn,
    getLayerVersionResponse_description,
    getLayerVersionResponse_compatibleRuntimes,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetLayerVersion' smart constructor.
data GetLayerVersion = GetLayerVersion'
  { -- | The name or Amazon Resource Name (ARN) of the layer.
    GetLayerVersion -> Text
layerName :: Prelude.Text,
    -- | The version number.
    GetLayerVersion -> Integer
versionNumber :: Prelude.Integer
  }
  deriving (GetLayerVersion -> GetLayerVersion -> Bool
(GetLayerVersion -> GetLayerVersion -> Bool)
-> (GetLayerVersion -> GetLayerVersion -> Bool)
-> Eq GetLayerVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLayerVersion -> GetLayerVersion -> Bool
$c/= :: GetLayerVersion -> GetLayerVersion -> Bool
== :: GetLayerVersion -> GetLayerVersion -> Bool
$c== :: GetLayerVersion -> GetLayerVersion -> Bool
Prelude.Eq, ReadPrec [GetLayerVersion]
ReadPrec GetLayerVersion
Int -> ReadS GetLayerVersion
ReadS [GetLayerVersion]
(Int -> ReadS GetLayerVersion)
-> ReadS [GetLayerVersion]
-> ReadPrec GetLayerVersion
-> ReadPrec [GetLayerVersion]
-> Read GetLayerVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLayerVersion]
$creadListPrec :: ReadPrec [GetLayerVersion]
readPrec :: ReadPrec GetLayerVersion
$creadPrec :: ReadPrec GetLayerVersion
readList :: ReadS [GetLayerVersion]
$creadList :: ReadS [GetLayerVersion]
readsPrec :: Int -> ReadS GetLayerVersion
$creadsPrec :: Int -> ReadS GetLayerVersion
Prelude.Read, Int -> GetLayerVersion -> ShowS
[GetLayerVersion] -> ShowS
GetLayerVersion -> String
(Int -> GetLayerVersion -> ShowS)
-> (GetLayerVersion -> String)
-> ([GetLayerVersion] -> ShowS)
-> Show GetLayerVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLayerVersion] -> ShowS
$cshowList :: [GetLayerVersion] -> ShowS
show :: GetLayerVersion -> String
$cshow :: GetLayerVersion -> String
showsPrec :: Int -> GetLayerVersion -> ShowS
$cshowsPrec :: Int -> GetLayerVersion -> ShowS
Prelude.Show, (forall x. GetLayerVersion -> Rep GetLayerVersion x)
-> (forall x. Rep GetLayerVersion x -> GetLayerVersion)
-> Generic GetLayerVersion
forall x. Rep GetLayerVersion x -> GetLayerVersion
forall x. GetLayerVersion -> Rep GetLayerVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLayerVersion x -> GetLayerVersion
$cfrom :: forall x. GetLayerVersion -> Rep GetLayerVersion x
Prelude.Generic)

-- |
-- Create a value of 'GetLayerVersion' 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:
--
-- 'layerName', 'getLayerVersion_layerName' - The name or Amazon Resource Name (ARN) of the layer.
--
-- 'versionNumber', 'getLayerVersion_versionNumber' - The version number.
newGetLayerVersion ::
  -- | 'layerName'
  Prelude.Text ->
  -- | 'versionNumber'
  Prelude.Integer ->
  GetLayerVersion
newGetLayerVersion :: Text -> Integer -> GetLayerVersion
newGetLayerVersion Text
pLayerName_ Integer
pVersionNumber_ =
  GetLayerVersion' :: Text -> Integer -> GetLayerVersion
GetLayerVersion'
    { $sel:layerName:GetLayerVersion' :: Text
layerName = Text
pLayerName_,
      $sel:versionNumber:GetLayerVersion' :: Integer
versionNumber = Integer
pVersionNumber_
    }

-- | The name or Amazon Resource Name (ARN) of the layer.
getLayerVersion_layerName :: Lens.Lens' GetLayerVersion Prelude.Text
getLayerVersion_layerName :: (Text -> f Text) -> GetLayerVersion -> f GetLayerVersion
getLayerVersion_layerName = (GetLayerVersion -> Text)
-> (GetLayerVersion -> Text -> GetLayerVersion)
-> Lens GetLayerVersion GetLayerVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLayerVersion' {Text
layerName :: Text
$sel:layerName:GetLayerVersion' :: GetLayerVersion -> Text
layerName} -> Text
layerName) (\s :: GetLayerVersion
s@GetLayerVersion' {} Text
a -> GetLayerVersion
s {$sel:layerName:GetLayerVersion' :: Text
layerName = Text
a} :: GetLayerVersion)

-- | The version number.
getLayerVersion_versionNumber :: Lens.Lens' GetLayerVersion Prelude.Integer
getLayerVersion_versionNumber :: (Integer -> f Integer) -> GetLayerVersion -> f GetLayerVersion
getLayerVersion_versionNumber = (GetLayerVersion -> Integer)
-> (GetLayerVersion -> Integer -> GetLayerVersion)
-> Lens GetLayerVersion GetLayerVersion Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLayerVersion' {Integer
versionNumber :: Integer
$sel:versionNumber:GetLayerVersion' :: GetLayerVersion -> Integer
versionNumber} -> Integer
versionNumber) (\s :: GetLayerVersion
s@GetLayerVersion' {} Integer
a -> GetLayerVersion
s {$sel:versionNumber:GetLayerVersion' :: Integer
versionNumber = Integer
a} :: GetLayerVersion)

instance Core.AWSRequest GetLayerVersion where
  type
    AWSResponse GetLayerVersion =
      GetLayerVersionResponse
  request :: GetLayerVersion -> Request GetLayerVersion
request = Service -> GetLayerVersion -> Request GetLayerVersion
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetLayerVersion
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLayerVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetLayerVersion))
-> Logger
-> Service
-> Proxy GetLayerVersion
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLayerVersion)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String GetLayerVersionResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetLayerVersion

instance Prelude.NFData GetLayerVersion

instance Core.ToHeaders GetLayerVersion where
  toHeaders :: GetLayerVersion -> ResponseHeaders
toHeaders = ResponseHeaders -> GetLayerVersion -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetLayerVersion where
  toPath :: GetLayerVersion -> ByteString
toPath GetLayerVersion' {Integer
Text
versionNumber :: Integer
layerName :: Text
$sel:versionNumber:GetLayerVersion' :: GetLayerVersion -> Integer
$sel:layerName:GetLayerVersion' :: GetLayerVersion -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2018-10-31/layers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
layerName,
        ByteString
"/versions/",
        Integer -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Integer
versionNumber
      ]

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