{-# 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.DeleteAccessPolicy
-- 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 an access policy that grants the specified identity access to
-- the specified IoT SiteWise Monitor resource. You can use this operation
-- to revoke access to an IoT SiteWise Monitor resource.
module Amazonka.IoTSiteWise.DeleteAccessPolicy
  ( -- * Creating a Request
    DeleteAccessPolicy (..),
    newDeleteAccessPolicy,

    -- * Request Lenses
    deleteAccessPolicy_clientToken,
    deleteAccessPolicy_accessPolicyId,

    -- * Destructuring the Response
    DeleteAccessPolicyResponse (..),
    newDeleteAccessPolicyResponse,

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

-- |
-- Create a value of 'DeleteAccessPolicy' 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', 'deleteAccessPolicy_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.
--
-- 'accessPolicyId', 'deleteAccessPolicy_accessPolicyId' - The ID of the access policy to be deleted.
newDeleteAccessPolicy ::
  -- | 'accessPolicyId'
  Prelude.Text ->
  DeleteAccessPolicy
newDeleteAccessPolicy :: Text -> DeleteAccessPolicy
newDeleteAccessPolicy Text
pAccessPolicyId_ =
  DeleteAccessPolicy'
    { $sel:clientToken:DeleteAccessPolicy' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:accessPolicyId:DeleteAccessPolicy' :: Text
accessPolicyId = Text
pAccessPolicyId_
    }

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

-- | The ID of the access policy to be deleted.
deleteAccessPolicy_accessPolicyId :: Lens.Lens' DeleteAccessPolicy Prelude.Text
deleteAccessPolicy_accessPolicyId :: Lens' DeleteAccessPolicy Text
deleteAccessPolicy_accessPolicyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccessPolicy' {Text
accessPolicyId :: Text
$sel:accessPolicyId:DeleteAccessPolicy' :: DeleteAccessPolicy -> Text
accessPolicyId} -> Text
accessPolicyId) (\s :: DeleteAccessPolicy
s@DeleteAccessPolicy' {} Text
a -> DeleteAccessPolicy
s {$sel:accessPolicyId:DeleteAccessPolicy' :: Text
accessPolicyId = Text
a} :: DeleteAccessPolicy)

instance Core.AWSRequest DeleteAccessPolicy where
  type
    AWSResponse DeleteAccessPolicy =
      DeleteAccessPolicyResponse
  request :: (Service -> Service)
-> DeleteAccessPolicy -> Request DeleteAccessPolicy
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 DeleteAccessPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccessPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteAccessPolicyResponse
DeleteAccessPolicyResponse'
            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))
      )

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

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

instance Data.ToHeaders DeleteAccessPolicy where
  toHeaders :: DeleteAccessPolicy -> 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 DeleteAccessPolicy where
  toPath :: DeleteAccessPolicy -> ByteString
toPath DeleteAccessPolicy' {Maybe Text
Text
accessPolicyId :: Text
clientToken :: Maybe Text
$sel:accessPolicyId:DeleteAccessPolicy' :: DeleteAccessPolicy -> Text
$sel:clientToken:DeleteAccessPolicy' :: DeleteAccessPolicy -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/access-policies/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
accessPolicyId]

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

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

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

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

instance Prelude.NFData DeleteAccessPolicyResponse where
  rnf :: DeleteAccessPolicyResponse -> ()
rnf DeleteAccessPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteAccessPolicyResponse' :: DeleteAccessPolicyResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus