{-# 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.GetImageRecipe
-- 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 an image recipe.
module Amazonka.ImageBuilder.GetImageRecipe
  ( -- * Creating a Request
    GetImageRecipe (..),
    newGetImageRecipe,

    -- * Request Lenses
    getImageRecipe_imageRecipeArn,

    -- * Destructuring the Response
    GetImageRecipeResponse (..),
    newGetImageRecipeResponse,

    -- * Response Lenses
    getImageRecipeResponse_imageRecipe,
    getImageRecipeResponse_requestId,
    getImageRecipeResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetImageRecipe' smart constructor.
data GetImageRecipe = GetImageRecipe'
  { -- | The Amazon Resource Name (ARN) of the image recipe that you want to
    -- retrieve.
    GetImageRecipe -> Text
imageRecipeArn :: Prelude.Text
  }
  deriving (GetImageRecipe -> GetImageRecipe -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetImageRecipe -> GetImageRecipe -> Bool
$c/= :: GetImageRecipe -> GetImageRecipe -> Bool
== :: GetImageRecipe -> GetImageRecipe -> Bool
$c== :: GetImageRecipe -> GetImageRecipe -> Bool
Prelude.Eq, ReadPrec [GetImageRecipe]
ReadPrec GetImageRecipe
Int -> ReadS GetImageRecipe
ReadS [GetImageRecipe]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetImageRecipe]
$creadListPrec :: ReadPrec [GetImageRecipe]
readPrec :: ReadPrec GetImageRecipe
$creadPrec :: ReadPrec GetImageRecipe
readList :: ReadS [GetImageRecipe]
$creadList :: ReadS [GetImageRecipe]
readsPrec :: Int -> ReadS GetImageRecipe
$creadsPrec :: Int -> ReadS GetImageRecipe
Prelude.Read, Int -> GetImageRecipe -> ShowS
[GetImageRecipe] -> ShowS
GetImageRecipe -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetImageRecipe] -> ShowS
$cshowList :: [GetImageRecipe] -> ShowS
show :: GetImageRecipe -> String
$cshow :: GetImageRecipe -> String
showsPrec :: Int -> GetImageRecipe -> ShowS
$cshowsPrec :: Int -> GetImageRecipe -> ShowS
Prelude.Show, forall x. Rep GetImageRecipe x -> GetImageRecipe
forall x. GetImageRecipe -> Rep GetImageRecipe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetImageRecipe x -> GetImageRecipe
$cfrom :: forall x. GetImageRecipe -> Rep GetImageRecipe x
Prelude.Generic)

-- |
-- Create a value of 'GetImageRecipe' 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:
--
-- 'imageRecipeArn', 'getImageRecipe_imageRecipeArn' - The Amazon Resource Name (ARN) of the image recipe that you want to
-- retrieve.
newGetImageRecipe ::
  -- | 'imageRecipeArn'
  Prelude.Text ->
  GetImageRecipe
newGetImageRecipe :: Text -> GetImageRecipe
newGetImageRecipe Text
pImageRecipeArn_ =
  GetImageRecipe' {$sel:imageRecipeArn:GetImageRecipe' :: Text
imageRecipeArn = Text
pImageRecipeArn_}

-- | The Amazon Resource Name (ARN) of the image recipe that you want to
-- retrieve.
getImageRecipe_imageRecipeArn :: Lens.Lens' GetImageRecipe Prelude.Text
getImageRecipe_imageRecipeArn :: Lens' GetImageRecipe Text
getImageRecipe_imageRecipeArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImageRecipe' {Text
imageRecipeArn :: Text
$sel:imageRecipeArn:GetImageRecipe' :: GetImageRecipe -> Text
imageRecipeArn} -> Text
imageRecipeArn) (\s :: GetImageRecipe
s@GetImageRecipe' {} Text
a -> GetImageRecipe
s {$sel:imageRecipeArn:GetImageRecipe' :: Text
imageRecipeArn = Text
a} :: GetImageRecipe)

instance Core.AWSRequest GetImageRecipe where
  type
    AWSResponse GetImageRecipe =
      GetImageRecipeResponse
  request :: (Service -> Service) -> GetImageRecipe -> Request GetImageRecipe
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 GetImageRecipe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetImageRecipe)))
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 ImageRecipe -> Maybe Text -> Int -> GetImageRecipeResponse
GetImageRecipeResponse'
            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
"imageRecipe")
            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
"requestId")
            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 GetImageRecipe where
  hashWithSalt :: Int -> GetImageRecipe -> Int
hashWithSalt Int
_salt GetImageRecipe' {Text
imageRecipeArn :: Text
$sel:imageRecipeArn:GetImageRecipe' :: GetImageRecipe -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
imageRecipeArn

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

instance Data.ToHeaders GetImageRecipe where
  toHeaders :: GetImageRecipe -> 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 GetImageRecipe where
  toPath :: GetImageRecipe -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/GetImageRecipe"

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

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

-- |
-- Create a value of 'GetImageRecipeResponse' 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:
--
-- 'imageRecipe', 'getImageRecipeResponse_imageRecipe' - The image recipe object.
--
-- 'requestId', 'getImageRecipeResponse_requestId' - The request ID that uniquely identifies this request.
--
-- 'httpStatus', 'getImageRecipeResponse_httpStatus' - The response's http status code.
newGetImageRecipeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetImageRecipeResponse
newGetImageRecipeResponse :: Int -> GetImageRecipeResponse
newGetImageRecipeResponse Int
pHttpStatus_ =
  GetImageRecipeResponse'
    { $sel:imageRecipe:GetImageRecipeResponse' :: Maybe ImageRecipe
imageRecipe =
        forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:GetImageRecipeResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetImageRecipeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The image recipe object.
getImageRecipeResponse_imageRecipe :: Lens.Lens' GetImageRecipeResponse (Prelude.Maybe ImageRecipe)
getImageRecipeResponse_imageRecipe :: Lens' GetImageRecipeResponse (Maybe ImageRecipe)
getImageRecipeResponse_imageRecipe = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImageRecipeResponse' {Maybe ImageRecipe
imageRecipe :: Maybe ImageRecipe
$sel:imageRecipe:GetImageRecipeResponse' :: GetImageRecipeResponse -> Maybe ImageRecipe
imageRecipe} -> Maybe ImageRecipe
imageRecipe) (\s :: GetImageRecipeResponse
s@GetImageRecipeResponse' {} Maybe ImageRecipe
a -> GetImageRecipeResponse
s {$sel:imageRecipe:GetImageRecipeResponse' :: Maybe ImageRecipe
imageRecipe = Maybe ImageRecipe
a} :: GetImageRecipeResponse)

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

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

instance Prelude.NFData GetImageRecipeResponse where
  rnf :: GetImageRecipeResponse -> ()
rnf GetImageRecipeResponse' {Int
Maybe Text
Maybe ImageRecipe
httpStatus :: Int
requestId :: Maybe Text
imageRecipe :: Maybe ImageRecipe
$sel:httpStatus:GetImageRecipeResponse' :: GetImageRecipeResponse -> Int
$sel:requestId:GetImageRecipeResponse' :: GetImageRecipeResponse -> Maybe Text
$sel:imageRecipe:GetImageRecipeResponse' :: GetImageRecipeResponse -> Maybe ImageRecipe
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ImageRecipe
imageRecipe
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus