{-# 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.IoT.DeleteSecurityProfile
-- 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 a Device Defender security profile.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeleteSecurityProfile>
-- action.
module Amazonka.IoT.DeleteSecurityProfile
  ( -- * Creating a Request
    DeleteSecurityProfile (..),
    newDeleteSecurityProfile,

    -- * Request Lenses
    deleteSecurityProfile_expectedVersion,
    deleteSecurityProfile_securityProfileName,

    -- * Destructuring the Response
    DeleteSecurityProfileResponse (..),
    newDeleteSecurityProfileResponse,

    -- * Response Lenses
    deleteSecurityProfileResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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:/ 'newDeleteSecurityProfile' smart constructor.
data DeleteSecurityProfile = DeleteSecurityProfile'
  { -- | The expected version of the security profile. A new version is generated
    -- whenever the security profile is updated. If you specify a value that is
    -- different from the actual version, a @VersionConflictException@ is
    -- thrown.
    DeleteSecurityProfile -> Maybe Integer
expectedVersion :: Prelude.Maybe Prelude.Integer,
    -- | The name of the security profile to be deleted.
    DeleteSecurityProfile -> Text
securityProfileName :: Prelude.Text
  }
  deriving (DeleteSecurityProfile -> DeleteSecurityProfile -> Bool
(DeleteSecurityProfile -> DeleteSecurityProfile -> Bool)
-> (DeleteSecurityProfile -> DeleteSecurityProfile -> Bool)
-> Eq DeleteSecurityProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSecurityProfile -> DeleteSecurityProfile -> Bool
$c/= :: DeleteSecurityProfile -> DeleteSecurityProfile -> Bool
== :: DeleteSecurityProfile -> DeleteSecurityProfile -> Bool
$c== :: DeleteSecurityProfile -> DeleteSecurityProfile -> Bool
Prelude.Eq, ReadPrec [DeleteSecurityProfile]
ReadPrec DeleteSecurityProfile
Int -> ReadS DeleteSecurityProfile
ReadS [DeleteSecurityProfile]
(Int -> ReadS DeleteSecurityProfile)
-> ReadS [DeleteSecurityProfile]
-> ReadPrec DeleteSecurityProfile
-> ReadPrec [DeleteSecurityProfile]
-> Read DeleteSecurityProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSecurityProfile]
$creadListPrec :: ReadPrec [DeleteSecurityProfile]
readPrec :: ReadPrec DeleteSecurityProfile
$creadPrec :: ReadPrec DeleteSecurityProfile
readList :: ReadS [DeleteSecurityProfile]
$creadList :: ReadS [DeleteSecurityProfile]
readsPrec :: Int -> ReadS DeleteSecurityProfile
$creadsPrec :: Int -> ReadS DeleteSecurityProfile
Prelude.Read, Int -> DeleteSecurityProfile -> ShowS
[DeleteSecurityProfile] -> ShowS
DeleteSecurityProfile -> String
(Int -> DeleteSecurityProfile -> ShowS)
-> (DeleteSecurityProfile -> String)
-> ([DeleteSecurityProfile] -> ShowS)
-> Show DeleteSecurityProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSecurityProfile] -> ShowS
$cshowList :: [DeleteSecurityProfile] -> ShowS
show :: DeleteSecurityProfile -> String
$cshow :: DeleteSecurityProfile -> String
showsPrec :: Int -> DeleteSecurityProfile -> ShowS
$cshowsPrec :: Int -> DeleteSecurityProfile -> ShowS
Prelude.Show, (forall x. DeleteSecurityProfile -> Rep DeleteSecurityProfile x)
-> (forall x. Rep DeleteSecurityProfile x -> DeleteSecurityProfile)
-> Generic DeleteSecurityProfile
forall x. Rep DeleteSecurityProfile x -> DeleteSecurityProfile
forall x. DeleteSecurityProfile -> Rep DeleteSecurityProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSecurityProfile x -> DeleteSecurityProfile
$cfrom :: forall x. DeleteSecurityProfile -> Rep DeleteSecurityProfile x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSecurityProfile' 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:
--
-- 'expectedVersion', 'deleteSecurityProfile_expectedVersion' - The expected version of the security profile. A new version is generated
-- whenever the security profile is updated. If you specify a value that is
-- different from the actual version, a @VersionConflictException@ is
-- thrown.
--
-- 'securityProfileName', 'deleteSecurityProfile_securityProfileName' - The name of the security profile to be deleted.
newDeleteSecurityProfile ::
  -- | 'securityProfileName'
  Prelude.Text ->
  DeleteSecurityProfile
newDeleteSecurityProfile :: Text -> DeleteSecurityProfile
newDeleteSecurityProfile Text
pSecurityProfileName_ =
  DeleteSecurityProfile' :: Maybe Integer -> Text -> DeleteSecurityProfile
DeleteSecurityProfile'
    { $sel:expectedVersion:DeleteSecurityProfile' :: Maybe Integer
expectedVersion =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileName:DeleteSecurityProfile' :: Text
securityProfileName = Text
pSecurityProfileName_
    }

-- | The expected version of the security profile. A new version is generated
-- whenever the security profile is updated. If you specify a value that is
-- different from the actual version, a @VersionConflictException@ is
-- thrown.
deleteSecurityProfile_expectedVersion :: Lens.Lens' DeleteSecurityProfile (Prelude.Maybe Prelude.Integer)
deleteSecurityProfile_expectedVersion :: (Maybe Integer -> f (Maybe Integer))
-> DeleteSecurityProfile -> f DeleteSecurityProfile
deleteSecurityProfile_expectedVersion = (DeleteSecurityProfile -> Maybe Integer)
-> (DeleteSecurityProfile
    -> Maybe Integer -> DeleteSecurityProfile)
-> Lens
     DeleteSecurityProfile
     DeleteSecurityProfile
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSecurityProfile' {Maybe Integer
expectedVersion :: Maybe Integer
$sel:expectedVersion:DeleteSecurityProfile' :: DeleteSecurityProfile -> Maybe Integer
expectedVersion} -> Maybe Integer
expectedVersion) (\s :: DeleteSecurityProfile
s@DeleteSecurityProfile' {} Maybe Integer
a -> DeleteSecurityProfile
s {$sel:expectedVersion:DeleteSecurityProfile' :: Maybe Integer
expectedVersion = Maybe Integer
a} :: DeleteSecurityProfile)

-- | The name of the security profile to be deleted.
deleteSecurityProfile_securityProfileName :: Lens.Lens' DeleteSecurityProfile Prelude.Text
deleteSecurityProfile_securityProfileName :: (Text -> f Text)
-> DeleteSecurityProfile -> f DeleteSecurityProfile
deleteSecurityProfile_securityProfileName = (DeleteSecurityProfile -> Text)
-> (DeleteSecurityProfile -> Text -> DeleteSecurityProfile)
-> Lens DeleteSecurityProfile DeleteSecurityProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSecurityProfile' {Text
securityProfileName :: Text
$sel:securityProfileName:DeleteSecurityProfile' :: DeleteSecurityProfile -> Text
securityProfileName} -> Text
securityProfileName) (\s :: DeleteSecurityProfile
s@DeleteSecurityProfile' {} Text
a -> DeleteSecurityProfile
s {$sel:securityProfileName:DeleteSecurityProfile' :: Text
securityProfileName = Text
a} :: DeleteSecurityProfile)

instance Core.AWSRequest DeleteSecurityProfile where
  type
    AWSResponse DeleteSecurityProfile =
      DeleteSecurityProfileResponse
  request :: DeleteSecurityProfile -> Request DeleteSecurityProfile
request = Service -> DeleteSecurityProfile -> Request DeleteSecurityProfile
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteSecurityProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSecurityProfile)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteSecurityProfile))
-> Logger
-> Service
-> Proxy DeleteSecurityProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSecurityProfile)))
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 -> DeleteSecurityProfileResponse
DeleteSecurityProfileResponse'
            (Int -> DeleteSecurityProfileResponse)
-> Either String Int -> Either String DeleteSecurityProfileResponse
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 DeleteSecurityProfile

instance Prelude.NFData DeleteSecurityProfile

instance Core.ToHeaders DeleteSecurityProfile where
  toHeaders :: DeleteSecurityProfile -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteSecurityProfile -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DeleteSecurityProfile where
  toPath :: DeleteSecurityProfile -> ByteString
toPath DeleteSecurityProfile' {Maybe Integer
Text
securityProfileName :: Text
expectedVersion :: Maybe Integer
$sel:securityProfileName:DeleteSecurityProfile' :: DeleteSecurityProfile -> Text
$sel:expectedVersion:DeleteSecurityProfile' :: DeleteSecurityProfile -> Maybe Integer
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/security-profiles/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
securityProfileName
      ]

instance Core.ToQuery DeleteSecurityProfile where
  toQuery :: DeleteSecurityProfile -> QueryString
toQuery DeleteSecurityProfile' {Maybe Integer
Text
securityProfileName :: Text
expectedVersion :: Maybe Integer
$sel:securityProfileName:DeleteSecurityProfile' :: DeleteSecurityProfile -> Text
$sel:expectedVersion:DeleteSecurityProfile' :: DeleteSecurityProfile -> Maybe Integer
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"expectedVersion" ByteString -> Maybe Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Integer
expectedVersion]

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

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

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

instance Prelude.NFData DeleteSecurityProfileResponse