{-# 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.Scheduler.DeleteScheduleGroup
-- 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 the specified schedule group. Deleting a schedule group results
-- in EventBridge Scheduler deleting all schedules associated with the
-- group. When you delete a group, it remains in a @DELETING@ state until
-- all of its associated schedules are deleted. Schedules associated with
-- the group that are set to run while the schedule group is in the process
-- of being deleted might continue to invoke their targets until the
-- schedule group and its associated schedules are deleted.
--
-- This operation is eventually consistent.
module Amazonka.Scheduler.DeleteScheduleGroup
  ( -- * Creating a Request
    DeleteScheduleGroup (..),
    newDeleteScheduleGroup,

    -- * Request Lenses
    deleteScheduleGroup_clientToken,
    deleteScheduleGroup_name,

    -- * Destructuring the Response
    DeleteScheduleGroupResponse (..),
    newDeleteScheduleGroupResponse,

    -- * Response Lenses
    deleteScheduleGroupResponse_httpStatus,
  )
where

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
import Amazonka.Scheduler.Types

-- | /See:/ 'newDeleteScheduleGroup' smart constructor.
data DeleteScheduleGroup = DeleteScheduleGroup'
  { -- | Unique, case-sensitive identifier you provide to ensure the idempotency
    -- of the request. If you do not specify a client token, EventBridge
    -- Scheduler uses a randomly generated token for the request to ensure
    -- idempotency.
    DeleteScheduleGroup -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the schedule group to delete.
    DeleteScheduleGroup -> Text
name :: Prelude.Text
  }
  deriving (DeleteScheduleGroup -> DeleteScheduleGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteScheduleGroup -> DeleteScheduleGroup -> Bool
$c/= :: DeleteScheduleGroup -> DeleteScheduleGroup -> Bool
== :: DeleteScheduleGroup -> DeleteScheduleGroup -> Bool
$c== :: DeleteScheduleGroup -> DeleteScheduleGroup -> Bool
Prelude.Eq, ReadPrec [DeleteScheduleGroup]
ReadPrec DeleteScheduleGroup
Int -> ReadS DeleteScheduleGroup
ReadS [DeleteScheduleGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteScheduleGroup]
$creadListPrec :: ReadPrec [DeleteScheduleGroup]
readPrec :: ReadPrec DeleteScheduleGroup
$creadPrec :: ReadPrec DeleteScheduleGroup
readList :: ReadS [DeleteScheduleGroup]
$creadList :: ReadS [DeleteScheduleGroup]
readsPrec :: Int -> ReadS DeleteScheduleGroup
$creadsPrec :: Int -> ReadS DeleteScheduleGroup
Prelude.Read, Int -> DeleteScheduleGroup -> ShowS
[DeleteScheduleGroup] -> ShowS
DeleteScheduleGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteScheduleGroup] -> ShowS
$cshowList :: [DeleteScheduleGroup] -> ShowS
show :: DeleteScheduleGroup -> String
$cshow :: DeleteScheduleGroup -> String
showsPrec :: Int -> DeleteScheduleGroup -> ShowS
$cshowsPrec :: Int -> DeleteScheduleGroup -> ShowS
Prelude.Show, forall x. Rep DeleteScheduleGroup x -> DeleteScheduleGroup
forall x. DeleteScheduleGroup -> Rep DeleteScheduleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteScheduleGroup x -> DeleteScheduleGroup
$cfrom :: forall x. DeleteScheduleGroup -> Rep DeleteScheduleGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteScheduleGroup' 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:
--
-- 'clientToken', 'deleteScheduleGroup_clientToken' - Unique, case-sensitive identifier you provide to ensure the idempotency
-- of the request. If you do not specify a client token, EventBridge
-- Scheduler uses a randomly generated token for the request to ensure
-- idempotency.
--
-- 'name', 'deleteScheduleGroup_name' - The name of the schedule group to delete.
newDeleteScheduleGroup ::
  -- | 'name'
  Prelude.Text ->
  DeleteScheduleGroup
newDeleteScheduleGroup :: Text -> DeleteScheduleGroup
newDeleteScheduleGroup Text
pName_ =
  DeleteScheduleGroup'
    { $sel:clientToken:DeleteScheduleGroup' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DeleteScheduleGroup' :: Text
name = Text
pName_
    }

-- | Unique, case-sensitive identifier you provide to ensure the idempotency
-- of the request. If you do not specify a client token, EventBridge
-- Scheduler uses a randomly generated token for the request to ensure
-- idempotency.
deleteScheduleGroup_clientToken :: Lens.Lens' DeleteScheduleGroup (Prelude.Maybe Prelude.Text)
deleteScheduleGroup_clientToken :: Lens' DeleteScheduleGroup (Maybe Text)
deleteScheduleGroup_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteScheduleGroup' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteScheduleGroup' :: DeleteScheduleGroup -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteScheduleGroup
s@DeleteScheduleGroup' {} Maybe Text
a -> DeleteScheduleGroup
s {$sel:clientToken:DeleteScheduleGroup' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteScheduleGroup)

-- | The name of the schedule group to delete.
deleteScheduleGroup_name :: Lens.Lens' DeleteScheduleGroup Prelude.Text
deleteScheduleGroup_name :: Lens' DeleteScheduleGroup Text
deleteScheduleGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteScheduleGroup' {Text
name :: Text
$sel:name:DeleteScheduleGroup' :: DeleteScheduleGroup -> Text
name} -> Text
name) (\s :: DeleteScheduleGroup
s@DeleteScheduleGroup' {} Text
a -> DeleteScheduleGroup
s {$sel:name:DeleteScheduleGroup' :: Text
name = Text
a} :: DeleteScheduleGroup)

instance Core.AWSRequest DeleteScheduleGroup where
  type
    AWSResponse DeleteScheduleGroup =
      DeleteScheduleGroupResponse
  request :: (Service -> Service)
-> DeleteScheduleGroup -> Request DeleteScheduleGroup
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteScheduleGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteScheduleGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteScheduleGroupResponse
DeleteScheduleGroupResponse'
            forall (f :: * -> *) a b. Functor 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 DeleteScheduleGroup where
  hashWithSalt :: Int -> DeleteScheduleGroup -> Int
hashWithSalt Int
_salt DeleteScheduleGroup' {Maybe Text
Text
name :: Text
clientToken :: Maybe Text
$sel:name:DeleteScheduleGroup' :: DeleteScheduleGroup -> Text
$sel:clientToken:DeleteScheduleGroup' :: DeleteScheduleGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeleteScheduleGroup where
  rnf :: DeleteScheduleGroup -> ()
rnf DeleteScheduleGroup' {Maybe Text
Text
name :: Text
clientToken :: Maybe Text
$sel:name:DeleteScheduleGroup' :: DeleteScheduleGroup -> Text
$sel:clientToken:DeleteScheduleGroup' :: DeleteScheduleGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

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

instance Data.ToPath DeleteScheduleGroup where
  toPath :: DeleteScheduleGroup -> ByteString
toPath DeleteScheduleGroup' {Maybe Text
Text
name :: Text
clientToken :: Maybe Text
$sel:name:DeleteScheduleGroup' :: DeleteScheduleGroup -> Text
$sel:clientToken:DeleteScheduleGroup' :: DeleteScheduleGroup -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/schedule-groups/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name]

instance Data.ToQuery DeleteScheduleGroup where
  toQuery :: DeleteScheduleGroup -> QueryString
toQuery DeleteScheduleGroup' {Maybe Text
Text
name :: Text
clientToken :: Maybe Text
$sel:name:DeleteScheduleGroup' :: DeleteScheduleGroup -> Text
$sel:clientToken:DeleteScheduleGroup' :: DeleteScheduleGroup -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"clientToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clientToken]

-- | /See:/ 'newDeleteScheduleGroupResponse' smart constructor.
data DeleteScheduleGroupResponse = DeleteScheduleGroupResponse'
  { -- | The response's http status code.
    DeleteScheduleGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteScheduleGroupResponse -> DeleteScheduleGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteScheduleGroupResponse -> DeleteScheduleGroupResponse -> Bool
$c/= :: DeleteScheduleGroupResponse -> DeleteScheduleGroupResponse -> Bool
== :: DeleteScheduleGroupResponse -> DeleteScheduleGroupResponse -> Bool
$c== :: DeleteScheduleGroupResponse -> DeleteScheduleGroupResponse -> Bool
Prelude.Eq, ReadPrec [DeleteScheduleGroupResponse]
ReadPrec DeleteScheduleGroupResponse
Int -> ReadS DeleteScheduleGroupResponse
ReadS [DeleteScheduleGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteScheduleGroupResponse]
$creadListPrec :: ReadPrec [DeleteScheduleGroupResponse]
readPrec :: ReadPrec DeleteScheduleGroupResponse
$creadPrec :: ReadPrec DeleteScheduleGroupResponse
readList :: ReadS [DeleteScheduleGroupResponse]
$creadList :: ReadS [DeleteScheduleGroupResponse]
readsPrec :: Int -> ReadS DeleteScheduleGroupResponse
$creadsPrec :: Int -> ReadS DeleteScheduleGroupResponse
Prelude.Read, Int -> DeleteScheduleGroupResponse -> ShowS
[DeleteScheduleGroupResponse] -> ShowS
DeleteScheduleGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteScheduleGroupResponse] -> ShowS
$cshowList :: [DeleteScheduleGroupResponse] -> ShowS
show :: DeleteScheduleGroupResponse -> String
$cshow :: DeleteScheduleGroupResponse -> String
showsPrec :: Int -> DeleteScheduleGroupResponse -> ShowS
$cshowsPrec :: Int -> DeleteScheduleGroupResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteScheduleGroupResponse x -> DeleteScheduleGroupResponse
forall x.
DeleteScheduleGroupResponse -> Rep DeleteScheduleGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteScheduleGroupResponse x -> DeleteScheduleGroupResponse
$cfrom :: forall x.
DeleteScheduleGroupResponse -> Rep DeleteScheduleGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteScheduleGroupResponse' 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:
--
-- 'httpStatus', 'deleteScheduleGroupResponse_httpStatus' - The response's http status code.
newDeleteScheduleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteScheduleGroupResponse
newDeleteScheduleGroupResponse :: Int -> DeleteScheduleGroupResponse
newDeleteScheduleGroupResponse Int
pHttpStatus_ =
  DeleteScheduleGroupResponse'
    { $sel:httpStatus:DeleteScheduleGroupResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteScheduleGroupResponse where
  rnf :: DeleteScheduleGroupResponse -> ()
rnf DeleteScheduleGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteScheduleGroupResponse' :: DeleteScheduleGroupResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus