{-# 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.WAFV2.GetSampledRequests
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets detailed information about a specified number of requests--a
-- sample--that WAF randomly selects from among the first 5,000 requests
-- that your Amazon Web Services resource received during a time range that
-- you choose. You can specify a sample size of up to 500 requests, and you
-- can specify any time range in the previous three hours.
--
-- @GetSampledRequests@ returns a time range, which is usually the time
-- range that you specified. However, if your resource (such as a
-- CloudFront distribution) received 5,000 requests before the specified
-- time range elapsed, @GetSampledRequests@ returns an updated time range.
-- This new time range indicates the actual period during which WAF
-- selected the requests in the sample.
module Amazonka.WAFV2.GetSampledRequests
  ( -- * Creating a Request
    GetSampledRequests (..),
    newGetSampledRequests,

    -- * Request Lenses
    getSampledRequests_webAclArn,
    getSampledRequests_ruleMetricName,
    getSampledRequests_scope,
    getSampledRequests_timeWindow,
    getSampledRequests_maxItems,

    -- * Destructuring the Response
    GetSampledRequestsResponse (..),
    newGetSampledRequestsResponse,

    -- * Response Lenses
    getSampledRequestsResponse_populationSize,
    getSampledRequestsResponse_sampledRequests,
    getSampledRequestsResponse_timeWindow,
    getSampledRequestsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WAFV2.Types

-- | /See:/ 'newGetSampledRequests' smart constructor.
data GetSampledRequests = GetSampledRequests'
  { -- | The Amazon resource name (ARN) of the @WebACL@ for which you want a
    -- sample of requests.
    GetSampledRequests -> Text
webAclArn :: Prelude.Text,
    -- | The metric name assigned to the @Rule@ or @RuleGroup@ for which you want
    -- a sample of requests.
    GetSampledRequests -> Text
ruleMetricName :: Prelude.Text,
    -- | Specifies whether this is for an Amazon CloudFront distribution or for a
    -- regional application. A regional application can be an Application Load
    -- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
    -- or an Amazon Cognito user pool.
    --
    -- To work with CloudFront, you must also specify the Region US East (N.
    -- Virginia) as follows:
    --
    -- -   CLI - Specify the Region when you use the CloudFront scope:
    --     @--scope=CLOUDFRONT --region=us-east-1@.
    --
    -- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
    GetSampledRequests -> Scope
scope :: Scope,
    -- | The start date and time and the end date and time of the range for which
    -- you want @GetSampledRequests@ to return a sample of requests. You must
    -- specify the times in Coordinated Universal Time (UTC) format. UTC format
    -- includes the special designator, @Z@. For example,
    -- @\"2016-09-27T14:50Z\"@. You can specify any time range in the previous
    -- three hours. If you specify a start time that\'s earlier than three
    -- hours ago, WAF sets it to three hours ago.
    GetSampledRequests -> TimeWindow
timeWindow :: TimeWindow,
    -- | The number of requests that you want WAF to return from among the first
    -- 5,000 requests that your Amazon Web Services resource received during
    -- the time range. If your resource received fewer requests than the value
    -- of @MaxItems@, @GetSampledRequests@ returns information about all of
    -- them.
    GetSampledRequests -> Natural
maxItems :: Prelude.Natural
  }
  deriving (GetSampledRequests -> GetSampledRequests -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSampledRequests -> GetSampledRequests -> Bool
$c/= :: GetSampledRequests -> GetSampledRequests -> Bool
== :: GetSampledRequests -> GetSampledRequests -> Bool
$c== :: GetSampledRequests -> GetSampledRequests -> Bool
Prelude.Eq, ReadPrec [GetSampledRequests]
ReadPrec GetSampledRequests
Int -> ReadS GetSampledRequests
ReadS [GetSampledRequests]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSampledRequests]
$creadListPrec :: ReadPrec [GetSampledRequests]
readPrec :: ReadPrec GetSampledRequests
$creadPrec :: ReadPrec GetSampledRequests
readList :: ReadS [GetSampledRequests]
$creadList :: ReadS [GetSampledRequests]
readsPrec :: Int -> ReadS GetSampledRequests
$creadsPrec :: Int -> ReadS GetSampledRequests
Prelude.Read, Int -> GetSampledRequests -> ShowS
[GetSampledRequests] -> ShowS
GetSampledRequests -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSampledRequests] -> ShowS
$cshowList :: [GetSampledRequests] -> ShowS
show :: GetSampledRequests -> String
$cshow :: GetSampledRequests -> String
showsPrec :: Int -> GetSampledRequests -> ShowS
$cshowsPrec :: Int -> GetSampledRequests -> ShowS
Prelude.Show, forall x. Rep GetSampledRequests x -> GetSampledRequests
forall x. GetSampledRequests -> Rep GetSampledRequests x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSampledRequests x -> GetSampledRequests
$cfrom :: forall x. GetSampledRequests -> Rep GetSampledRequests x
Prelude.Generic)

-- |
-- Create a value of 'GetSampledRequests' 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:
--
-- 'webAclArn', 'getSampledRequests_webAclArn' - The Amazon resource name (ARN) of the @WebACL@ for which you want a
-- sample of requests.
--
-- 'ruleMetricName', 'getSampledRequests_ruleMetricName' - The metric name assigned to the @Rule@ or @RuleGroup@ for which you want
-- a sample of requests.
--
-- 'scope', 'getSampledRequests_scope' - Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
--
-- 'timeWindow', 'getSampledRequests_timeWindow' - The start date and time and the end date and time of the range for which
-- you want @GetSampledRequests@ to return a sample of requests. You must
-- specify the times in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, @Z@. For example,
-- @\"2016-09-27T14:50Z\"@. You can specify any time range in the previous
-- three hours. If you specify a start time that\'s earlier than three
-- hours ago, WAF sets it to three hours ago.
--
-- 'maxItems', 'getSampledRequests_maxItems' - The number of requests that you want WAF to return from among the first
-- 5,000 requests that your Amazon Web Services resource received during
-- the time range. If your resource received fewer requests than the value
-- of @MaxItems@, @GetSampledRequests@ returns information about all of
-- them.
newGetSampledRequests ::
  -- | 'webAclArn'
  Prelude.Text ->
  -- | 'ruleMetricName'
  Prelude.Text ->
  -- | 'scope'
  Scope ->
  -- | 'timeWindow'
  TimeWindow ->
  -- | 'maxItems'
  Prelude.Natural ->
  GetSampledRequests
newGetSampledRequests :: Text
-> Text -> Scope -> TimeWindow -> Natural -> GetSampledRequests
newGetSampledRequests
  Text
pWebAclArn_
  Text
pRuleMetricName_
  Scope
pScope_
  TimeWindow
pTimeWindow_
  Natural
pMaxItems_ =
    GetSampledRequests'
      { $sel:webAclArn:GetSampledRequests' :: Text
webAclArn = Text
pWebAclArn_,
        $sel:ruleMetricName:GetSampledRequests' :: Text
ruleMetricName = Text
pRuleMetricName_,
        $sel:scope:GetSampledRequests' :: Scope
scope = Scope
pScope_,
        $sel:timeWindow:GetSampledRequests' :: TimeWindow
timeWindow = TimeWindow
pTimeWindow_,
        $sel:maxItems:GetSampledRequests' :: Natural
maxItems = Natural
pMaxItems_
      }

-- | The Amazon resource name (ARN) of the @WebACL@ for which you want a
-- sample of requests.
getSampledRequests_webAclArn :: Lens.Lens' GetSampledRequests Prelude.Text
getSampledRequests_webAclArn :: Lens' GetSampledRequests Text
getSampledRequests_webAclArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequests' {Text
webAclArn :: Text
$sel:webAclArn:GetSampledRequests' :: GetSampledRequests -> Text
webAclArn} -> Text
webAclArn) (\s :: GetSampledRequests
s@GetSampledRequests' {} Text
a -> GetSampledRequests
s {$sel:webAclArn:GetSampledRequests' :: Text
webAclArn = Text
a} :: GetSampledRequests)

-- | The metric name assigned to the @Rule@ or @RuleGroup@ for which you want
-- a sample of requests.
getSampledRequests_ruleMetricName :: Lens.Lens' GetSampledRequests Prelude.Text
getSampledRequests_ruleMetricName :: Lens' GetSampledRequests Text
getSampledRequests_ruleMetricName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequests' {Text
ruleMetricName :: Text
$sel:ruleMetricName:GetSampledRequests' :: GetSampledRequests -> Text
ruleMetricName} -> Text
ruleMetricName) (\s :: GetSampledRequests
s@GetSampledRequests' {} Text
a -> GetSampledRequests
s {$sel:ruleMetricName:GetSampledRequests' :: Text
ruleMetricName = Text
a} :: GetSampledRequests)

-- | Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
getSampledRequests_scope :: Lens.Lens' GetSampledRequests Scope
getSampledRequests_scope :: Lens' GetSampledRequests Scope
getSampledRequests_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequests' {Scope
scope :: Scope
$sel:scope:GetSampledRequests' :: GetSampledRequests -> Scope
scope} -> Scope
scope) (\s :: GetSampledRequests
s@GetSampledRequests' {} Scope
a -> GetSampledRequests
s {$sel:scope:GetSampledRequests' :: Scope
scope = Scope
a} :: GetSampledRequests)

-- | The start date and time and the end date and time of the range for which
-- you want @GetSampledRequests@ to return a sample of requests. You must
-- specify the times in Coordinated Universal Time (UTC) format. UTC format
-- includes the special designator, @Z@. For example,
-- @\"2016-09-27T14:50Z\"@. You can specify any time range in the previous
-- three hours. If you specify a start time that\'s earlier than three
-- hours ago, WAF sets it to three hours ago.
getSampledRequests_timeWindow :: Lens.Lens' GetSampledRequests TimeWindow
getSampledRequests_timeWindow :: Lens' GetSampledRequests TimeWindow
getSampledRequests_timeWindow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequests' {TimeWindow
timeWindow :: TimeWindow
$sel:timeWindow:GetSampledRequests' :: GetSampledRequests -> TimeWindow
timeWindow} -> TimeWindow
timeWindow) (\s :: GetSampledRequests
s@GetSampledRequests' {} TimeWindow
a -> GetSampledRequests
s {$sel:timeWindow:GetSampledRequests' :: TimeWindow
timeWindow = TimeWindow
a} :: GetSampledRequests)

-- | The number of requests that you want WAF to return from among the first
-- 5,000 requests that your Amazon Web Services resource received during
-- the time range. If your resource received fewer requests than the value
-- of @MaxItems@, @GetSampledRequests@ returns information about all of
-- them.
getSampledRequests_maxItems :: Lens.Lens' GetSampledRequests Prelude.Natural
getSampledRequests_maxItems :: Lens' GetSampledRequests Natural
getSampledRequests_maxItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequests' {Natural
maxItems :: Natural
$sel:maxItems:GetSampledRequests' :: GetSampledRequests -> Natural
maxItems} -> Natural
maxItems) (\s :: GetSampledRequests
s@GetSampledRequests' {} Natural
a -> GetSampledRequests
s {$sel:maxItems:GetSampledRequests' :: Natural
maxItems = Natural
a} :: GetSampledRequests)

instance Core.AWSRequest GetSampledRequests where
  type
    AWSResponse GetSampledRequests =
      GetSampledRequestsResponse
  request :: (Service -> Service)
-> GetSampledRequests -> Request GetSampledRequests
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetSampledRequests
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSampledRequests)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Integer
-> Maybe [SampledHTTPRequest]
-> Maybe TimeWindow
-> Int
-> GetSampledRequestsResponse
GetSampledRequestsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PopulationSize")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SampledRequests"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TimeWindow")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetSampledRequests where
  hashWithSalt :: Int -> GetSampledRequests -> Int
hashWithSalt Int
_salt GetSampledRequests' {Natural
Text
Scope
TimeWindow
maxItems :: Natural
timeWindow :: TimeWindow
scope :: Scope
ruleMetricName :: Text
webAclArn :: Text
$sel:maxItems:GetSampledRequests' :: GetSampledRequests -> Natural
$sel:timeWindow:GetSampledRequests' :: GetSampledRequests -> TimeWindow
$sel:scope:GetSampledRequests' :: GetSampledRequests -> Scope
$sel:ruleMetricName:GetSampledRequests' :: GetSampledRequests -> Text
$sel:webAclArn:GetSampledRequests' :: GetSampledRequests -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
webAclArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleMetricName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Scope
scope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TimeWindow
timeWindow
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maxItems

instance Prelude.NFData GetSampledRequests where
  rnf :: GetSampledRequests -> ()
rnf GetSampledRequests' {Natural
Text
Scope
TimeWindow
maxItems :: Natural
timeWindow :: TimeWindow
scope :: Scope
ruleMetricName :: Text
webAclArn :: Text
$sel:maxItems:GetSampledRequests' :: GetSampledRequests -> Natural
$sel:timeWindow:GetSampledRequests' :: GetSampledRequests -> TimeWindow
$sel:scope:GetSampledRequests' :: GetSampledRequests -> Scope
$sel:ruleMetricName:GetSampledRequests' :: GetSampledRequests -> Text
$sel:webAclArn:GetSampledRequests' :: GetSampledRequests -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
webAclArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ruleMetricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Scope
scope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TimeWindow
timeWindow
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
maxItems

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

instance Data.ToJSON GetSampledRequests where
  toJSON :: GetSampledRequests -> Value
toJSON GetSampledRequests' {Natural
Text
Scope
TimeWindow
maxItems :: Natural
timeWindow :: TimeWindow
scope :: Scope
ruleMetricName :: Text
webAclArn :: Text
$sel:maxItems:GetSampledRequests' :: GetSampledRequests -> Natural
$sel:timeWindow:GetSampledRequests' :: GetSampledRequests -> TimeWindow
$sel:scope:GetSampledRequests' :: GetSampledRequests -> Scope
$sel:ruleMetricName:GetSampledRequests' :: GetSampledRequests -> Text
$sel:webAclArn:GetSampledRequests' :: GetSampledRequests -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"WebAclArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
webAclArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"RuleMetricName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ruleMetricName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Scope" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Scope
scope),
            forall a. a -> Maybe a
Prelude.Just (Key
"TimeWindow" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TimeWindow
timeWindow),
            forall a. a -> Maybe a
Prelude.Just (Key
"MaxItems" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maxItems)
          ]
      )

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

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

-- | /See:/ 'newGetSampledRequestsResponse' smart constructor.
data GetSampledRequestsResponse = GetSampledRequestsResponse'
  { -- | The total number of requests from which @GetSampledRequests@ got a
    -- sample of @MaxItems@ requests. If @PopulationSize@ is less than
    -- @MaxItems@, the sample includes every request that your Amazon Web
    -- Services resource received during the specified time range.
    GetSampledRequestsResponse -> Maybe Integer
populationSize :: Prelude.Maybe Prelude.Integer,
    -- | A complex type that contains detailed information about each of the
    -- requests in the sample.
    GetSampledRequestsResponse -> Maybe [SampledHTTPRequest]
sampledRequests :: Prelude.Maybe [SampledHTTPRequest],
    -- | Usually, @TimeWindow@ is the time range that you specified in the
    -- @GetSampledRequests@ request. However, if your Amazon Web Services
    -- resource received more than 5,000 requests during the time range that
    -- you specified in the request, @GetSampledRequests@ returns the time
    -- range for the first 5,000 requests. Times are in Coordinated Universal
    -- Time (UTC) format.
    GetSampledRequestsResponse -> Maybe TimeWindow
timeWindow :: Prelude.Maybe TimeWindow,
    -- | The response's http status code.
    GetSampledRequestsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSampledRequestsResponse -> GetSampledRequestsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSampledRequestsResponse -> GetSampledRequestsResponse -> Bool
$c/= :: GetSampledRequestsResponse -> GetSampledRequestsResponse -> Bool
== :: GetSampledRequestsResponse -> GetSampledRequestsResponse -> Bool
$c== :: GetSampledRequestsResponse -> GetSampledRequestsResponse -> Bool
Prelude.Eq, ReadPrec [GetSampledRequestsResponse]
ReadPrec GetSampledRequestsResponse
Int -> ReadS GetSampledRequestsResponse
ReadS [GetSampledRequestsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSampledRequestsResponse]
$creadListPrec :: ReadPrec [GetSampledRequestsResponse]
readPrec :: ReadPrec GetSampledRequestsResponse
$creadPrec :: ReadPrec GetSampledRequestsResponse
readList :: ReadS [GetSampledRequestsResponse]
$creadList :: ReadS [GetSampledRequestsResponse]
readsPrec :: Int -> ReadS GetSampledRequestsResponse
$creadsPrec :: Int -> ReadS GetSampledRequestsResponse
Prelude.Read, Int -> GetSampledRequestsResponse -> ShowS
[GetSampledRequestsResponse] -> ShowS
GetSampledRequestsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSampledRequestsResponse] -> ShowS
$cshowList :: [GetSampledRequestsResponse] -> ShowS
show :: GetSampledRequestsResponse -> String
$cshow :: GetSampledRequestsResponse -> String
showsPrec :: Int -> GetSampledRequestsResponse -> ShowS
$cshowsPrec :: Int -> GetSampledRequestsResponse -> ShowS
Prelude.Show, forall x.
Rep GetSampledRequestsResponse x -> GetSampledRequestsResponse
forall x.
GetSampledRequestsResponse -> Rep GetSampledRequestsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSampledRequestsResponse x -> GetSampledRequestsResponse
$cfrom :: forall x.
GetSampledRequestsResponse -> Rep GetSampledRequestsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSampledRequestsResponse' 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:
--
-- 'populationSize', 'getSampledRequestsResponse_populationSize' - The total number of requests from which @GetSampledRequests@ got a
-- sample of @MaxItems@ requests. If @PopulationSize@ is less than
-- @MaxItems@, the sample includes every request that your Amazon Web
-- Services resource received during the specified time range.
--
-- 'sampledRequests', 'getSampledRequestsResponse_sampledRequests' - A complex type that contains detailed information about each of the
-- requests in the sample.
--
-- 'timeWindow', 'getSampledRequestsResponse_timeWindow' - Usually, @TimeWindow@ is the time range that you specified in the
-- @GetSampledRequests@ request. However, if your Amazon Web Services
-- resource received more than 5,000 requests during the time range that
-- you specified in the request, @GetSampledRequests@ returns the time
-- range for the first 5,000 requests. Times are in Coordinated Universal
-- Time (UTC) format.
--
-- 'httpStatus', 'getSampledRequestsResponse_httpStatus' - The response's http status code.
newGetSampledRequestsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSampledRequestsResponse
newGetSampledRequestsResponse :: Int -> GetSampledRequestsResponse
newGetSampledRequestsResponse Int
pHttpStatus_ =
  GetSampledRequestsResponse'
    { $sel:populationSize:GetSampledRequestsResponse' :: Maybe Integer
populationSize =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sampledRequests:GetSampledRequestsResponse' :: Maybe [SampledHTTPRequest]
sampledRequests = forall a. Maybe a
Prelude.Nothing,
      $sel:timeWindow:GetSampledRequestsResponse' :: Maybe TimeWindow
timeWindow = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSampledRequestsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The total number of requests from which @GetSampledRequests@ got a
-- sample of @MaxItems@ requests. If @PopulationSize@ is less than
-- @MaxItems@, the sample includes every request that your Amazon Web
-- Services resource received during the specified time range.
getSampledRequestsResponse_populationSize :: Lens.Lens' GetSampledRequestsResponse (Prelude.Maybe Prelude.Integer)
getSampledRequestsResponse_populationSize :: Lens' GetSampledRequestsResponse (Maybe Integer)
getSampledRequestsResponse_populationSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequestsResponse' {Maybe Integer
populationSize :: Maybe Integer
$sel:populationSize:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Maybe Integer
populationSize} -> Maybe Integer
populationSize) (\s :: GetSampledRequestsResponse
s@GetSampledRequestsResponse' {} Maybe Integer
a -> GetSampledRequestsResponse
s {$sel:populationSize:GetSampledRequestsResponse' :: Maybe Integer
populationSize = Maybe Integer
a} :: GetSampledRequestsResponse)

-- | A complex type that contains detailed information about each of the
-- requests in the sample.
getSampledRequestsResponse_sampledRequests :: Lens.Lens' GetSampledRequestsResponse (Prelude.Maybe [SampledHTTPRequest])
getSampledRequestsResponse_sampledRequests :: Lens' GetSampledRequestsResponse (Maybe [SampledHTTPRequest])
getSampledRequestsResponse_sampledRequests = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequestsResponse' {Maybe [SampledHTTPRequest]
sampledRequests :: Maybe [SampledHTTPRequest]
$sel:sampledRequests:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Maybe [SampledHTTPRequest]
sampledRequests} -> Maybe [SampledHTTPRequest]
sampledRequests) (\s :: GetSampledRequestsResponse
s@GetSampledRequestsResponse' {} Maybe [SampledHTTPRequest]
a -> GetSampledRequestsResponse
s {$sel:sampledRequests:GetSampledRequestsResponse' :: Maybe [SampledHTTPRequest]
sampledRequests = Maybe [SampledHTTPRequest]
a} :: GetSampledRequestsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Usually, @TimeWindow@ is the time range that you specified in the
-- @GetSampledRequests@ request. However, if your Amazon Web Services
-- resource received more than 5,000 requests during the time range that
-- you specified in the request, @GetSampledRequests@ returns the time
-- range for the first 5,000 requests. Times are in Coordinated Universal
-- Time (UTC) format.
getSampledRequestsResponse_timeWindow :: Lens.Lens' GetSampledRequestsResponse (Prelude.Maybe TimeWindow)
getSampledRequestsResponse_timeWindow :: Lens' GetSampledRequestsResponse (Maybe TimeWindow)
getSampledRequestsResponse_timeWindow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSampledRequestsResponse' {Maybe TimeWindow
timeWindow :: Maybe TimeWindow
$sel:timeWindow:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Maybe TimeWindow
timeWindow} -> Maybe TimeWindow
timeWindow) (\s :: GetSampledRequestsResponse
s@GetSampledRequestsResponse' {} Maybe TimeWindow
a -> GetSampledRequestsResponse
s {$sel:timeWindow:GetSampledRequestsResponse' :: Maybe TimeWindow
timeWindow = Maybe TimeWindow
a} :: GetSampledRequestsResponse)

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

instance Prelude.NFData GetSampledRequestsResponse where
  rnf :: GetSampledRequestsResponse -> ()
rnf GetSampledRequestsResponse' {Int
Maybe Integer
Maybe [SampledHTTPRequest]
Maybe TimeWindow
httpStatus :: Int
timeWindow :: Maybe TimeWindow
sampledRequests :: Maybe [SampledHTTPRequest]
populationSize :: Maybe Integer
$sel:httpStatus:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Int
$sel:timeWindow:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Maybe TimeWindow
$sel:sampledRequests:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Maybe [SampledHTTPRequest]
$sel:populationSize:GetSampledRequestsResponse' :: GetSampledRequestsResponse -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
populationSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SampledHTTPRequest]
sampledRequests
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeWindow
timeWindow
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus