{-# 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.DeleteAssetModel
-- 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 an asset model. This action can\'t be undone. You must delete
-- all assets created from an asset model before you can delete the model.
-- Also, you can\'t delete an asset model if a parent asset model exists
-- that contains a property formula expression that depends on the asset
-- model that you want to delete. For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/delete-assets-and-models.html Deleting assets and models>
-- in the /IoT SiteWise User Guide/.
module Amazonka.IoTSiteWise.DeleteAssetModel
  ( -- * Creating a Request
    DeleteAssetModel (..),
    newDeleteAssetModel,

    -- * Request Lenses
    deleteAssetModel_clientToken,
    deleteAssetModel_assetModelId,

    -- * Destructuring the Response
    DeleteAssetModelResponse (..),
    newDeleteAssetModelResponse,

    -- * Response Lenses
    deleteAssetModelResponse_httpStatus,
    deleteAssetModelResponse_assetModelStatus,
  )
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:/ 'newDeleteAssetModel' smart constructor.
data DeleteAssetModel = DeleteAssetModel'
  { -- | 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.
    DeleteAssetModel -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the asset model to delete.
    DeleteAssetModel -> Text
assetModelId :: Prelude.Text
  }
  deriving (DeleteAssetModel -> DeleteAssetModel -> Bool
(DeleteAssetModel -> DeleteAssetModel -> Bool)
-> (DeleteAssetModel -> DeleteAssetModel -> Bool)
-> Eq DeleteAssetModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAssetModel -> DeleteAssetModel -> Bool
$c/= :: DeleteAssetModel -> DeleteAssetModel -> Bool
== :: DeleteAssetModel -> DeleteAssetModel -> Bool
$c== :: DeleteAssetModel -> DeleteAssetModel -> Bool
Prelude.Eq, ReadPrec [DeleteAssetModel]
ReadPrec DeleteAssetModel
Int -> ReadS DeleteAssetModel
ReadS [DeleteAssetModel]
(Int -> ReadS DeleteAssetModel)
-> ReadS [DeleteAssetModel]
-> ReadPrec DeleteAssetModel
-> ReadPrec [DeleteAssetModel]
-> Read DeleteAssetModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAssetModel]
$creadListPrec :: ReadPrec [DeleteAssetModel]
readPrec :: ReadPrec DeleteAssetModel
$creadPrec :: ReadPrec DeleteAssetModel
readList :: ReadS [DeleteAssetModel]
$creadList :: ReadS [DeleteAssetModel]
readsPrec :: Int -> ReadS DeleteAssetModel
$creadsPrec :: Int -> ReadS DeleteAssetModel
Prelude.Read, Int -> DeleteAssetModel -> ShowS
[DeleteAssetModel] -> ShowS
DeleteAssetModel -> String
(Int -> DeleteAssetModel -> ShowS)
-> (DeleteAssetModel -> String)
-> ([DeleteAssetModel] -> ShowS)
-> Show DeleteAssetModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAssetModel] -> ShowS
$cshowList :: [DeleteAssetModel] -> ShowS
show :: DeleteAssetModel -> String
$cshow :: DeleteAssetModel -> String
showsPrec :: Int -> DeleteAssetModel -> ShowS
$cshowsPrec :: Int -> DeleteAssetModel -> ShowS
Prelude.Show, (forall x. DeleteAssetModel -> Rep DeleteAssetModel x)
-> (forall x. Rep DeleteAssetModel x -> DeleteAssetModel)
-> Generic DeleteAssetModel
forall x. Rep DeleteAssetModel x -> DeleteAssetModel
forall x. DeleteAssetModel -> Rep DeleteAssetModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAssetModel x -> DeleteAssetModel
$cfrom :: forall x. DeleteAssetModel -> Rep DeleteAssetModel x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAssetModel' 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', 'deleteAssetModel_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.
--
-- 'assetModelId', 'deleteAssetModel_assetModelId' - The ID of the asset model to delete.
newDeleteAssetModel ::
  -- | 'assetModelId'
  Prelude.Text ->
  DeleteAssetModel
newDeleteAssetModel :: Text -> DeleteAssetModel
newDeleteAssetModel Text
pAssetModelId_ =
  DeleteAssetModel' :: Maybe Text -> Text -> DeleteAssetModel
DeleteAssetModel'
    { $sel:clientToken:DeleteAssetModel' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:assetModelId:DeleteAssetModel' :: Text
assetModelId = Text
pAssetModelId_
    }

-- | 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.
deleteAssetModel_clientToken :: Lens.Lens' DeleteAssetModel (Prelude.Maybe Prelude.Text)
deleteAssetModel_clientToken :: (Maybe Text -> f (Maybe Text))
-> DeleteAssetModel -> f DeleteAssetModel
deleteAssetModel_clientToken = (DeleteAssetModel -> Maybe Text)
-> (DeleteAssetModel -> Maybe Text -> DeleteAssetModel)
-> Lens DeleteAssetModel DeleteAssetModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAssetModel' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteAssetModel' :: DeleteAssetModel -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteAssetModel
s@DeleteAssetModel' {} Maybe Text
a -> DeleteAssetModel
s {$sel:clientToken:DeleteAssetModel' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteAssetModel)

-- | The ID of the asset model to delete.
deleteAssetModel_assetModelId :: Lens.Lens' DeleteAssetModel Prelude.Text
deleteAssetModel_assetModelId :: (Text -> f Text) -> DeleteAssetModel -> f DeleteAssetModel
deleteAssetModel_assetModelId = (DeleteAssetModel -> Text)
-> (DeleteAssetModel -> Text -> DeleteAssetModel)
-> Lens DeleteAssetModel DeleteAssetModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAssetModel' {Text
assetModelId :: Text
$sel:assetModelId:DeleteAssetModel' :: DeleteAssetModel -> Text
assetModelId} -> Text
assetModelId) (\s :: DeleteAssetModel
s@DeleteAssetModel' {} Text
a -> DeleteAssetModel
s {$sel:assetModelId:DeleteAssetModel' :: Text
assetModelId = Text
a} :: DeleteAssetModel)

instance Core.AWSRequest DeleteAssetModel where
  type
    AWSResponse DeleteAssetModel =
      DeleteAssetModelResponse
  request :: DeleteAssetModel -> Request DeleteAssetModel
request = Service -> DeleteAssetModel -> Request DeleteAssetModel
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAssetModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAssetModel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteAssetModel))
-> Logger
-> Service
-> Proxy DeleteAssetModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAssetModel)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> AssetModelStatus -> DeleteAssetModelResponse
DeleteAssetModelResponse'
            (Int -> AssetModelStatus -> DeleteAssetModelResponse)
-> Either String Int
-> Either String (AssetModelStatus -> DeleteAssetModelResponse)
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))
            Either String (AssetModelStatus -> DeleteAssetModelResponse)
-> Either String AssetModelStatus
-> Either String DeleteAssetModelResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String AssetModelStatus
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"assetModelStatus")
      )

instance Prelude.Hashable DeleteAssetModel

instance Prelude.NFData DeleteAssetModel

instance Core.ToHeaders DeleteAssetModel where
  toHeaders :: DeleteAssetModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAssetModel -> 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.ToPath DeleteAssetModel where
  toPath :: DeleteAssetModel -> ByteString
toPath DeleteAssetModel' {Maybe Text
Text
assetModelId :: Text
clientToken :: Maybe Text
$sel:assetModelId:DeleteAssetModel' :: DeleteAssetModel -> Text
$sel:clientToken:DeleteAssetModel' :: DeleteAssetModel -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/asset-models/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
assetModelId]

instance Core.ToQuery DeleteAssetModel where
  toQuery :: DeleteAssetModel -> QueryString
toQuery DeleteAssetModel' {Maybe Text
Text
assetModelId :: Text
clientToken :: Maybe Text
$sel:assetModelId:DeleteAssetModel' :: DeleteAssetModel -> Text
$sel:clientToken:DeleteAssetModel' :: DeleteAssetModel -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"clientToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
clientToken]

-- | /See:/ 'newDeleteAssetModelResponse' smart constructor.
data DeleteAssetModelResponse = DeleteAssetModelResponse'
  { -- | The response's http status code.
    DeleteAssetModelResponse -> Int
httpStatus :: Prelude.Int,
    -- | The status of the asset model, which contains a state (@DELETING@ after
    -- successfully calling this operation) and any error message.
    DeleteAssetModelResponse -> AssetModelStatus
assetModelStatus :: AssetModelStatus
  }
  deriving (DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool
(DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool)
-> (DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool)
-> Eq DeleteAssetModelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool
$c/= :: DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool
== :: DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool
$c== :: DeleteAssetModelResponse -> DeleteAssetModelResponse -> Bool
Prelude.Eq, ReadPrec [DeleteAssetModelResponse]
ReadPrec DeleteAssetModelResponse
Int -> ReadS DeleteAssetModelResponse
ReadS [DeleteAssetModelResponse]
(Int -> ReadS DeleteAssetModelResponse)
-> ReadS [DeleteAssetModelResponse]
-> ReadPrec DeleteAssetModelResponse
-> ReadPrec [DeleteAssetModelResponse]
-> Read DeleteAssetModelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAssetModelResponse]
$creadListPrec :: ReadPrec [DeleteAssetModelResponse]
readPrec :: ReadPrec DeleteAssetModelResponse
$creadPrec :: ReadPrec DeleteAssetModelResponse
readList :: ReadS [DeleteAssetModelResponse]
$creadList :: ReadS [DeleteAssetModelResponse]
readsPrec :: Int -> ReadS DeleteAssetModelResponse
$creadsPrec :: Int -> ReadS DeleteAssetModelResponse
Prelude.Read, Int -> DeleteAssetModelResponse -> ShowS
[DeleteAssetModelResponse] -> ShowS
DeleteAssetModelResponse -> String
(Int -> DeleteAssetModelResponse -> ShowS)
-> (DeleteAssetModelResponse -> String)
-> ([DeleteAssetModelResponse] -> ShowS)
-> Show DeleteAssetModelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAssetModelResponse] -> ShowS
$cshowList :: [DeleteAssetModelResponse] -> ShowS
show :: DeleteAssetModelResponse -> String
$cshow :: DeleteAssetModelResponse -> String
showsPrec :: Int -> DeleteAssetModelResponse -> ShowS
$cshowsPrec :: Int -> DeleteAssetModelResponse -> ShowS
Prelude.Show, (forall x.
 DeleteAssetModelResponse -> Rep DeleteAssetModelResponse x)
-> (forall x.
    Rep DeleteAssetModelResponse x -> DeleteAssetModelResponse)
-> Generic DeleteAssetModelResponse
forall x.
Rep DeleteAssetModelResponse x -> DeleteAssetModelResponse
forall x.
DeleteAssetModelResponse -> Rep DeleteAssetModelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteAssetModelResponse x -> DeleteAssetModelResponse
$cfrom :: forall x.
DeleteAssetModelResponse -> Rep DeleteAssetModelResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAssetModelResponse' 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', 'deleteAssetModelResponse_httpStatus' - The response's http status code.
--
-- 'assetModelStatus', 'deleteAssetModelResponse_assetModelStatus' - The status of the asset model, which contains a state (@DELETING@ after
-- successfully calling this operation) and any error message.
newDeleteAssetModelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'assetModelStatus'
  AssetModelStatus ->
  DeleteAssetModelResponse
newDeleteAssetModelResponse :: Int -> AssetModelStatus -> DeleteAssetModelResponse
newDeleteAssetModelResponse
  Int
pHttpStatus_
  AssetModelStatus
pAssetModelStatus_ =
    DeleteAssetModelResponse' :: Int -> AssetModelStatus -> DeleteAssetModelResponse
DeleteAssetModelResponse'
      { $sel:httpStatus:DeleteAssetModelResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:assetModelStatus:DeleteAssetModelResponse' :: AssetModelStatus
assetModelStatus = AssetModelStatus
pAssetModelStatus_
      }

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

-- | The status of the asset model, which contains a state (@DELETING@ after
-- successfully calling this operation) and any error message.
deleteAssetModelResponse_assetModelStatus :: Lens.Lens' DeleteAssetModelResponse AssetModelStatus
deleteAssetModelResponse_assetModelStatus :: (AssetModelStatus -> f AssetModelStatus)
-> DeleteAssetModelResponse -> f DeleteAssetModelResponse
deleteAssetModelResponse_assetModelStatus = (DeleteAssetModelResponse -> AssetModelStatus)
-> (DeleteAssetModelResponse
    -> AssetModelStatus -> DeleteAssetModelResponse)
-> Lens
     DeleteAssetModelResponse
     DeleteAssetModelResponse
     AssetModelStatus
     AssetModelStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAssetModelResponse' {AssetModelStatus
assetModelStatus :: AssetModelStatus
$sel:assetModelStatus:DeleteAssetModelResponse' :: DeleteAssetModelResponse -> AssetModelStatus
assetModelStatus} -> AssetModelStatus
assetModelStatus) (\s :: DeleteAssetModelResponse
s@DeleteAssetModelResponse' {} AssetModelStatus
a -> DeleteAssetModelResponse
s {$sel:assetModelStatus:DeleteAssetModelResponse' :: AssetModelStatus
assetModelStatus = AssetModelStatus
a} :: DeleteAssetModelResponse)

instance Prelude.NFData DeleteAssetModelResponse