{-# 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.ListViolationEvents
-- 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 Device Defender security profile violations discovered during
-- the given time period. You can use filters to limit the results to those
-- alerts issued for a particular security profile, behavior, or thing
-- (device).
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions ListViolationEvents>
-- action.
--
-- This operation returns paginated results.
module Amazonka.IoT.ListViolationEvents
  ( -- * Creating a Request
    ListViolationEvents (..),
    newListViolationEvents,

    -- * Request Lenses
    listViolationEvents_nextToken,
    listViolationEvents_listSuppressedAlerts,
    listViolationEvents_behaviorCriteriaType,
    listViolationEvents_securityProfileName,
    listViolationEvents_thingName,
    listViolationEvents_verificationState,
    listViolationEvents_maxResults,
    listViolationEvents_startTime,
    listViolationEvents_endTime,

    -- * Destructuring the Response
    ListViolationEventsResponse (..),
    newListViolationEventsResponse,

    -- * Response Lenses
    listViolationEventsResponse_violationEvents,
    listViolationEventsResponse_nextToken,
    listViolationEventsResponse_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:/ 'newListViolationEvents' smart constructor.
data ListViolationEvents = ListViolationEvents'
  { -- | The token for the next set of results.
    ListViolationEvents -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of all suppressed alerts.
    ListViolationEvents -> Maybe Bool
listSuppressedAlerts :: Prelude.Maybe Prelude.Bool,
    -- | The criteria for a behavior.
    ListViolationEvents -> Maybe BehaviorCriteriaType
behaviorCriteriaType :: Prelude.Maybe BehaviorCriteriaType,
    -- | A filter to limit results to those alerts generated by the specified
    -- security profile.
    ListViolationEvents -> Maybe Text
securityProfileName :: Prelude.Maybe Prelude.Text,
    -- | A filter to limit results to those alerts caused by the specified thing.
    ListViolationEvents -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
    -- | The verification state of the violation (detect alarm).
    ListViolationEvents -> Maybe VerificationState
verificationState :: Prelude.Maybe VerificationState,
    -- | The maximum number of results to return at one time.
    ListViolationEvents -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The start time for the alerts to be listed.
    ListViolationEvents -> POSIX
startTime :: Core.POSIX,
    -- | The end time for the alerts to be listed.
    ListViolationEvents -> POSIX
endTime :: Core.POSIX
  }
  deriving (ListViolationEvents -> ListViolationEvents -> Bool
(ListViolationEvents -> ListViolationEvents -> Bool)
-> (ListViolationEvents -> ListViolationEvents -> Bool)
-> Eq ListViolationEvents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListViolationEvents -> ListViolationEvents -> Bool
$c/= :: ListViolationEvents -> ListViolationEvents -> Bool
== :: ListViolationEvents -> ListViolationEvents -> Bool
$c== :: ListViolationEvents -> ListViolationEvents -> Bool
Prelude.Eq, ReadPrec [ListViolationEvents]
ReadPrec ListViolationEvents
Int -> ReadS ListViolationEvents
ReadS [ListViolationEvents]
(Int -> ReadS ListViolationEvents)
-> ReadS [ListViolationEvents]
-> ReadPrec ListViolationEvents
-> ReadPrec [ListViolationEvents]
-> Read ListViolationEvents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListViolationEvents]
$creadListPrec :: ReadPrec [ListViolationEvents]
readPrec :: ReadPrec ListViolationEvents
$creadPrec :: ReadPrec ListViolationEvents
readList :: ReadS [ListViolationEvents]
$creadList :: ReadS [ListViolationEvents]
readsPrec :: Int -> ReadS ListViolationEvents
$creadsPrec :: Int -> ReadS ListViolationEvents
Prelude.Read, Int -> ListViolationEvents -> ShowS
[ListViolationEvents] -> ShowS
ListViolationEvents -> String
(Int -> ListViolationEvents -> ShowS)
-> (ListViolationEvents -> String)
-> ([ListViolationEvents] -> ShowS)
-> Show ListViolationEvents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListViolationEvents] -> ShowS
$cshowList :: [ListViolationEvents] -> ShowS
show :: ListViolationEvents -> String
$cshow :: ListViolationEvents -> String
showsPrec :: Int -> ListViolationEvents -> ShowS
$cshowsPrec :: Int -> ListViolationEvents -> ShowS
Prelude.Show, (forall x. ListViolationEvents -> Rep ListViolationEvents x)
-> (forall x. Rep ListViolationEvents x -> ListViolationEvents)
-> Generic ListViolationEvents
forall x. Rep ListViolationEvents x -> ListViolationEvents
forall x. ListViolationEvents -> Rep ListViolationEvents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListViolationEvents x -> ListViolationEvents
$cfrom :: forall x. ListViolationEvents -> Rep ListViolationEvents x
Prelude.Generic)

-- |
-- Create a value of 'ListViolationEvents' 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', 'listViolationEvents_nextToken' - The token for the next set of results.
--
-- 'listSuppressedAlerts', 'listViolationEvents_listSuppressedAlerts' - A list of all suppressed alerts.
--
-- 'behaviorCriteriaType', 'listViolationEvents_behaviorCriteriaType' - The criteria for a behavior.
--
-- 'securityProfileName', 'listViolationEvents_securityProfileName' - A filter to limit results to those alerts generated by the specified
-- security profile.
--
-- 'thingName', 'listViolationEvents_thingName' - A filter to limit results to those alerts caused by the specified thing.
--
-- 'verificationState', 'listViolationEvents_verificationState' - The verification state of the violation (detect alarm).
--
-- 'maxResults', 'listViolationEvents_maxResults' - The maximum number of results to return at one time.
--
-- 'startTime', 'listViolationEvents_startTime' - The start time for the alerts to be listed.
--
-- 'endTime', 'listViolationEvents_endTime' - The end time for the alerts to be listed.
newListViolationEvents ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  ListViolationEvents
newListViolationEvents :: UTCTime -> UTCTime -> ListViolationEvents
newListViolationEvents UTCTime
pStartTime_ UTCTime
pEndTime_ =
  ListViolationEvents' :: Maybe Text
-> Maybe Bool
-> Maybe BehaviorCriteriaType
-> Maybe Text
-> Maybe Text
-> Maybe VerificationState
-> Maybe Natural
-> POSIX
-> POSIX
-> ListViolationEvents
ListViolationEvents'
    { $sel:nextToken:ListViolationEvents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:listSuppressedAlerts:ListViolationEvents' :: Maybe Bool
listSuppressedAlerts = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:behaviorCriteriaType:ListViolationEvents' :: Maybe BehaviorCriteriaType
behaviorCriteriaType = Maybe BehaviorCriteriaType
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileName:ListViolationEvents' :: Maybe Text
securityProfileName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ListViolationEvents' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:verificationState:ListViolationEvents' :: Maybe VerificationState
verificationState = Maybe VerificationState
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListViolationEvents' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:ListViolationEvents' :: POSIX
startTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:endTime:ListViolationEvents' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
    }

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

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

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

-- | A filter to limit results to those alerts generated by the specified
-- security profile.
listViolationEvents_securityProfileName :: Lens.Lens' ListViolationEvents (Prelude.Maybe Prelude.Text)
listViolationEvents_securityProfileName :: (Maybe Text -> f (Maybe Text))
-> ListViolationEvents -> f ListViolationEvents
listViolationEvents_securityProfileName = (ListViolationEvents -> Maybe Text)
-> (ListViolationEvents -> Maybe Text -> ListViolationEvents)
-> Lens
     ListViolationEvents ListViolationEvents (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListViolationEvents' {Maybe Text
securityProfileName :: Maybe Text
$sel:securityProfileName:ListViolationEvents' :: ListViolationEvents -> Maybe Text
securityProfileName} -> Maybe Text
securityProfileName) (\s :: ListViolationEvents
s@ListViolationEvents' {} Maybe Text
a -> ListViolationEvents
s {$sel:securityProfileName:ListViolationEvents' :: Maybe Text
securityProfileName = Maybe Text
a} :: ListViolationEvents)

-- | A filter to limit results to those alerts caused by the specified thing.
listViolationEvents_thingName :: Lens.Lens' ListViolationEvents (Prelude.Maybe Prelude.Text)
listViolationEvents_thingName :: (Maybe Text -> f (Maybe Text))
-> ListViolationEvents -> f ListViolationEvents
listViolationEvents_thingName = (ListViolationEvents -> Maybe Text)
-> (ListViolationEvents -> Maybe Text -> ListViolationEvents)
-> Lens
     ListViolationEvents ListViolationEvents (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListViolationEvents' {Maybe Text
thingName :: Maybe Text
$sel:thingName:ListViolationEvents' :: ListViolationEvents -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: ListViolationEvents
s@ListViolationEvents' {} Maybe Text
a -> ListViolationEvents
s {$sel:thingName:ListViolationEvents' :: Maybe Text
thingName = Maybe Text
a} :: ListViolationEvents)

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

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

-- | The start time for the alerts to be listed.
listViolationEvents_startTime :: Lens.Lens' ListViolationEvents Prelude.UTCTime
listViolationEvents_startTime :: (UTCTime -> f UTCTime)
-> ListViolationEvents -> f ListViolationEvents
listViolationEvents_startTime = (ListViolationEvents -> POSIX)
-> (ListViolationEvents -> POSIX -> ListViolationEvents)
-> Lens ListViolationEvents ListViolationEvents POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListViolationEvents' {POSIX
startTime :: POSIX
$sel:startTime:ListViolationEvents' :: ListViolationEvents -> POSIX
startTime} -> POSIX
startTime) (\s :: ListViolationEvents
s@ListViolationEvents' {} POSIX
a -> ListViolationEvents
s {$sel:startTime:ListViolationEvents' :: POSIX
startTime = POSIX
a} :: ListViolationEvents) ((POSIX -> f POSIX)
 -> ListViolationEvents -> f ListViolationEvents)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListViolationEvents
-> f ListViolationEvents
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The end time for the alerts to be listed.
listViolationEvents_endTime :: Lens.Lens' ListViolationEvents Prelude.UTCTime
listViolationEvents_endTime :: (UTCTime -> f UTCTime)
-> ListViolationEvents -> f ListViolationEvents
listViolationEvents_endTime = (ListViolationEvents -> POSIX)
-> (ListViolationEvents -> POSIX -> ListViolationEvents)
-> Lens ListViolationEvents ListViolationEvents POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListViolationEvents' {POSIX
endTime :: POSIX
$sel:endTime:ListViolationEvents' :: ListViolationEvents -> POSIX
endTime} -> POSIX
endTime) (\s :: ListViolationEvents
s@ListViolationEvents' {} POSIX
a -> ListViolationEvents
s {$sel:endTime:ListViolationEvents' :: POSIX
endTime = POSIX
a} :: ListViolationEvents) ((POSIX -> f POSIX)
 -> ListViolationEvents -> f ListViolationEvents)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListViolationEvents
-> f ListViolationEvents
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.AWSPager ListViolationEvents where
  page :: ListViolationEvents
-> AWSResponse ListViolationEvents -> Maybe ListViolationEvents
page ListViolationEvents
rq AWSResponse ListViolationEvents
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListViolationEvents
ListViolationEventsResponse
rs
            ListViolationEventsResponse
-> Getting (First Text) ListViolationEventsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListViolationEventsResponse
-> Const (First Text) ListViolationEventsResponse
Lens' ListViolationEventsResponse (Maybe Text)
listViolationEventsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListViolationEventsResponse
 -> Const (First Text) ListViolationEventsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListViolationEventsResponse 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 ListViolationEvents
forall a. Maybe a
Prelude.Nothing
    | Maybe [ViolationEvent] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListViolationEvents
ListViolationEventsResponse
rs
            ListViolationEventsResponse
-> Getting
     (First [ViolationEvent])
     ListViolationEventsResponse
     [ViolationEvent]
-> Maybe [ViolationEvent]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ViolationEvent]
 -> Const (First [ViolationEvent]) (Maybe [ViolationEvent]))
-> ListViolationEventsResponse
-> Const (First [ViolationEvent]) ListViolationEventsResponse
Lens' ListViolationEventsResponse (Maybe [ViolationEvent])
listViolationEventsResponse_violationEvents
              ((Maybe [ViolationEvent]
  -> Const (First [ViolationEvent]) (Maybe [ViolationEvent]))
 -> ListViolationEventsResponse
 -> Const (First [ViolationEvent]) ListViolationEventsResponse)
-> (([ViolationEvent]
     -> Const (First [ViolationEvent]) [ViolationEvent])
    -> Maybe [ViolationEvent]
    -> Const (First [ViolationEvent]) (Maybe [ViolationEvent]))
-> Getting
     (First [ViolationEvent])
     ListViolationEventsResponse
     [ViolationEvent]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ViolationEvent]
 -> Const (First [ViolationEvent]) [ViolationEvent])
-> Maybe [ViolationEvent]
-> Const (First [ViolationEvent]) (Maybe [ViolationEvent])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListViolationEvents
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListViolationEvents -> Maybe ListViolationEvents
forall a. a -> Maybe a
Prelude.Just (ListViolationEvents -> Maybe ListViolationEvents)
-> ListViolationEvents -> Maybe ListViolationEvents
forall a b. (a -> b) -> a -> b
Prelude.$
        ListViolationEvents
rq
          ListViolationEvents
-> (ListViolationEvents -> ListViolationEvents)
-> ListViolationEvents
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListViolationEvents -> Identity ListViolationEvents
Lens
  ListViolationEvents ListViolationEvents (Maybe Text) (Maybe Text)
listViolationEvents_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListViolationEvents -> Identity ListViolationEvents)
-> Maybe Text -> ListViolationEvents -> ListViolationEvents
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListViolationEvents
ListViolationEventsResponse
rs
          ListViolationEventsResponse
-> Getting (First Text) ListViolationEventsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListViolationEventsResponse
-> Const (First Text) ListViolationEventsResponse
Lens' ListViolationEventsResponse (Maybe Text)
listViolationEventsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListViolationEventsResponse
 -> Const (First Text) ListViolationEventsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListViolationEventsResponse 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 ListViolationEvents where
  type
    AWSResponse ListViolationEvents =
      ListViolationEventsResponse
  request :: ListViolationEvents -> Request ListViolationEvents
request = Service -> ListViolationEvents -> Request ListViolationEvents
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListViolationEvents
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListViolationEvents)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListViolationEvents))
-> Logger
-> Service
-> Proxy ListViolationEvents
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListViolationEvents)))
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 [ViolationEvent]
-> Maybe Text -> Int -> ListViolationEventsResponse
ListViolationEventsResponse'
            (Maybe [ViolationEvent]
 -> Maybe Text -> Int -> ListViolationEventsResponse)
-> Either String (Maybe [ViolationEvent])
-> Either String (Maybe Text -> Int -> ListViolationEventsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ViolationEvent]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"violationEvents"
                            Either String (Maybe (Maybe [ViolationEvent]))
-> Maybe [ViolationEvent] -> Either String (Maybe [ViolationEvent])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ViolationEvent]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe Text -> Int -> ListViolationEventsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListViolationEventsResponse)
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 -> ListViolationEventsResponse)
-> Either String Int -> Either String ListViolationEventsResponse
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 ListViolationEvents

instance Prelude.NFData ListViolationEvents

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

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

instance Core.ToQuery ListViolationEvents where
  toQuery :: ListViolationEvents -> QueryString
toQuery ListViolationEvents' {Maybe Bool
Maybe Natural
Maybe Text
Maybe BehaviorCriteriaType
Maybe VerificationState
POSIX
endTime :: POSIX
startTime :: POSIX
maxResults :: Maybe Natural
verificationState :: Maybe VerificationState
thingName :: Maybe Text
securityProfileName :: Maybe Text
behaviorCriteriaType :: Maybe BehaviorCriteriaType
listSuppressedAlerts :: Maybe Bool
nextToken :: Maybe Text
$sel:endTime:ListViolationEvents' :: ListViolationEvents -> POSIX
$sel:startTime:ListViolationEvents' :: ListViolationEvents -> POSIX
$sel:maxResults:ListViolationEvents' :: ListViolationEvents -> Maybe Natural
$sel:verificationState:ListViolationEvents' :: ListViolationEvents -> Maybe VerificationState
$sel:thingName:ListViolationEvents' :: ListViolationEvents -> Maybe Text
$sel:securityProfileName:ListViolationEvents' :: ListViolationEvents -> Maybe Text
$sel:behaviorCriteriaType:ListViolationEvents' :: ListViolationEvents -> Maybe BehaviorCriteriaType
$sel:listSuppressedAlerts:ListViolationEvents' :: ListViolationEvents -> Maybe Bool
$sel:nextToken:ListViolationEvents' :: ListViolationEvents -> 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,
        ByteString
"startTime" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
startTime,
        ByteString
"endTime" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
endTime
      ]

-- | /See:/ 'newListViolationEventsResponse' smart constructor.
data ListViolationEventsResponse = ListViolationEventsResponse'
  { -- | The security profile violation alerts issued for this account during the
    -- given time period, potentially filtered by security profile, behavior
    -- violated, or thing (device) violating.
    ListViolationEventsResponse -> Maybe [ViolationEvent]
violationEvents :: Prelude.Maybe [ViolationEvent],
    -- | A token that can be used to retrieve the next set of results, or @null@
    -- if there are no additional results.
    ListViolationEventsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListViolationEventsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListViolationEventsResponse -> ListViolationEventsResponse -> Bool
(ListViolationEventsResponse
 -> ListViolationEventsResponse -> Bool)
-> (ListViolationEventsResponse
    -> ListViolationEventsResponse -> Bool)
-> Eq ListViolationEventsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListViolationEventsResponse -> ListViolationEventsResponse -> Bool
$c/= :: ListViolationEventsResponse -> ListViolationEventsResponse -> Bool
== :: ListViolationEventsResponse -> ListViolationEventsResponse -> Bool
$c== :: ListViolationEventsResponse -> ListViolationEventsResponse -> Bool
Prelude.Eq, ReadPrec [ListViolationEventsResponse]
ReadPrec ListViolationEventsResponse
Int -> ReadS ListViolationEventsResponse
ReadS [ListViolationEventsResponse]
(Int -> ReadS ListViolationEventsResponse)
-> ReadS [ListViolationEventsResponse]
-> ReadPrec ListViolationEventsResponse
-> ReadPrec [ListViolationEventsResponse]
-> Read ListViolationEventsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListViolationEventsResponse]
$creadListPrec :: ReadPrec [ListViolationEventsResponse]
readPrec :: ReadPrec ListViolationEventsResponse
$creadPrec :: ReadPrec ListViolationEventsResponse
readList :: ReadS [ListViolationEventsResponse]
$creadList :: ReadS [ListViolationEventsResponse]
readsPrec :: Int -> ReadS ListViolationEventsResponse
$creadsPrec :: Int -> ReadS ListViolationEventsResponse
Prelude.Read, Int -> ListViolationEventsResponse -> ShowS
[ListViolationEventsResponse] -> ShowS
ListViolationEventsResponse -> String
(Int -> ListViolationEventsResponse -> ShowS)
-> (ListViolationEventsResponse -> String)
-> ([ListViolationEventsResponse] -> ShowS)
-> Show ListViolationEventsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListViolationEventsResponse] -> ShowS
$cshowList :: [ListViolationEventsResponse] -> ShowS
show :: ListViolationEventsResponse -> String
$cshow :: ListViolationEventsResponse -> String
showsPrec :: Int -> ListViolationEventsResponse -> ShowS
$cshowsPrec :: Int -> ListViolationEventsResponse -> ShowS
Prelude.Show, (forall x.
 ListViolationEventsResponse -> Rep ListViolationEventsResponse x)
-> (forall x.
    Rep ListViolationEventsResponse x -> ListViolationEventsResponse)
-> Generic ListViolationEventsResponse
forall x.
Rep ListViolationEventsResponse x -> ListViolationEventsResponse
forall x.
ListViolationEventsResponse -> Rep ListViolationEventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListViolationEventsResponse x -> ListViolationEventsResponse
$cfrom :: forall x.
ListViolationEventsResponse -> Rep ListViolationEventsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListViolationEventsResponse' 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:
--
-- 'violationEvents', 'listViolationEventsResponse_violationEvents' - The security profile violation alerts issued for this account during the
-- given time period, potentially filtered by security profile, behavior
-- violated, or thing (device) violating.
--
-- 'nextToken', 'listViolationEventsResponse_nextToken' - A token that can be used to retrieve the next set of results, or @null@
-- if there are no additional results.
--
-- 'httpStatus', 'listViolationEventsResponse_httpStatus' - The response's http status code.
newListViolationEventsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListViolationEventsResponse
newListViolationEventsResponse :: Int -> ListViolationEventsResponse
newListViolationEventsResponse Int
pHttpStatus_ =
  ListViolationEventsResponse' :: Maybe [ViolationEvent]
-> Maybe Text -> Int -> ListViolationEventsResponse
ListViolationEventsResponse'
    { $sel:violationEvents:ListViolationEventsResponse' :: Maybe [ViolationEvent]
violationEvents =
        Maybe [ViolationEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListViolationEventsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListViolationEventsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The security profile violation alerts issued for this account during the
-- given time period, potentially filtered by security profile, behavior
-- violated, or thing (device) violating.
listViolationEventsResponse_violationEvents :: Lens.Lens' ListViolationEventsResponse (Prelude.Maybe [ViolationEvent])
listViolationEventsResponse_violationEvents :: (Maybe [ViolationEvent] -> f (Maybe [ViolationEvent]))
-> ListViolationEventsResponse -> f ListViolationEventsResponse
listViolationEventsResponse_violationEvents = (ListViolationEventsResponse -> Maybe [ViolationEvent])
-> (ListViolationEventsResponse
    -> Maybe [ViolationEvent] -> ListViolationEventsResponse)
-> Lens' ListViolationEventsResponse (Maybe [ViolationEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListViolationEventsResponse' {Maybe [ViolationEvent]
violationEvents :: Maybe [ViolationEvent]
$sel:violationEvents:ListViolationEventsResponse' :: ListViolationEventsResponse -> Maybe [ViolationEvent]
violationEvents} -> Maybe [ViolationEvent]
violationEvents) (\s :: ListViolationEventsResponse
s@ListViolationEventsResponse' {} Maybe [ViolationEvent]
a -> ListViolationEventsResponse
s {$sel:violationEvents:ListViolationEventsResponse' :: Maybe [ViolationEvent]
violationEvents = Maybe [ViolationEvent]
a} :: ListViolationEventsResponse) ((Maybe [ViolationEvent] -> f (Maybe [ViolationEvent]))
 -> ListViolationEventsResponse -> f ListViolationEventsResponse)
-> ((Maybe [ViolationEvent] -> f (Maybe [ViolationEvent]))
    -> Maybe [ViolationEvent] -> f (Maybe [ViolationEvent]))
-> (Maybe [ViolationEvent] -> f (Maybe [ViolationEvent]))
-> ListViolationEventsResponse
-> f ListViolationEventsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ViolationEvent] [ViolationEvent] [ViolationEvent] [ViolationEvent]
-> Iso
     (Maybe [ViolationEvent])
     (Maybe [ViolationEvent])
     (Maybe [ViolationEvent])
     (Maybe [ViolationEvent])
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
  [ViolationEvent] [ViolationEvent] [ViolationEvent] [ViolationEvent]
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.
listViolationEventsResponse_nextToken :: Lens.Lens' ListViolationEventsResponse (Prelude.Maybe Prelude.Text)
listViolationEventsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListViolationEventsResponse -> f ListViolationEventsResponse
listViolationEventsResponse_nextToken = (ListViolationEventsResponse -> Maybe Text)
-> (ListViolationEventsResponse
    -> Maybe Text -> ListViolationEventsResponse)
-> Lens' ListViolationEventsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListViolationEventsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListViolationEventsResponse' :: ListViolationEventsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListViolationEventsResponse
s@ListViolationEventsResponse' {} Maybe Text
a -> ListViolationEventsResponse
s {$sel:nextToken:ListViolationEventsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListViolationEventsResponse)

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

instance Prelude.NFData ListViolationEventsResponse