{-# 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-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)
--
-- 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.Lens as Lens
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
(StopEngagement -> StopEngagement -> Bool)
-> (StopEngagement -> StopEngagement -> Bool) -> Eq StopEngagement
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]
(Int -> ReadS StopEngagement)
-> ReadS [StopEngagement]
-> ReadPrec StopEngagement
-> ReadPrec [StopEngagement]
-> Read 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
(Int -> StopEngagement -> ShowS)
-> (StopEngagement -> String)
-> ([StopEngagement] -> ShowS)
-> Show StopEngagement
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. StopEngagement -> Rep StopEngagement x)
-> (forall x. Rep StopEngagement x -> StopEngagement)
-> Generic StopEngagement
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' :: Maybe Text -> Text -> StopEngagement
StopEngagement'
    { $sel:reason:StopEngagement' :: Maybe Text
reason = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> StopEngagement -> f StopEngagement
stopEngagement_reason = (StopEngagement -> Maybe Text)
-> (StopEngagement -> Maybe Text -> StopEngagement)
-> Lens StopEngagement StopEngagement (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> StopEngagement -> f StopEngagement
stopEngagement_engagementId = (StopEngagement -> Text)
-> (StopEngagement -> Text -> StopEngagement)
-> Lens StopEngagement StopEngagement Text Text
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 :: StopEngagement -> Request StopEngagement
request = Service -> StopEngagement -> Request StopEngagement
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopEngagement
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopEngagement)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StopEngagement))
-> Logger
-> Service
-> Proxy StopEngagement
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopEngagement)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StopEngagementResponse
StopEngagementResponse'
            (Int -> StopEngagementResponse)
-> Either String Int -> Either String StopEngagementResponse
forall (f :: * -> *) a b. Functor 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 StopEngagement

instance Prelude.NFData StopEngagement

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

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

instance Core.ToQuery StopEngagement where
  toQuery :: StopEngagement -> QueryString
toQuery = QueryString -> StopEngagement -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopEngagementResponse -> StopEngagementResponse -> Bool)
-> (StopEngagementResponse -> StopEngagementResponse -> Bool)
-> Eq StopEngagementResponse
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]
(Int -> ReadS StopEngagementResponse)
-> ReadS [StopEngagementResponse]
-> ReadPrec StopEngagementResponse
-> ReadPrec [StopEngagementResponse]
-> Read 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
(Int -> StopEngagementResponse -> ShowS)
-> (StopEngagementResponse -> String)
-> ([StopEngagementResponse] -> ShowS)
-> Show StopEngagementResponse
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. StopEngagementResponse -> Rep StopEngagementResponse x)
-> (forall x.
    Rep StopEngagementResponse x -> StopEngagementResponse)
-> Generic StopEngagementResponse
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' :: Int -> StopEngagementResponse
StopEngagementResponse' {$sel:httpStatus:StopEngagementResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
stopEngagementResponse_httpStatus :: Lens.Lens' StopEngagementResponse Prelude.Int
stopEngagementResponse_httpStatus :: (Int -> f Int)
-> StopEngagementResponse -> f StopEngagementResponse
stopEngagementResponse_httpStatus = (StopEngagementResponse -> Int)
-> (StopEngagementResponse -> Int -> StopEngagementResponse)
-> Lens StopEngagementResponse StopEngagementResponse Int Int
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