{-# 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.GetDeploymentStrategy
-- 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 deployment strategy. A deployment strategy
-- defines important criteria for rolling out your configuration to the
-- designated targets. A deployment strategy includes: the overall duration
-- required, a percentage of targets to receive the deployment during each
-- interval, an algorithm that defines how percentage grows, and bake time.
module Amazonka.AppConfig.GetDeploymentStrategy
  ( -- * Creating a Request
    GetDeploymentStrategy (..),
    newGetDeploymentStrategy,

    -- * Request Lenses
    getDeploymentStrategy_deploymentStrategyId,

    -- * Destructuring the Response
    DeploymentStrategy (..),
    newDeploymentStrategy,

    -- * Response Lenses
    deploymentStrategy_growthFactor,
    deploymentStrategy_replicateTo,
    deploymentStrategy_name,
    deploymentStrategy_id,
    deploymentStrategy_deploymentDurationInMinutes,
    deploymentStrategy_finalBakeTimeInMinutes,
    deploymentStrategy_description,
    deploymentStrategy_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:/ 'newGetDeploymentStrategy' smart constructor.
data GetDeploymentStrategy = GetDeploymentStrategy'
  { -- | The ID of the deployment strategy to get.
    GetDeploymentStrategy -> Text
deploymentStrategyId :: Prelude.Text
  }
  deriving (GetDeploymentStrategy -> GetDeploymentStrategy -> Bool
(GetDeploymentStrategy -> GetDeploymentStrategy -> Bool)
-> (GetDeploymentStrategy -> GetDeploymentStrategy -> Bool)
-> Eq GetDeploymentStrategy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeploymentStrategy -> GetDeploymentStrategy -> Bool
$c/= :: GetDeploymentStrategy -> GetDeploymentStrategy -> Bool
== :: GetDeploymentStrategy -> GetDeploymentStrategy -> Bool
$c== :: GetDeploymentStrategy -> GetDeploymentStrategy -> Bool
Prelude.Eq, ReadPrec [GetDeploymentStrategy]
ReadPrec GetDeploymentStrategy
Int -> ReadS GetDeploymentStrategy
ReadS [GetDeploymentStrategy]
(Int -> ReadS GetDeploymentStrategy)
-> ReadS [GetDeploymentStrategy]
-> ReadPrec GetDeploymentStrategy
-> ReadPrec [GetDeploymentStrategy]
-> Read GetDeploymentStrategy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeploymentStrategy]
$creadListPrec :: ReadPrec [GetDeploymentStrategy]
readPrec :: ReadPrec GetDeploymentStrategy
$creadPrec :: ReadPrec GetDeploymentStrategy
readList :: ReadS [GetDeploymentStrategy]
$creadList :: ReadS [GetDeploymentStrategy]
readsPrec :: Int -> ReadS GetDeploymentStrategy
$creadsPrec :: Int -> ReadS GetDeploymentStrategy
Prelude.Read, Int -> GetDeploymentStrategy -> ShowS
[GetDeploymentStrategy] -> ShowS
GetDeploymentStrategy -> String
(Int -> GetDeploymentStrategy -> ShowS)
-> (GetDeploymentStrategy -> String)
-> ([GetDeploymentStrategy] -> ShowS)
-> Show GetDeploymentStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeploymentStrategy] -> ShowS
$cshowList :: [GetDeploymentStrategy] -> ShowS
show :: GetDeploymentStrategy -> String
$cshow :: GetDeploymentStrategy -> String
showsPrec :: Int -> GetDeploymentStrategy -> ShowS
$cshowsPrec :: Int -> GetDeploymentStrategy -> ShowS
Prelude.Show, (forall x. GetDeploymentStrategy -> Rep GetDeploymentStrategy x)
-> (forall x. Rep GetDeploymentStrategy x -> GetDeploymentStrategy)
-> Generic GetDeploymentStrategy
forall x. Rep GetDeploymentStrategy x -> GetDeploymentStrategy
forall x. GetDeploymentStrategy -> Rep GetDeploymentStrategy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeploymentStrategy x -> GetDeploymentStrategy
$cfrom :: forall x. GetDeploymentStrategy -> Rep GetDeploymentStrategy x
Prelude.Generic)

-- |
-- Create a value of 'GetDeploymentStrategy' 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:
--
-- 'deploymentStrategyId', 'getDeploymentStrategy_deploymentStrategyId' - The ID of the deployment strategy to get.
newGetDeploymentStrategy ::
  -- | 'deploymentStrategyId'
  Prelude.Text ->
  GetDeploymentStrategy
newGetDeploymentStrategy :: Text -> GetDeploymentStrategy
newGetDeploymentStrategy Text
pDeploymentStrategyId_ =
  GetDeploymentStrategy' :: Text -> GetDeploymentStrategy
GetDeploymentStrategy'
    { $sel:deploymentStrategyId:GetDeploymentStrategy' :: Text
deploymentStrategyId =
        Text
pDeploymentStrategyId_
    }

-- | The ID of the deployment strategy to get.
getDeploymentStrategy_deploymentStrategyId :: Lens.Lens' GetDeploymentStrategy Prelude.Text
getDeploymentStrategy_deploymentStrategyId :: (Text -> f Text)
-> GetDeploymentStrategy -> f GetDeploymentStrategy
getDeploymentStrategy_deploymentStrategyId = (GetDeploymentStrategy -> Text)
-> (GetDeploymentStrategy -> Text -> GetDeploymentStrategy)
-> Lens GetDeploymentStrategy GetDeploymentStrategy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentStrategy' {Text
deploymentStrategyId :: Text
$sel:deploymentStrategyId:GetDeploymentStrategy' :: GetDeploymentStrategy -> Text
deploymentStrategyId} -> Text
deploymentStrategyId) (\s :: GetDeploymentStrategy
s@GetDeploymentStrategy' {} Text
a -> GetDeploymentStrategy
s {$sel:deploymentStrategyId:GetDeploymentStrategy' :: Text
deploymentStrategyId = Text
a} :: GetDeploymentStrategy)

instance Core.AWSRequest GetDeploymentStrategy where
  type
    AWSResponse GetDeploymentStrategy =
      DeploymentStrategy
  request :: GetDeploymentStrategy -> Request GetDeploymentStrategy
request = Service -> GetDeploymentStrategy -> Request GetDeploymentStrategy
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDeploymentStrategy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentStrategy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDeploymentStrategy))
-> Logger
-> Service
-> Proxy GetDeploymentStrategy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentStrategy)))
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 DeploymentStrategy
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetDeploymentStrategy

instance Prelude.NFData GetDeploymentStrategy

instance Core.ToHeaders GetDeploymentStrategy where
  toHeaders :: GetDeploymentStrategy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDeploymentStrategy -> 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 GetDeploymentStrategy where
  toPath :: GetDeploymentStrategy -> ByteString
toPath GetDeploymentStrategy' {Text
deploymentStrategyId :: Text
$sel:deploymentStrategyId:GetDeploymentStrategy' :: GetDeploymentStrategy -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/deploymentstrategies/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deploymentStrategyId
      ]

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