{-# 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.OpenSearchServerless.DeleteSecurityPolicy
-- 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 OpenSearch Serverless security policy.
module Amazonka.OpenSearchServerless.DeleteSecurityPolicy
  ( -- * Creating a Request
    DeleteSecurityPolicy (..),
    newDeleteSecurityPolicy,

    -- * Request Lenses
    deleteSecurityPolicy_clientToken,
    deleteSecurityPolicy_name,
    deleteSecurityPolicy_type,

    -- * Destructuring the Response
    DeleteSecurityPolicyResponse (..),
    newDeleteSecurityPolicyResponse,

    -- * Response Lenses
    deleteSecurityPolicyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.OpenSearchServerless.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteSecurityPolicy' smart constructor.
data DeleteSecurityPolicy = DeleteSecurityPolicy'
  { -- | Unique, case-sensitive identifier to ensure idempotency of the request.
    DeleteSecurityPolicy -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the policy to delete.
    DeleteSecurityPolicy -> Text
name :: Prelude.Text,
    -- | The type of policy.
    DeleteSecurityPolicy -> SecurityPolicyType
type' :: SecurityPolicyType
  }
  deriving (DeleteSecurityPolicy -> DeleteSecurityPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSecurityPolicy -> DeleteSecurityPolicy -> Bool
$c/= :: DeleteSecurityPolicy -> DeleteSecurityPolicy -> Bool
== :: DeleteSecurityPolicy -> DeleteSecurityPolicy -> Bool
$c== :: DeleteSecurityPolicy -> DeleteSecurityPolicy -> Bool
Prelude.Eq, ReadPrec [DeleteSecurityPolicy]
ReadPrec DeleteSecurityPolicy
Int -> ReadS DeleteSecurityPolicy
ReadS [DeleteSecurityPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSecurityPolicy]
$creadListPrec :: ReadPrec [DeleteSecurityPolicy]
readPrec :: ReadPrec DeleteSecurityPolicy
$creadPrec :: ReadPrec DeleteSecurityPolicy
readList :: ReadS [DeleteSecurityPolicy]
$creadList :: ReadS [DeleteSecurityPolicy]
readsPrec :: Int -> ReadS DeleteSecurityPolicy
$creadsPrec :: Int -> ReadS DeleteSecurityPolicy
Prelude.Read, Int -> DeleteSecurityPolicy -> ShowS
[DeleteSecurityPolicy] -> ShowS
DeleteSecurityPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSecurityPolicy] -> ShowS
$cshowList :: [DeleteSecurityPolicy] -> ShowS
show :: DeleteSecurityPolicy -> String
$cshow :: DeleteSecurityPolicy -> String
showsPrec :: Int -> DeleteSecurityPolicy -> ShowS
$cshowsPrec :: Int -> DeleteSecurityPolicy -> ShowS
Prelude.Show, forall x. Rep DeleteSecurityPolicy x -> DeleteSecurityPolicy
forall x. DeleteSecurityPolicy -> Rep DeleteSecurityPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSecurityPolicy x -> DeleteSecurityPolicy
$cfrom :: forall x. DeleteSecurityPolicy -> Rep DeleteSecurityPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSecurityPolicy' 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', 'deleteSecurityPolicy_clientToken' - Unique, case-sensitive identifier to ensure idempotency of the request.
--
-- 'name', 'deleteSecurityPolicy_name' - The name of the policy to delete.
--
-- 'type'', 'deleteSecurityPolicy_type' - The type of policy.
newDeleteSecurityPolicy ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  SecurityPolicyType ->
  DeleteSecurityPolicy
newDeleteSecurityPolicy :: Text -> SecurityPolicyType -> DeleteSecurityPolicy
newDeleteSecurityPolicy Text
pName_ SecurityPolicyType
pType_ =
  DeleteSecurityPolicy'
    { $sel:clientToken:DeleteSecurityPolicy' :: Maybe Text
clientToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:DeleteSecurityPolicy' :: Text
name = Text
pName_,
      $sel:type':DeleteSecurityPolicy' :: SecurityPolicyType
type' = SecurityPolicyType
pType_
    }

-- | Unique, case-sensitive identifier to ensure idempotency of the request.
deleteSecurityPolicy_clientToken :: Lens.Lens' DeleteSecurityPolicy (Prelude.Maybe Prelude.Text)
deleteSecurityPolicy_clientToken :: Lens' DeleteSecurityPolicy (Maybe Text)
deleteSecurityPolicy_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSecurityPolicy' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteSecurityPolicy
s@DeleteSecurityPolicy' {} Maybe Text
a -> DeleteSecurityPolicy
s {$sel:clientToken:DeleteSecurityPolicy' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteSecurityPolicy)

-- | The name of the policy to delete.
deleteSecurityPolicy_name :: Lens.Lens' DeleteSecurityPolicy Prelude.Text
deleteSecurityPolicy_name :: Lens' DeleteSecurityPolicy Text
deleteSecurityPolicy_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSecurityPolicy' {Text
name :: Text
$sel:name:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> Text
name} -> Text
name) (\s :: DeleteSecurityPolicy
s@DeleteSecurityPolicy' {} Text
a -> DeleteSecurityPolicy
s {$sel:name:DeleteSecurityPolicy' :: Text
name = Text
a} :: DeleteSecurityPolicy)

-- | The type of policy.
deleteSecurityPolicy_type :: Lens.Lens' DeleteSecurityPolicy SecurityPolicyType
deleteSecurityPolicy_type :: Lens' DeleteSecurityPolicy SecurityPolicyType
deleteSecurityPolicy_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSecurityPolicy' {SecurityPolicyType
type' :: SecurityPolicyType
$sel:type':DeleteSecurityPolicy' :: DeleteSecurityPolicy -> SecurityPolicyType
type'} -> SecurityPolicyType
type') (\s :: DeleteSecurityPolicy
s@DeleteSecurityPolicy' {} SecurityPolicyType
a -> DeleteSecurityPolicy
s {$sel:type':DeleteSecurityPolicy' :: SecurityPolicyType
type' = SecurityPolicyType
a} :: DeleteSecurityPolicy)

instance Core.AWSRequest DeleteSecurityPolicy where
  type
    AWSResponse DeleteSecurityPolicy =
      DeleteSecurityPolicyResponse
  request :: (Service -> Service)
-> DeleteSecurityPolicy -> Request DeleteSecurityPolicy
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteSecurityPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSecurityPolicy)))
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 -> DeleteSecurityPolicyResponse
DeleteSecurityPolicyResponse'
            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 DeleteSecurityPolicy where
  hashWithSalt :: Int -> DeleteSecurityPolicy -> Int
hashWithSalt Int
_salt DeleteSecurityPolicy' {Maybe Text
Text
SecurityPolicyType
type' :: SecurityPolicyType
name :: Text
clientToken :: Maybe Text
$sel:type':DeleteSecurityPolicy' :: DeleteSecurityPolicy -> SecurityPolicyType
$sel:name:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> Text
$sel:clientToken:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> 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
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SecurityPolicyType
type'

instance Prelude.NFData DeleteSecurityPolicy where
  rnf :: DeleteSecurityPolicy -> ()
rnf DeleteSecurityPolicy' {Maybe Text
Text
SecurityPolicyType
type' :: SecurityPolicyType
name :: Text
clientToken :: Maybe Text
$sel:type':DeleteSecurityPolicy' :: DeleteSecurityPolicy -> SecurityPolicyType
$sel:name:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> Text
$sel:clientToken:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> 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
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SecurityPolicyType
type'

instance Data.ToHeaders DeleteSecurityPolicy where
  toHeaders :: DeleteSecurityPolicy -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"OpenSearchServerless.DeleteSecurityPolicy" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteSecurityPolicy where
  toJSON :: DeleteSecurityPolicy -> Value
toJSON DeleteSecurityPolicy' {Maybe Text
Text
SecurityPolicyType
type' :: SecurityPolicyType
name :: Text
clientToken :: Maybe Text
$sel:type':DeleteSecurityPolicy' :: DeleteSecurityPolicy -> SecurityPolicyType
$sel:name:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> Text
$sel:clientToken:DeleteSecurityPolicy' :: DeleteSecurityPolicy -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SecurityPolicyType
type')
          ]
      )

instance Data.ToPath DeleteSecurityPolicy where
  toPath :: DeleteSecurityPolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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