{-# 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.AppConfig.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)
--
-- Retrieve information about a configuration deployment.
module Amazonka.AppConfig.GetDeployment
  ( -- * Creating a Request
    GetDeployment (..),
    newGetDeployment,

    -- * Request Lenses
    getDeployment_applicationId,
    getDeployment_environmentId,
    getDeployment_deploymentNumber,

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

    -- * Response Lenses
    deployment_growthFactor,
    deployment_configurationName,
    deployment_state,
    deployment_deploymentStrategyId,
    deployment_deploymentNumber,
    deployment_configurationVersion,
    deployment_eventLog,
    deployment_percentageComplete,
    deployment_startedAt,
    deployment_applicationId,
    deployment_deploymentDurationInMinutes,
    deployment_environmentId,
    deployment_completedAt,
    deployment_configurationLocationUri,
    deployment_finalBakeTimeInMinutes,
    deployment_description,
    deployment_configurationProfileId,
    deployment_growthType,
  )
where

import Amazonka.AppConfig.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

-- | /See:/ 'newGetDeployment' smart constructor.
data GetDeployment = GetDeployment'
  { -- | The ID of the application that includes the deployment you want to get.
    GetDeployment -> Text
applicationId :: Prelude.Text,
    -- | The ID of the environment that includes the deployment you want to get.
    GetDeployment -> Text
environmentId :: Prelude.Text,
    -- | The sequence number of the deployment.
    GetDeployment -> Int
deploymentNumber :: Prelude.Int
  }
  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:
--
-- 'applicationId', 'getDeployment_applicationId' - The ID of the application that includes the deployment you want to get.
--
-- 'environmentId', 'getDeployment_environmentId' - The ID of the environment that includes the deployment you want to get.
--
-- 'deploymentNumber', 'getDeployment_deploymentNumber' - The sequence number of the deployment.
newGetDeployment ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'environmentId'
  Prelude.Text ->
  -- | 'deploymentNumber'
  Prelude.Int ->
  GetDeployment
newGetDeployment :: Text -> Text -> Int -> GetDeployment
newGetDeployment
  Text
pApplicationId_
  Text
pEnvironmentId_
  Int
pDeploymentNumber_ =
    GetDeployment' :: Text -> Text -> Int -> GetDeployment
GetDeployment'
      { $sel:applicationId:GetDeployment' :: Text
applicationId = Text
pApplicationId_,
        $sel:environmentId:GetDeployment' :: Text
environmentId = Text
pEnvironmentId_,
        $sel:deploymentNumber:GetDeployment' :: Int
deploymentNumber = Int
pDeploymentNumber_
      }

-- | The ID of the application that includes the deployment you want to get.
getDeployment_applicationId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_applicationId :: (Text -> f Text) -> GetDeployment -> f GetDeployment
getDeployment_applicationId = (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
applicationId :: Text
$sel:applicationId:GetDeployment' :: GetDeployment -> Text
applicationId} -> Text
applicationId) (\s :: GetDeployment
s@GetDeployment' {} Text
a -> GetDeployment
s {$sel:applicationId:GetDeployment' :: Text
applicationId = Text
a} :: GetDeployment)

-- | The ID of the environment that includes the deployment you want to get.
getDeployment_environmentId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_environmentId :: (Text -> f Text) -> GetDeployment -> f GetDeployment
getDeployment_environmentId = (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
environmentId :: Text
$sel:environmentId:GetDeployment' :: GetDeployment -> Text
environmentId} -> Text
environmentId) (\s :: GetDeployment
s@GetDeployment' {} Text
a -> GetDeployment
s {$sel:environmentId:GetDeployment' :: Text
environmentId = Text
a} :: GetDeployment)

-- | The sequence number of the deployment.
getDeployment_deploymentNumber :: Lens.Lens' GetDeployment Prelude.Int
getDeployment_deploymentNumber :: (Int -> f Int) -> GetDeployment -> f GetDeployment
getDeployment_deploymentNumber = (GetDeployment -> Int)
-> (GetDeployment -> Int -> GetDeployment)
-> Lens GetDeployment GetDeployment Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeployment' {Int
deploymentNumber :: Int
$sel:deploymentNumber:GetDeployment' :: GetDeployment -> Int
deploymentNumber} -> Int
deploymentNumber) (\s :: GetDeployment
s@GetDeployment' {} Int
a -> GetDeployment
s {$sel:deploymentNumber:GetDeployment' :: Int
deploymentNumber = Int
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
"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 GetDeployment where
  toPath :: GetDeployment -> ByteString
toPath GetDeployment' {Int
Text
deploymentNumber :: Int
environmentId :: Text
applicationId :: Text
$sel:deploymentNumber:GetDeployment' :: GetDeployment -> Int
$sel:environmentId:GetDeployment' :: GetDeployment -> Text
$sel:applicationId:GetDeployment' :: GetDeployment -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/environments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
environmentId,
        ByteString
"/deployments/",
        Int -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Int
deploymentNumber
      ]

instance Core.ToQuery GetDeployment where
  toQuery :: GetDeployment -> QueryString
toQuery = QueryString -> GetDeployment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty