{-# 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-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 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.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

-- | 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
    -- Amazon Web Services account.
    GetDeploymentConfig -> Text
deploymentConfigName :: Prelude.Text
  }
  deriving (GetDeploymentConfig -> GetDeploymentConfig -> Bool
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]
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
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. 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
-- Amazon Web Services account.
newGetDeploymentConfig ::
  -- | 'deploymentConfigName'
  Prelude.Text ->
  GetDeploymentConfig
newGetDeploymentConfig :: Text -> GetDeploymentConfig
newGetDeploymentConfig Text
pDeploymentConfigName_ =
  GetDeploymentConfig'
    { $sel:deploymentConfigName:GetDeploymentConfig' :: Text
deploymentConfigName =
        Text
pDeploymentConfigName_
    }

-- | The name of a deployment configuration associated with the IAM user or
-- Amazon Web Services account.
getDeploymentConfig_deploymentConfigName :: Lens.Lens' GetDeploymentConfig Prelude.Text
getDeploymentConfig_deploymentConfigName :: Lens' GetDeploymentConfig Text
getDeploymentConfig_deploymentConfigName = 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 :: (Service -> Service)
-> GetDeploymentConfig -> Request GetDeploymentConfig
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDeploymentConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentConfig)))
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 ->
          Maybe DeploymentConfigInfo -> Int -> GetDeploymentConfigResponse
GetDeploymentConfigResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"deploymentConfigInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetDeploymentConfig where
  hashWithSalt :: Int -> GetDeploymentConfig -> Int
hashWithSalt Int
_salt GetDeploymentConfig' {Text
deploymentConfigName :: Text
$sel:deploymentConfigName:GetDeploymentConfig' :: GetDeploymentConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deploymentConfigName

instance Prelude.NFData GetDeploymentConfig where
  rnf :: GetDeploymentConfig -> ()
rnf GetDeploymentConfig' {Text
deploymentConfigName :: Text
$sel:deploymentConfigName:GetDeploymentConfig' :: GetDeploymentConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
deploymentConfigName

instance Data.ToHeaders GetDeploymentConfig where
  toHeaders :: GetDeploymentConfig -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"CodeDeploy_20141006.GetDeploymentConfig" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetDeploymentConfig where
  toJSON :: GetDeploymentConfig -> Value
toJSON GetDeploymentConfig' {Text
deploymentConfigName :: Text
$sel:deploymentConfigName:GetDeploymentConfig' :: GetDeploymentConfig -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"deploymentConfigName"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deploymentConfigName
              )
          ]
      )

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

instance Data.ToQuery GetDeploymentConfig where
  toQuery :: GetDeploymentConfig -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:deploymentConfigInfo:GetDeploymentConfigResponse' :: Maybe DeploymentConfigInfo
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 :: Lens' GetDeploymentConfigResponse (Maybe DeploymentConfigInfo)
getDeploymentConfigResponse_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 :: Lens' GetDeploymentConfigResponse Int
getDeploymentConfigResponse_httpStatus = 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 where
  rnf :: GetDeploymentConfigResponse -> ()
rnf GetDeploymentConfigResponse' {Int
Maybe DeploymentConfigInfo
httpStatus :: Int
deploymentConfigInfo :: Maybe DeploymentConfigInfo
$sel:httpStatus:GetDeploymentConfigResponse' :: GetDeploymentConfigResponse -> Int
$sel:deploymentConfigInfo:GetDeploymentConfigResponse' :: GetDeploymentConfigResponse -> Maybe DeploymentConfigInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DeploymentConfigInfo
deploymentConfigInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus