{-# 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.APIGateway.GetDeployment
-- 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 information about a Deployment resource.
module Amazonka.APIGateway.GetDeployment
  ( -- * Creating a Request
    GetDeployment (..),
    newGetDeployment,

    -- * Request Lenses
    getDeployment_embed,
    getDeployment_restApiId,
    getDeployment_deploymentId,

    -- * Destructuring the Response
    Deployment (..),
    newDeployment,

    -- * Response Lenses
    deployment_apiSummary,
    deployment_createdDate,
    deployment_description,
    deployment_id,
  )
where

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

-- | Requests API Gateway to get information about a Deployment resource.
--
-- /See:/ 'newGetDeployment' smart constructor.
data GetDeployment = GetDeployment'
  { -- | A query parameter to retrieve the specified embedded resources of the
    -- returned Deployment resource in the response. In a REST API call, this
    -- @embed@ parameter value is a list of comma-separated strings, as in
    -- @GET \/restapis\/{restapi_id}\/deployments\/{deployment_id}?embed=var1,var2@.
    -- The SDK and other platform-dependent libraries might use a different
    -- format for the list. Currently, this request supports only retrieval of
    -- the embedded API summary this way. Hence, the parameter value must be a
    -- single-valued list containing only the @\"apisummary\"@ string. For
    -- example,
    -- @GET \/restapis\/{restapi_id}\/deployments\/{deployment_id}?embed=apisummary@.
    GetDeployment -> Maybe [Text]
embed :: Prelude.Maybe [Prelude.Text],
    -- | The string identifier of the associated RestApi.
    GetDeployment -> Text
restApiId :: Prelude.Text,
    -- | The identifier of the Deployment resource to get information about.
    GetDeployment -> Text
deploymentId :: Prelude.Text
  }
  deriving (GetDeployment -> GetDeployment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeployment -> GetDeployment -> Bool
$c/= :: GetDeployment -> GetDeployment -> Bool
== :: GetDeployment -> GetDeployment -> Bool
$c== :: GetDeployment -> GetDeployment -> Bool
Prelude.Eq, ReadPrec [GetDeployment]
ReadPrec GetDeployment
Int -> ReadS GetDeployment
ReadS [GetDeployment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeployment]
$creadListPrec :: ReadPrec [GetDeployment]
readPrec :: ReadPrec GetDeployment
$creadPrec :: ReadPrec GetDeployment
readList :: ReadS [GetDeployment]
$creadList :: ReadS [GetDeployment]
readsPrec :: Int -> ReadS GetDeployment
$creadsPrec :: Int -> ReadS GetDeployment
Prelude.Read, Int -> GetDeployment -> ShowS
[GetDeployment] -> ShowS
GetDeployment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeployment] -> ShowS
$cshowList :: [GetDeployment] -> ShowS
show :: GetDeployment -> String
$cshow :: GetDeployment -> String
showsPrec :: Int -> GetDeployment -> ShowS
$cshowsPrec :: Int -> GetDeployment -> ShowS
Prelude.Show, forall x. Rep GetDeployment x -> GetDeployment
forall x. GetDeployment -> Rep GetDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeployment x -> GetDeployment
$cfrom :: forall x. GetDeployment -> Rep GetDeployment x
Prelude.Generic)

-- |
-- Create a value of 'GetDeployment' 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:
--
-- 'embed', 'getDeployment_embed' - A query parameter to retrieve the specified embedded resources of the
-- returned Deployment resource in the response. In a REST API call, this
-- @embed@ parameter value is a list of comma-separated strings, as in
-- @GET \/restapis\/{restapi_id}\/deployments\/{deployment_id}?embed=var1,var2@.
-- The SDK and other platform-dependent libraries might use a different
-- format for the list. Currently, this request supports only retrieval of
-- the embedded API summary this way. Hence, the parameter value must be a
-- single-valued list containing only the @\"apisummary\"@ string. For
-- example,
-- @GET \/restapis\/{restapi_id}\/deployments\/{deployment_id}?embed=apisummary@.
--
-- 'restApiId', 'getDeployment_restApiId' - The string identifier of the associated RestApi.
--
-- 'deploymentId', 'getDeployment_deploymentId' - The identifier of the Deployment resource to get information about.
newGetDeployment ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'deploymentId'
  Prelude.Text ->
  GetDeployment
newGetDeployment :: Text -> Text -> GetDeployment
newGetDeployment Text
pRestApiId_ Text
pDeploymentId_ =
  GetDeployment'
    { $sel:embed:GetDeployment' :: Maybe [Text]
embed = forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:GetDeployment' :: Text
restApiId = Text
pRestApiId_,
      $sel:deploymentId:GetDeployment' :: Text
deploymentId = Text
pDeploymentId_
    }

-- | A query parameter to retrieve the specified embedded resources of the
-- returned Deployment resource in the response. In a REST API call, this
-- @embed@ parameter value is a list of comma-separated strings, as in
-- @GET \/restapis\/{restapi_id}\/deployments\/{deployment_id}?embed=var1,var2@.
-- The SDK and other platform-dependent libraries might use a different
-- format for the list. Currently, this request supports only retrieval of
-- the embedded API summary this way. Hence, the parameter value must be a
-- single-valued list containing only the @\"apisummary\"@ string. For
-- example,
-- @GET \/restapis\/{restapi_id}\/deployments\/{deployment_id}?embed=apisummary@.
getDeployment_embed :: Lens.Lens' GetDeployment (Prelude.Maybe [Prelude.Text])
getDeployment_embed :: Lens' GetDeployment (Maybe [Text])
getDeployment_embed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeployment' {Maybe [Text]
embed :: Maybe [Text]
$sel:embed:GetDeployment' :: GetDeployment -> Maybe [Text]
embed} -> Maybe [Text]
embed) (\s :: GetDeployment
s@GetDeployment' {} Maybe [Text]
a -> GetDeployment
s {$sel:embed:GetDeployment' :: Maybe [Text]
embed = Maybe [Text]
a} :: GetDeployment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The string identifier of the associated RestApi.
getDeployment_restApiId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_restApiId :: Lens' GetDeployment Text
getDeployment_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeployment' {Text
restApiId :: Text
$sel:restApiId:GetDeployment' :: GetDeployment -> Text
restApiId} -> Text
restApiId) (\s :: GetDeployment
s@GetDeployment' {} Text
a -> GetDeployment
s {$sel:restApiId:GetDeployment' :: Text
restApiId = Text
a} :: GetDeployment)

-- | The identifier of the Deployment resource to get information about.
getDeployment_deploymentId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_deploymentId :: Lens' GetDeployment Text
getDeployment_deploymentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeployment' {Text
deploymentId :: Text
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
deploymentId} -> Text
deploymentId) (\s :: GetDeployment
s@GetDeployment' {} Text
a -> GetDeployment
s {$sel:deploymentId:GetDeployment' :: Text
deploymentId = Text
a} :: GetDeployment)

instance Core.AWSRequest GetDeployment where
  type AWSResponse GetDeployment = Deployment
  request :: (Service -> Service) -> GetDeployment -> Request GetDeployment
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 GetDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDeployment)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GetDeployment where
  hashWithSalt :: Int -> GetDeployment -> Int
hashWithSalt Int
_salt GetDeployment' {Maybe [Text]
Text
deploymentId :: Text
restApiId :: Text
embed :: Maybe [Text]
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
$sel:restApiId:GetDeployment' :: GetDeployment -> Text
$sel:embed:GetDeployment' :: GetDeployment -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
embed
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deploymentId

instance Prelude.NFData GetDeployment where
  rnf :: GetDeployment -> ()
rnf GetDeployment' {Maybe [Text]
Text
deploymentId :: Text
restApiId :: Text
embed :: Maybe [Text]
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
$sel:restApiId:GetDeployment' :: GetDeployment -> Text
$sel:embed:GetDeployment' :: GetDeployment -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
embed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deploymentId

instance Data.ToHeaders GetDeployment where
  toHeaders :: GetDeployment -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToPath GetDeployment where
  toPath :: GetDeployment -> ByteString
toPath GetDeployment' {Maybe [Text]
Text
deploymentId :: Text
restApiId :: Text
embed :: Maybe [Text]
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
$sel:restApiId:GetDeployment' :: GetDeployment -> Text
$sel:embed:GetDeployment' :: GetDeployment -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/deployments/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
deploymentId
      ]

instance Data.ToQuery GetDeployment where
  toQuery :: GetDeployment -> QueryString
toQuery GetDeployment' {Maybe [Text]
Text
deploymentId :: Text
restApiId :: Text
embed :: Maybe [Text]
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
$sel:restApiId:GetDeployment' :: GetDeployment -> Text
$sel:embed:GetDeployment' :: GetDeployment -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"embed"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
embed)
      ]