{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EC2.Types.DataQuery
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.DataQuery where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.MetricType
import Amazonka.EC2.Types.PeriodType
import Amazonka.EC2.Types.StatisticType
import qualified Amazonka.Prelude as Prelude

-- | A query used for retrieving network health data.
--
-- /See:/ 'newDataQuery' smart constructor.
data DataQuery = DataQuery'
  { -- | The Region or Availability Zone that\'s the target for the data query.
    -- For example, @eu-north-1@.
    DataQuery -> Maybe Text
destination :: Prelude.Maybe Prelude.Text,
    -- | A user-defined ID associated with a data query that\'s returned in the
    -- @dataResponse@ identifying the query. For example, if you set the Id to
    -- @MyQuery01@in the query, the @dataResponse@ identifies the query as
    -- @MyQuery01@.
    DataQuery -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The aggregation metric used for the data query. Currently only
    -- @aggregation-latency@ is supported, indicating network latency.
    DataQuery -> Maybe MetricType
metric :: Prelude.Maybe MetricType,
    -- | The aggregation period used for the data query.
    DataQuery -> Maybe PeriodType
period :: Prelude.Maybe PeriodType,
    -- | The Region or Availability Zone that\'s the source for the data query.
    -- For example, @us-east-1@.
    DataQuery -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | Metric data aggregations over specified periods of time. The following
    -- are the supported Infrastructure Performance statistics:
    --
    -- -   @p50@ - The median value of the metric aggregated over a specified
    --     start and end time. For example, a metric of @five_minutes@ is the
    --     median of all the data points gathered within those five minutes.
    DataQuery -> Maybe StatisticType
statistic :: Prelude.Maybe StatisticType
  }
  deriving (DataQuery -> DataQuery -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataQuery -> DataQuery -> Bool
$c/= :: DataQuery -> DataQuery -> Bool
== :: DataQuery -> DataQuery -> Bool
$c== :: DataQuery -> DataQuery -> Bool
Prelude.Eq, ReadPrec [DataQuery]
ReadPrec DataQuery
Int -> ReadS DataQuery
ReadS [DataQuery]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataQuery]
$creadListPrec :: ReadPrec [DataQuery]
readPrec :: ReadPrec DataQuery
$creadPrec :: ReadPrec DataQuery
readList :: ReadS [DataQuery]
$creadList :: ReadS [DataQuery]
readsPrec :: Int -> ReadS DataQuery
$creadsPrec :: Int -> ReadS DataQuery
Prelude.Read, Int -> DataQuery -> ShowS
[DataQuery] -> ShowS
DataQuery -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataQuery] -> ShowS
$cshowList :: [DataQuery] -> ShowS
show :: DataQuery -> String
$cshow :: DataQuery -> String
showsPrec :: Int -> DataQuery -> ShowS
$cshowsPrec :: Int -> DataQuery -> ShowS
Prelude.Show, forall x. Rep DataQuery x -> DataQuery
forall x. DataQuery -> Rep DataQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataQuery x -> DataQuery
$cfrom :: forall x. DataQuery -> Rep DataQuery x
Prelude.Generic)

-- |
-- Create a value of 'DataQuery' 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:
--
-- 'destination', 'dataQuery_destination' - The Region or Availability Zone that\'s the target for the data query.
-- For example, @eu-north-1@.
--
-- 'id', 'dataQuery_id' - A user-defined ID associated with a data query that\'s returned in the
-- @dataResponse@ identifying the query. For example, if you set the Id to
-- @MyQuery01@in the query, the @dataResponse@ identifies the query as
-- @MyQuery01@.
--
-- 'metric', 'dataQuery_metric' - The aggregation metric used for the data query. Currently only
-- @aggregation-latency@ is supported, indicating network latency.
--
-- 'period', 'dataQuery_period' - The aggregation period used for the data query.
--
-- 'source', 'dataQuery_source' - The Region or Availability Zone that\'s the source for the data query.
-- For example, @us-east-1@.
--
-- 'statistic', 'dataQuery_statistic' - Metric data aggregations over specified periods of time. The following
-- are the supported Infrastructure Performance statistics:
--
-- -   @p50@ - The median value of the metric aggregated over a specified
--     start and end time. For example, a metric of @five_minutes@ is the
--     median of all the data points gathered within those five minutes.
newDataQuery ::
  DataQuery
newDataQuery :: DataQuery
newDataQuery =
  DataQuery'
    { $sel:destination:DataQuery' :: Maybe Text
destination = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DataQuery' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:metric:DataQuery' :: Maybe MetricType
metric = forall a. Maybe a
Prelude.Nothing,
      $sel:period:DataQuery' :: Maybe PeriodType
period = forall a. Maybe a
Prelude.Nothing,
      $sel:source:DataQuery' :: Maybe Text
source = forall a. Maybe a
Prelude.Nothing,
      $sel:statistic:DataQuery' :: Maybe StatisticType
statistic = forall a. Maybe a
Prelude.Nothing
    }

-- | The Region or Availability Zone that\'s the target for the data query.
-- For example, @eu-north-1@.
dataQuery_destination :: Lens.Lens' DataQuery (Prelude.Maybe Prelude.Text)
dataQuery_destination :: Lens' DataQuery (Maybe Text)
dataQuery_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataQuery' {Maybe Text
destination :: Maybe Text
$sel:destination:DataQuery' :: DataQuery -> Maybe Text
destination} -> Maybe Text
destination) (\s :: DataQuery
s@DataQuery' {} Maybe Text
a -> DataQuery
s {$sel:destination:DataQuery' :: Maybe Text
destination = Maybe Text
a} :: DataQuery)

-- | A user-defined ID associated with a data query that\'s returned in the
-- @dataResponse@ identifying the query. For example, if you set the Id to
-- @MyQuery01@in the query, the @dataResponse@ identifies the query as
-- @MyQuery01@.
dataQuery_id :: Lens.Lens' DataQuery (Prelude.Maybe Prelude.Text)
dataQuery_id :: Lens' DataQuery (Maybe Text)
dataQuery_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataQuery' {Maybe Text
id :: Maybe Text
$sel:id:DataQuery' :: DataQuery -> Maybe Text
id} -> Maybe Text
id) (\s :: DataQuery
s@DataQuery' {} Maybe Text
a -> DataQuery
s {$sel:id:DataQuery' :: Maybe Text
id = Maybe Text
a} :: DataQuery)

-- | The aggregation metric used for the data query. Currently only
-- @aggregation-latency@ is supported, indicating network latency.
dataQuery_metric :: Lens.Lens' DataQuery (Prelude.Maybe MetricType)
dataQuery_metric :: Lens' DataQuery (Maybe MetricType)
dataQuery_metric = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataQuery' {Maybe MetricType
metric :: Maybe MetricType
$sel:metric:DataQuery' :: DataQuery -> Maybe MetricType
metric} -> Maybe MetricType
metric) (\s :: DataQuery
s@DataQuery' {} Maybe MetricType
a -> DataQuery
s {$sel:metric:DataQuery' :: Maybe MetricType
metric = Maybe MetricType
a} :: DataQuery)

-- | The aggregation period used for the data query.
dataQuery_period :: Lens.Lens' DataQuery (Prelude.Maybe PeriodType)
dataQuery_period :: Lens' DataQuery (Maybe PeriodType)
dataQuery_period = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataQuery' {Maybe PeriodType
period :: Maybe PeriodType
$sel:period:DataQuery' :: DataQuery -> Maybe PeriodType
period} -> Maybe PeriodType
period) (\s :: DataQuery
s@DataQuery' {} Maybe PeriodType
a -> DataQuery
s {$sel:period:DataQuery' :: Maybe PeriodType
period = Maybe PeriodType
a} :: DataQuery)

-- | The Region or Availability Zone that\'s the source for the data query.
-- For example, @us-east-1@.
dataQuery_source :: Lens.Lens' DataQuery (Prelude.Maybe Prelude.Text)
dataQuery_source :: Lens' DataQuery (Maybe Text)
dataQuery_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataQuery' {Maybe Text
source :: Maybe Text
$sel:source:DataQuery' :: DataQuery -> Maybe Text
source} -> Maybe Text
source) (\s :: DataQuery
s@DataQuery' {} Maybe Text
a -> DataQuery
s {$sel:source:DataQuery' :: Maybe Text
source = Maybe Text
a} :: DataQuery)

-- | Metric data aggregations over specified periods of time. The following
-- are the supported Infrastructure Performance statistics:
--
-- -   @p50@ - The median value of the metric aggregated over a specified
--     start and end time. For example, a metric of @five_minutes@ is the
--     median of all the data points gathered within those five minutes.
dataQuery_statistic :: Lens.Lens' DataQuery (Prelude.Maybe StatisticType)
dataQuery_statistic :: Lens' DataQuery (Maybe StatisticType)
dataQuery_statistic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataQuery' {Maybe StatisticType
statistic :: Maybe StatisticType
$sel:statistic:DataQuery' :: DataQuery -> Maybe StatisticType
statistic} -> Maybe StatisticType
statistic) (\s :: DataQuery
s@DataQuery' {} Maybe StatisticType
a -> DataQuery
s {$sel:statistic:DataQuery' :: Maybe StatisticType
statistic = Maybe StatisticType
a} :: DataQuery)

instance Prelude.Hashable DataQuery where
  hashWithSalt :: Int -> DataQuery -> Int
hashWithSalt Int
_salt DataQuery' {Maybe Text
Maybe MetricType
Maybe PeriodType
Maybe StatisticType
statistic :: Maybe StatisticType
source :: Maybe Text
period :: Maybe PeriodType
metric :: Maybe MetricType
id :: Maybe Text
destination :: Maybe Text
$sel:statistic:DataQuery' :: DataQuery -> Maybe StatisticType
$sel:source:DataQuery' :: DataQuery -> Maybe Text
$sel:period:DataQuery' :: DataQuery -> Maybe PeriodType
$sel:metric:DataQuery' :: DataQuery -> Maybe MetricType
$sel:id:DataQuery' :: DataQuery -> Maybe Text
$sel:destination:DataQuery' :: DataQuery -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MetricType
metric
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PeriodType
period
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
source
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatisticType
statistic

instance Prelude.NFData DataQuery where
  rnf :: DataQuery -> ()
rnf DataQuery' {Maybe Text
Maybe MetricType
Maybe PeriodType
Maybe StatisticType
statistic :: Maybe StatisticType
source :: Maybe Text
period :: Maybe PeriodType
metric :: Maybe MetricType
id :: Maybe Text
destination :: Maybe Text
$sel:statistic:DataQuery' :: DataQuery -> Maybe StatisticType
$sel:source:DataQuery' :: DataQuery -> Maybe Text
$sel:period:DataQuery' :: DataQuery -> Maybe PeriodType
$sel:metric:DataQuery' :: DataQuery -> Maybe MetricType
$sel:id:DataQuery' :: DataQuery -> Maybe Text
$sel:destination:DataQuery' :: DataQuery -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MetricType
metric
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PeriodType
period
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
source
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StatisticType
statistic

instance Data.ToQuery DataQuery where
  toQuery :: DataQuery -> QueryString
toQuery DataQuery' {Maybe Text
Maybe MetricType
Maybe PeriodType
Maybe StatisticType
statistic :: Maybe StatisticType
source :: Maybe Text
period :: Maybe PeriodType
metric :: Maybe MetricType
id :: Maybe Text
destination :: Maybe Text
$sel:statistic:DataQuery' :: DataQuery -> Maybe StatisticType
$sel:source:DataQuery' :: DataQuery -> Maybe Text
$sel:period:DataQuery' :: DataQuery -> Maybe PeriodType
$sel:metric:DataQuery' :: DataQuery -> Maybe MetricType
$sel:id:DataQuery' :: DataQuery -> Maybe Text
$sel:destination:DataQuery' :: DataQuery -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Destination" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
destination,
        ByteString
"Id" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
id,
        ByteString
"Metric" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe MetricType
metric,
        ByteString
"Period" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe PeriodType
period,
        ByteString
"Source" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
source,
        ByteString
"Statistic" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe StatisticType
statistic
      ]