{-# 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.DeletePortal
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a portal from IoT SiteWise Monitor.
module Amazonka.IoTSiteWise.DeletePortal
  ( -- * Creating a Request
    DeletePortal (..),
    newDeletePortal,

    -- * Request Lenses
    deletePortal_clientToken,
    deletePortal_portalId,

    -- * Destructuring the Response
    DeletePortalResponse (..),
    newDeletePortalResponse,

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

-- |
-- Create a value of 'DeletePortal' 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', 'deletePortal_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.
--
-- 'portalId', 'deletePortal_portalId' - The ID of the portal to delete.
newDeletePortal ::
  -- | 'portalId'
  Prelude.Text ->
  DeletePortal
newDeletePortal :: Text -> DeletePortal
newDeletePortal Text
pPortalId_ =
  DeletePortal'
    { $sel:clientToken:DeletePortal' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:portalId:DeletePortal' :: Text
portalId = Text
pPortalId_
    }

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

-- | The ID of the portal to delete.
deletePortal_portalId :: Lens.Lens' DeletePortal Prelude.Text
deletePortal_portalId :: Lens' DeletePortal Text
deletePortal_portalId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePortal' {Text
portalId :: Text
$sel:portalId:DeletePortal' :: DeletePortal -> Text
portalId} -> Text
portalId) (\s :: DeletePortal
s@DeletePortal' {} Text
a -> DeletePortal
s {$sel:portalId:DeletePortal' :: Text
portalId = Text
a} :: DeletePortal)

instance Core.AWSRequest DeletePortal where
  type AWSResponse DeletePortal = DeletePortalResponse
  request :: (Service -> Service) -> DeletePortal -> Request DeletePortal
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeletePortal
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePortal)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> PortalStatus -> DeletePortalResponse
DeletePortalResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"portalStatus")
      )

instance Prelude.Hashable DeletePortal where
  hashWithSalt :: Int -> DeletePortal -> Int
hashWithSalt Int
_salt DeletePortal' {Maybe Text
Text
portalId :: Text
clientToken :: Maybe Text
$sel:portalId:DeletePortal' :: DeletePortal -> Text
$sel:clientToken:DeletePortal' :: DeletePortal -> 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
portalId

instance Prelude.NFData DeletePortal where
  rnf :: DeletePortal -> ()
rnf DeletePortal' {Maybe Text
Text
portalId :: Text
clientToken :: Maybe Text
$sel:portalId:DeletePortal' :: DeletePortal -> Text
$sel:clientToken:DeletePortal' :: DeletePortal -> 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
portalId

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

instance Data.ToPath DeletePortal where
  toPath :: DeletePortal -> ByteString
toPath DeletePortal' {Maybe Text
Text
portalId :: Text
clientToken :: Maybe Text
$sel:portalId:DeletePortal' :: DeletePortal -> Text
$sel:clientToken:DeletePortal' :: DeletePortal -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/portals/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
portalId]

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

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

-- |
-- Create a value of 'DeletePortalResponse' 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', 'deletePortalResponse_httpStatus' - The response's http status code.
--
-- 'portalStatus', 'deletePortalResponse_portalStatus' - The status of the portal, which contains a state (@DELETING@ after
-- successfully calling this operation) and any error message.
newDeletePortalResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'portalStatus'
  PortalStatus ->
  DeletePortalResponse
newDeletePortalResponse :: Int -> PortalStatus -> DeletePortalResponse
newDeletePortalResponse Int
pHttpStatus_ PortalStatus
pPortalStatus_ =
  DeletePortalResponse'
    { $sel:httpStatus:DeletePortalResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:portalStatus:DeletePortalResponse' :: PortalStatus
portalStatus = PortalStatus
pPortalStatus_
    }

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

-- | The status of the portal, which contains a state (@DELETING@ after
-- successfully calling this operation) and any error message.
deletePortalResponse_portalStatus :: Lens.Lens' DeletePortalResponse PortalStatus
deletePortalResponse_portalStatus :: Lens' DeletePortalResponse PortalStatus
deletePortalResponse_portalStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePortalResponse' {PortalStatus
portalStatus :: PortalStatus
$sel:portalStatus:DeletePortalResponse' :: DeletePortalResponse -> PortalStatus
portalStatus} -> PortalStatus
portalStatus) (\s :: DeletePortalResponse
s@DeletePortalResponse' {} PortalStatus
a -> DeletePortalResponse
s {$sel:portalStatus:DeletePortalResponse' :: PortalStatus
portalStatus = PortalStatus
a} :: DeletePortalResponse)

instance Prelude.NFData DeletePortalResponse where
  rnf :: DeletePortalResponse -> ()
rnf DeletePortalResponse' {Int
PortalStatus
portalStatus :: PortalStatus
httpStatus :: Int
$sel:portalStatus:DeletePortalResponse' :: DeletePortalResponse -> PortalStatus
$sel:httpStatus:DeletePortalResponse' :: DeletePortalResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PortalStatus
portalStatus