{-# 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-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)
--
-- 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.Lens as Lens
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
(DisableInsightRules -> DisableInsightRules -> Bool)
-> (DisableInsightRules -> DisableInsightRules -> Bool)
-> Eq DisableInsightRules
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]
(Int -> ReadS DisableInsightRules)
-> ReadS [DisableInsightRules]
-> ReadPrec DisableInsightRules
-> ReadPrec [DisableInsightRules]
-> Read 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
(Int -> DisableInsightRules -> ShowS)
-> (DisableInsightRules -> String)
-> ([DisableInsightRules] -> ShowS)
-> Show DisableInsightRules
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. DisableInsightRules -> Rep DisableInsightRules x)
-> (forall x. Rep DisableInsightRules x -> DisableInsightRules)
-> Generic DisableInsightRules
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' :: [Text] -> DisableInsightRules
DisableInsightRules' {$sel:ruleNames:DisableInsightRules' :: [Text]
ruleNames = [Text]
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 :: ([Text] -> f [Text])
-> DisableInsightRules -> f DisableInsightRules
disableInsightRules_ruleNames = (DisableInsightRules -> [Text])
-> (DisableInsightRules -> [Text] -> DisableInsightRules)
-> Lens DisableInsightRules DisableInsightRules [Text] [Text]
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) (([Text] -> f [Text])
 -> DisableInsightRules -> f DisableInsightRules)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DisableInsightRules
-> f DisableInsightRules
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
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 :: DisableInsightRules -> Request DisableInsightRules
request = Service -> DisableInsightRules -> Request DisableInsightRules
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableInsightRules
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableInsightRules)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DisableInsightRules))
-> Logger
-> Service
-> Proxy DisableInsightRules
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableInsightRules)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe [PartialFailure] -> Int -> DisableInsightRulesResponse)
-> Either String (Maybe [PartialFailure])
-> Either String (Int -> DisableInsightRulesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Failures" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [PartialFailure]))
-> Either String (Maybe [PartialFailure])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [PartialFailure])
-> [Node] -> Either String (Maybe [PartialFailure])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [PartialFailure]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> DisableInsightRulesResponse)
-> Either String Int -> Either String DisableInsightRulesResponse
forall (f :: * -> *) a b. Applicative f => 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 DisableInsightRules

instance Prelude.NFData DisableInsightRules

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

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

instance Core.ToQuery DisableInsightRules where
  toQuery :: DisableInsightRules -> QueryString
toQuery DisableInsightRules' {[Text]
ruleNames :: [Text]
$sel:ruleNames:DisableInsightRules' :: DisableInsightRules -> [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DisableInsightRules" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"RuleNames"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.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
(DisableInsightRulesResponse
 -> DisableInsightRulesResponse -> Bool)
-> (DisableInsightRulesResponse
    -> DisableInsightRulesResponse -> Bool)
-> Eq DisableInsightRulesResponse
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]
(Int -> ReadS DisableInsightRulesResponse)
-> ReadS [DisableInsightRulesResponse]
-> ReadPrec DisableInsightRulesResponse
-> ReadPrec [DisableInsightRulesResponse]
-> Read 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
(Int -> DisableInsightRulesResponse -> ShowS)
-> (DisableInsightRulesResponse -> String)
-> ([DisableInsightRulesResponse] -> ShowS)
-> Show DisableInsightRulesResponse
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.
 DisableInsightRulesResponse -> Rep DisableInsightRulesResponse x)
-> (forall x.
    Rep DisableInsightRulesResponse x -> DisableInsightRulesResponse)
-> Generic DisableInsightRulesResponse
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' :: Maybe [PartialFailure] -> Int -> DisableInsightRulesResponse
DisableInsightRulesResponse'
    { $sel:failures:DisableInsightRulesResponse' :: Maybe [PartialFailure]
failures =
        Maybe [PartialFailure]
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 :: (Maybe [PartialFailure] -> f (Maybe [PartialFailure]))
-> DisableInsightRulesResponse -> f DisableInsightRulesResponse
disableInsightRulesResponse_failures = (DisableInsightRulesResponse -> Maybe [PartialFailure])
-> (DisableInsightRulesResponse
    -> Maybe [PartialFailure] -> DisableInsightRulesResponse)
-> Lens
     DisableInsightRulesResponse
     DisableInsightRulesResponse
     (Maybe [PartialFailure])
     (Maybe [PartialFailure])
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) ((Maybe [PartialFailure] -> f (Maybe [PartialFailure]))
 -> DisableInsightRulesResponse -> f DisableInsightRulesResponse)
-> ((Maybe [PartialFailure] -> f (Maybe [PartialFailure]))
    -> Maybe [PartialFailure] -> f (Maybe [PartialFailure]))
-> (Maybe [PartialFailure] -> f (Maybe [PartialFailure]))
-> DisableInsightRulesResponse
-> f DisableInsightRulesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PartialFailure] [PartialFailure] [PartialFailure] [PartialFailure]
-> Iso
     (Maybe [PartialFailure])
     (Maybe [PartialFailure])
     (Maybe [PartialFailure])
     (Maybe [PartialFailure])
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 AnIso
  [PartialFailure] [PartialFailure] [PartialFailure] [PartialFailure]
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 :: (Int -> f Int)
-> DisableInsightRulesResponse -> f DisableInsightRulesResponse
disableInsightRulesResponse_httpStatus = (DisableInsightRulesResponse -> Int)
-> (DisableInsightRulesResponse
    -> Int -> DisableInsightRulesResponse)
-> Lens
     DisableInsightRulesResponse DisableInsightRulesResponse Int Int
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