{-# 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.SSMContacts.StopEngagement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops an engagement before it finishes the final stage of the escalation
-- plan or engagement plan. Further contacts aren\'t engaged.
module Amazonka.SSMContacts.StopEngagement
  ( -- * Creating a Request
    StopEngagement (..),
    newStopEngagement,

    -- * Request Lenses
    stopEngagement_reason,
    stopEngagement_engagementId,

    -- * Destructuring the Response
    StopEngagementResponse (..),
    newStopEngagementResponse,

    -- * Response Lenses
    stopEngagementResponse_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.SSMContacts.Types

-- | /See:/ 'newStopEngagement' smart constructor.
data StopEngagement = StopEngagement'
  { -- | The reason that you\'re stopping the engagement.
    StopEngagement -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the engagement.
    StopEngagement -> Text
engagementId :: Prelude.Text
  }
  deriving (StopEngagement -> StopEngagement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopEngagement -> StopEngagement -> Bool
$c/= :: StopEngagement -> StopEngagement -> Bool
== :: StopEngagement -> StopEngagement -> Bool
$c== :: StopEngagement -> StopEngagement -> Bool
Prelude.Eq, ReadPrec [StopEngagement]
ReadPrec StopEngagement
Int -> ReadS StopEngagement
ReadS [StopEngagement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopEngagement]
$creadListPrec :: ReadPrec [StopEngagement]
readPrec :: ReadPrec StopEngagement
$creadPrec :: ReadPrec StopEngagement
readList :: ReadS [StopEngagement]
$creadList :: ReadS [StopEngagement]
readsPrec :: Int -> ReadS StopEngagement
$creadsPrec :: Int -> ReadS StopEngagement
Prelude.Read, Int -> StopEngagement -> ShowS
[StopEngagement] -> ShowS
StopEngagement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopEngagement] -> ShowS
$cshowList :: [StopEngagement] -> ShowS
show :: StopEngagement -> String
$cshow :: StopEngagement -> String
showsPrec :: Int -> StopEngagement -> ShowS
$cshowsPrec :: Int -> StopEngagement -> ShowS
Prelude.Show, forall x. Rep StopEngagement x -> StopEngagement
forall x. StopEngagement -> Rep StopEngagement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopEngagement x -> StopEngagement
$cfrom :: forall x. StopEngagement -> Rep StopEngagement x
Prelude.Generic)

-- |
-- Create a value of 'StopEngagement' 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:
--
-- 'reason', 'stopEngagement_reason' - The reason that you\'re stopping the engagement.
--
-- 'engagementId', 'stopEngagement_engagementId' - The Amazon Resource Name (ARN) of the engagement.
newStopEngagement ::
  -- | 'engagementId'
  Prelude.Text ->
  StopEngagement
newStopEngagement :: Text -> StopEngagement
newStopEngagement Text
pEngagementId_ =
  StopEngagement'
    { $sel:reason:StopEngagement' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing,
      $sel:engagementId:StopEngagement' :: Text
engagementId = Text
pEngagementId_
    }

-- | The reason that you\'re stopping the engagement.
stopEngagement_reason :: Lens.Lens' StopEngagement (Prelude.Maybe Prelude.Text)
stopEngagement_reason :: Lens' StopEngagement (Maybe Text)
stopEngagement_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopEngagement' {Maybe Text
reason :: Maybe Text
$sel:reason:StopEngagement' :: StopEngagement -> Maybe Text
reason} -> Maybe Text
reason) (\s :: StopEngagement
s@StopEngagement' {} Maybe Text
a -> StopEngagement
s {$sel:reason:StopEngagement' :: Maybe Text
reason = Maybe Text
a} :: StopEngagement)

-- | The Amazon Resource Name (ARN) of the engagement.
stopEngagement_engagementId :: Lens.Lens' StopEngagement Prelude.Text
stopEngagement_engagementId :: Lens' StopEngagement Text
stopEngagement_engagementId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopEngagement' {Text
engagementId :: Text
$sel:engagementId:StopEngagement' :: StopEngagement -> Text
engagementId} -> Text
engagementId) (\s :: StopEngagement
s@StopEngagement' {} Text
a -> StopEngagement
s {$sel:engagementId:StopEngagement' :: Text
engagementId = Text
a} :: StopEngagement)

instance Core.AWSRequest StopEngagement where
  type
    AWSResponse StopEngagement =
      StopEngagementResponse
  request :: (Service -> Service) -> StopEngagement -> Request StopEngagement
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 StopEngagement
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopEngagement)))
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 -> StopEngagementResponse
StopEngagementResponse'
            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 StopEngagement where
  hashWithSalt :: Int -> StopEngagement -> Int
hashWithSalt Int
_salt StopEngagement' {Maybe Text
Text
engagementId :: Text
reason :: Maybe Text
$sel:engagementId:StopEngagement' :: StopEngagement -> Text
$sel:reason:StopEngagement' :: StopEngagement -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
engagementId

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

instance Data.ToHeaders StopEngagement where
  toHeaders :: StopEngagement -> 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
"SSMContacts.StopEngagement" :: 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 StopEngagement where
  toJSON :: StopEngagement -> Value
toJSON StopEngagement' {Maybe Text
Text
engagementId :: Text
reason :: Maybe Text
$sel:engagementId:StopEngagement' :: StopEngagement -> Text
$sel:reason:StopEngagement' :: StopEngagement -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Reason" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
reason,
            forall a. a -> Maybe a
Prelude.Just (Key
"EngagementId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
engagementId)
          ]
      )

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

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

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

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

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

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