{-# 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-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 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_id,
    deployment_description,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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],
    -- | [Required] The string identifier of the associated RestApi.
    GetDeployment -> Text
restApiId :: Prelude.Text,
    -- | [Required] The identifier of the Deployment resource to get information
    -- about.
    GetDeployment -> Text
deploymentId :: Prelude.Text
  }
  deriving (GetDeployment -> GetDeployment -> Bool
(GetDeployment -> GetDeployment -> Bool)
-> (GetDeployment -> GetDeployment -> Bool) -> Eq GetDeployment
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]
(Int -> ReadS GetDeployment)
-> ReadS [GetDeployment]
-> ReadPrec GetDeployment
-> ReadPrec [GetDeployment]
-> Read 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
(Int -> GetDeployment -> ShowS)
-> (GetDeployment -> String)
-> ([GetDeployment] -> ShowS)
-> Show GetDeployment
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. GetDeployment -> Rep GetDeployment x)
-> (forall x. Rep GetDeployment x -> GetDeployment)
-> Generic GetDeployment
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' - [Required] The string identifier of the associated RestApi.
--
-- 'deploymentId', 'getDeployment_deploymentId' - [Required] 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' :: Maybe [Text] -> Text -> Text -> GetDeployment
GetDeployment'
    { $sel:embed:GetDeployment' :: Maybe [Text]
embed = Maybe [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> GetDeployment -> f GetDeployment
getDeployment_embed = (GetDeployment -> Maybe [Text])
-> (GetDeployment -> Maybe [Text] -> GetDeployment)
-> Lens GetDeployment GetDeployment (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetDeployment -> f GetDeployment)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetDeployment
-> f GetDeployment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [Required] The string identifier of the associated RestApi.
getDeployment_restApiId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_restApiId :: (Text -> f Text) -> GetDeployment -> f GetDeployment
getDeployment_restApiId = (GetDeployment -> Text)
-> (GetDeployment -> Text -> GetDeployment)
-> Lens GetDeployment GetDeployment Text Text
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)

-- | [Required] The identifier of the Deployment resource to get information
-- about.
getDeployment_deploymentId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_deploymentId :: (Text -> f Text) -> GetDeployment -> f GetDeployment
getDeployment_deploymentId = (GetDeployment -> Text)
-> (GetDeployment -> Text -> GetDeployment)
-> Lens GetDeployment GetDeployment Text Text
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 :: GetDeployment -> Request GetDeployment
request = Service -> GetDeployment -> Request GetDeployment
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDeployment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDeployment))
-> Logger
-> Service
-> Proxy GetDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDeployment)))
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 -> Object -> Either String Deployment
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetDeployment

instance Prelude.NFData GetDeployment

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

instance Core.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]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
restApiId,
        ByteString
"/deployments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deploymentId
      ]

instance Core.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]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"embed"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
embed)
      ]