{-# 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-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)
--
-- 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 Amazonka.IoTSiteWise.Types
import qualified Amazonka.Lens as Lens
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
(DisassociateAssets -> DisassociateAssets -> Bool)
-> (DisassociateAssets -> DisassociateAssets -> Bool)
-> Eq DisassociateAssets
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]
(Int -> ReadS DisassociateAssets)
-> ReadS [DisassociateAssets]
-> ReadPrec DisassociateAssets
-> ReadPrec [DisassociateAssets]
-> Read 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
(Int -> DisassociateAssets -> ShowS)
-> (DisassociateAssets -> String)
-> ([DisassociateAssets] -> ShowS)
-> Show DisassociateAssets
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. DisassociateAssets -> Rep DisassociateAssets x)
-> (forall x. Rep DisassociateAssets x -> DisassociateAssets)
-> Generic DisassociateAssets
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' :: Maybe Text -> Text -> Text -> Text -> DisassociateAssets
DisassociateAssets'
      { $sel:clientToken:DisassociateAssets' :: Maybe Text
clientToken = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DisassociateAssets -> f DisassociateAssets
disassociateAssets_clientToken = (DisassociateAssets -> Maybe Text)
-> (DisassociateAssets -> Maybe Text -> DisassociateAssets)
-> Lens
     DisassociateAssets DisassociateAssets (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DisassociateAssets -> f DisassociateAssets
disassociateAssets_assetId = (DisassociateAssets -> Text)
-> (DisassociateAssets -> Text -> DisassociateAssets)
-> Lens DisassociateAssets DisassociateAssets Text Text
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 :: (Text -> f Text) -> DisassociateAssets -> f DisassociateAssets
disassociateAssets_hierarchyId = (DisassociateAssets -> Text)
-> (DisassociateAssets -> Text -> DisassociateAssets)
-> Lens DisassociateAssets DisassociateAssets Text Text
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 :: (Text -> f Text) -> DisassociateAssets -> f DisassociateAssets
disassociateAssets_childAssetId = (DisassociateAssets -> Text)
-> (DisassociateAssets -> Text -> DisassociateAssets)
-> Lens DisassociateAssets DisassociateAssets Text Text
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 :: DisassociateAssets -> Request DisassociateAssets
request = Service -> DisassociateAssets -> Request DisassociateAssets
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateAssets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateAssets)))
response =
    AWSResponse DisassociateAssets
-> Logger
-> Service
-> Proxy DisassociateAssets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateAssets)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DisassociateAssets
DisassociateAssetsResponse
DisassociateAssetsResponse'

instance Prelude.Hashable DisassociateAssets

instance Prelude.NFData DisassociateAssets

instance Core.ToHeaders DisassociateAssets where
  toHeaders :: DisassociateAssets -> [Header]
toHeaders =
    [Header] -> DisassociateAssets -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.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
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
"hierarchyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hierarchyId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"childAssetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
childAssetId)
          ]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/assets/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
assetId, ByteString
"/disassociate"]

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

-- | /See:/ 'newDisassociateAssetsResponse' smart constructor.
data DisassociateAssetsResponse = DisassociateAssetsResponse'
  {
  }
  deriving (DisassociateAssetsResponse -> DisassociateAssetsResponse -> Bool
(DisassociateAssetsResponse -> DisassociateAssetsResponse -> Bool)
-> (DisassociateAssetsResponse
    -> DisassociateAssetsResponse -> Bool)
-> Eq DisassociateAssetsResponse
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]
(Int -> ReadS DisassociateAssetsResponse)
-> ReadS [DisassociateAssetsResponse]
-> ReadPrec DisassociateAssetsResponse
-> ReadPrec [DisassociateAssetsResponse]
-> Read 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
(Int -> DisassociateAssetsResponse -> ShowS)
-> (DisassociateAssetsResponse -> String)
-> ([DisassociateAssetsResponse] -> ShowS)
-> Show DisassociateAssetsResponse
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.
 DisassociateAssetsResponse -> Rep DisassociateAssetsResponse x)
-> (forall x.
    Rep DisassociateAssetsResponse x -> DisassociateAssetsResponse)
-> Generic DisassociateAssetsResponse
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