{-# 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.ListActiveViolations
-- 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)
--
-- Lists the active violations for a given 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 ListActiveViolations>
-- action.
--
-- This operation returns paginated results.
module Amazonka.IoT.ListActiveViolations
  ( -- * Creating a Request
    ListActiveViolations (..),
    newListActiveViolations,

    -- * Request Lenses
    listActiveViolations_nextToken,
    listActiveViolations_listSuppressedAlerts,
    listActiveViolations_behaviorCriteriaType,
    listActiveViolations_securityProfileName,
    listActiveViolations_thingName,
    listActiveViolations_verificationState,
    listActiveViolations_maxResults,

    -- * Destructuring the Response
    ListActiveViolationsResponse (..),
    newListActiveViolationsResponse,

    -- * Response Lenses
    listActiveViolationsResponse_activeViolations,
    listActiveViolationsResponse_nextToken,
    listActiveViolationsResponse_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:/ 'newListActiveViolations' smart constructor.
data ListActiveViolations = ListActiveViolations'
  { -- | The token for the next set of results.
    ListActiveViolations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of all suppressed alerts.
    ListActiveViolations -> Maybe Bool
listSuppressedAlerts :: Prelude.Maybe Prelude.Bool,
    -- | The criteria for a behavior.
    ListActiveViolations -> Maybe BehaviorCriteriaType
behaviorCriteriaType :: Prelude.Maybe BehaviorCriteriaType,
    -- | The name of the Device Defender security profile for which violations
    -- are listed.
    ListActiveViolations -> Maybe Text
securityProfileName :: Prelude.Maybe Prelude.Text,
    -- | The name of the thing whose active violations are listed.
    ListActiveViolations -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
    -- | The verification state of the violation (detect alarm).
    ListActiveViolations -> Maybe VerificationState
verificationState :: Prelude.Maybe VerificationState,
    -- | The maximum number of results to return at one time.
    ListActiveViolations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListActiveViolations -> ListActiveViolations -> Bool
(ListActiveViolations -> ListActiveViolations -> Bool)
-> (ListActiveViolations -> ListActiveViolations -> Bool)
-> Eq ListActiveViolations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListActiveViolations -> ListActiveViolations -> Bool
$c/= :: ListActiveViolations -> ListActiveViolations -> Bool
== :: ListActiveViolations -> ListActiveViolations -> Bool
$c== :: ListActiveViolations -> ListActiveViolations -> Bool
Prelude.Eq, ReadPrec [ListActiveViolations]
ReadPrec ListActiveViolations
Int -> ReadS ListActiveViolations
ReadS [ListActiveViolations]
(Int -> ReadS ListActiveViolations)
-> ReadS [ListActiveViolations]
-> ReadPrec ListActiveViolations
-> ReadPrec [ListActiveViolations]
-> Read ListActiveViolations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListActiveViolations]
$creadListPrec :: ReadPrec [ListActiveViolations]
readPrec :: ReadPrec ListActiveViolations
$creadPrec :: ReadPrec ListActiveViolations
readList :: ReadS [ListActiveViolations]
$creadList :: ReadS [ListActiveViolations]
readsPrec :: Int -> ReadS ListActiveViolations
$creadsPrec :: Int -> ReadS ListActiveViolations
Prelude.Read, Int -> ListActiveViolations -> ShowS
[ListActiveViolations] -> ShowS
ListActiveViolations -> String
(Int -> ListActiveViolations -> ShowS)
-> (ListActiveViolations -> String)
-> ([ListActiveViolations] -> ShowS)
-> Show ListActiveViolations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListActiveViolations] -> ShowS
$cshowList :: [ListActiveViolations] -> ShowS
show :: ListActiveViolations -> String
$cshow :: ListActiveViolations -> String
showsPrec :: Int -> ListActiveViolations -> ShowS
$cshowsPrec :: Int -> ListActiveViolations -> ShowS
Prelude.Show, (forall x. ListActiveViolations -> Rep ListActiveViolations x)
-> (forall x. Rep ListActiveViolations x -> ListActiveViolations)
-> Generic ListActiveViolations
forall x. Rep ListActiveViolations x -> ListActiveViolations
forall x. ListActiveViolations -> Rep ListActiveViolations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListActiveViolations x -> ListActiveViolations
$cfrom :: forall x. ListActiveViolations -> Rep ListActiveViolations x
Prelude.Generic)

-- |
-- Create a value of 'ListActiveViolations' 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:
--
-- 'nextToken', 'listActiveViolations_nextToken' - The token for the next set of results.
--
-- 'listSuppressedAlerts', 'listActiveViolations_listSuppressedAlerts' - A list of all suppressed alerts.
--
-- 'behaviorCriteriaType', 'listActiveViolations_behaviorCriteriaType' - The criteria for a behavior.
--
-- 'securityProfileName', 'listActiveViolations_securityProfileName' - The name of the Device Defender security profile for which violations
-- are listed.
--
-- 'thingName', 'listActiveViolations_thingName' - The name of the thing whose active violations are listed.
--
-- 'verificationState', 'listActiveViolations_verificationState' - The verification state of the violation (detect alarm).
--
-- 'maxResults', 'listActiveViolations_maxResults' - The maximum number of results to return at one time.
newListActiveViolations ::
  ListActiveViolations
newListActiveViolations :: ListActiveViolations
newListActiveViolations =
  ListActiveViolations' :: Maybe Text
-> Maybe Bool
-> Maybe BehaviorCriteriaType
-> Maybe Text
-> Maybe Text
-> Maybe VerificationState
-> Maybe Natural
-> ListActiveViolations
ListActiveViolations'
    { $sel:nextToken:ListActiveViolations' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:listSuppressedAlerts:ListActiveViolations' :: Maybe Bool
listSuppressedAlerts = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:behaviorCriteriaType:ListActiveViolations' :: Maybe BehaviorCriteriaType
behaviorCriteriaType = Maybe BehaviorCriteriaType
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileName:ListActiveViolations' :: Maybe Text
securityProfileName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ListActiveViolations' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:verificationState:ListActiveViolations' :: Maybe VerificationState
verificationState = Maybe VerificationState
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListActiveViolations' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The token for the next set of results.
listActiveViolations_nextToken :: Lens.Lens' ListActiveViolations (Prelude.Maybe Prelude.Text)
listActiveViolations_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_nextToken = (ListActiveViolations -> Maybe Text)
-> (ListActiveViolations -> Maybe Text -> ListActiveViolations)
-> Lens
     ListActiveViolations ListActiveViolations (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListActiveViolations' :: ListActiveViolations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe Text
a -> ListActiveViolations
s {$sel:nextToken:ListActiveViolations' :: Maybe Text
nextToken = Maybe Text
a} :: ListActiveViolations)

-- | A list of all suppressed alerts.
listActiveViolations_listSuppressedAlerts :: Lens.Lens' ListActiveViolations (Prelude.Maybe Prelude.Bool)
listActiveViolations_listSuppressedAlerts :: (Maybe Bool -> f (Maybe Bool))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_listSuppressedAlerts = (ListActiveViolations -> Maybe Bool)
-> (ListActiveViolations -> Maybe Bool -> ListActiveViolations)
-> Lens
     ListActiveViolations ListActiveViolations (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe Bool
listSuppressedAlerts :: Maybe Bool
$sel:listSuppressedAlerts:ListActiveViolations' :: ListActiveViolations -> Maybe Bool
listSuppressedAlerts} -> Maybe Bool
listSuppressedAlerts) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe Bool
a -> ListActiveViolations
s {$sel:listSuppressedAlerts:ListActiveViolations' :: Maybe Bool
listSuppressedAlerts = Maybe Bool
a} :: ListActiveViolations)

-- | The criteria for a behavior.
listActiveViolations_behaviorCriteriaType :: Lens.Lens' ListActiveViolations (Prelude.Maybe BehaviorCriteriaType)
listActiveViolations_behaviorCriteriaType :: (Maybe BehaviorCriteriaType -> f (Maybe BehaviorCriteriaType))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_behaviorCriteriaType = (ListActiveViolations -> Maybe BehaviorCriteriaType)
-> (ListActiveViolations
    -> Maybe BehaviorCriteriaType -> ListActiveViolations)
-> Lens
     ListActiveViolations
     ListActiveViolations
     (Maybe BehaviorCriteriaType)
     (Maybe BehaviorCriteriaType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe BehaviorCriteriaType
behaviorCriteriaType :: Maybe BehaviorCriteriaType
$sel:behaviorCriteriaType:ListActiveViolations' :: ListActiveViolations -> Maybe BehaviorCriteriaType
behaviorCriteriaType} -> Maybe BehaviorCriteriaType
behaviorCriteriaType) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe BehaviorCriteriaType
a -> ListActiveViolations
s {$sel:behaviorCriteriaType:ListActiveViolations' :: Maybe BehaviorCriteriaType
behaviorCriteriaType = Maybe BehaviorCriteriaType
a} :: ListActiveViolations)

-- | The name of the Device Defender security profile for which violations
-- are listed.
listActiveViolations_securityProfileName :: Lens.Lens' ListActiveViolations (Prelude.Maybe Prelude.Text)
listActiveViolations_securityProfileName :: (Maybe Text -> f (Maybe Text))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_securityProfileName = (ListActiveViolations -> Maybe Text)
-> (ListActiveViolations -> Maybe Text -> ListActiveViolations)
-> Lens
     ListActiveViolations ListActiveViolations (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe Text
securityProfileName :: Maybe Text
$sel:securityProfileName:ListActiveViolations' :: ListActiveViolations -> Maybe Text
securityProfileName} -> Maybe Text
securityProfileName) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe Text
a -> ListActiveViolations
s {$sel:securityProfileName:ListActiveViolations' :: Maybe Text
securityProfileName = Maybe Text
a} :: ListActiveViolations)

-- | The name of the thing whose active violations are listed.
listActiveViolations_thingName :: Lens.Lens' ListActiveViolations (Prelude.Maybe Prelude.Text)
listActiveViolations_thingName :: (Maybe Text -> f (Maybe Text))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_thingName = (ListActiveViolations -> Maybe Text)
-> (ListActiveViolations -> Maybe Text -> ListActiveViolations)
-> Lens
     ListActiveViolations ListActiveViolations (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe Text
thingName :: Maybe Text
$sel:thingName:ListActiveViolations' :: ListActiveViolations -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe Text
a -> ListActiveViolations
s {$sel:thingName:ListActiveViolations' :: Maybe Text
thingName = Maybe Text
a} :: ListActiveViolations)

-- | The verification state of the violation (detect alarm).
listActiveViolations_verificationState :: Lens.Lens' ListActiveViolations (Prelude.Maybe VerificationState)
listActiveViolations_verificationState :: (Maybe VerificationState -> f (Maybe VerificationState))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_verificationState = (ListActiveViolations -> Maybe VerificationState)
-> (ListActiveViolations
    -> Maybe VerificationState -> ListActiveViolations)
-> Lens
     ListActiveViolations
     ListActiveViolations
     (Maybe VerificationState)
     (Maybe VerificationState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe VerificationState
verificationState :: Maybe VerificationState
$sel:verificationState:ListActiveViolations' :: ListActiveViolations -> Maybe VerificationState
verificationState} -> Maybe VerificationState
verificationState) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe VerificationState
a -> ListActiveViolations
s {$sel:verificationState:ListActiveViolations' :: Maybe VerificationState
verificationState = Maybe VerificationState
a} :: ListActiveViolations)

-- | The maximum number of results to return at one time.
listActiveViolations_maxResults :: Lens.Lens' ListActiveViolations (Prelude.Maybe Prelude.Natural)
listActiveViolations_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListActiveViolations -> f ListActiveViolations
listActiveViolations_maxResults = (ListActiveViolations -> Maybe Natural)
-> (ListActiveViolations -> Maybe Natural -> ListActiveViolations)
-> Lens
     ListActiveViolations
     ListActiveViolations
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListActiveViolations' :: ListActiveViolations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListActiveViolations
s@ListActiveViolations' {} Maybe Natural
a -> ListActiveViolations
s {$sel:maxResults:ListActiveViolations' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListActiveViolations)

instance Core.AWSPager ListActiveViolations where
  page :: ListActiveViolations
-> AWSResponse ListActiveViolations -> Maybe ListActiveViolations
page ListActiveViolations
rq AWSResponse ListActiveViolations
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListActiveViolations
ListActiveViolationsResponse
rs
            ListActiveViolationsResponse
-> Getting (First Text) ListActiveViolationsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListActiveViolationsResponse
-> Const (First Text) ListActiveViolationsResponse
Lens' ListActiveViolationsResponse (Maybe Text)
listActiveViolationsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListActiveViolationsResponse
 -> Const (First Text) ListActiveViolationsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListActiveViolationsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListActiveViolations
forall a. Maybe a
Prelude.Nothing
    | Maybe [ActiveViolation] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListActiveViolations
ListActiveViolationsResponse
rs
            ListActiveViolationsResponse
-> Getting
     (First [ActiveViolation])
     ListActiveViolationsResponse
     [ActiveViolation]
-> Maybe [ActiveViolation]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ActiveViolation]
 -> Const (First [ActiveViolation]) (Maybe [ActiveViolation]))
-> ListActiveViolationsResponse
-> Const (First [ActiveViolation]) ListActiveViolationsResponse
Lens' ListActiveViolationsResponse (Maybe [ActiveViolation])
listActiveViolationsResponse_activeViolations
              ((Maybe [ActiveViolation]
  -> Const (First [ActiveViolation]) (Maybe [ActiveViolation]))
 -> ListActiveViolationsResponse
 -> Const (First [ActiveViolation]) ListActiveViolationsResponse)
-> (([ActiveViolation]
     -> Const (First [ActiveViolation]) [ActiveViolation])
    -> Maybe [ActiveViolation]
    -> Const (First [ActiveViolation]) (Maybe [ActiveViolation]))
-> Getting
     (First [ActiveViolation])
     ListActiveViolationsResponse
     [ActiveViolation]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ActiveViolation]
 -> Const (First [ActiveViolation]) [ActiveViolation])
-> Maybe [ActiveViolation]
-> Const (First [ActiveViolation]) (Maybe [ActiveViolation])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListActiveViolations
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListActiveViolations -> Maybe ListActiveViolations
forall a. a -> Maybe a
Prelude.Just (ListActiveViolations -> Maybe ListActiveViolations)
-> ListActiveViolations -> Maybe ListActiveViolations
forall a b. (a -> b) -> a -> b
Prelude.$
        ListActiveViolations
rq
          ListActiveViolations
-> (ListActiveViolations -> ListActiveViolations)
-> ListActiveViolations
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListActiveViolations -> Identity ListActiveViolations
Lens
  ListActiveViolations ListActiveViolations (Maybe Text) (Maybe Text)
listActiveViolations_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListActiveViolations -> Identity ListActiveViolations)
-> Maybe Text -> ListActiveViolations -> ListActiveViolations
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListActiveViolations
ListActiveViolationsResponse
rs
          ListActiveViolationsResponse
-> Getting (First Text) ListActiveViolationsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListActiveViolationsResponse
-> Const (First Text) ListActiveViolationsResponse
Lens' ListActiveViolationsResponse (Maybe Text)
listActiveViolationsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListActiveViolationsResponse
 -> Const (First Text) ListActiveViolationsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListActiveViolationsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListActiveViolations where
  type
    AWSResponse ListActiveViolations =
      ListActiveViolationsResponse
  request :: ListActiveViolations -> Request ListActiveViolations
request = Service -> ListActiveViolations -> Request ListActiveViolations
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListActiveViolations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListActiveViolations)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListActiveViolations))
-> Logger
-> Service
-> Proxy ListActiveViolations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListActiveViolations)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ActiveViolation]
-> Maybe Text -> Int -> ListActiveViolationsResponse
ListActiveViolationsResponse'
            (Maybe [ActiveViolation]
 -> Maybe Text -> Int -> ListActiveViolationsResponse)
-> Either String (Maybe [ActiveViolation])
-> Either
     String (Maybe Text -> Int -> ListActiveViolationsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ActiveViolation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"activeViolations"
                            Either String (Maybe (Maybe [ActiveViolation]))
-> Maybe [ActiveViolation]
-> Either String (Maybe [ActiveViolation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ActiveViolation]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe Text -> Int -> ListActiveViolationsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListActiveViolationsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> ListActiveViolationsResponse)
-> Either String Int -> Either String ListActiveViolationsResponse
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 ListActiveViolations

instance Prelude.NFData ListActiveViolations

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

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

instance Core.ToQuery ListActiveViolations where
  toQuery :: ListActiveViolations -> QueryString
toQuery ListActiveViolations' {Maybe Bool
Maybe Natural
Maybe Text
Maybe BehaviorCriteriaType
Maybe VerificationState
maxResults :: Maybe Natural
verificationState :: Maybe VerificationState
thingName :: Maybe Text
securityProfileName :: Maybe Text
behaviorCriteriaType :: Maybe BehaviorCriteriaType
listSuppressedAlerts :: Maybe Bool
nextToken :: Maybe Text
$sel:maxResults:ListActiveViolations' :: ListActiveViolations -> Maybe Natural
$sel:verificationState:ListActiveViolations' :: ListActiveViolations -> Maybe VerificationState
$sel:thingName:ListActiveViolations' :: ListActiveViolations -> Maybe Text
$sel:securityProfileName:ListActiveViolations' :: ListActiveViolations -> Maybe Text
$sel:behaviorCriteriaType:ListActiveViolations' :: ListActiveViolations -> Maybe BehaviorCriteriaType
$sel:listSuppressedAlerts:ListActiveViolations' :: ListActiveViolations -> Maybe Bool
$sel:nextToken:ListActiveViolations' :: ListActiveViolations -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"listSuppressedAlerts" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
listSuppressedAlerts,
        ByteString
"behaviorCriteriaType" ByteString -> Maybe BehaviorCriteriaType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe BehaviorCriteriaType
behaviorCriteriaType,
        ByteString
"securityProfileName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
securityProfileName,
        ByteString
"thingName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
thingName,
        ByteString
"verificationState" ByteString -> Maybe VerificationState -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe VerificationState
verificationState,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
      ]

-- | /See:/ 'newListActiveViolationsResponse' smart constructor.
data ListActiveViolationsResponse = ListActiveViolationsResponse'
  { -- | The list of active violations.
    ListActiveViolationsResponse -> Maybe [ActiveViolation]
activeViolations :: Prelude.Maybe [ActiveViolation],
    -- | A token that can be used to retrieve the next set of results, or @null@
    -- if there are no additional results.
    ListActiveViolationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListActiveViolationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListActiveViolationsResponse
-> ListActiveViolationsResponse -> Bool
(ListActiveViolationsResponse
 -> ListActiveViolationsResponse -> Bool)
-> (ListActiveViolationsResponse
    -> ListActiveViolationsResponse -> Bool)
-> Eq ListActiveViolationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListActiveViolationsResponse
-> ListActiveViolationsResponse -> Bool
$c/= :: ListActiveViolationsResponse
-> ListActiveViolationsResponse -> Bool
== :: ListActiveViolationsResponse
-> ListActiveViolationsResponse -> Bool
$c== :: ListActiveViolationsResponse
-> ListActiveViolationsResponse -> Bool
Prelude.Eq, ReadPrec [ListActiveViolationsResponse]
ReadPrec ListActiveViolationsResponse
Int -> ReadS ListActiveViolationsResponse
ReadS [ListActiveViolationsResponse]
(Int -> ReadS ListActiveViolationsResponse)
-> ReadS [ListActiveViolationsResponse]
-> ReadPrec ListActiveViolationsResponse
-> ReadPrec [ListActiveViolationsResponse]
-> Read ListActiveViolationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListActiveViolationsResponse]
$creadListPrec :: ReadPrec [ListActiveViolationsResponse]
readPrec :: ReadPrec ListActiveViolationsResponse
$creadPrec :: ReadPrec ListActiveViolationsResponse
readList :: ReadS [ListActiveViolationsResponse]
$creadList :: ReadS [ListActiveViolationsResponse]
readsPrec :: Int -> ReadS ListActiveViolationsResponse
$creadsPrec :: Int -> ReadS ListActiveViolationsResponse
Prelude.Read, Int -> ListActiveViolationsResponse -> ShowS
[ListActiveViolationsResponse] -> ShowS
ListActiveViolationsResponse -> String
(Int -> ListActiveViolationsResponse -> ShowS)
-> (ListActiveViolationsResponse -> String)
-> ([ListActiveViolationsResponse] -> ShowS)
-> Show ListActiveViolationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListActiveViolationsResponse] -> ShowS
$cshowList :: [ListActiveViolationsResponse] -> ShowS
show :: ListActiveViolationsResponse -> String
$cshow :: ListActiveViolationsResponse -> String
showsPrec :: Int -> ListActiveViolationsResponse -> ShowS
$cshowsPrec :: Int -> ListActiveViolationsResponse -> ShowS
Prelude.Show, (forall x.
 ListActiveViolationsResponse -> Rep ListActiveViolationsResponse x)
-> (forall x.
    Rep ListActiveViolationsResponse x -> ListActiveViolationsResponse)
-> Generic ListActiveViolationsResponse
forall x.
Rep ListActiveViolationsResponse x -> ListActiveViolationsResponse
forall x.
ListActiveViolationsResponse -> Rep ListActiveViolationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListActiveViolationsResponse x -> ListActiveViolationsResponse
$cfrom :: forall x.
ListActiveViolationsResponse -> Rep ListActiveViolationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListActiveViolationsResponse' 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:
--
-- 'activeViolations', 'listActiveViolationsResponse_activeViolations' - The list of active violations.
--
-- 'nextToken', 'listActiveViolationsResponse_nextToken' - A token that can be used to retrieve the next set of results, or @null@
-- if there are no additional results.
--
-- 'httpStatus', 'listActiveViolationsResponse_httpStatus' - The response's http status code.
newListActiveViolationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListActiveViolationsResponse
newListActiveViolationsResponse :: Int -> ListActiveViolationsResponse
newListActiveViolationsResponse Int
pHttpStatus_ =
  ListActiveViolationsResponse' :: Maybe [ActiveViolation]
-> Maybe Text -> Int -> ListActiveViolationsResponse
ListActiveViolationsResponse'
    { $sel:activeViolations:ListActiveViolationsResponse' :: Maybe [ActiveViolation]
activeViolations =
        Maybe [ActiveViolation]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListActiveViolationsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListActiveViolationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of active violations.
listActiveViolationsResponse_activeViolations :: Lens.Lens' ListActiveViolationsResponse (Prelude.Maybe [ActiveViolation])
listActiveViolationsResponse_activeViolations :: (Maybe [ActiveViolation] -> f (Maybe [ActiveViolation]))
-> ListActiveViolationsResponse -> f ListActiveViolationsResponse
listActiveViolationsResponse_activeViolations = (ListActiveViolationsResponse -> Maybe [ActiveViolation])
-> (ListActiveViolationsResponse
    -> Maybe [ActiveViolation] -> ListActiveViolationsResponse)
-> Lens' ListActiveViolationsResponse (Maybe [ActiveViolation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolationsResponse' {Maybe [ActiveViolation]
activeViolations :: Maybe [ActiveViolation]
$sel:activeViolations:ListActiveViolationsResponse' :: ListActiveViolationsResponse -> Maybe [ActiveViolation]
activeViolations} -> Maybe [ActiveViolation]
activeViolations) (\s :: ListActiveViolationsResponse
s@ListActiveViolationsResponse' {} Maybe [ActiveViolation]
a -> ListActiveViolationsResponse
s {$sel:activeViolations:ListActiveViolationsResponse' :: Maybe [ActiveViolation]
activeViolations = Maybe [ActiveViolation]
a} :: ListActiveViolationsResponse) ((Maybe [ActiveViolation] -> f (Maybe [ActiveViolation]))
 -> ListActiveViolationsResponse -> f ListActiveViolationsResponse)
-> ((Maybe [ActiveViolation] -> f (Maybe [ActiveViolation]))
    -> Maybe [ActiveViolation] -> f (Maybe [ActiveViolation]))
-> (Maybe [ActiveViolation] -> f (Maybe [ActiveViolation]))
-> ListActiveViolationsResponse
-> f ListActiveViolationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ActiveViolation]
  [ActiveViolation]
  [ActiveViolation]
  [ActiveViolation]
-> Iso
     (Maybe [ActiveViolation])
     (Maybe [ActiveViolation])
     (Maybe [ActiveViolation])
     (Maybe [ActiveViolation])
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
  [ActiveViolation]
  [ActiveViolation]
  [ActiveViolation]
  [ActiveViolation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token that can be used to retrieve the next set of results, or @null@
-- if there are no additional results.
listActiveViolationsResponse_nextToken :: Lens.Lens' ListActiveViolationsResponse (Prelude.Maybe Prelude.Text)
listActiveViolationsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListActiveViolationsResponse -> f ListActiveViolationsResponse
listActiveViolationsResponse_nextToken = (ListActiveViolationsResponse -> Maybe Text)
-> (ListActiveViolationsResponse
    -> Maybe Text -> ListActiveViolationsResponse)
-> Lens' ListActiveViolationsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActiveViolationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListActiveViolationsResponse' :: ListActiveViolationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListActiveViolationsResponse
s@ListActiveViolationsResponse' {} Maybe Text
a -> ListActiveViolationsResponse
s {$sel:nextToken:ListActiveViolationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListActiveViolationsResponse)

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

instance Prelude.NFData ListActiveViolationsResponse