{-# 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.CodeDeploy.GetDeploymentConfig
-- 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 configuration.
module Amazonka.CodeDeploy.GetDeploymentConfig
  ( -- * Creating a Request
    GetDeploymentConfig (..),
    newGetDeploymentConfig,

    -- * Request Lenses
    getDeploymentConfig_deploymentConfigName,

    -- * Destructuring the Response
    GetDeploymentConfigResponse (..),
    newGetDeploymentConfigResponse,

    -- * Response Lenses
    getDeploymentConfigResponse_deploymentConfigInfo,
    getDeploymentConfigResponse_httpStatus,
  )
where

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

-- | Represents the input of a @GetDeploymentConfig@ operation.
--
-- /See:/ 'newGetDeploymentConfig' smart constructor.
data GetDeploymentConfig = GetDeploymentConfig'
  { -- | The name of a deployment configuration associated with the IAM user or
    -- AWS account.
    GetDeploymentConfig -> Text
deploymentConfigName :: Prelude.Text
  }
  deriving (GetDeploymentConfig -> GetDeploymentConfig -> Bool
(GetDeploymentConfig -> GetDeploymentConfig -> Bool)
-> (GetDeploymentConfig -> GetDeploymentConfig -> Bool)
-> Eq GetDeploymentConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeploymentConfig -> GetDeploymentConfig -> Bool
$c/= :: GetDeploymentConfig -> GetDeploymentConfig -> Bool
== :: GetDeploymentConfig -> GetDeploymentConfig -> Bool
$c== :: GetDeploymentConfig -> GetDeploymentConfig -> Bool
Prelude.Eq, ReadPrec [GetDeploymentConfig]
ReadPrec GetDeploymentConfig
Int -> ReadS GetDeploymentConfig
ReadS [GetDeploymentConfig]
(Int -> ReadS GetDeploymentConfig)
-> ReadS [GetDeploymentConfig]
-> ReadPrec GetDeploymentConfig
-> ReadPrec [GetDeploymentConfig]
-> Read GetDeploymentConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeploymentConfig]
$creadListPrec :: ReadPrec [GetDeploymentConfig]
readPrec :: ReadPrec GetDeploymentConfig
$creadPrec :: ReadPrec GetDeploymentConfig
readList :: ReadS [GetDeploymentConfig]
$creadList :: ReadS [GetDeploymentConfig]
readsPrec :: Int -> ReadS GetDeploymentConfig
$creadsPrec :: Int -> ReadS GetDeploymentConfig
Prelude.Read, Int -> GetDeploymentConfig -> ShowS
[GetDeploymentConfig] -> ShowS
GetDeploymentConfig -> String
(Int -> GetDeploymentConfig -> ShowS)
-> (GetDeploymentConfig -> String)
-> ([GetDeploymentConfig] -> ShowS)
-> Show GetDeploymentConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeploymentConfig] -> ShowS
$cshowList :: [GetDeploymentConfig] -> ShowS
show :: GetDeploymentConfig -> String
$cshow :: GetDeploymentConfig -> String
showsPrec :: Int -> GetDeploymentConfig -> ShowS
$cshowsPrec :: Int -> GetDeploymentConfig -> ShowS
Prelude.Show, (forall x. GetDeploymentConfig -> Rep GetDeploymentConfig x)
-> (forall x. Rep GetDeploymentConfig x -> GetDeploymentConfig)
-> Generic GetDeploymentConfig
forall x. Rep GetDeploymentConfig x -> GetDeploymentConfig
forall x. GetDeploymentConfig -> Rep GetDeploymentConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeploymentConfig x -> GetDeploymentConfig
$cfrom :: forall x. GetDeploymentConfig -> Rep GetDeploymentConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetDeploymentConfig' 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:
--
-- 'deploymentConfigName', 'getDeploymentConfig_deploymentConfigName' - The name of a deployment configuration associated with the IAM user or
-- AWS account.
newGetDeploymentConfig ::
  -- | 'deploymentConfigName'
  Prelude.Text ->
  GetDeploymentConfig
newGetDeploymentConfig :: Text -> GetDeploymentConfig
newGetDeploymentConfig Text
pDeploymentConfigName_ =
  GetDeploymentConfig' :: Text -> GetDeploymentConfig
GetDeploymentConfig'
    { $sel:deploymentConfigName:GetDeploymentConfig' :: Text
deploymentConfigName =
        Text
pDeploymentConfigName_
    }

-- | The name of a deployment configuration associated with the IAM user or
-- AWS account.
getDeploymentConfig_deploymentConfigName :: Lens.Lens' GetDeploymentConfig Prelude.Text
getDeploymentConfig_deploymentConfigName :: (Text -> f Text) -> GetDeploymentConfig -> f GetDeploymentConfig
getDeploymentConfig_deploymentConfigName = (GetDeploymentConfig -> Text)
-> (GetDeploymentConfig -> Text -> GetDeploymentConfig)
-> Lens GetDeploymentConfig GetDeploymentConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentConfig' {Text
deploymentConfigName :: Text
$sel:deploymentConfigName:GetDeploymentConfig' :: GetDeploymentConfig -> Text
deploymentConfigName} -> Text
deploymentConfigName) (\s :: GetDeploymentConfig
s@GetDeploymentConfig' {} Text
a -> GetDeploymentConfig
s {$sel:deploymentConfigName:GetDeploymentConfig' :: Text
deploymentConfigName = Text
a} :: GetDeploymentConfig)

instance Core.AWSRequest GetDeploymentConfig where
  type
    AWSResponse GetDeploymentConfig =
      GetDeploymentConfigResponse
  request :: GetDeploymentConfig -> Request GetDeploymentConfig
request = Service -> GetDeploymentConfig -> Request GetDeploymentConfig
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDeploymentConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentConfig)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDeploymentConfig))
-> Logger
-> Service
-> Proxy GetDeploymentConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentConfig)))
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 DeploymentConfigInfo -> Int -> GetDeploymentConfigResponse
GetDeploymentConfigResponse'
            (Maybe DeploymentConfigInfo -> Int -> GetDeploymentConfigResponse)
-> Either String (Maybe DeploymentConfigInfo)
-> Either String (Int -> GetDeploymentConfigResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DeploymentConfigInfo)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deploymentConfigInfo")
            Either String (Int -> GetDeploymentConfigResponse)
-> Either String Int -> Either String GetDeploymentConfigResponse
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 GetDeploymentConfig

instance Prelude.NFData GetDeploymentConfig

instance Core.ToHeaders GetDeploymentConfig where
  toHeaders :: GetDeploymentConfig -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDeploymentConfig -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeDeploy_20141006.GetDeploymentConfig" ::
                          Prelude.ByteString
                      ),
            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.ToJSON GetDeploymentConfig where
  toJSON :: GetDeploymentConfig -> Value
toJSON GetDeploymentConfig' {Text
deploymentConfigName :: Text
$sel:deploymentConfigName:GetDeploymentConfig' :: GetDeploymentConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"deploymentConfigName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deploymentConfigName
              )
          ]
      )

instance Core.ToPath GetDeploymentConfig where
  toPath :: GetDeploymentConfig -> ByteString
toPath = ByteString -> GetDeploymentConfig -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the output of a @GetDeploymentConfig@ operation.
--
-- /See:/ 'newGetDeploymentConfigResponse' smart constructor.
data GetDeploymentConfigResponse = GetDeploymentConfigResponse'
  { -- | Information about the deployment configuration.
    GetDeploymentConfigResponse -> Maybe DeploymentConfigInfo
deploymentConfigInfo :: Prelude.Maybe DeploymentConfigInfo,
    -- | The response's http status code.
    GetDeploymentConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDeploymentConfigResponse -> GetDeploymentConfigResponse -> Bool
(GetDeploymentConfigResponse
 -> GetDeploymentConfigResponse -> Bool)
-> (GetDeploymentConfigResponse
    -> GetDeploymentConfigResponse -> Bool)
-> Eq GetDeploymentConfigResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeploymentConfigResponse -> GetDeploymentConfigResponse -> Bool
$c/= :: GetDeploymentConfigResponse -> GetDeploymentConfigResponse -> Bool
== :: GetDeploymentConfigResponse -> GetDeploymentConfigResponse -> Bool
$c== :: GetDeploymentConfigResponse -> GetDeploymentConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetDeploymentConfigResponse]
ReadPrec GetDeploymentConfigResponse
Int -> ReadS GetDeploymentConfigResponse
ReadS [GetDeploymentConfigResponse]
(Int -> ReadS GetDeploymentConfigResponse)
-> ReadS [GetDeploymentConfigResponse]
-> ReadPrec GetDeploymentConfigResponse
-> ReadPrec [GetDeploymentConfigResponse]
-> Read GetDeploymentConfigResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeploymentConfigResponse]
$creadListPrec :: ReadPrec [GetDeploymentConfigResponse]
readPrec :: ReadPrec GetDeploymentConfigResponse
$creadPrec :: ReadPrec GetDeploymentConfigResponse
readList :: ReadS [GetDeploymentConfigResponse]
$creadList :: ReadS [GetDeploymentConfigResponse]
readsPrec :: Int -> ReadS GetDeploymentConfigResponse
$creadsPrec :: Int -> ReadS GetDeploymentConfigResponse
Prelude.Read, Int -> GetDeploymentConfigResponse -> ShowS
[GetDeploymentConfigResponse] -> ShowS
GetDeploymentConfigResponse -> String
(Int -> GetDeploymentConfigResponse -> ShowS)
-> (GetDeploymentConfigResponse -> String)
-> ([GetDeploymentConfigResponse] -> ShowS)
-> Show GetDeploymentConfigResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeploymentConfigResponse] -> ShowS
$cshowList :: [GetDeploymentConfigResponse] -> ShowS
show :: GetDeploymentConfigResponse -> String
$cshow :: GetDeploymentConfigResponse -> String
showsPrec :: Int -> GetDeploymentConfigResponse -> ShowS
$cshowsPrec :: Int -> GetDeploymentConfigResponse -> ShowS
Prelude.Show, (forall x.
 GetDeploymentConfigResponse -> Rep GetDeploymentConfigResponse x)
-> (forall x.
    Rep GetDeploymentConfigResponse x -> GetDeploymentConfigResponse)
-> Generic GetDeploymentConfigResponse
forall x.
Rep GetDeploymentConfigResponse x -> GetDeploymentConfigResponse
forall x.
GetDeploymentConfigResponse -> Rep GetDeploymentConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDeploymentConfigResponse x -> GetDeploymentConfigResponse
$cfrom :: forall x.
GetDeploymentConfigResponse -> Rep GetDeploymentConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDeploymentConfigResponse' 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:
--
-- 'deploymentConfigInfo', 'getDeploymentConfigResponse_deploymentConfigInfo' - Information about the deployment configuration.
--
-- 'httpStatus', 'getDeploymentConfigResponse_httpStatus' - The response's http status code.
newGetDeploymentConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDeploymentConfigResponse
newGetDeploymentConfigResponse :: Int -> GetDeploymentConfigResponse
newGetDeploymentConfigResponse Int
pHttpStatus_ =
  GetDeploymentConfigResponse' :: Maybe DeploymentConfigInfo -> Int -> GetDeploymentConfigResponse
GetDeploymentConfigResponse'
    { $sel:deploymentConfigInfo:GetDeploymentConfigResponse' :: Maybe DeploymentConfigInfo
deploymentConfigInfo =
        Maybe DeploymentConfigInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDeploymentConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the deployment configuration.
getDeploymentConfigResponse_deploymentConfigInfo :: Lens.Lens' GetDeploymentConfigResponse (Prelude.Maybe DeploymentConfigInfo)
getDeploymentConfigResponse_deploymentConfigInfo :: (Maybe DeploymentConfigInfo -> f (Maybe DeploymentConfigInfo))
-> GetDeploymentConfigResponse -> f GetDeploymentConfigResponse
getDeploymentConfigResponse_deploymentConfigInfo = (GetDeploymentConfigResponse -> Maybe DeploymentConfigInfo)
-> (GetDeploymentConfigResponse
    -> Maybe DeploymentConfigInfo -> GetDeploymentConfigResponse)
-> Lens
     GetDeploymentConfigResponse
     GetDeploymentConfigResponse
     (Maybe DeploymentConfigInfo)
     (Maybe DeploymentConfigInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentConfigResponse' {Maybe DeploymentConfigInfo
deploymentConfigInfo :: Maybe DeploymentConfigInfo
$sel:deploymentConfigInfo:GetDeploymentConfigResponse' :: GetDeploymentConfigResponse -> Maybe DeploymentConfigInfo
deploymentConfigInfo} -> Maybe DeploymentConfigInfo
deploymentConfigInfo) (\s :: GetDeploymentConfigResponse
s@GetDeploymentConfigResponse' {} Maybe DeploymentConfigInfo
a -> GetDeploymentConfigResponse
s {$sel:deploymentConfigInfo:GetDeploymentConfigResponse' :: Maybe DeploymentConfigInfo
deploymentConfigInfo = Maybe DeploymentConfigInfo
a} :: GetDeploymentConfigResponse)

-- | The response's http status code.
getDeploymentConfigResponse_httpStatus :: Lens.Lens' GetDeploymentConfigResponse Prelude.Int
getDeploymentConfigResponse_httpStatus :: (Int -> f Int)
-> GetDeploymentConfigResponse -> f GetDeploymentConfigResponse
getDeploymentConfigResponse_httpStatus = (GetDeploymentConfigResponse -> Int)
-> (GetDeploymentConfigResponse
    -> Int -> GetDeploymentConfigResponse)
-> Lens
     GetDeploymentConfigResponse GetDeploymentConfigResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentConfigResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDeploymentConfigResponse' :: GetDeploymentConfigResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDeploymentConfigResponse
s@GetDeploymentConfigResponse' {} Int
a -> GetDeploymentConfigResponse
s {$sel:httpStatus:GetDeploymentConfigResponse' :: Int
httpStatus = Int
a} :: GetDeploymentConfigResponse)

instance Prelude.NFData GetDeploymentConfigResponse