{-# 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.SSMIncidents.UpdateRelatedItems
-- 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)
--
-- Add or remove related items from the related items tab of an incident
-- record.
module Amazonka.SSMIncidents.UpdateRelatedItems
  ( -- * Creating a Request
    UpdateRelatedItems (..),
    newUpdateRelatedItems,

    -- * Request Lenses
    updateRelatedItems_clientToken,
    updateRelatedItems_incidentRecordArn,
    updateRelatedItems_relatedItemsUpdate,

    -- * Destructuring the Response
    UpdateRelatedItemsResponse (..),
    newUpdateRelatedItemsResponse,

    -- * Response Lenses
    updateRelatedItemsResponse_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.SSMIncidents.Types

-- | /See:/ 'newUpdateRelatedItems' smart constructor.
data UpdateRelatedItems = UpdateRelatedItems'
  { -- | A token ensuring that the action is called only once with the specified
    -- details.
    UpdateRelatedItems -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the incident record you are updating
    -- related items in.
    UpdateRelatedItems -> Text
incidentRecordArn :: Prelude.Text,
    -- | Details about the item you are adding or deleting.
    UpdateRelatedItems -> RelatedItemsUpdate
relatedItemsUpdate :: RelatedItemsUpdate
  }
  deriving (UpdateRelatedItems -> UpdateRelatedItems -> Bool
(UpdateRelatedItems -> UpdateRelatedItems -> Bool)
-> (UpdateRelatedItems -> UpdateRelatedItems -> Bool)
-> Eq UpdateRelatedItems
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRelatedItems -> UpdateRelatedItems -> Bool
$c/= :: UpdateRelatedItems -> UpdateRelatedItems -> Bool
== :: UpdateRelatedItems -> UpdateRelatedItems -> Bool
$c== :: UpdateRelatedItems -> UpdateRelatedItems -> Bool
Prelude.Eq, ReadPrec [UpdateRelatedItems]
ReadPrec UpdateRelatedItems
Int -> ReadS UpdateRelatedItems
ReadS [UpdateRelatedItems]
(Int -> ReadS UpdateRelatedItems)
-> ReadS [UpdateRelatedItems]
-> ReadPrec UpdateRelatedItems
-> ReadPrec [UpdateRelatedItems]
-> Read UpdateRelatedItems
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRelatedItems]
$creadListPrec :: ReadPrec [UpdateRelatedItems]
readPrec :: ReadPrec UpdateRelatedItems
$creadPrec :: ReadPrec UpdateRelatedItems
readList :: ReadS [UpdateRelatedItems]
$creadList :: ReadS [UpdateRelatedItems]
readsPrec :: Int -> ReadS UpdateRelatedItems
$creadsPrec :: Int -> ReadS UpdateRelatedItems
Prelude.Read, Int -> UpdateRelatedItems -> ShowS
[UpdateRelatedItems] -> ShowS
UpdateRelatedItems -> String
(Int -> UpdateRelatedItems -> ShowS)
-> (UpdateRelatedItems -> String)
-> ([UpdateRelatedItems] -> ShowS)
-> Show UpdateRelatedItems
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRelatedItems] -> ShowS
$cshowList :: [UpdateRelatedItems] -> ShowS
show :: UpdateRelatedItems -> String
$cshow :: UpdateRelatedItems -> String
showsPrec :: Int -> UpdateRelatedItems -> ShowS
$cshowsPrec :: Int -> UpdateRelatedItems -> ShowS
Prelude.Show, (forall x. UpdateRelatedItems -> Rep UpdateRelatedItems x)
-> (forall x. Rep UpdateRelatedItems x -> UpdateRelatedItems)
-> Generic UpdateRelatedItems
forall x. Rep UpdateRelatedItems x -> UpdateRelatedItems
forall x. UpdateRelatedItems -> Rep UpdateRelatedItems x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRelatedItems x -> UpdateRelatedItems
$cfrom :: forall x. UpdateRelatedItems -> Rep UpdateRelatedItems x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRelatedItems' 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', 'updateRelatedItems_clientToken' - A token ensuring that the action is called only once with the specified
-- details.
--
-- 'incidentRecordArn', 'updateRelatedItems_incidentRecordArn' - The Amazon Resource Name (ARN) of the incident record you are updating
-- related items in.
--
-- 'relatedItemsUpdate', 'updateRelatedItems_relatedItemsUpdate' - Details about the item you are adding or deleting.
newUpdateRelatedItems ::
  -- | 'incidentRecordArn'
  Prelude.Text ->
  -- | 'relatedItemsUpdate'
  RelatedItemsUpdate ->
  UpdateRelatedItems
newUpdateRelatedItems :: Text -> RelatedItemsUpdate -> UpdateRelatedItems
newUpdateRelatedItems
  Text
pIncidentRecordArn_
  RelatedItemsUpdate
pRelatedItemsUpdate_ =
    UpdateRelatedItems' :: Maybe Text -> Text -> RelatedItemsUpdate -> UpdateRelatedItems
UpdateRelatedItems'
      { $sel:clientToken:UpdateRelatedItems' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:incidentRecordArn:UpdateRelatedItems' :: Text
incidentRecordArn = Text
pIncidentRecordArn_,
        $sel:relatedItemsUpdate:UpdateRelatedItems' :: RelatedItemsUpdate
relatedItemsUpdate = RelatedItemsUpdate
pRelatedItemsUpdate_
      }

-- | A token ensuring that the action is called only once with the specified
-- details.
updateRelatedItems_clientToken :: Lens.Lens' UpdateRelatedItems (Prelude.Maybe Prelude.Text)
updateRelatedItems_clientToken :: (Maybe Text -> f (Maybe Text))
-> UpdateRelatedItems -> f UpdateRelatedItems
updateRelatedItems_clientToken = (UpdateRelatedItems -> Maybe Text)
-> (UpdateRelatedItems -> Maybe Text -> UpdateRelatedItems)
-> Lens
     UpdateRelatedItems UpdateRelatedItems (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRelatedItems' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateRelatedItems' :: UpdateRelatedItems -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateRelatedItems
s@UpdateRelatedItems' {} Maybe Text
a -> UpdateRelatedItems
s {$sel:clientToken:UpdateRelatedItems' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateRelatedItems)

-- | The Amazon Resource Name (ARN) of the incident record you are updating
-- related items in.
updateRelatedItems_incidentRecordArn :: Lens.Lens' UpdateRelatedItems Prelude.Text
updateRelatedItems_incidentRecordArn :: (Text -> f Text) -> UpdateRelatedItems -> f UpdateRelatedItems
updateRelatedItems_incidentRecordArn = (UpdateRelatedItems -> Text)
-> (UpdateRelatedItems -> Text -> UpdateRelatedItems)
-> Lens UpdateRelatedItems UpdateRelatedItems Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRelatedItems' {Text
incidentRecordArn :: Text
$sel:incidentRecordArn:UpdateRelatedItems' :: UpdateRelatedItems -> Text
incidentRecordArn} -> Text
incidentRecordArn) (\s :: UpdateRelatedItems
s@UpdateRelatedItems' {} Text
a -> UpdateRelatedItems
s {$sel:incidentRecordArn:UpdateRelatedItems' :: Text
incidentRecordArn = Text
a} :: UpdateRelatedItems)

-- | Details about the item you are adding or deleting.
updateRelatedItems_relatedItemsUpdate :: Lens.Lens' UpdateRelatedItems RelatedItemsUpdate
updateRelatedItems_relatedItemsUpdate :: (RelatedItemsUpdate -> f RelatedItemsUpdate)
-> UpdateRelatedItems -> f UpdateRelatedItems
updateRelatedItems_relatedItemsUpdate = (UpdateRelatedItems -> RelatedItemsUpdate)
-> (UpdateRelatedItems -> RelatedItemsUpdate -> UpdateRelatedItems)
-> Lens
     UpdateRelatedItems
     UpdateRelatedItems
     RelatedItemsUpdate
     RelatedItemsUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRelatedItems' {RelatedItemsUpdate
relatedItemsUpdate :: RelatedItemsUpdate
$sel:relatedItemsUpdate:UpdateRelatedItems' :: UpdateRelatedItems -> RelatedItemsUpdate
relatedItemsUpdate} -> RelatedItemsUpdate
relatedItemsUpdate) (\s :: UpdateRelatedItems
s@UpdateRelatedItems' {} RelatedItemsUpdate
a -> UpdateRelatedItems
s {$sel:relatedItemsUpdate:UpdateRelatedItems' :: RelatedItemsUpdate
relatedItemsUpdate = RelatedItemsUpdate
a} :: UpdateRelatedItems)

instance Core.AWSRequest UpdateRelatedItems where
  type
    AWSResponse UpdateRelatedItems =
      UpdateRelatedItemsResponse
  request :: UpdateRelatedItems -> Request UpdateRelatedItems
request = Service -> UpdateRelatedItems -> Request UpdateRelatedItems
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateRelatedItems
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateRelatedItems)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateRelatedItems))
-> Logger
-> Service
-> Proxy UpdateRelatedItems
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateRelatedItems)))
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 -> UpdateRelatedItemsResponse
UpdateRelatedItemsResponse'
            (Int -> UpdateRelatedItemsResponse)
-> Either String Int -> Either String UpdateRelatedItemsResponse
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 UpdateRelatedItems

instance Prelude.NFData UpdateRelatedItems

instance Core.ToHeaders UpdateRelatedItems where
  toHeaders :: UpdateRelatedItems -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateRelatedItems -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 UpdateRelatedItems where
  toJSON :: UpdateRelatedItems -> Value
toJSON UpdateRelatedItems' {Maybe Text
Text
RelatedItemsUpdate
relatedItemsUpdate :: RelatedItemsUpdate
incidentRecordArn :: Text
clientToken :: Maybe Text
$sel:relatedItemsUpdate:UpdateRelatedItems' :: UpdateRelatedItems -> RelatedItemsUpdate
$sel:incidentRecordArn:UpdateRelatedItems' :: UpdateRelatedItems -> Text
$sel:clientToken:UpdateRelatedItems' :: UpdateRelatedItems -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" 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
clientToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"incidentRecordArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
incidentRecordArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"relatedItemsUpdate" Text -> RelatedItemsUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RelatedItemsUpdate
relatedItemsUpdate)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateRelatedItemsResponse