{-# 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.ImageBuilder.GetContainerRecipe
-- 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)
--
-- Retrieves a container recipe.
module Amazonka.ImageBuilder.GetContainerRecipe
  ( -- * Creating a Request
    GetContainerRecipe (..),
    newGetContainerRecipe,

    -- * Request Lenses
    getContainerRecipe_containerRecipeArn,

    -- * Destructuring the Response
    GetContainerRecipeResponse (..),
    newGetContainerRecipeResponse,

    -- * Response Lenses
    getContainerRecipeResponse_requestId,
    getContainerRecipeResponse_containerRecipe,
    getContainerRecipeResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ImageBuilder.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:/ 'newGetContainerRecipe' smart constructor.
data GetContainerRecipe = GetContainerRecipe'
  { -- | The Amazon Resource Name (ARN) of the container recipe to retrieve.
    GetContainerRecipe -> Text
containerRecipeArn :: Prelude.Text
  }
  deriving (GetContainerRecipe -> GetContainerRecipe -> Bool
(GetContainerRecipe -> GetContainerRecipe -> Bool)
-> (GetContainerRecipe -> GetContainerRecipe -> Bool)
-> Eq GetContainerRecipe
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerRecipe -> GetContainerRecipe -> Bool
$c/= :: GetContainerRecipe -> GetContainerRecipe -> Bool
== :: GetContainerRecipe -> GetContainerRecipe -> Bool
$c== :: GetContainerRecipe -> GetContainerRecipe -> Bool
Prelude.Eq, ReadPrec [GetContainerRecipe]
ReadPrec GetContainerRecipe
Int -> ReadS GetContainerRecipe
ReadS [GetContainerRecipe]
(Int -> ReadS GetContainerRecipe)
-> ReadS [GetContainerRecipe]
-> ReadPrec GetContainerRecipe
-> ReadPrec [GetContainerRecipe]
-> Read GetContainerRecipe
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerRecipe]
$creadListPrec :: ReadPrec [GetContainerRecipe]
readPrec :: ReadPrec GetContainerRecipe
$creadPrec :: ReadPrec GetContainerRecipe
readList :: ReadS [GetContainerRecipe]
$creadList :: ReadS [GetContainerRecipe]
readsPrec :: Int -> ReadS GetContainerRecipe
$creadsPrec :: Int -> ReadS GetContainerRecipe
Prelude.Read, Int -> GetContainerRecipe -> ShowS
[GetContainerRecipe] -> ShowS
GetContainerRecipe -> String
(Int -> GetContainerRecipe -> ShowS)
-> (GetContainerRecipe -> String)
-> ([GetContainerRecipe] -> ShowS)
-> Show GetContainerRecipe
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerRecipe] -> ShowS
$cshowList :: [GetContainerRecipe] -> ShowS
show :: GetContainerRecipe -> String
$cshow :: GetContainerRecipe -> String
showsPrec :: Int -> GetContainerRecipe -> ShowS
$cshowsPrec :: Int -> GetContainerRecipe -> ShowS
Prelude.Show, (forall x. GetContainerRecipe -> Rep GetContainerRecipe x)
-> (forall x. Rep GetContainerRecipe x -> GetContainerRecipe)
-> Generic GetContainerRecipe
forall x. Rep GetContainerRecipe x -> GetContainerRecipe
forall x. GetContainerRecipe -> Rep GetContainerRecipe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContainerRecipe x -> GetContainerRecipe
$cfrom :: forall x. GetContainerRecipe -> Rep GetContainerRecipe x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerRecipe' 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:
--
-- 'containerRecipeArn', 'getContainerRecipe_containerRecipeArn' - The Amazon Resource Name (ARN) of the container recipe to retrieve.
newGetContainerRecipe ::
  -- | 'containerRecipeArn'
  Prelude.Text ->
  GetContainerRecipe
newGetContainerRecipe :: Text -> GetContainerRecipe
newGetContainerRecipe Text
pContainerRecipeArn_ =
  GetContainerRecipe' :: Text -> GetContainerRecipe
GetContainerRecipe'
    { $sel:containerRecipeArn:GetContainerRecipe' :: Text
containerRecipeArn =
        Text
pContainerRecipeArn_
    }

-- | The Amazon Resource Name (ARN) of the container recipe to retrieve.
getContainerRecipe_containerRecipeArn :: Lens.Lens' GetContainerRecipe Prelude.Text
getContainerRecipe_containerRecipeArn :: (Text -> f Text) -> GetContainerRecipe -> f GetContainerRecipe
getContainerRecipe_containerRecipeArn = (GetContainerRecipe -> Text)
-> (GetContainerRecipe -> Text -> GetContainerRecipe)
-> Lens GetContainerRecipe GetContainerRecipe Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerRecipe' {Text
containerRecipeArn :: Text
$sel:containerRecipeArn:GetContainerRecipe' :: GetContainerRecipe -> Text
containerRecipeArn} -> Text
containerRecipeArn) (\s :: GetContainerRecipe
s@GetContainerRecipe' {} Text
a -> GetContainerRecipe
s {$sel:containerRecipeArn:GetContainerRecipe' :: Text
containerRecipeArn = Text
a} :: GetContainerRecipe)

instance Core.AWSRequest GetContainerRecipe where
  type
    AWSResponse GetContainerRecipe =
      GetContainerRecipeResponse
  request :: GetContainerRecipe -> Request GetContainerRecipe
request = Service -> GetContainerRecipe -> Request GetContainerRecipe
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetContainerRecipe
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContainerRecipe)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetContainerRecipe))
-> Logger
-> Service
-> Proxy GetContainerRecipe
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContainerRecipe)))
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 ->
          Maybe Text
-> Maybe ContainerRecipe -> Int -> GetContainerRecipeResponse
GetContainerRecipeResponse'
            (Maybe Text
 -> Maybe ContainerRecipe -> Int -> GetContainerRecipeResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe ContainerRecipe -> Int -> GetContainerRecipeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"requestId")
            Either
  String (Maybe ContainerRecipe -> Int -> GetContainerRecipeResponse)
-> Either String (Maybe ContainerRecipe)
-> Either String (Int -> GetContainerRecipeResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ContainerRecipe)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"containerRecipe")
            Either String (Int -> GetContainerRecipeResponse)
-> Either String Int -> Either String GetContainerRecipeResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetContainerRecipe

instance Prelude.NFData GetContainerRecipe

instance Core.ToHeaders GetContainerRecipe where
  toHeaders :: GetContainerRecipe -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetContainerRecipe -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Core.ToQuery GetContainerRecipe where
  toQuery :: GetContainerRecipe -> QueryString
toQuery GetContainerRecipe' {Text
containerRecipeArn :: Text
$sel:containerRecipeArn:GetContainerRecipe' :: GetContainerRecipe -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"containerRecipeArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
containerRecipeArn]

-- | /See:/ 'newGetContainerRecipeResponse' smart constructor.
data GetContainerRecipeResponse = GetContainerRecipeResponse'
  { -- | The request ID that uniquely identifies this request.
    GetContainerRecipeResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The container recipe object that is returned.
    GetContainerRecipeResponse -> Maybe ContainerRecipe
containerRecipe :: Prelude.Maybe ContainerRecipe,
    -- | The response's http status code.
    GetContainerRecipeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetContainerRecipeResponse -> GetContainerRecipeResponse -> Bool
(GetContainerRecipeResponse -> GetContainerRecipeResponse -> Bool)
-> (GetContainerRecipeResponse
    -> GetContainerRecipeResponse -> Bool)
-> Eq GetContainerRecipeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerRecipeResponse -> GetContainerRecipeResponse -> Bool
$c/= :: GetContainerRecipeResponse -> GetContainerRecipeResponse -> Bool
== :: GetContainerRecipeResponse -> GetContainerRecipeResponse -> Bool
$c== :: GetContainerRecipeResponse -> GetContainerRecipeResponse -> Bool
Prelude.Eq, ReadPrec [GetContainerRecipeResponse]
ReadPrec GetContainerRecipeResponse
Int -> ReadS GetContainerRecipeResponse
ReadS [GetContainerRecipeResponse]
(Int -> ReadS GetContainerRecipeResponse)
-> ReadS [GetContainerRecipeResponse]
-> ReadPrec GetContainerRecipeResponse
-> ReadPrec [GetContainerRecipeResponse]
-> Read GetContainerRecipeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerRecipeResponse]
$creadListPrec :: ReadPrec [GetContainerRecipeResponse]
readPrec :: ReadPrec GetContainerRecipeResponse
$creadPrec :: ReadPrec GetContainerRecipeResponse
readList :: ReadS [GetContainerRecipeResponse]
$creadList :: ReadS [GetContainerRecipeResponse]
readsPrec :: Int -> ReadS GetContainerRecipeResponse
$creadsPrec :: Int -> ReadS GetContainerRecipeResponse
Prelude.Read, Int -> GetContainerRecipeResponse -> ShowS
[GetContainerRecipeResponse] -> ShowS
GetContainerRecipeResponse -> String
(Int -> GetContainerRecipeResponse -> ShowS)
-> (GetContainerRecipeResponse -> String)
-> ([GetContainerRecipeResponse] -> ShowS)
-> Show GetContainerRecipeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerRecipeResponse] -> ShowS
$cshowList :: [GetContainerRecipeResponse] -> ShowS
show :: GetContainerRecipeResponse -> String
$cshow :: GetContainerRecipeResponse -> String
showsPrec :: Int -> GetContainerRecipeResponse -> ShowS
$cshowsPrec :: Int -> GetContainerRecipeResponse -> ShowS
Prelude.Show, (forall x.
 GetContainerRecipeResponse -> Rep GetContainerRecipeResponse x)
-> (forall x.
    Rep GetContainerRecipeResponse x -> GetContainerRecipeResponse)
-> Generic GetContainerRecipeResponse
forall x.
Rep GetContainerRecipeResponse x -> GetContainerRecipeResponse
forall x.
GetContainerRecipeResponse -> Rep GetContainerRecipeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContainerRecipeResponse x -> GetContainerRecipeResponse
$cfrom :: forall x.
GetContainerRecipeResponse -> Rep GetContainerRecipeResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerRecipeResponse' 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:
--
-- 'requestId', 'getContainerRecipeResponse_requestId' - The request ID that uniquely identifies this request.
--
-- 'containerRecipe', 'getContainerRecipeResponse_containerRecipe' - The container recipe object that is returned.
--
-- 'httpStatus', 'getContainerRecipeResponse_httpStatus' - The response's http status code.
newGetContainerRecipeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContainerRecipeResponse
newGetContainerRecipeResponse :: Int -> GetContainerRecipeResponse
newGetContainerRecipeResponse Int
pHttpStatus_ =
  GetContainerRecipeResponse' :: Maybe Text
-> Maybe ContainerRecipe -> Int -> GetContainerRecipeResponse
GetContainerRecipeResponse'
    { $sel:requestId:GetContainerRecipeResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerRecipe:GetContainerRecipeResponse' :: Maybe ContainerRecipe
containerRecipe = Maybe ContainerRecipe
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContainerRecipeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The request ID that uniquely identifies this request.
getContainerRecipeResponse_requestId :: Lens.Lens' GetContainerRecipeResponse (Prelude.Maybe Prelude.Text)
getContainerRecipeResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> GetContainerRecipeResponse -> f GetContainerRecipeResponse
getContainerRecipeResponse_requestId = (GetContainerRecipeResponse -> Maybe Text)
-> (GetContainerRecipeResponse
    -> Maybe Text -> GetContainerRecipeResponse)
-> Lens
     GetContainerRecipeResponse
     GetContainerRecipeResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerRecipeResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:GetContainerRecipeResponse' :: GetContainerRecipeResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: GetContainerRecipeResponse
s@GetContainerRecipeResponse' {} Maybe Text
a -> GetContainerRecipeResponse
s {$sel:requestId:GetContainerRecipeResponse' :: Maybe Text
requestId = Maybe Text
a} :: GetContainerRecipeResponse)

-- | The container recipe object that is returned.
getContainerRecipeResponse_containerRecipe :: Lens.Lens' GetContainerRecipeResponse (Prelude.Maybe ContainerRecipe)
getContainerRecipeResponse_containerRecipe :: (Maybe ContainerRecipe -> f (Maybe ContainerRecipe))
-> GetContainerRecipeResponse -> f GetContainerRecipeResponse
getContainerRecipeResponse_containerRecipe = (GetContainerRecipeResponse -> Maybe ContainerRecipe)
-> (GetContainerRecipeResponse
    -> Maybe ContainerRecipe -> GetContainerRecipeResponse)
-> Lens
     GetContainerRecipeResponse
     GetContainerRecipeResponse
     (Maybe ContainerRecipe)
     (Maybe ContainerRecipe)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerRecipeResponse' {Maybe ContainerRecipe
containerRecipe :: Maybe ContainerRecipe
$sel:containerRecipe:GetContainerRecipeResponse' :: GetContainerRecipeResponse -> Maybe ContainerRecipe
containerRecipe} -> Maybe ContainerRecipe
containerRecipe) (\s :: GetContainerRecipeResponse
s@GetContainerRecipeResponse' {} Maybe ContainerRecipe
a -> GetContainerRecipeResponse
s {$sel:containerRecipe:GetContainerRecipeResponse' :: Maybe ContainerRecipe
containerRecipe = Maybe ContainerRecipe
a} :: GetContainerRecipeResponse)

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

instance Prelude.NFData GetContainerRecipeResponse