{-# 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.GetDeploymentGroup
-- 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 group.
module Amazonka.CodeDeploy.GetDeploymentGroup
  ( -- * Creating a Request
    GetDeploymentGroup (..),
    newGetDeploymentGroup,

    -- * Request Lenses
    getDeploymentGroup_applicationName,
    getDeploymentGroup_deploymentGroupName,

    -- * Destructuring the Response
    GetDeploymentGroupResponse (..),
    newGetDeploymentGroupResponse,

    -- * Response Lenses
    getDeploymentGroupResponse_deploymentGroupInfo,
    getDeploymentGroupResponse_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 @GetDeploymentGroup@ operation.
--
-- /See:/ 'newGetDeploymentGroup' smart constructor.
data GetDeploymentGroup = GetDeploymentGroup'
  { -- | The name of an CodeDeploy application associated with the IAM user or
    -- Amazon Web Services account.
    GetDeploymentGroup -> Text
applicationName :: Prelude.Text,
    -- | The name of a deployment group for the specified application.
    GetDeploymentGroup -> Text
deploymentGroupName :: Prelude.Text
  }
  deriving (GetDeploymentGroup -> GetDeploymentGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeploymentGroup -> GetDeploymentGroup -> Bool
$c/= :: GetDeploymentGroup -> GetDeploymentGroup -> Bool
== :: GetDeploymentGroup -> GetDeploymentGroup -> Bool
$c== :: GetDeploymentGroup -> GetDeploymentGroup -> Bool
Prelude.Eq, ReadPrec [GetDeploymentGroup]
ReadPrec GetDeploymentGroup
Int -> ReadS GetDeploymentGroup
ReadS [GetDeploymentGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeploymentGroup]
$creadListPrec :: ReadPrec [GetDeploymentGroup]
readPrec :: ReadPrec GetDeploymentGroup
$creadPrec :: ReadPrec GetDeploymentGroup
readList :: ReadS [GetDeploymentGroup]
$creadList :: ReadS [GetDeploymentGroup]
readsPrec :: Int -> ReadS GetDeploymentGroup
$creadsPrec :: Int -> ReadS GetDeploymentGroup
Prelude.Read, Int -> GetDeploymentGroup -> ShowS
[GetDeploymentGroup] -> ShowS
GetDeploymentGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeploymentGroup] -> ShowS
$cshowList :: [GetDeploymentGroup] -> ShowS
show :: GetDeploymentGroup -> String
$cshow :: GetDeploymentGroup -> String
showsPrec :: Int -> GetDeploymentGroup -> ShowS
$cshowsPrec :: Int -> GetDeploymentGroup -> ShowS
Prelude.Show, forall x. Rep GetDeploymentGroup x -> GetDeploymentGroup
forall x. GetDeploymentGroup -> Rep GetDeploymentGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeploymentGroup x -> GetDeploymentGroup
$cfrom :: forall x. GetDeploymentGroup -> Rep GetDeploymentGroup x
Prelude.Generic)

-- |
-- Create a value of 'GetDeploymentGroup' 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:
--
-- 'applicationName', 'getDeploymentGroup_applicationName' - The name of an CodeDeploy application associated with the IAM user or
-- Amazon Web Services account.
--
-- 'deploymentGroupName', 'getDeploymentGroup_deploymentGroupName' - The name of a deployment group for the specified application.
newGetDeploymentGroup ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'deploymentGroupName'
  Prelude.Text ->
  GetDeploymentGroup
newGetDeploymentGroup :: Text -> Text -> GetDeploymentGroup
newGetDeploymentGroup
  Text
pApplicationName_
  Text
pDeploymentGroupName_ =
    GetDeploymentGroup'
      { $sel:applicationName:GetDeploymentGroup' :: Text
applicationName =
          Text
pApplicationName_,
        $sel:deploymentGroupName:GetDeploymentGroup' :: Text
deploymentGroupName = Text
pDeploymentGroupName_
      }

-- | The name of an CodeDeploy application associated with the IAM user or
-- Amazon Web Services account.
getDeploymentGroup_applicationName :: Lens.Lens' GetDeploymentGroup Prelude.Text
getDeploymentGroup_applicationName :: Lens' GetDeploymentGroup Text
getDeploymentGroup_applicationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentGroup' {Text
applicationName :: Text
$sel:applicationName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
applicationName} -> Text
applicationName) (\s :: GetDeploymentGroup
s@GetDeploymentGroup' {} Text
a -> GetDeploymentGroup
s {$sel:applicationName:GetDeploymentGroup' :: Text
applicationName = Text
a} :: GetDeploymentGroup)

-- | The name of a deployment group for the specified application.
getDeploymentGroup_deploymentGroupName :: Lens.Lens' GetDeploymentGroup Prelude.Text
getDeploymentGroup_deploymentGroupName :: Lens' GetDeploymentGroup Text
getDeploymentGroup_deploymentGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentGroup' {Text
deploymentGroupName :: Text
$sel:deploymentGroupName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
deploymentGroupName} -> Text
deploymentGroupName) (\s :: GetDeploymentGroup
s@GetDeploymentGroup' {} Text
a -> GetDeploymentGroup
s {$sel:deploymentGroupName:GetDeploymentGroup' :: Text
deploymentGroupName = Text
a} :: GetDeploymentGroup)

instance Core.AWSRequest GetDeploymentGroup where
  type
    AWSResponse GetDeploymentGroup =
      GetDeploymentGroupResponse
  request :: (Service -> Service)
-> GetDeploymentGroup -> Request GetDeploymentGroup
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 GetDeploymentGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentGroup)))
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 DeploymentGroupInfo -> Int -> GetDeploymentGroupResponse
GetDeploymentGroupResponse'
            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
"deploymentGroupInfo")
            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 GetDeploymentGroup where
  hashWithSalt :: Int -> GetDeploymentGroup -> Int
hashWithSalt Int
_salt GetDeploymentGroup' {Text
deploymentGroupName :: Text
applicationName :: Text
$sel:deploymentGroupName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
$sel:applicationName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deploymentGroupName

instance Prelude.NFData GetDeploymentGroup where
  rnf :: GetDeploymentGroup -> ()
rnf GetDeploymentGroup' {Text
deploymentGroupName :: Text
applicationName :: Text
$sel:deploymentGroupName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
$sel:applicationName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deploymentGroupName

instance Data.ToHeaders GetDeploymentGroup where
  toHeaders :: GetDeploymentGroup -> 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.GetDeploymentGroup" ::
                          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 GetDeploymentGroup where
  toJSON :: GetDeploymentGroup -> Value
toJSON GetDeploymentGroup' {Text
deploymentGroupName :: Text
applicationName :: Text
$sel:deploymentGroupName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
$sel:applicationName:GetDeploymentGroup' :: GetDeploymentGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"applicationName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
applicationName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"deploymentGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deploymentGroupName)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetDeploymentGroupResponse' 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:
--
-- 'deploymentGroupInfo', 'getDeploymentGroupResponse_deploymentGroupInfo' - Information about the deployment group.
--
-- 'httpStatus', 'getDeploymentGroupResponse_httpStatus' - The response's http status code.
newGetDeploymentGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDeploymentGroupResponse
newGetDeploymentGroupResponse :: Int -> GetDeploymentGroupResponse
newGetDeploymentGroupResponse Int
pHttpStatus_ =
  GetDeploymentGroupResponse'
    { $sel:deploymentGroupInfo:GetDeploymentGroupResponse' :: Maybe DeploymentGroupInfo
deploymentGroupInfo =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDeploymentGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the deployment group.
getDeploymentGroupResponse_deploymentGroupInfo :: Lens.Lens' GetDeploymentGroupResponse (Prelude.Maybe DeploymentGroupInfo)
getDeploymentGroupResponse_deploymentGroupInfo :: Lens' GetDeploymentGroupResponse (Maybe DeploymentGroupInfo)
getDeploymentGroupResponse_deploymentGroupInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentGroupResponse' {Maybe DeploymentGroupInfo
deploymentGroupInfo :: Maybe DeploymentGroupInfo
$sel:deploymentGroupInfo:GetDeploymentGroupResponse' :: GetDeploymentGroupResponse -> Maybe DeploymentGroupInfo
deploymentGroupInfo} -> Maybe DeploymentGroupInfo
deploymentGroupInfo) (\s :: GetDeploymentGroupResponse
s@GetDeploymentGroupResponse' {} Maybe DeploymentGroupInfo
a -> GetDeploymentGroupResponse
s {$sel:deploymentGroupInfo:GetDeploymentGroupResponse' :: Maybe DeploymentGroupInfo
deploymentGroupInfo = Maybe DeploymentGroupInfo
a} :: GetDeploymentGroupResponse)

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

instance Prelude.NFData GetDeploymentGroupResponse where
  rnf :: GetDeploymentGroupResponse -> ()
rnf GetDeploymentGroupResponse' {Int
Maybe DeploymentGroupInfo
httpStatus :: Int
deploymentGroupInfo :: Maybe DeploymentGroupInfo
$sel:httpStatus:GetDeploymentGroupResponse' :: GetDeploymentGroupResponse -> Int
$sel:deploymentGroupInfo:GetDeploymentGroupResponse' :: GetDeploymentGroupResponse -> Maybe DeploymentGroupInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DeploymentGroupInfo
deploymentGroupInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus