{-# 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.DeleteDeploymentGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a deployment group.
module Amazonka.CodeDeploy.DeleteDeploymentGroup
  ( -- * Creating a Request
    DeleteDeploymentGroup (..),
    newDeleteDeploymentGroup,

    -- * Request Lenses
    deleteDeploymentGroup_applicationName,
    deleteDeploymentGroup_deploymentGroupName,

    -- * Destructuring the Response
    DeleteDeploymentGroupResponse (..),
    newDeleteDeploymentGroupResponse,

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

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

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

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

instance Core.AWSRequest DeleteDeploymentGroup where
  type
    AWSResponse DeleteDeploymentGroup =
      DeleteDeploymentGroupResponse
  request :: (Service -> Service)
-> DeleteDeploymentGroup -> Request DeleteDeploymentGroup
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 DeleteDeploymentGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDeploymentGroup)))
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 [AutoScalingGroup] -> Int -> DeleteDeploymentGroupResponse
DeleteDeploymentGroupResponse'
            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
"hooksNotCleanedUp"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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 DeleteDeploymentGroup where
  hashWithSalt :: Int -> DeleteDeploymentGroup -> Int
hashWithSalt Int
_salt DeleteDeploymentGroup' {Text
deploymentGroupName :: Text
applicationName :: Text
$sel:deploymentGroupName:DeleteDeploymentGroup' :: DeleteDeploymentGroup -> Text
$sel:applicationName:DeleteDeploymentGroup' :: DeleteDeploymentGroup -> 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 DeleteDeploymentGroup where
  rnf :: DeleteDeploymentGroup -> ()
rnf DeleteDeploymentGroup' {Text
deploymentGroupName :: Text
applicationName :: Text
$sel:deploymentGroupName:DeleteDeploymentGroup' :: DeleteDeploymentGroup -> Text
$sel:applicationName:DeleteDeploymentGroup' :: DeleteDeploymentGroup -> 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 DeleteDeploymentGroup where
  toHeaders :: DeleteDeploymentGroup -> 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.DeleteDeploymentGroup" ::
                          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 DeleteDeploymentGroup where
  toJSON :: DeleteDeploymentGroup -> Value
toJSON DeleteDeploymentGroup' {Text
deploymentGroupName :: Text
applicationName :: Text
$sel:deploymentGroupName:DeleteDeploymentGroup' :: DeleteDeploymentGroup -> Text
$sel:applicationName:DeleteDeploymentGroup' :: DeleteDeploymentGroup -> 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 DeleteDeploymentGroup where
  toPath :: DeleteDeploymentGroup -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the output of a @DeleteDeploymentGroup@ operation.
--
-- /See:/ 'newDeleteDeploymentGroupResponse' smart constructor.
data DeleteDeploymentGroupResponse = DeleteDeploymentGroupResponse'
  { -- | If the output contains no data, and the corresponding deployment group
    -- contained at least one Auto Scaling group, CodeDeploy successfully
    -- removed all corresponding Auto Scaling lifecycle event hooks from the
    -- Amazon EC2 instances in the Auto Scaling group. If the output contains
    -- data, CodeDeploy could not remove some Auto Scaling lifecycle event
    -- hooks from the Amazon EC2 instances in the Auto Scaling group.
    DeleteDeploymentGroupResponse -> Maybe [AutoScalingGroup]
hooksNotCleanedUp :: Prelude.Maybe [AutoScalingGroup],
    -- | The response's http status code.
    DeleteDeploymentGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteDeploymentGroupResponse
-> DeleteDeploymentGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDeploymentGroupResponse
-> DeleteDeploymentGroupResponse -> Bool
$c/= :: DeleteDeploymentGroupResponse
-> DeleteDeploymentGroupResponse -> Bool
== :: DeleteDeploymentGroupResponse
-> DeleteDeploymentGroupResponse -> Bool
$c== :: DeleteDeploymentGroupResponse
-> DeleteDeploymentGroupResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDeploymentGroupResponse]
ReadPrec DeleteDeploymentGroupResponse
Int -> ReadS DeleteDeploymentGroupResponse
ReadS [DeleteDeploymentGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDeploymentGroupResponse]
$creadListPrec :: ReadPrec [DeleteDeploymentGroupResponse]
readPrec :: ReadPrec DeleteDeploymentGroupResponse
$creadPrec :: ReadPrec DeleteDeploymentGroupResponse
readList :: ReadS [DeleteDeploymentGroupResponse]
$creadList :: ReadS [DeleteDeploymentGroupResponse]
readsPrec :: Int -> ReadS DeleteDeploymentGroupResponse
$creadsPrec :: Int -> ReadS DeleteDeploymentGroupResponse
Prelude.Read, Int -> DeleteDeploymentGroupResponse -> ShowS
[DeleteDeploymentGroupResponse] -> ShowS
DeleteDeploymentGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDeploymentGroupResponse] -> ShowS
$cshowList :: [DeleteDeploymentGroupResponse] -> ShowS
show :: DeleteDeploymentGroupResponse -> String
$cshow :: DeleteDeploymentGroupResponse -> String
showsPrec :: Int -> DeleteDeploymentGroupResponse -> ShowS
$cshowsPrec :: Int -> DeleteDeploymentGroupResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteDeploymentGroupResponse x
-> DeleteDeploymentGroupResponse
forall x.
DeleteDeploymentGroupResponse
-> Rep DeleteDeploymentGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDeploymentGroupResponse x
-> DeleteDeploymentGroupResponse
$cfrom :: forall x.
DeleteDeploymentGroupResponse
-> Rep DeleteDeploymentGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDeploymentGroupResponse' 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:
--
-- 'hooksNotCleanedUp', 'deleteDeploymentGroupResponse_hooksNotCleanedUp' - If the output contains no data, and the corresponding deployment group
-- contained at least one Auto Scaling group, CodeDeploy successfully
-- removed all corresponding Auto Scaling lifecycle event hooks from the
-- Amazon EC2 instances in the Auto Scaling group. If the output contains
-- data, CodeDeploy could not remove some Auto Scaling lifecycle event
-- hooks from the Amazon EC2 instances in the Auto Scaling group.
--
-- 'httpStatus', 'deleteDeploymentGroupResponse_httpStatus' - The response's http status code.
newDeleteDeploymentGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDeploymentGroupResponse
newDeleteDeploymentGroupResponse :: Int -> DeleteDeploymentGroupResponse
newDeleteDeploymentGroupResponse Int
pHttpStatus_ =
  DeleteDeploymentGroupResponse'
    { $sel:hooksNotCleanedUp:DeleteDeploymentGroupResponse' :: Maybe [AutoScalingGroup]
hooksNotCleanedUp =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDeploymentGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the output contains no data, and the corresponding deployment group
-- contained at least one Auto Scaling group, CodeDeploy successfully
-- removed all corresponding Auto Scaling lifecycle event hooks from the
-- Amazon EC2 instances in the Auto Scaling group. If the output contains
-- data, CodeDeploy could not remove some Auto Scaling lifecycle event
-- hooks from the Amazon EC2 instances in the Auto Scaling group.
deleteDeploymentGroupResponse_hooksNotCleanedUp :: Lens.Lens' DeleteDeploymentGroupResponse (Prelude.Maybe [AutoScalingGroup])
deleteDeploymentGroupResponse_hooksNotCleanedUp :: Lens' DeleteDeploymentGroupResponse (Maybe [AutoScalingGroup])
deleteDeploymentGroupResponse_hooksNotCleanedUp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDeploymentGroupResponse' {Maybe [AutoScalingGroup]
hooksNotCleanedUp :: Maybe [AutoScalingGroup]
$sel:hooksNotCleanedUp:DeleteDeploymentGroupResponse' :: DeleteDeploymentGroupResponse -> Maybe [AutoScalingGroup]
hooksNotCleanedUp} -> Maybe [AutoScalingGroup]
hooksNotCleanedUp) (\s :: DeleteDeploymentGroupResponse
s@DeleteDeploymentGroupResponse' {} Maybe [AutoScalingGroup]
a -> DeleteDeploymentGroupResponse
s {$sel:hooksNotCleanedUp:DeleteDeploymentGroupResponse' :: Maybe [AutoScalingGroup]
hooksNotCleanedUp = Maybe [AutoScalingGroup]
a} :: DeleteDeploymentGroupResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteDeploymentGroupResponse where
  rnf :: DeleteDeploymentGroupResponse -> ()
rnf DeleteDeploymentGroupResponse' {Int
Maybe [AutoScalingGroup]
httpStatus :: Int
hooksNotCleanedUp :: Maybe [AutoScalingGroup]
$sel:httpStatus:DeleteDeploymentGroupResponse' :: DeleteDeploymentGroupResponse -> Int
$sel:hooksNotCleanedUp:DeleteDeploymentGroupResponse' :: DeleteDeploymentGroupResponse -> Maybe [AutoScalingGroup]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AutoScalingGroup]
hooksNotCleanedUp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus