{-# 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.IoTSiteWise.DisassociateAssets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates a child asset from the given parent asset through a
-- hierarchy defined in the parent asset\'s model.
module Amazonka.IoTSiteWise.DisassociateAssets
  ( -- * Creating a Request
    DisassociateAssets (..),
    newDisassociateAssets,

    -- * Request Lenses
    disassociateAssets_clientToken,
    disassociateAssets_assetId,
    disassociateAssets_hierarchyId,
    disassociateAssets_childAssetId,

    -- * Destructuring the Response
    DisassociateAssetsResponse (..),
    newDisassociateAssetsResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDisassociateAssets' smart constructor.
data DisassociateAssets = DisassociateAssets'
  { -- | A unique case-sensitive identifier that you can provide to ensure the
    -- idempotency of the request. Don\'t reuse this client token if a new
    -- idempotent request is required.
    DisassociateAssets -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the parent asset from which to disassociate the child asset.
    DisassociateAssets -> Text
assetId :: Prelude.Text,
    -- | The ID of a hierarchy in the parent asset\'s model. Hierarchies allow
    -- different groupings of assets to be formed that all come from the same
    -- asset model. You can use the hierarchy ID to identify the correct asset
    -- to disassociate. For more information, see
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-hierarchies.html Asset hierarchies>
    -- in the /IoT SiteWise User Guide/.
    DisassociateAssets -> Text
hierarchyId :: Prelude.Text,
    -- | The ID of the child asset to disassociate.
    DisassociateAssets -> Text
childAssetId :: Prelude.Text
  }
  deriving (DisassociateAssets -> DisassociateAssets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateAssets -> DisassociateAssets -> Bool
$c/= :: DisassociateAssets -> DisassociateAssets -> Bool
== :: DisassociateAssets -> DisassociateAssets -> Bool
$c== :: DisassociateAssets -> DisassociateAssets -> Bool
Prelude.Eq, ReadPrec [DisassociateAssets]
ReadPrec DisassociateAssets
Int -> ReadS DisassociateAssets
ReadS [DisassociateAssets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateAssets]
$creadListPrec :: ReadPrec [DisassociateAssets]
readPrec :: ReadPrec DisassociateAssets
$creadPrec :: ReadPrec DisassociateAssets
readList :: ReadS [DisassociateAssets]
$creadList :: ReadS [DisassociateAssets]
readsPrec :: Int -> ReadS DisassociateAssets
$creadsPrec :: Int -> ReadS DisassociateAssets
Prelude.Read, Int -> DisassociateAssets -> ShowS
[DisassociateAssets] -> ShowS
DisassociateAssets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateAssets] -> ShowS
$cshowList :: [DisassociateAssets] -> ShowS
show :: DisassociateAssets -> String
$cshow :: DisassociateAssets -> String
showsPrec :: Int -> DisassociateAssets -> ShowS
$cshowsPrec :: Int -> DisassociateAssets -> ShowS
Prelude.Show, forall x. Rep DisassociateAssets x -> DisassociateAssets
forall x. DisassociateAssets -> Rep DisassociateAssets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateAssets x -> DisassociateAssets
$cfrom :: forall x. DisassociateAssets -> Rep DisassociateAssets x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateAssets' 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', 'disassociateAssets_clientToken' - A unique case-sensitive identifier that you can provide to ensure the
-- idempotency of the request. Don\'t reuse this client token if a new
-- idempotent request is required.
--
-- 'assetId', 'disassociateAssets_assetId' - The ID of the parent asset from which to disassociate the child asset.
--
-- 'hierarchyId', 'disassociateAssets_hierarchyId' - The ID of a hierarchy in the parent asset\'s model. Hierarchies allow
-- different groupings of assets to be formed that all come from the same
-- asset model. You can use the hierarchy ID to identify the correct asset
-- to disassociate. For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-hierarchies.html Asset hierarchies>
-- in the /IoT SiteWise User Guide/.
--
-- 'childAssetId', 'disassociateAssets_childAssetId' - The ID of the child asset to disassociate.
newDisassociateAssets ::
  -- | 'assetId'
  Prelude.Text ->
  -- | 'hierarchyId'
  Prelude.Text ->
  -- | 'childAssetId'
  Prelude.Text ->
  DisassociateAssets
newDisassociateAssets :: Text -> Text -> Text -> DisassociateAssets
newDisassociateAssets
  Text
pAssetId_
  Text
pHierarchyId_
  Text
pChildAssetId_ =
    DisassociateAssets'
      { $sel:clientToken:DisassociateAssets' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
        $sel:assetId:DisassociateAssets' :: Text
assetId = Text
pAssetId_,
        $sel:hierarchyId:DisassociateAssets' :: Text
hierarchyId = Text
pHierarchyId_,
        $sel:childAssetId:DisassociateAssets' :: Text
childAssetId = Text
pChildAssetId_
      }

-- | A unique case-sensitive identifier that you can provide to ensure the
-- idempotency of the request. Don\'t reuse this client token if a new
-- idempotent request is required.
disassociateAssets_clientToken :: Lens.Lens' DisassociateAssets (Prelude.Maybe Prelude.Text)
disassociateAssets_clientToken :: Lens' DisassociateAssets (Maybe Text)
disassociateAssets_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAssets' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DisassociateAssets' :: DisassociateAssets -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DisassociateAssets
s@DisassociateAssets' {} Maybe Text
a -> DisassociateAssets
s {$sel:clientToken:DisassociateAssets' :: Maybe Text
clientToken = Maybe Text
a} :: DisassociateAssets)

-- | The ID of the parent asset from which to disassociate the child asset.
disassociateAssets_assetId :: Lens.Lens' DisassociateAssets Prelude.Text
disassociateAssets_assetId :: Lens' DisassociateAssets Text
disassociateAssets_assetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAssets' {Text
assetId :: Text
$sel:assetId:DisassociateAssets' :: DisassociateAssets -> Text
assetId} -> Text
assetId) (\s :: DisassociateAssets
s@DisassociateAssets' {} Text
a -> DisassociateAssets
s {$sel:assetId:DisassociateAssets' :: Text
assetId = Text
a} :: DisassociateAssets)

-- | The ID of a hierarchy in the parent asset\'s model. Hierarchies allow
-- different groupings of assets to be formed that all come from the same
-- asset model. You can use the hierarchy ID to identify the correct asset
-- to disassociate. For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-hierarchies.html Asset hierarchies>
-- in the /IoT SiteWise User Guide/.
disassociateAssets_hierarchyId :: Lens.Lens' DisassociateAssets Prelude.Text
disassociateAssets_hierarchyId :: Lens' DisassociateAssets Text
disassociateAssets_hierarchyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAssets' {Text
hierarchyId :: Text
$sel:hierarchyId:DisassociateAssets' :: DisassociateAssets -> Text
hierarchyId} -> Text
hierarchyId) (\s :: DisassociateAssets
s@DisassociateAssets' {} Text
a -> DisassociateAssets
s {$sel:hierarchyId:DisassociateAssets' :: Text
hierarchyId = Text
a} :: DisassociateAssets)

-- | The ID of the child asset to disassociate.
disassociateAssets_childAssetId :: Lens.Lens' DisassociateAssets Prelude.Text
disassociateAssets_childAssetId :: Lens' DisassociateAssets Text
disassociateAssets_childAssetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAssets' {Text
childAssetId :: Text
$sel:childAssetId:DisassociateAssets' :: DisassociateAssets -> Text
childAssetId} -> Text
childAssetId) (\s :: DisassociateAssets
s@DisassociateAssets' {} Text
a -> DisassociateAssets
s {$sel:childAssetId:DisassociateAssets' :: Text
childAssetId = Text
a} :: DisassociateAssets)

instance Core.AWSRequest DisassociateAssets where
  type
    AWSResponse DisassociateAssets =
      DisassociateAssetsResponse
  request :: (Service -> Service)
-> DisassociateAssets -> Request DisassociateAssets
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 DisassociateAssets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateAssets)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DisassociateAssetsResponse
DisassociateAssetsResponse'

instance Prelude.Hashable DisassociateAssets where
  hashWithSalt :: Int -> DisassociateAssets -> Int
hashWithSalt Int
_salt DisassociateAssets' {Maybe Text
Text
childAssetId :: Text
hierarchyId :: Text
assetId :: Text
clientToken :: Maybe Text
$sel:childAssetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:hierarchyId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:assetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:clientToken:DisassociateAssets' :: DisassociateAssets -> 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
assetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hierarchyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
childAssetId

instance Prelude.NFData DisassociateAssets where
  rnf :: DisassociateAssets -> ()
rnf DisassociateAssets' {Maybe Text
Text
childAssetId :: Text
hierarchyId :: Text
assetId :: Text
clientToken :: Maybe Text
$sel:childAssetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:hierarchyId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:assetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:clientToken:DisassociateAssets' :: DisassociateAssets -> 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
assetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hierarchyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
childAssetId

instance Data.ToHeaders DisassociateAssets where
  toHeaders :: DisassociateAssets -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DisassociateAssets where
  toJSON :: DisassociateAssets -> Value
toJSON DisassociateAssets' {Maybe Text
Text
childAssetId :: Text
hierarchyId :: Text
assetId :: Text
clientToken :: Maybe Text
$sel:childAssetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:hierarchyId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:assetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:clientToken:DisassociateAssets' :: DisassociateAssets -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" 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
clientToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"hierarchyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hierarchyId),
            forall a. a -> Maybe a
Prelude.Just (Key
"childAssetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
childAssetId)
          ]
      )

instance Data.ToPath DisassociateAssets where
  toPath :: DisassociateAssets -> ByteString
toPath DisassociateAssets' {Maybe Text
Text
childAssetId :: Text
hierarchyId :: Text
assetId :: Text
clientToken :: Maybe Text
$sel:childAssetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:hierarchyId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:assetId:DisassociateAssets' :: DisassociateAssets -> Text
$sel:clientToken:DisassociateAssets' :: DisassociateAssets -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/assets/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
assetId, ByteString
"/disassociate"]

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

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

-- |
-- Create a value of 'DisassociateAssetsResponse' 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.
newDisassociateAssetsResponse ::
  DisassociateAssetsResponse
newDisassociateAssetsResponse :: DisassociateAssetsResponse
newDisassociateAssetsResponse =
  DisassociateAssetsResponse
DisassociateAssetsResponse'

instance Prelude.NFData DisassociateAssetsResponse where
  rnf :: DisassociateAssetsResponse -> ()
rnf DisassociateAssetsResponse
_ = ()