{-# 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-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)
--
-- 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_requestId,
    getImageRecipePolicyResponse_policy,
    getImageRecipePolicyResponse_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:/ '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
(GetImageRecipePolicy -> GetImageRecipePolicy -> Bool)
-> (GetImageRecipePolicy -> GetImageRecipePolicy -> Bool)
-> Eq GetImageRecipePolicy
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]
(Int -> ReadS GetImageRecipePolicy)
-> ReadS [GetImageRecipePolicy]
-> ReadPrec GetImageRecipePolicy
-> ReadPrec [GetImageRecipePolicy]
-> Read 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
(Int -> GetImageRecipePolicy -> ShowS)
-> (GetImageRecipePolicy -> String)
-> ([GetImageRecipePolicy] -> ShowS)
-> Show GetImageRecipePolicy
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. GetImageRecipePolicy -> Rep GetImageRecipePolicy x)
-> (forall x. Rep GetImageRecipePolicy x -> GetImageRecipePolicy)
-> Generic GetImageRecipePolicy
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' :: Text -> GetImageRecipePolicy
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 :: (Text -> f Text) -> GetImageRecipePolicy -> f GetImageRecipePolicy
getImageRecipePolicy_imageRecipeArn = (GetImageRecipePolicy -> Text)
-> (GetImageRecipePolicy -> Text -> GetImageRecipePolicy)
-> Lens GetImageRecipePolicy GetImageRecipePolicy Text Text
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 :: GetImageRecipePolicy -> Request GetImageRecipePolicy
request = Service -> GetImageRecipePolicy -> Request GetImageRecipePolicy
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetImageRecipePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetImageRecipePolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetImageRecipePolicy))
-> Logger
-> Service
-> Proxy GetImageRecipePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetImageRecipePolicy)))
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 Text -> Int -> GetImageRecipePolicyResponse
GetImageRecipePolicyResponse'
            (Maybe Text -> Maybe Text -> Int -> GetImageRecipePolicyResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> GetImageRecipePolicyResponse)
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 Text -> Int -> GetImageRecipePolicyResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetImageRecipePolicyResponse)
forall (f :: * -> *) a b. Applicative f => 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
"policy")
            Either String (Int -> GetImageRecipePolicyResponse)
-> Either String Int -> Either String GetImageRecipePolicyResponse
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 GetImageRecipePolicy

instance Prelude.NFData GetImageRecipePolicy

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

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

-- | /See:/ 'newGetImageRecipePolicyResponse' smart constructor.
data GetImageRecipePolicyResponse = GetImageRecipePolicyResponse'
  { -- | The request ID that uniquely identifies this request.
    GetImageRecipePolicyResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The image recipe policy object.
    GetImageRecipePolicyResponse -> Maybe Text
policy :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetImageRecipePolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetImageRecipePolicyResponse
-> GetImageRecipePolicyResponse -> Bool
(GetImageRecipePolicyResponse
 -> GetImageRecipePolicyResponse -> Bool)
-> (GetImageRecipePolicyResponse
    -> GetImageRecipePolicyResponse -> Bool)
-> Eq GetImageRecipePolicyResponse
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]
(Int -> ReadS GetImageRecipePolicyResponse)
-> ReadS [GetImageRecipePolicyResponse]
-> ReadPrec GetImageRecipePolicyResponse
-> ReadPrec [GetImageRecipePolicyResponse]
-> Read 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
(Int -> GetImageRecipePolicyResponse -> ShowS)
-> (GetImageRecipePolicyResponse -> String)
-> ([GetImageRecipePolicyResponse] -> ShowS)
-> Show GetImageRecipePolicyResponse
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.
 GetImageRecipePolicyResponse -> Rep GetImageRecipePolicyResponse x)
-> (forall x.
    Rep GetImageRecipePolicyResponse x -> GetImageRecipePolicyResponse)
-> Generic GetImageRecipePolicyResponse
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:
--
-- 'requestId', 'getImageRecipePolicyResponse_requestId' - The request ID that uniquely identifies this request.
--
-- 'policy', 'getImageRecipePolicyResponse_policy' - The image recipe policy object.
--
-- 'httpStatus', 'getImageRecipePolicyResponse_httpStatus' - The response's http status code.
newGetImageRecipePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetImageRecipePolicyResponse
newGetImageRecipePolicyResponse :: Int -> GetImageRecipePolicyResponse
newGetImageRecipePolicyResponse Int
pHttpStatus_ =
  GetImageRecipePolicyResponse' :: Maybe Text -> Maybe Text -> Int -> GetImageRecipePolicyResponse
GetImageRecipePolicyResponse'
    { $sel:requestId:GetImageRecipePolicyResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policy:GetImageRecipePolicyResponse' :: Maybe Text
policy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetImageRecipePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The request ID that uniquely identifies this request.
getImageRecipePolicyResponse_requestId :: Lens.Lens' GetImageRecipePolicyResponse (Prelude.Maybe Prelude.Text)
getImageRecipePolicyResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> GetImageRecipePolicyResponse -> f GetImageRecipePolicyResponse
getImageRecipePolicyResponse_requestId = (GetImageRecipePolicyResponse -> Maybe Text)
-> (GetImageRecipePolicyResponse
    -> Maybe Text -> GetImageRecipePolicyResponse)
-> Lens
     GetImageRecipePolicyResponse
     GetImageRecipePolicyResponse
     (Maybe Text)
     (Maybe Text)
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 image recipe policy object.
getImageRecipePolicyResponse_policy :: Lens.Lens' GetImageRecipePolicyResponse (Prelude.Maybe Prelude.Text)
getImageRecipePolicyResponse_policy :: (Maybe Text -> f (Maybe Text))
-> GetImageRecipePolicyResponse -> f GetImageRecipePolicyResponse
getImageRecipePolicyResponse_policy = (GetImageRecipePolicyResponse -> Maybe Text)
-> (GetImageRecipePolicyResponse
    -> Maybe Text -> GetImageRecipePolicyResponse)
-> Lens
     GetImageRecipePolicyResponse
     GetImageRecipePolicyResponse
     (Maybe Text)
     (Maybe Text)
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 response's http status code.
getImageRecipePolicyResponse_httpStatus :: Lens.Lens' GetImageRecipePolicyResponse Prelude.Int
getImageRecipePolicyResponse_httpStatus :: (Int -> f Int)
-> GetImageRecipePolicyResponse -> f GetImageRecipePolicyResponse
getImageRecipePolicyResponse_httpStatus = (GetImageRecipePolicyResponse -> Int)
-> (GetImageRecipePolicyResponse
    -> Int -> GetImageRecipePolicyResponse)
-> Lens
     GetImageRecipePolicyResponse GetImageRecipePolicyResponse Int Int
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