{-# 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.SSM.DisassociateOpsItemRelatedItem
-- 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)
--
-- Deletes the association between an OpsItem and a related item. For
-- example, this API operation can delete an Incident Manager incident from
-- an OpsItem. Incident Manager is a capability of Amazon Web Services
-- Systems Manager.
module Amazonka.SSM.DisassociateOpsItemRelatedItem
  ( -- * Creating a Request
    DisassociateOpsItemRelatedItem (..),
    newDisassociateOpsItemRelatedItem,

    -- * Request Lenses
    disassociateOpsItemRelatedItem_opsItemId,
    disassociateOpsItemRelatedItem_associationId,

    -- * Destructuring the Response
    DisassociateOpsItemRelatedItemResponse (..),
    newDisassociateOpsItemRelatedItemResponse,

    -- * Response Lenses
    disassociateOpsItemRelatedItemResponse_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.SSM.Types

-- | /See:/ 'newDisassociateOpsItemRelatedItem' smart constructor.
data DisassociateOpsItemRelatedItem = DisassociateOpsItemRelatedItem'
  { -- | The ID of the OpsItem for which you want to delete an association
    -- between the OpsItem and a related item.
    DisassociateOpsItemRelatedItem -> Text
opsItemId :: Prelude.Text,
    -- | The ID of the association for which you want to delete an association
    -- between the OpsItem and a related item.
    DisassociateOpsItemRelatedItem -> Text
associationId :: Prelude.Text
  }
  deriving (DisassociateOpsItemRelatedItem
-> DisassociateOpsItemRelatedItem -> Bool
(DisassociateOpsItemRelatedItem
 -> DisassociateOpsItemRelatedItem -> Bool)
-> (DisassociateOpsItemRelatedItem
    -> DisassociateOpsItemRelatedItem -> Bool)
-> Eq DisassociateOpsItemRelatedItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateOpsItemRelatedItem
-> DisassociateOpsItemRelatedItem -> Bool
$c/= :: DisassociateOpsItemRelatedItem
-> DisassociateOpsItemRelatedItem -> Bool
== :: DisassociateOpsItemRelatedItem
-> DisassociateOpsItemRelatedItem -> Bool
$c== :: DisassociateOpsItemRelatedItem
-> DisassociateOpsItemRelatedItem -> Bool
Prelude.Eq, ReadPrec [DisassociateOpsItemRelatedItem]
ReadPrec DisassociateOpsItemRelatedItem
Int -> ReadS DisassociateOpsItemRelatedItem
ReadS [DisassociateOpsItemRelatedItem]
(Int -> ReadS DisassociateOpsItemRelatedItem)
-> ReadS [DisassociateOpsItemRelatedItem]
-> ReadPrec DisassociateOpsItemRelatedItem
-> ReadPrec [DisassociateOpsItemRelatedItem]
-> Read DisassociateOpsItemRelatedItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateOpsItemRelatedItem]
$creadListPrec :: ReadPrec [DisassociateOpsItemRelatedItem]
readPrec :: ReadPrec DisassociateOpsItemRelatedItem
$creadPrec :: ReadPrec DisassociateOpsItemRelatedItem
readList :: ReadS [DisassociateOpsItemRelatedItem]
$creadList :: ReadS [DisassociateOpsItemRelatedItem]
readsPrec :: Int -> ReadS DisassociateOpsItemRelatedItem
$creadsPrec :: Int -> ReadS DisassociateOpsItemRelatedItem
Prelude.Read, Int -> DisassociateOpsItemRelatedItem -> ShowS
[DisassociateOpsItemRelatedItem] -> ShowS
DisassociateOpsItemRelatedItem -> String
(Int -> DisassociateOpsItemRelatedItem -> ShowS)
-> (DisassociateOpsItemRelatedItem -> String)
-> ([DisassociateOpsItemRelatedItem] -> ShowS)
-> Show DisassociateOpsItemRelatedItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateOpsItemRelatedItem] -> ShowS
$cshowList :: [DisassociateOpsItemRelatedItem] -> ShowS
show :: DisassociateOpsItemRelatedItem -> String
$cshow :: DisassociateOpsItemRelatedItem -> String
showsPrec :: Int -> DisassociateOpsItemRelatedItem -> ShowS
$cshowsPrec :: Int -> DisassociateOpsItemRelatedItem -> ShowS
Prelude.Show, (forall x.
 DisassociateOpsItemRelatedItem
 -> Rep DisassociateOpsItemRelatedItem x)
-> (forall x.
    Rep DisassociateOpsItemRelatedItem x
    -> DisassociateOpsItemRelatedItem)
-> Generic DisassociateOpsItemRelatedItem
forall x.
Rep DisassociateOpsItemRelatedItem x
-> DisassociateOpsItemRelatedItem
forall x.
DisassociateOpsItemRelatedItem
-> Rep DisassociateOpsItemRelatedItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateOpsItemRelatedItem x
-> DisassociateOpsItemRelatedItem
$cfrom :: forall x.
DisassociateOpsItemRelatedItem
-> Rep DisassociateOpsItemRelatedItem x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateOpsItemRelatedItem' 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:
--
-- 'opsItemId', 'disassociateOpsItemRelatedItem_opsItemId' - The ID of the OpsItem for which you want to delete an association
-- between the OpsItem and a related item.
--
-- 'associationId', 'disassociateOpsItemRelatedItem_associationId' - The ID of the association for which you want to delete an association
-- between the OpsItem and a related item.
newDisassociateOpsItemRelatedItem ::
  -- | 'opsItemId'
  Prelude.Text ->
  -- | 'associationId'
  Prelude.Text ->
  DisassociateOpsItemRelatedItem
newDisassociateOpsItemRelatedItem :: Text -> Text -> DisassociateOpsItemRelatedItem
newDisassociateOpsItemRelatedItem
  Text
pOpsItemId_
  Text
pAssociationId_ =
    DisassociateOpsItemRelatedItem' :: Text -> Text -> DisassociateOpsItemRelatedItem
DisassociateOpsItemRelatedItem'
      { $sel:opsItemId:DisassociateOpsItemRelatedItem' :: Text
opsItemId =
          Text
pOpsItemId_,
        $sel:associationId:DisassociateOpsItemRelatedItem' :: Text
associationId = Text
pAssociationId_
      }

-- | The ID of the OpsItem for which you want to delete an association
-- between the OpsItem and a related item.
disassociateOpsItemRelatedItem_opsItemId :: Lens.Lens' DisassociateOpsItemRelatedItem Prelude.Text
disassociateOpsItemRelatedItem_opsItemId :: (Text -> f Text)
-> DisassociateOpsItemRelatedItem
-> f DisassociateOpsItemRelatedItem
disassociateOpsItemRelatedItem_opsItemId = (DisassociateOpsItemRelatedItem -> Text)
-> (DisassociateOpsItemRelatedItem
    -> Text -> DisassociateOpsItemRelatedItem)
-> Lens
     DisassociateOpsItemRelatedItem
     DisassociateOpsItemRelatedItem
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateOpsItemRelatedItem' {Text
opsItemId :: Text
$sel:opsItemId:DisassociateOpsItemRelatedItem' :: DisassociateOpsItemRelatedItem -> Text
opsItemId} -> Text
opsItemId) (\s :: DisassociateOpsItemRelatedItem
s@DisassociateOpsItemRelatedItem' {} Text
a -> DisassociateOpsItemRelatedItem
s {$sel:opsItemId:DisassociateOpsItemRelatedItem' :: Text
opsItemId = Text
a} :: DisassociateOpsItemRelatedItem)

-- | The ID of the association for which you want to delete an association
-- between the OpsItem and a related item.
disassociateOpsItemRelatedItem_associationId :: Lens.Lens' DisassociateOpsItemRelatedItem Prelude.Text
disassociateOpsItemRelatedItem_associationId :: (Text -> f Text)
-> DisassociateOpsItemRelatedItem
-> f DisassociateOpsItemRelatedItem
disassociateOpsItemRelatedItem_associationId = (DisassociateOpsItemRelatedItem -> Text)
-> (DisassociateOpsItemRelatedItem
    -> Text -> DisassociateOpsItemRelatedItem)
-> Lens
     DisassociateOpsItemRelatedItem
     DisassociateOpsItemRelatedItem
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateOpsItemRelatedItem' {Text
associationId :: Text
$sel:associationId:DisassociateOpsItemRelatedItem' :: DisassociateOpsItemRelatedItem -> Text
associationId} -> Text
associationId) (\s :: DisassociateOpsItemRelatedItem
s@DisassociateOpsItemRelatedItem' {} Text
a -> DisassociateOpsItemRelatedItem
s {$sel:associationId:DisassociateOpsItemRelatedItem' :: Text
associationId = Text
a} :: DisassociateOpsItemRelatedItem)

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

instance
  Prelude.NFData
    DisassociateOpsItemRelatedItem

instance
  Core.ToHeaders
    DisassociateOpsItemRelatedItem
  where
  toHeaders :: DisassociateOpsItemRelatedItem -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DisassociateOpsItemRelatedItem -> 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
"AmazonSSM.DisassociateOpsItemRelatedItem" ::
                          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 DisassociateOpsItemRelatedItem where
  toJSON :: DisassociateOpsItemRelatedItem -> Value
toJSON DisassociateOpsItemRelatedItem' {Text
associationId :: Text
opsItemId :: Text
$sel:associationId:DisassociateOpsItemRelatedItem' :: DisassociateOpsItemRelatedItem -> Text
$sel:opsItemId:DisassociateOpsItemRelatedItem' :: DisassociateOpsItemRelatedItem -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"OpsItemId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
opsItemId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AssociationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
associationId)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DisassociateOpsItemRelatedItemResponse