{-# 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.CloudWatch.DeleteInsightRules
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Permanently deletes the specified Contributor Insights rules.
--
-- If you create a rule, delete it, and then re-create it with the same
-- name, historical data from the first time the rule was created might not
-- be available.
module Amazonka.CloudWatch.DeleteInsightRules
  ( -- * Creating a Request
    DeleteInsightRules (..),
    newDeleteInsightRules,

    -- * Request Lenses
    deleteInsightRules_ruleNames,

    -- * Destructuring the Response
    DeleteInsightRulesResponse (..),
    newDeleteInsightRulesResponse,

    -- * Response Lenses
    deleteInsightRulesResponse_failures,
    deleteInsightRulesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteInsightRules' smart constructor.
data DeleteInsightRules = DeleteInsightRules'
  { -- | An array of the rule names to delete. If you need to find out the names
    -- of your rules, use
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeInsightRules.html DescribeInsightRules>.
    DeleteInsightRules -> [Text]
ruleNames :: [Prelude.Text]
  }
  deriving (DeleteInsightRules -> DeleteInsightRules -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInsightRules -> DeleteInsightRules -> Bool
$c/= :: DeleteInsightRules -> DeleteInsightRules -> Bool
== :: DeleteInsightRules -> DeleteInsightRules -> Bool
$c== :: DeleteInsightRules -> DeleteInsightRules -> Bool
Prelude.Eq, ReadPrec [DeleteInsightRules]
ReadPrec DeleteInsightRules
Int -> ReadS DeleteInsightRules
ReadS [DeleteInsightRules]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInsightRules]
$creadListPrec :: ReadPrec [DeleteInsightRules]
readPrec :: ReadPrec DeleteInsightRules
$creadPrec :: ReadPrec DeleteInsightRules
readList :: ReadS [DeleteInsightRules]
$creadList :: ReadS [DeleteInsightRules]
readsPrec :: Int -> ReadS DeleteInsightRules
$creadsPrec :: Int -> ReadS DeleteInsightRules
Prelude.Read, Int -> DeleteInsightRules -> ShowS
[DeleteInsightRules] -> ShowS
DeleteInsightRules -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInsightRules] -> ShowS
$cshowList :: [DeleteInsightRules] -> ShowS
show :: DeleteInsightRules -> String
$cshow :: DeleteInsightRules -> String
showsPrec :: Int -> DeleteInsightRules -> ShowS
$cshowsPrec :: Int -> DeleteInsightRules -> ShowS
Prelude.Show, forall x. Rep DeleteInsightRules x -> DeleteInsightRules
forall x. DeleteInsightRules -> Rep DeleteInsightRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteInsightRules x -> DeleteInsightRules
$cfrom :: forall x. DeleteInsightRules -> Rep DeleteInsightRules x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInsightRules' 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:
--
-- 'ruleNames', 'deleteInsightRules_ruleNames' - An array of the rule names to delete. If you need to find out the names
-- of your rules, use
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeInsightRules.html DescribeInsightRules>.
newDeleteInsightRules ::
  DeleteInsightRules
newDeleteInsightRules :: DeleteInsightRules
newDeleteInsightRules =
  DeleteInsightRules' {$sel:ruleNames:DeleteInsightRules' :: [Text]
ruleNames = forall a. Monoid a => a
Prelude.mempty}

-- | An array of the rule names to delete. If you need to find out the names
-- of your rules, use
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeInsightRules.html DescribeInsightRules>.
deleteInsightRules_ruleNames :: Lens.Lens' DeleteInsightRules [Prelude.Text]
deleteInsightRules_ruleNames :: Lens' DeleteInsightRules [Text]
deleteInsightRules_ruleNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DeleteInsightRules' :: DeleteInsightRules -> [Text]
ruleNames} -> [Text]
ruleNames) (\s :: DeleteInsightRules
s@DeleteInsightRules' {} [Text]
a -> DeleteInsightRules
s {$sel:ruleNames:DeleteInsightRules' :: [Text]
ruleNames = [Text]
a} :: DeleteInsightRules) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DeleteInsightRules where
  type
    AWSResponse DeleteInsightRules =
      DeleteInsightRulesResponse
  request :: (Service -> Service)
-> DeleteInsightRules -> Request DeleteInsightRules
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteInsightRules
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInsightRules)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DeleteInsightRulesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [PartialFailure] -> Int -> DeleteInsightRulesResponse
DeleteInsightRulesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Failures"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => 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 DeleteInsightRules where
  hashWithSalt :: Int -> DeleteInsightRules -> Int
hashWithSalt Int
_salt DeleteInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DeleteInsightRules' :: DeleteInsightRules -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
ruleNames

instance Prelude.NFData DeleteInsightRules where
  rnf :: DeleteInsightRules -> ()
rnf DeleteInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DeleteInsightRules' :: DeleteInsightRules -> [Text]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Text]
ruleNames

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

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

instance Data.ToQuery DeleteInsightRules where
  toQuery :: DeleteInsightRules -> QueryString
toQuery DeleteInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DeleteInsightRules' :: DeleteInsightRules -> [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteInsightRules" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"RuleNames"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Text]
ruleNames
      ]

-- | /See:/ 'newDeleteInsightRulesResponse' smart constructor.
data DeleteInsightRulesResponse = DeleteInsightRulesResponse'
  { -- | An array listing the rules that could not be deleted. You cannot delete
    -- built-in rules.
    DeleteInsightRulesResponse -> Maybe [PartialFailure]
failures :: Prelude.Maybe [PartialFailure],
    -- | The response's http status code.
    DeleteInsightRulesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteInsightRulesResponse -> DeleteInsightRulesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInsightRulesResponse -> DeleteInsightRulesResponse -> Bool
$c/= :: DeleteInsightRulesResponse -> DeleteInsightRulesResponse -> Bool
== :: DeleteInsightRulesResponse -> DeleteInsightRulesResponse -> Bool
$c== :: DeleteInsightRulesResponse -> DeleteInsightRulesResponse -> Bool
Prelude.Eq, ReadPrec [DeleteInsightRulesResponse]
ReadPrec DeleteInsightRulesResponse
Int -> ReadS DeleteInsightRulesResponse
ReadS [DeleteInsightRulesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInsightRulesResponse]
$creadListPrec :: ReadPrec [DeleteInsightRulesResponse]
readPrec :: ReadPrec DeleteInsightRulesResponse
$creadPrec :: ReadPrec DeleteInsightRulesResponse
readList :: ReadS [DeleteInsightRulesResponse]
$creadList :: ReadS [DeleteInsightRulesResponse]
readsPrec :: Int -> ReadS DeleteInsightRulesResponse
$creadsPrec :: Int -> ReadS DeleteInsightRulesResponse
Prelude.Read, Int -> DeleteInsightRulesResponse -> ShowS
[DeleteInsightRulesResponse] -> ShowS
DeleteInsightRulesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInsightRulesResponse] -> ShowS
$cshowList :: [DeleteInsightRulesResponse] -> ShowS
show :: DeleteInsightRulesResponse -> String
$cshow :: DeleteInsightRulesResponse -> String
showsPrec :: Int -> DeleteInsightRulesResponse -> ShowS
$cshowsPrec :: Int -> DeleteInsightRulesResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteInsightRulesResponse x -> DeleteInsightRulesResponse
forall x.
DeleteInsightRulesResponse -> Rep DeleteInsightRulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteInsightRulesResponse x -> DeleteInsightRulesResponse
$cfrom :: forall x.
DeleteInsightRulesResponse -> Rep DeleteInsightRulesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInsightRulesResponse' 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:
--
-- 'failures', 'deleteInsightRulesResponse_failures' - An array listing the rules that could not be deleted. You cannot delete
-- built-in rules.
--
-- 'httpStatus', 'deleteInsightRulesResponse_httpStatus' - The response's http status code.
newDeleteInsightRulesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteInsightRulesResponse
newDeleteInsightRulesResponse :: Int -> DeleteInsightRulesResponse
newDeleteInsightRulesResponse Int
pHttpStatus_ =
  DeleteInsightRulesResponse'
    { $sel:failures:DeleteInsightRulesResponse' :: Maybe [PartialFailure]
failures =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteInsightRulesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array listing the rules that could not be deleted. You cannot delete
-- built-in rules.
deleteInsightRulesResponse_failures :: Lens.Lens' DeleteInsightRulesResponse (Prelude.Maybe [PartialFailure])
deleteInsightRulesResponse_failures :: Lens' DeleteInsightRulesResponse (Maybe [PartialFailure])
deleteInsightRulesResponse_failures = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInsightRulesResponse' {Maybe [PartialFailure]
failures :: Maybe [PartialFailure]
$sel:failures:DeleteInsightRulesResponse' :: DeleteInsightRulesResponse -> Maybe [PartialFailure]
failures} -> Maybe [PartialFailure]
failures) (\s :: DeleteInsightRulesResponse
s@DeleteInsightRulesResponse' {} Maybe [PartialFailure]
a -> DeleteInsightRulesResponse
s {$sel:failures:DeleteInsightRulesResponse' :: Maybe [PartialFailure]
failures = Maybe [PartialFailure]
a} :: DeleteInsightRulesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteInsightRulesResponse where
  rnf :: DeleteInsightRulesResponse -> ()
rnf DeleteInsightRulesResponse' {Int
Maybe [PartialFailure]
httpStatus :: Int
failures :: Maybe [PartialFailure]
$sel:httpStatus:DeleteInsightRulesResponse' :: DeleteInsightRulesResponse -> Int
$sel:failures:DeleteInsightRulesResponse' :: DeleteInsightRulesResponse -> Maybe [PartialFailure]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PartialFailure]
failures
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus