{-# 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-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 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 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:/ '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
(DeleteAccessPolicy -> DeleteAccessPolicy -> Bool)
-> (DeleteAccessPolicy -> DeleteAccessPolicy -> Bool)
-> Eq DeleteAccessPolicy
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]
(Int -> ReadS DeleteAccessPolicy)
-> ReadS [DeleteAccessPolicy]
-> ReadPrec DeleteAccessPolicy
-> ReadPrec [DeleteAccessPolicy]
-> Read 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
(Int -> DeleteAccessPolicy -> ShowS)
-> (DeleteAccessPolicy -> String)
-> ([DeleteAccessPolicy] -> ShowS)
-> Show DeleteAccessPolicy
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. DeleteAccessPolicy -> Rep DeleteAccessPolicy x)
-> (forall x. Rep DeleteAccessPolicy x -> DeleteAccessPolicy)
-> Generic DeleteAccessPolicy
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' :: Maybe Text -> Text -> DeleteAccessPolicy
DeleteAccessPolicy'
    { $sel:clientToken:DeleteAccessPolicy' :: Maybe Text
clientToken = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteAccessPolicy -> f DeleteAccessPolicy
deleteAccessPolicy_clientToken = (DeleteAccessPolicy -> Maybe Text)
-> (DeleteAccessPolicy -> Maybe Text -> DeleteAccessPolicy)
-> Lens
     DeleteAccessPolicy DeleteAccessPolicy (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeleteAccessPolicy -> f DeleteAccessPolicy
deleteAccessPolicy_accessPolicyId = (DeleteAccessPolicy -> Text)
-> (DeleteAccessPolicy -> Text -> DeleteAccessPolicy)
-> Lens DeleteAccessPolicy DeleteAccessPolicy Text Text
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 :: DeleteAccessPolicy -> Request DeleteAccessPolicy
request = Service -> DeleteAccessPolicy -> Request DeleteAccessPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAccessPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccessPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteAccessPolicy))
-> Logger
-> Service
-> Proxy DeleteAccessPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccessPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteAccessPolicyResponse
DeleteAccessPolicyResponse'
            (Int -> DeleteAccessPolicyResponse)
-> Either String Int -> Either String DeleteAccessPolicyResponse
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))
      )

instance Prelude.Hashable DeleteAccessPolicy

instance Prelude.NFData DeleteAccessPolicy

instance Core.ToHeaders DeleteAccessPolicy where
  toHeaders :: DeleteAccessPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAccessPolicy -> 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 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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/access-policies/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accessPolicyId]

instance Core.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
..} =
    [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:/ 'newDeleteAccessPolicyResponse' smart constructor.
data DeleteAccessPolicyResponse = DeleteAccessPolicyResponse'
  { -- | The response's http status code.
    DeleteAccessPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteAccessPolicyResponse -> DeleteAccessPolicyResponse -> Bool
(DeleteAccessPolicyResponse -> DeleteAccessPolicyResponse -> Bool)
-> (DeleteAccessPolicyResponse
    -> DeleteAccessPolicyResponse -> Bool)
-> Eq DeleteAccessPolicyResponse
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]
(Int -> ReadS DeleteAccessPolicyResponse)
-> ReadS [DeleteAccessPolicyResponse]
-> ReadPrec DeleteAccessPolicyResponse
-> ReadPrec [DeleteAccessPolicyResponse]
-> Read 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
(Int -> DeleteAccessPolicyResponse -> ShowS)
-> (DeleteAccessPolicyResponse -> String)
-> ([DeleteAccessPolicyResponse] -> ShowS)
-> Show DeleteAccessPolicyResponse
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.
 DeleteAccessPolicyResponse -> Rep DeleteAccessPolicyResponse x)
-> (forall x.
    Rep DeleteAccessPolicyResponse x -> DeleteAccessPolicyResponse)
-> Generic DeleteAccessPolicyResponse
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' :: Int -> DeleteAccessPolicyResponse
DeleteAccessPolicyResponse'
    { $sel:httpStatus:DeleteAccessPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteAccessPolicyResponse_httpStatus :: Lens.Lens' DeleteAccessPolicyResponse Prelude.Int
deleteAccessPolicyResponse_httpStatus :: (Int -> f Int)
-> DeleteAccessPolicyResponse -> f DeleteAccessPolicyResponse
deleteAccessPolicyResponse_httpStatus = (DeleteAccessPolicyResponse -> Int)
-> (DeleteAccessPolicyResponse
    -> Int -> DeleteAccessPolicyResponse)
-> Lens
     DeleteAccessPolicyResponse DeleteAccessPolicyResponse Int Int
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