{-# 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.DisableInsightRules
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables the specified Contributor Insights rules. When rules are
-- disabled, they do not analyze log groups and do not incur costs.
module Amazonka.CloudWatch.DisableInsightRules
  ( -- * Creating a Request
    DisableInsightRules (..),
    newDisableInsightRules,

    -- * Request Lenses
    disableInsightRules_ruleNames,

    -- * Destructuring the Response
    DisableInsightRulesResponse (..),
    newDisableInsightRulesResponse,

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

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

-- | An array of the rule names to disable. If you need to find out the names
-- of your rules, use
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeInsightRules.html DescribeInsightRules>.
disableInsightRules_ruleNames :: Lens.Lens' DisableInsightRules [Prelude.Text]
disableInsightRules_ruleNames :: Lens' DisableInsightRules [Text]
disableInsightRules_ruleNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DisableInsightRules' :: DisableInsightRules -> [Text]
ruleNames} -> [Text]
ruleNames) (\s :: DisableInsightRules
s@DisableInsightRules' {} [Text]
a -> DisableInsightRules
s {$sel:ruleNames:DisableInsightRules' :: [Text]
ruleNames = [Text]
a} :: DisableInsightRules) 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 DisableInsightRules where
  type
    AWSResponse DisableInsightRules =
      DisableInsightRulesResponse
  request :: (Service -> Service)
-> DisableInsightRules -> Request DisableInsightRules
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 DisableInsightRules
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableInsightRules)))
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
"DisableInsightRulesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [PartialFailure] -> Int -> DisableInsightRulesResponse
DisableInsightRulesResponse'
            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 DisableInsightRules where
  hashWithSalt :: Int -> DisableInsightRules -> Int
hashWithSalt Int
_salt DisableInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DisableInsightRules' :: DisableInsightRules -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
ruleNames

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

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

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

instance Data.ToQuery DisableInsightRules where
  toQuery :: DisableInsightRules -> QueryString
toQuery DisableInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DisableInsightRules' :: DisableInsightRules -> [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DisableInsightRules" :: 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:/ 'newDisableInsightRulesResponse' smart constructor.
data DisableInsightRulesResponse = DisableInsightRulesResponse'
  { -- | An array listing the rules that could not be disabled. You cannot
    -- disable built-in rules.
    DisableInsightRulesResponse -> Maybe [PartialFailure]
failures :: Prelude.Maybe [PartialFailure],
    -- | The response's http status code.
    DisableInsightRulesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisableInsightRulesResponse -> DisableInsightRulesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableInsightRulesResponse -> DisableInsightRulesResponse -> Bool
$c/= :: DisableInsightRulesResponse -> DisableInsightRulesResponse -> Bool
== :: DisableInsightRulesResponse -> DisableInsightRulesResponse -> Bool
$c== :: DisableInsightRulesResponse -> DisableInsightRulesResponse -> Bool
Prelude.Eq, ReadPrec [DisableInsightRulesResponse]
ReadPrec DisableInsightRulesResponse
Int -> ReadS DisableInsightRulesResponse
ReadS [DisableInsightRulesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableInsightRulesResponse]
$creadListPrec :: ReadPrec [DisableInsightRulesResponse]
readPrec :: ReadPrec DisableInsightRulesResponse
$creadPrec :: ReadPrec DisableInsightRulesResponse
readList :: ReadS [DisableInsightRulesResponse]
$creadList :: ReadS [DisableInsightRulesResponse]
readsPrec :: Int -> ReadS DisableInsightRulesResponse
$creadsPrec :: Int -> ReadS DisableInsightRulesResponse
Prelude.Read, Int -> DisableInsightRulesResponse -> ShowS
[DisableInsightRulesResponse] -> ShowS
DisableInsightRulesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableInsightRulesResponse] -> ShowS
$cshowList :: [DisableInsightRulesResponse] -> ShowS
show :: DisableInsightRulesResponse -> String
$cshow :: DisableInsightRulesResponse -> String
showsPrec :: Int -> DisableInsightRulesResponse -> ShowS
$cshowsPrec :: Int -> DisableInsightRulesResponse -> ShowS
Prelude.Show, forall x.
Rep DisableInsightRulesResponse x -> DisableInsightRulesResponse
forall x.
DisableInsightRulesResponse -> Rep DisableInsightRulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableInsightRulesResponse x -> DisableInsightRulesResponse
$cfrom :: forall x.
DisableInsightRulesResponse -> Rep DisableInsightRulesResponse x
Prelude.Generic)

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

-- | An array listing the rules that could not be disabled. You cannot
-- disable built-in rules.
disableInsightRulesResponse_failures :: Lens.Lens' DisableInsightRulesResponse (Prelude.Maybe [PartialFailure])
disableInsightRulesResponse_failures :: Lens' DisableInsightRulesResponse (Maybe [PartialFailure])
disableInsightRulesResponse_failures = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableInsightRulesResponse' {Maybe [PartialFailure]
failures :: Maybe [PartialFailure]
$sel:failures:DisableInsightRulesResponse' :: DisableInsightRulesResponse -> Maybe [PartialFailure]
failures} -> Maybe [PartialFailure]
failures) (\s :: DisableInsightRulesResponse
s@DisableInsightRulesResponse' {} Maybe [PartialFailure]
a -> DisableInsightRulesResponse
s {$sel:failures:DisableInsightRulesResponse' :: Maybe [PartialFailure]
failures = Maybe [PartialFailure]
a} :: DisableInsightRulesResponse) 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.
disableInsightRulesResponse_httpStatus :: Lens.Lens' DisableInsightRulesResponse Prelude.Int
disableInsightRulesResponse_httpStatus :: Lens' DisableInsightRulesResponse Int
disableInsightRulesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableInsightRulesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DisableInsightRulesResponse' :: DisableInsightRulesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DisableInsightRulesResponse
s@DisableInsightRulesResponse' {} Int
a -> DisableInsightRulesResponse
s {$sel:httpStatus:DisableInsightRulesResponse' :: Int
httpStatus = Int
a} :: DisableInsightRulesResponse)

instance Prelude.NFData DisableInsightRulesResponse where
  rnf :: DisableInsightRulesResponse -> ()
rnf DisableInsightRulesResponse' {Int
Maybe [PartialFailure]
httpStatus :: Int
failures :: Maybe [PartialFailure]
$sel:httpStatus:DisableInsightRulesResponse' :: DisableInsightRulesResponse -> Int
$sel:failures:DisableInsightRulesResponse' :: DisableInsightRulesResponse -> 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