{-# 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.GetImageRecipePolicy
-- 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 policy.
module Amazonka.ImageBuilder.GetImageRecipePolicy
  ( -- * Creating a Request
    GetImageRecipePolicy (..),
    newGetImageRecipePolicy,

    -- * Request Lenses
    getImageRecipePolicy_imageRecipeArn,

    -- * Destructuring the Response
    GetImageRecipePolicyResponse (..),
    newGetImageRecipePolicyResponse,

    -- * Response Lenses
    getImageRecipePolicyResponse_policy,
    getImageRecipePolicyResponse_requestId,
    getImageRecipePolicyResponse_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:/ 'newGetImageRecipePolicy' smart constructor.
data GetImageRecipePolicy = GetImageRecipePolicy'
  { -- | The Amazon Resource Name (ARN) of the image recipe whose policy you want
    -- to retrieve.
    GetImageRecipePolicy -> Text
imageRecipeArn :: Prelude.Text
  }
  deriving (GetImageRecipePolicy -> GetImageRecipePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetImageRecipePolicy -> GetImageRecipePolicy -> Bool
$c/= :: GetImageRecipePolicy -> GetImageRecipePolicy -> Bool
== :: GetImageRecipePolicy -> GetImageRecipePolicy -> Bool
$c== :: GetImageRecipePolicy -> GetImageRecipePolicy -> Bool
Prelude.Eq, ReadPrec [GetImageRecipePolicy]
ReadPrec GetImageRecipePolicy
Int -> ReadS GetImageRecipePolicy
ReadS [GetImageRecipePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetImageRecipePolicy]
$creadListPrec :: ReadPrec [GetImageRecipePolicy]
readPrec :: ReadPrec GetImageRecipePolicy
$creadPrec :: ReadPrec GetImageRecipePolicy
readList :: ReadS [GetImageRecipePolicy]
$creadList :: ReadS [GetImageRecipePolicy]
readsPrec :: Int -> ReadS GetImageRecipePolicy
$creadsPrec :: Int -> ReadS GetImageRecipePolicy
Prelude.Read, Int -> GetImageRecipePolicy -> ShowS
[GetImageRecipePolicy] -> ShowS
GetImageRecipePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetImageRecipePolicy] -> ShowS
$cshowList :: [GetImageRecipePolicy] -> ShowS
show :: GetImageRecipePolicy -> String
$cshow :: GetImageRecipePolicy -> String
showsPrec :: Int -> GetImageRecipePolicy -> ShowS
$cshowsPrec :: Int -> GetImageRecipePolicy -> ShowS
Prelude.Show, forall x. Rep GetImageRecipePolicy x -> GetImageRecipePolicy
forall x. GetImageRecipePolicy -> Rep GetImageRecipePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetImageRecipePolicy x -> GetImageRecipePolicy
$cfrom :: forall x. GetImageRecipePolicy -> Rep GetImageRecipePolicy x
Prelude.Generic)

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

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

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

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

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

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

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

-- |
-- Create a value of 'GetImageRecipePolicyResponse' 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:
--
-- 'policy', 'getImageRecipePolicyResponse_policy' - The image recipe policy object.
--
-- 'requestId', 'getImageRecipePolicyResponse_requestId' - The request ID that uniquely identifies this request.
--
-- 'httpStatus', 'getImageRecipePolicyResponse_httpStatus' - The response's http status code.
newGetImageRecipePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetImageRecipePolicyResponse
newGetImageRecipePolicyResponse :: Int -> GetImageRecipePolicyResponse
newGetImageRecipePolicyResponse Int
pHttpStatus_ =
  GetImageRecipePolicyResponse'
    { $sel:policy:GetImageRecipePolicyResponse' :: Maybe Text
policy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:GetImageRecipePolicyResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetImageRecipePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The image recipe policy object.
getImageRecipePolicyResponse_policy :: Lens.Lens' GetImageRecipePolicyResponse (Prelude.Maybe Prelude.Text)
getImageRecipePolicyResponse_policy :: Lens' GetImageRecipePolicyResponse (Maybe Text)
getImageRecipePolicyResponse_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetImageRecipePolicyResponse' {Maybe Text
policy :: Maybe Text
$sel:policy:GetImageRecipePolicyResponse' :: GetImageRecipePolicyResponse -> Maybe Text
policy} -> Maybe Text
policy) (\s :: GetImageRecipePolicyResponse
s@GetImageRecipePolicyResponse' {} Maybe Text
a -> GetImageRecipePolicyResponse
s {$sel:policy:GetImageRecipePolicyResponse' :: Maybe Text
policy = Maybe Text
a} :: GetImageRecipePolicyResponse)

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

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

instance Prelude.NFData GetImageRecipePolicyResponse where
  rnf :: GetImageRecipePolicyResponse -> ()
rnf GetImageRecipePolicyResponse' {Int
Maybe Text
httpStatus :: Int
requestId :: Maybe Text
policy :: Maybe Text
$sel:httpStatus:GetImageRecipePolicyResponse' :: GetImageRecipePolicyResponse -> Int
$sel:requestId:GetImageRecipePolicyResponse' :: GetImageRecipePolicyResponse -> Maybe Text
$sel:policy:GetImageRecipePolicyResponse' :: GetImageRecipePolicyResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policy
      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