{-# 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.Shield.ListAttacks
-- 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)
--
-- Returns all ongoing DDoS attacks or all DDoS attacks during a specified
-- time period.
--
-- This operation returns paginated results.
module Amazonka.Shield.ListAttacks
  ( -- * Creating a Request
    ListAttacks (..),
    newListAttacks,

    -- * Request Lenses
    listAttacks_startTime,
    listAttacks_resourceArns,
    listAttacks_nextToken,
    listAttacks_endTime,
    listAttacks_maxResults,

    -- * Destructuring the Response
    ListAttacksResponse (..),
    newListAttacksResponse,

    -- * Response Lenses
    listAttacksResponse_attackSummaries,
    listAttacksResponse_nextToken,
    listAttacksResponse_httpStatus,
  )
where

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
import Amazonka.Shield.Types

-- | /See:/ 'newListAttacks' smart constructor.
data ListAttacks = ListAttacks'
  { -- | The start of the time period for the attacks. This is a @timestamp@
    -- type. The sample request above indicates a @number@ type because the
    -- default used by WAF is Unix time in seconds. However any valid
    -- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp format>
    -- is allowed.
    ListAttacks -> Maybe TimeRange
startTime :: Prelude.Maybe TimeRange,
    -- | The ARN (Amazon Resource Name) of the resource that was attacked. If
    -- this is left blank, all applicable resources for this account will be
    -- included.
    ListAttacks -> Maybe [Text]
resourceArns :: Prelude.Maybe [Prelude.Text],
    -- | The @ListAttacksRequest.NextMarker@ value from a previous call to
    -- @ListAttacksRequest@. Pass null if this is the first call.
    ListAttacks -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The end of the time period for the attacks. This is a @timestamp@ type.
    -- The sample request above indicates a @number@ type because the default
    -- used by WAF is Unix time in seconds. However any valid
    -- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp format>
    -- is allowed.
    ListAttacks -> Maybe TimeRange
endTime :: Prelude.Maybe TimeRange,
    -- | The maximum number of AttackSummary objects to return. If you leave this
    -- blank, Shield Advanced returns the first 20 results.
    --
    -- This is a maximum value. Shield Advanced might return the results in
    -- smaller batches. That is, the number of objects returned could be less
    -- than @MaxResults@, even if there are still more objects yet to return.
    -- If there are more objects to return, Shield Advanced returns a value in
    -- @NextToken@ that you can use in your next request, to get the next batch
    -- of objects.
    ListAttacks -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListAttacks -> ListAttacks -> Bool
(ListAttacks -> ListAttacks -> Bool)
-> (ListAttacks -> ListAttacks -> Bool) -> Eq ListAttacks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttacks -> ListAttacks -> Bool
$c/= :: ListAttacks -> ListAttacks -> Bool
== :: ListAttacks -> ListAttacks -> Bool
$c== :: ListAttacks -> ListAttacks -> Bool
Prelude.Eq, ReadPrec [ListAttacks]
ReadPrec ListAttacks
Int -> ReadS ListAttacks
ReadS [ListAttacks]
(Int -> ReadS ListAttacks)
-> ReadS [ListAttacks]
-> ReadPrec ListAttacks
-> ReadPrec [ListAttacks]
-> Read ListAttacks
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttacks]
$creadListPrec :: ReadPrec [ListAttacks]
readPrec :: ReadPrec ListAttacks
$creadPrec :: ReadPrec ListAttacks
readList :: ReadS [ListAttacks]
$creadList :: ReadS [ListAttacks]
readsPrec :: Int -> ReadS ListAttacks
$creadsPrec :: Int -> ReadS ListAttacks
Prelude.Read, Int -> ListAttacks -> ShowS
[ListAttacks] -> ShowS
ListAttacks -> String
(Int -> ListAttacks -> ShowS)
-> (ListAttacks -> String)
-> ([ListAttacks] -> ShowS)
-> Show ListAttacks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttacks] -> ShowS
$cshowList :: [ListAttacks] -> ShowS
show :: ListAttacks -> String
$cshow :: ListAttacks -> String
showsPrec :: Int -> ListAttacks -> ShowS
$cshowsPrec :: Int -> ListAttacks -> ShowS
Prelude.Show, (forall x. ListAttacks -> Rep ListAttacks x)
-> (forall x. Rep ListAttacks x -> ListAttacks)
-> Generic ListAttacks
forall x. Rep ListAttacks x -> ListAttacks
forall x. ListAttacks -> Rep ListAttacks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAttacks x -> ListAttacks
$cfrom :: forall x. ListAttacks -> Rep ListAttacks x
Prelude.Generic)

-- |
-- Create a value of 'ListAttacks' 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:
--
-- 'startTime', 'listAttacks_startTime' - The start of the time period for the attacks. This is a @timestamp@
-- type. The sample request above indicates a @number@ type because the
-- default used by WAF is Unix time in seconds. However any valid
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp format>
-- is allowed.
--
-- 'resourceArns', 'listAttacks_resourceArns' - The ARN (Amazon Resource Name) of the resource that was attacked. If
-- this is left blank, all applicable resources for this account will be
-- included.
--
-- 'nextToken', 'listAttacks_nextToken' - The @ListAttacksRequest.NextMarker@ value from a previous call to
-- @ListAttacksRequest@. Pass null if this is the first call.
--
-- 'endTime', 'listAttacks_endTime' - The end of the time period for the attacks. This is a @timestamp@ type.
-- The sample request above indicates a @number@ type because the default
-- used by WAF is Unix time in seconds. However any valid
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp format>
-- is allowed.
--
-- 'maxResults', 'listAttacks_maxResults' - The maximum number of AttackSummary objects to return. If you leave this
-- blank, Shield Advanced returns the first 20 results.
--
-- This is a maximum value. Shield Advanced might return the results in
-- smaller batches. That is, the number of objects returned could be less
-- than @MaxResults@, even if there are still more objects yet to return.
-- If there are more objects to return, Shield Advanced returns a value in
-- @NextToken@ that you can use in your next request, to get the next batch
-- of objects.
newListAttacks ::
  ListAttacks
newListAttacks :: ListAttacks
newListAttacks =
  ListAttacks' :: Maybe TimeRange
-> Maybe [Text]
-> Maybe Text
-> Maybe TimeRange
-> Maybe Natural
-> ListAttacks
ListAttacks'
    { $sel:startTime:ListAttacks' :: Maybe TimeRange
startTime = Maybe TimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArns:ListAttacks' :: Maybe [Text]
resourceArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAttacks' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:ListAttacks' :: Maybe TimeRange
endTime = Maybe TimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAttacks' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The start of the time period for the attacks. This is a @timestamp@
-- type. The sample request above indicates a @number@ type because the
-- default used by WAF is Unix time in seconds. However any valid
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp format>
-- is allowed.
listAttacks_startTime :: Lens.Lens' ListAttacks (Prelude.Maybe TimeRange)
listAttacks_startTime :: (Maybe TimeRange -> f (Maybe TimeRange))
-> ListAttacks -> f ListAttacks
listAttacks_startTime = (ListAttacks -> Maybe TimeRange)
-> (ListAttacks -> Maybe TimeRange -> ListAttacks)
-> Lens ListAttacks ListAttacks (Maybe TimeRange) (Maybe TimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacks' {Maybe TimeRange
startTime :: Maybe TimeRange
$sel:startTime:ListAttacks' :: ListAttacks -> Maybe TimeRange
startTime} -> Maybe TimeRange
startTime) (\s :: ListAttacks
s@ListAttacks' {} Maybe TimeRange
a -> ListAttacks
s {$sel:startTime:ListAttacks' :: Maybe TimeRange
startTime = Maybe TimeRange
a} :: ListAttacks)

-- | The ARN (Amazon Resource Name) of the resource that was attacked. If
-- this is left blank, all applicable resources for this account will be
-- included.
listAttacks_resourceArns :: Lens.Lens' ListAttacks (Prelude.Maybe [Prelude.Text])
listAttacks_resourceArns :: (Maybe [Text] -> f (Maybe [Text])) -> ListAttacks -> f ListAttacks
listAttacks_resourceArns = (ListAttacks -> Maybe [Text])
-> (ListAttacks -> Maybe [Text] -> ListAttacks)
-> Lens ListAttacks ListAttacks (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacks' {Maybe [Text]
resourceArns :: Maybe [Text]
$sel:resourceArns:ListAttacks' :: ListAttacks -> Maybe [Text]
resourceArns} -> Maybe [Text]
resourceArns) (\s :: ListAttacks
s@ListAttacks' {} Maybe [Text]
a -> ListAttacks
s {$sel:resourceArns:ListAttacks' :: Maybe [Text]
resourceArns = Maybe [Text]
a} :: ListAttacks) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListAttacks -> f ListAttacks)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListAttacks
-> f ListAttacks
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The @ListAttacksRequest.NextMarker@ value from a previous call to
-- @ListAttacksRequest@. Pass null if this is the first call.
listAttacks_nextToken :: Lens.Lens' ListAttacks (Prelude.Maybe Prelude.Text)
listAttacks_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListAttacks -> f ListAttacks
listAttacks_nextToken = (ListAttacks -> Maybe Text)
-> (ListAttacks -> Maybe Text -> ListAttacks)
-> Lens ListAttacks ListAttacks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacks' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAttacks' :: ListAttacks -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAttacks
s@ListAttacks' {} Maybe Text
a -> ListAttacks
s {$sel:nextToken:ListAttacks' :: Maybe Text
nextToken = Maybe Text
a} :: ListAttacks)

-- | The end of the time period for the attacks. This is a @timestamp@ type.
-- The sample request above indicates a @number@ type because the default
-- used by WAF is Unix time in seconds. However any valid
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp format>
-- is allowed.
listAttacks_endTime :: Lens.Lens' ListAttacks (Prelude.Maybe TimeRange)
listAttacks_endTime :: (Maybe TimeRange -> f (Maybe TimeRange))
-> ListAttacks -> f ListAttacks
listAttacks_endTime = (ListAttacks -> Maybe TimeRange)
-> (ListAttacks -> Maybe TimeRange -> ListAttacks)
-> Lens ListAttacks ListAttacks (Maybe TimeRange) (Maybe TimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacks' {Maybe TimeRange
endTime :: Maybe TimeRange
$sel:endTime:ListAttacks' :: ListAttacks -> Maybe TimeRange
endTime} -> Maybe TimeRange
endTime) (\s :: ListAttacks
s@ListAttacks' {} Maybe TimeRange
a -> ListAttacks
s {$sel:endTime:ListAttacks' :: Maybe TimeRange
endTime = Maybe TimeRange
a} :: ListAttacks)

-- | The maximum number of AttackSummary objects to return. If you leave this
-- blank, Shield Advanced returns the first 20 results.
--
-- This is a maximum value. Shield Advanced might return the results in
-- smaller batches. That is, the number of objects returned could be less
-- than @MaxResults@, even if there are still more objects yet to return.
-- If there are more objects to return, Shield Advanced returns a value in
-- @NextToken@ that you can use in your next request, to get the next batch
-- of objects.
listAttacks_maxResults :: Lens.Lens' ListAttacks (Prelude.Maybe Prelude.Natural)
listAttacks_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAttacks -> f ListAttacks
listAttacks_maxResults = (ListAttacks -> Maybe Natural)
-> (ListAttacks -> Maybe Natural -> ListAttacks)
-> Lens ListAttacks ListAttacks (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacks' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAttacks' :: ListAttacks -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAttacks
s@ListAttacks' {} Maybe Natural
a -> ListAttacks
s {$sel:maxResults:ListAttacks' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAttacks)

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

instance Prelude.NFData ListAttacks

instance Core.ToHeaders ListAttacks where
  toHeaders :: ListAttacks -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAttacks -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSShield_20160616.ListAttacks" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListAttacks where
  toJSON :: ListAttacks -> Value
toJSON ListAttacks' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe TimeRange
maxResults :: Maybe Natural
endTime :: Maybe TimeRange
nextToken :: Maybe Text
resourceArns :: Maybe [Text]
startTime :: Maybe TimeRange
$sel:maxResults:ListAttacks' :: ListAttacks -> Maybe Natural
$sel:endTime:ListAttacks' :: ListAttacks -> Maybe TimeRange
$sel:nextToken:ListAttacks' :: ListAttacks -> Maybe Text
$sel:resourceArns:ListAttacks' :: ListAttacks -> Maybe [Text]
$sel:startTime:ListAttacks' :: ListAttacks -> Maybe TimeRange
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StartTime" Text -> TimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TimeRange -> Pair) -> Maybe TimeRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeRange
startTime,
            (Text
"ResourceArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
resourceArns,
            (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"EndTime" Text -> TimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TimeRange -> Pair) -> Maybe TimeRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeRange
endTime,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

instance Core.ToQuery ListAttacks where
  toQuery :: ListAttacks -> QueryString
toQuery = QueryString -> ListAttacks -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListAttacksResponse' smart constructor.
data ListAttacksResponse = ListAttacksResponse'
  { -- | The attack information for the specified time range.
    ListAttacksResponse -> Maybe [AttackSummary]
attackSummaries :: Prelude.Maybe [AttackSummary],
    -- | The token returned by a previous call to indicate that there is more
    -- data available. If not null, more results are available. Pass this value
    -- for the @NextMarker@ parameter in a subsequent call to @ListAttacks@ to
    -- retrieve the next set of items.
    --
    -- Shield Advanced might return the list of AttackSummary objects in
    -- batches smaller than the number specified by MaxResults. If there are
    -- more attack summary objects to return, Shield Advanced will always also
    -- return a @NextToken@.
    ListAttacksResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAttacksResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAttacksResponse -> ListAttacksResponse -> Bool
(ListAttacksResponse -> ListAttacksResponse -> Bool)
-> (ListAttacksResponse -> ListAttacksResponse -> Bool)
-> Eq ListAttacksResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttacksResponse -> ListAttacksResponse -> Bool
$c/= :: ListAttacksResponse -> ListAttacksResponse -> Bool
== :: ListAttacksResponse -> ListAttacksResponse -> Bool
$c== :: ListAttacksResponse -> ListAttacksResponse -> Bool
Prelude.Eq, ReadPrec [ListAttacksResponse]
ReadPrec ListAttacksResponse
Int -> ReadS ListAttacksResponse
ReadS [ListAttacksResponse]
(Int -> ReadS ListAttacksResponse)
-> ReadS [ListAttacksResponse]
-> ReadPrec ListAttacksResponse
-> ReadPrec [ListAttacksResponse]
-> Read ListAttacksResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttacksResponse]
$creadListPrec :: ReadPrec [ListAttacksResponse]
readPrec :: ReadPrec ListAttacksResponse
$creadPrec :: ReadPrec ListAttacksResponse
readList :: ReadS [ListAttacksResponse]
$creadList :: ReadS [ListAttacksResponse]
readsPrec :: Int -> ReadS ListAttacksResponse
$creadsPrec :: Int -> ReadS ListAttacksResponse
Prelude.Read, Int -> ListAttacksResponse -> ShowS
[ListAttacksResponse] -> ShowS
ListAttacksResponse -> String
(Int -> ListAttacksResponse -> ShowS)
-> (ListAttacksResponse -> String)
-> ([ListAttacksResponse] -> ShowS)
-> Show ListAttacksResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttacksResponse] -> ShowS
$cshowList :: [ListAttacksResponse] -> ShowS
show :: ListAttacksResponse -> String
$cshow :: ListAttacksResponse -> String
showsPrec :: Int -> ListAttacksResponse -> ShowS
$cshowsPrec :: Int -> ListAttacksResponse -> ShowS
Prelude.Show, (forall x. ListAttacksResponse -> Rep ListAttacksResponse x)
-> (forall x. Rep ListAttacksResponse x -> ListAttacksResponse)
-> Generic ListAttacksResponse
forall x. Rep ListAttacksResponse x -> ListAttacksResponse
forall x. ListAttacksResponse -> Rep ListAttacksResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAttacksResponse x -> ListAttacksResponse
$cfrom :: forall x. ListAttacksResponse -> Rep ListAttacksResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAttacksResponse' 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:
--
-- 'attackSummaries', 'listAttacksResponse_attackSummaries' - The attack information for the specified time range.
--
-- 'nextToken', 'listAttacksResponse_nextToken' - The token returned by a previous call to indicate that there is more
-- data available. If not null, more results are available. Pass this value
-- for the @NextMarker@ parameter in a subsequent call to @ListAttacks@ to
-- retrieve the next set of items.
--
-- Shield Advanced might return the list of AttackSummary objects in
-- batches smaller than the number specified by MaxResults. If there are
-- more attack summary objects to return, Shield Advanced will always also
-- return a @NextToken@.
--
-- 'httpStatus', 'listAttacksResponse_httpStatus' - The response's http status code.
newListAttacksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAttacksResponse
newListAttacksResponse :: Int -> ListAttacksResponse
newListAttacksResponse Int
pHttpStatus_ =
  ListAttacksResponse' :: Maybe [AttackSummary] -> Maybe Text -> Int -> ListAttacksResponse
ListAttacksResponse'
    { $sel:attackSummaries:ListAttacksResponse' :: Maybe [AttackSummary]
attackSummaries =
        Maybe [AttackSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAttacksResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAttacksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The attack information for the specified time range.
listAttacksResponse_attackSummaries :: Lens.Lens' ListAttacksResponse (Prelude.Maybe [AttackSummary])
listAttacksResponse_attackSummaries :: (Maybe [AttackSummary] -> f (Maybe [AttackSummary]))
-> ListAttacksResponse -> f ListAttacksResponse
listAttacksResponse_attackSummaries = (ListAttacksResponse -> Maybe [AttackSummary])
-> (ListAttacksResponse
    -> Maybe [AttackSummary] -> ListAttacksResponse)
-> Lens' ListAttacksResponse (Maybe [AttackSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacksResponse' {Maybe [AttackSummary]
attackSummaries :: Maybe [AttackSummary]
$sel:attackSummaries:ListAttacksResponse' :: ListAttacksResponse -> Maybe [AttackSummary]
attackSummaries} -> Maybe [AttackSummary]
attackSummaries) (\s :: ListAttacksResponse
s@ListAttacksResponse' {} Maybe [AttackSummary]
a -> ListAttacksResponse
s {$sel:attackSummaries:ListAttacksResponse' :: Maybe [AttackSummary]
attackSummaries = Maybe [AttackSummary]
a} :: ListAttacksResponse) ((Maybe [AttackSummary] -> f (Maybe [AttackSummary]))
 -> ListAttacksResponse -> f ListAttacksResponse)
-> ((Maybe [AttackSummary] -> f (Maybe [AttackSummary]))
    -> Maybe [AttackSummary] -> f (Maybe [AttackSummary]))
-> (Maybe [AttackSummary] -> f (Maybe [AttackSummary]))
-> ListAttacksResponse
-> f ListAttacksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttackSummary] [AttackSummary] [AttackSummary] [AttackSummary]
-> Iso
     (Maybe [AttackSummary])
     (Maybe [AttackSummary])
     (Maybe [AttackSummary])
     (Maybe [AttackSummary])
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
  [AttackSummary] [AttackSummary] [AttackSummary] [AttackSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token returned by a previous call to indicate that there is more
-- data available. If not null, more results are available. Pass this value
-- for the @NextMarker@ parameter in a subsequent call to @ListAttacks@ to
-- retrieve the next set of items.
--
-- Shield Advanced might return the list of AttackSummary objects in
-- batches smaller than the number specified by MaxResults. If there are
-- more attack summary objects to return, Shield Advanced will always also
-- return a @NextToken@.
listAttacksResponse_nextToken :: Lens.Lens' ListAttacksResponse (Prelude.Maybe Prelude.Text)
listAttacksResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAttacksResponse -> f ListAttacksResponse
listAttacksResponse_nextToken = (ListAttacksResponse -> Maybe Text)
-> (ListAttacksResponse -> Maybe Text -> ListAttacksResponse)
-> Lens' ListAttacksResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttacksResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAttacksResponse' :: ListAttacksResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAttacksResponse
s@ListAttacksResponse' {} Maybe Text
a -> ListAttacksResponse
s {$sel:nextToken:ListAttacksResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAttacksResponse)

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

instance Prelude.NFData ListAttacksResponse