{-# 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-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 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.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 @GetDeploymentGroup@ operation.
--
-- /See:/ 'newGetDeploymentGroup' smart constructor.
data GetDeploymentGroup = GetDeploymentGroup'
  { -- | The name of an AWS CodeDeploy application associated with the IAM user
    -- or AWS 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
(GetDeploymentGroup -> GetDeploymentGroup -> Bool)
-> (GetDeploymentGroup -> GetDeploymentGroup -> Bool)
-> Eq GetDeploymentGroup
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]
(Int -> ReadS GetDeploymentGroup)
-> ReadS [GetDeploymentGroup]
-> ReadPrec GetDeploymentGroup
-> ReadPrec [GetDeploymentGroup]
-> Read 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
(Int -> GetDeploymentGroup -> ShowS)
-> (GetDeploymentGroup -> String)
-> ([GetDeploymentGroup] -> ShowS)
-> Show GetDeploymentGroup
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. GetDeploymentGroup -> Rep GetDeploymentGroup x)
-> (forall x. Rep GetDeploymentGroup x -> GetDeploymentGroup)
-> Generic GetDeploymentGroup
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 AWS CodeDeploy application associated with the IAM user
-- or AWS 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' :: Text -> Text -> GetDeploymentGroup
GetDeploymentGroup'
      { $sel:applicationName:GetDeploymentGroup' :: Text
applicationName =
          Text
pApplicationName_,
        $sel:deploymentGroupName:GetDeploymentGroup' :: Text
deploymentGroupName = Text
pDeploymentGroupName_
      }

-- | The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
getDeploymentGroup_applicationName :: Lens.Lens' GetDeploymentGroup Prelude.Text
getDeploymentGroup_applicationName :: (Text -> f Text) -> GetDeploymentGroup -> f GetDeploymentGroup
getDeploymentGroup_applicationName = (GetDeploymentGroup -> Text)
-> (GetDeploymentGroup -> Text -> GetDeploymentGroup)
-> Lens GetDeploymentGroup GetDeploymentGroup Text Text
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 :: (Text -> f Text) -> GetDeploymentGroup -> f GetDeploymentGroup
getDeploymentGroup_deploymentGroupName = (GetDeploymentGroup -> Text)
-> (GetDeploymentGroup -> Text -> GetDeploymentGroup)
-> Lens GetDeploymentGroup GetDeploymentGroup Text Text
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 :: GetDeploymentGroup -> Request GetDeploymentGroup
request = Service -> GetDeploymentGroup -> Request GetDeploymentGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDeploymentGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDeploymentGroup))
-> Logger
-> Service
-> Proxy GetDeploymentGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeploymentGroup)))
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 DeploymentGroupInfo -> Int -> GetDeploymentGroupResponse
GetDeploymentGroupResponse'
            (Maybe DeploymentGroupInfo -> Int -> GetDeploymentGroupResponse)
-> Either String (Maybe DeploymentGroupInfo)
-> Either String (Int -> GetDeploymentGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DeploymentGroupInfo)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deploymentGroupInfo")
            Either String (Int -> GetDeploymentGroupResponse)
-> Either String Int -> Either String GetDeploymentGroupResponse
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 GetDeploymentGroup

instance Prelude.NFData GetDeploymentGroup

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

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

instance Core.ToQuery GetDeploymentGroup where
  toQuery :: GetDeploymentGroup -> QueryString
toQuery = QueryString -> GetDeploymentGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetDeploymentGroupResponse -> GetDeploymentGroupResponse -> Bool)
-> (GetDeploymentGroupResponse
    -> GetDeploymentGroupResponse -> Bool)
-> Eq GetDeploymentGroupResponse
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]
(Int -> ReadS GetDeploymentGroupResponse)
-> ReadS [GetDeploymentGroupResponse]
-> ReadPrec GetDeploymentGroupResponse
-> ReadPrec [GetDeploymentGroupResponse]
-> Read 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
(Int -> GetDeploymentGroupResponse -> ShowS)
-> (GetDeploymentGroupResponse -> String)
-> ([GetDeploymentGroupResponse] -> ShowS)
-> Show GetDeploymentGroupResponse
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.
 GetDeploymentGroupResponse -> Rep GetDeploymentGroupResponse x)
-> (forall x.
    Rep GetDeploymentGroupResponse x -> GetDeploymentGroupResponse)
-> Generic GetDeploymentGroupResponse
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' :: Maybe DeploymentGroupInfo -> Int -> GetDeploymentGroupResponse
GetDeploymentGroupResponse'
    { $sel:deploymentGroupInfo:GetDeploymentGroupResponse' :: Maybe DeploymentGroupInfo
deploymentGroupInfo =
        Maybe 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 :: (Maybe DeploymentGroupInfo -> f (Maybe DeploymentGroupInfo))
-> GetDeploymentGroupResponse -> f GetDeploymentGroupResponse
getDeploymentGroupResponse_deploymentGroupInfo = (GetDeploymentGroupResponse -> Maybe DeploymentGroupInfo)
-> (GetDeploymentGroupResponse
    -> Maybe DeploymentGroupInfo -> GetDeploymentGroupResponse)
-> Lens
     GetDeploymentGroupResponse
     GetDeploymentGroupResponse
     (Maybe DeploymentGroupInfo)
     (Maybe 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 :: (Int -> f Int)
-> GetDeploymentGroupResponse -> f GetDeploymentGroupResponse
getDeploymentGroupResponse_httpStatus = (GetDeploymentGroupResponse -> Int)
-> (GetDeploymentGroupResponse
    -> Int -> GetDeploymentGroupResponse)
-> Lens
     GetDeploymentGroupResponse GetDeploymentGroupResponse Int Int
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