{-# 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.Pi.Types.DimensionGroup
-- 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)
module Amazonka.Pi.Types.DimensionGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A logical grouping of Performance Insights metrics for a related subject
-- area. For example, the @db.sql@ dimension group consists of the
-- following dimensions: @db.sql.id@, @db.sql.db_id@, @db.sql.statement@,
-- and @db.sql.tokenized_id@.
--
-- Each response element returns a maximum of 500 bytes. For larger
-- elements, such as SQL statements, only the first 500 bytes are returned.
--
-- /See:/ 'newDimensionGroup' smart constructor.
data DimensionGroup = DimensionGroup'
  { -- | The maximum number of items to fetch for this dimension group.
    DimensionGroup -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A list of specific dimensions from a dimension group. If this parameter
    -- is not present, then it signifies that all of the dimensions in the
    -- group were requested, or are present in the response.
    --
    -- Valid values for elements in the @Dimensions@ array are:
    --
    -- -   @db.application.name@ - The name of the application that is
    --     connected to the database (only Aurora PostgreSQL and RDS
    --     PostgreSQL)
    --
    -- -   @db.host.id@ - The host ID of the connected client (all engines)
    --
    -- -   @db.host.name@ - The host name of the connected client (all engines)
    --
    -- -   @db.name@ - The name of the database to which the client is
    --     connected (only Aurora PostgreSQL, RDS PostgreSQL, Aurora MySQL, RDS
    --     MySQL, and MariaDB)
    --
    -- -   @db.session_type.name@ - The type of the current session (only
    --     Aurora PostgreSQL and RDS PostgreSQL)
    --
    -- -   @db.sql.id@ - The SQL ID generated by Performance Insights (all
    --     engines)
    --
    -- -   @db.sql.db_id@ - The SQL ID generated by the database (all engines)
    --
    -- -   @db.sql.statement@ - The SQL text that is being executed (all
    --     engines)
    --
    -- -   @db.sql.tokenized_id@
    --
    -- -   @db.sql_tokenized.id@ - The SQL digest ID generated by Performance
    --     Insights (all engines)
    --
    -- -   @db.sql_tokenized.db_id@ - SQL digest ID generated by the database
    --     (all engines)
    --
    -- -   @db.sql_tokenized.statement@ - The SQL digest text (all engines)
    --
    -- -   @db.user.id@ - The ID of the user logged in to the database (all
    --     engines)
    --
    -- -   @db.user.name@ - The name of the user logged in to the database (all
    --     engines)
    --
    -- -   @db.wait_event.name@ - The event for which the backend is waiting
    --     (all engines)
    --
    -- -   @db.wait_event.type@ - The type of event for which the backend is
    --     waiting (all engines)
    --
    -- -   @db.wait_event_type.name@ - The name of the event type for which the
    --     backend is waiting (all engines)
    DimensionGroup -> Maybe (NonEmpty Text)
dimensions :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The name of the dimension group. Valid values are:
    --
    -- -   @db@ - The name of the database to which the client is connected
    --     (only Aurora PostgreSQL, RDS PostgreSQL, Aurora MySQL, RDS MySQL,
    --     and MariaDB)
    --
    -- -   @db.application@ - The name of the application that is connected to
    --     the database (only Aurora PostgreSQL and RDS PostgreSQL)
    --
    -- -   @db.host@ - The host name of the connected client (all engines)
    --
    -- -   @db.session_type@ - The type of the current session (only Aurora
    --     PostgreSQL and RDS PostgreSQL)
    --
    -- -   @db.sql@ - The SQL that is currently executing (all engines)
    --
    -- -   @db.sql_tokenized@ - The SQL digest (all engines)
    --
    -- -   @db.wait_event@ - The event for which the database backend is
    --     waiting (all engines)
    --
    -- -   @db.wait_event_type@ - The type of event for which the database
    --     backend is waiting (all engines)
    --
    -- -   @db.user@ - The user logged in to the database (all engines)
    DimensionGroup -> Text
group' :: Prelude.Text
  }
  deriving (DimensionGroup -> DimensionGroup -> Bool
(DimensionGroup -> DimensionGroup -> Bool)
-> (DimensionGroup -> DimensionGroup -> Bool) -> Eq DimensionGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DimensionGroup -> DimensionGroup -> Bool
$c/= :: DimensionGroup -> DimensionGroup -> Bool
== :: DimensionGroup -> DimensionGroup -> Bool
$c== :: DimensionGroup -> DimensionGroup -> Bool
Prelude.Eq, ReadPrec [DimensionGroup]
ReadPrec DimensionGroup
Int -> ReadS DimensionGroup
ReadS [DimensionGroup]
(Int -> ReadS DimensionGroup)
-> ReadS [DimensionGroup]
-> ReadPrec DimensionGroup
-> ReadPrec [DimensionGroup]
-> Read DimensionGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DimensionGroup]
$creadListPrec :: ReadPrec [DimensionGroup]
readPrec :: ReadPrec DimensionGroup
$creadPrec :: ReadPrec DimensionGroup
readList :: ReadS [DimensionGroup]
$creadList :: ReadS [DimensionGroup]
readsPrec :: Int -> ReadS DimensionGroup
$creadsPrec :: Int -> ReadS DimensionGroup
Prelude.Read, Int -> DimensionGroup -> ShowS
[DimensionGroup] -> ShowS
DimensionGroup -> String
(Int -> DimensionGroup -> ShowS)
-> (DimensionGroup -> String)
-> ([DimensionGroup] -> ShowS)
-> Show DimensionGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DimensionGroup] -> ShowS
$cshowList :: [DimensionGroup] -> ShowS
show :: DimensionGroup -> String
$cshow :: DimensionGroup -> String
showsPrec :: Int -> DimensionGroup -> ShowS
$cshowsPrec :: Int -> DimensionGroup -> ShowS
Prelude.Show, (forall x. DimensionGroup -> Rep DimensionGroup x)
-> (forall x. Rep DimensionGroup x -> DimensionGroup)
-> Generic DimensionGroup
forall x. Rep DimensionGroup x -> DimensionGroup
forall x. DimensionGroup -> Rep DimensionGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DimensionGroup x -> DimensionGroup
$cfrom :: forall x. DimensionGroup -> Rep DimensionGroup x
Prelude.Generic)

-- |
-- Create a value of 'DimensionGroup' 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:
--
-- 'limit', 'dimensionGroup_limit' - The maximum number of items to fetch for this dimension group.
--
-- 'dimensions', 'dimensionGroup_dimensions' - A list of specific dimensions from a dimension group. If this parameter
-- is not present, then it signifies that all of the dimensions in the
-- group were requested, or are present in the response.
--
-- Valid values for elements in the @Dimensions@ array are:
--
-- -   @db.application.name@ - The name of the application that is
--     connected to the database (only Aurora PostgreSQL and RDS
--     PostgreSQL)
--
-- -   @db.host.id@ - The host ID of the connected client (all engines)
--
-- -   @db.host.name@ - The host name of the connected client (all engines)
--
-- -   @db.name@ - The name of the database to which the client is
--     connected (only Aurora PostgreSQL, RDS PostgreSQL, Aurora MySQL, RDS
--     MySQL, and MariaDB)
--
-- -   @db.session_type.name@ - The type of the current session (only
--     Aurora PostgreSQL and RDS PostgreSQL)
--
-- -   @db.sql.id@ - The SQL ID generated by Performance Insights (all
--     engines)
--
-- -   @db.sql.db_id@ - The SQL ID generated by the database (all engines)
--
-- -   @db.sql.statement@ - The SQL text that is being executed (all
--     engines)
--
-- -   @db.sql.tokenized_id@
--
-- -   @db.sql_tokenized.id@ - The SQL digest ID generated by Performance
--     Insights (all engines)
--
-- -   @db.sql_tokenized.db_id@ - SQL digest ID generated by the database
--     (all engines)
--
-- -   @db.sql_tokenized.statement@ - The SQL digest text (all engines)
--
-- -   @db.user.id@ - The ID of the user logged in to the database (all
--     engines)
--
-- -   @db.user.name@ - The name of the user logged in to the database (all
--     engines)
--
-- -   @db.wait_event.name@ - The event for which the backend is waiting
--     (all engines)
--
-- -   @db.wait_event.type@ - The type of event for which the backend is
--     waiting (all engines)
--
-- -   @db.wait_event_type.name@ - The name of the event type for which the
--     backend is waiting (all engines)
--
-- 'group'', 'dimensionGroup_group' - The name of the dimension group. Valid values are:
--
-- -   @db@ - The name of the database to which the client is connected
--     (only Aurora PostgreSQL, RDS PostgreSQL, Aurora MySQL, RDS MySQL,
--     and MariaDB)
--
-- -   @db.application@ - The name of the application that is connected to
--     the database (only Aurora PostgreSQL and RDS PostgreSQL)
--
-- -   @db.host@ - The host name of the connected client (all engines)
--
-- -   @db.session_type@ - The type of the current session (only Aurora
--     PostgreSQL and RDS PostgreSQL)
--
-- -   @db.sql@ - The SQL that is currently executing (all engines)
--
-- -   @db.sql_tokenized@ - The SQL digest (all engines)
--
-- -   @db.wait_event@ - The event for which the database backend is
--     waiting (all engines)
--
-- -   @db.wait_event_type@ - The type of event for which the database
--     backend is waiting (all engines)
--
-- -   @db.user@ - The user logged in to the database (all engines)
newDimensionGroup ::
  -- | 'group''
  Prelude.Text ->
  DimensionGroup
newDimensionGroup :: Text -> DimensionGroup
newDimensionGroup Text
pGroup_ =
  DimensionGroup' :: Maybe Natural -> Maybe (NonEmpty Text) -> Text -> DimensionGroup
DimensionGroup'
    { $sel:limit:DimensionGroup' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:DimensionGroup' :: Maybe (NonEmpty Text)
dimensions = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:group':DimensionGroup' :: Text
group' = Text
pGroup_
    }

-- | The maximum number of items to fetch for this dimension group.
dimensionGroup_limit :: Lens.Lens' DimensionGroup (Prelude.Maybe Prelude.Natural)
dimensionGroup_limit :: (Maybe Natural -> f (Maybe Natural))
-> DimensionGroup -> f DimensionGroup
dimensionGroup_limit = (DimensionGroup -> Maybe Natural)
-> (DimensionGroup -> Maybe Natural -> DimensionGroup)
-> Lens
     DimensionGroup DimensionGroup (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionGroup' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DimensionGroup' :: DimensionGroup -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DimensionGroup
s@DimensionGroup' {} Maybe Natural
a -> DimensionGroup
s {$sel:limit:DimensionGroup' :: Maybe Natural
limit = Maybe Natural
a} :: DimensionGroup)

-- | A list of specific dimensions from a dimension group. If this parameter
-- is not present, then it signifies that all of the dimensions in the
-- group were requested, or are present in the response.
--
-- Valid values for elements in the @Dimensions@ array are:
--
-- -   @db.application.name@ - The name of the application that is
--     connected to the database (only Aurora PostgreSQL and RDS
--     PostgreSQL)
--
-- -   @db.host.id@ - The host ID of the connected client (all engines)
--
-- -   @db.host.name@ - The host name of the connected client (all engines)
--
-- -   @db.name@ - The name of the database to which the client is
--     connected (only Aurora PostgreSQL, RDS PostgreSQL, Aurora MySQL, RDS
--     MySQL, and MariaDB)
--
-- -   @db.session_type.name@ - The type of the current session (only
--     Aurora PostgreSQL and RDS PostgreSQL)
--
-- -   @db.sql.id@ - The SQL ID generated by Performance Insights (all
--     engines)
--
-- -   @db.sql.db_id@ - The SQL ID generated by the database (all engines)
--
-- -   @db.sql.statement@ - The SQL text that is being executed (all
--     engines)
--
-- -   @db.sql.tokenized_id@
--
-- -   @db.sql_tokenized.id@ - The SQL digest ID generated by Performance
--     Insights (all engines)
--
-- -   @db.sql_tokenized.db_id@ - SQL digest ID generated by the database
--     (all engines)
--
-- -   @db.sql_tokenized.statement@ - The SQL digest text (all engines)
--
-- -   @db.user.id@ - The ID of the user logged in to the database (all
--     engines)
--
-- -   @db.user.name@ - The name of the user logged in to the database (all
--     engines)
--
-- -   @db.wait_event.name@ - The event for which the backend is waiting
--     (all engines)
--
-- -   @db.wait_event.type@ - The type of event for which the backend is
--     waiting (all engines)
--
-- -   @db.wait_event_type.name@ - The name of the event type for which the
--     backend is waiting (all engines)
dimensionGroup_dimensions :: Lens.Lens' DimensionGroup (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
dimensionGroup_dimensions :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DimensionGroup -> f DimensionGroup
dimensionGroup_dimensions = (DimensionGroup -> Maybe (NonEmpty Text))
-> (DimensionGroup -> Maybe (NonEmpty Text) -> DimensionGroup)
-> Lens
     DimensionGroup
     DimensionGroup
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionGroup' {Maybe (NonEmpty Text)
dimensions :: Maybe (NonEmpty Text)
$sel:dimensions:DimensionGroup' :: DimensionGroup -> Maybe (NonEmpty Text)
dimensions} -> Maybe (NonEmpty Text)
dimensions) (\s :: DimensionGroup
s@DimensionGroup' {} Maybe (NonEmpty Text)
a -> DimensionGroup
s {$sel:dimensions:DimensionGroup' :: Maybe (NonEmpty Text)
dimensions = Maybe (NonEmpty Text)
a} :: DimensionGroup) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> DimensionGroup -> f DimensionGroup)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DimensionGroup
-> f DimensionGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the dimension group. Valid values are:
--
-- -   @db@ - The name of the database to which the client is connected
--     (only Aurora PostgreSQL, RDS PostgreSQL, Aurora MySQL, RDS MySQL,
--     and MariaDB)
--
-- -   @db.application@ - The name of the application that is connected to
--     the database (only Aurora PostgreSQL and RDS PostgreSQL)
--
-- -   @db.host@ - The host name of the connected client (all engines)
--
-- -   @db.session_type@ - The type of the current session (only Aurora
--     PostgreSQL and RDS PostgreSQL)
--
-- -   @db.sql@ - The SQL that is currently executing (all engines)
--
-- -   @db.sql_tokenized@ - The SQL digest (all engines)
--
-- -   @db.wait_event@ - The event for which the database backend is
--     waiting (all engines)
--
-- -   @db.wait_event_type@ - The type of event for which the database
--     backend is waiting (all engines)
--
-- -   @db.user@ - The user logged in to the database (all engines)
dimensionGroup_group :: Lens.Lens' DimensionGroup Prelude.Text
dimensionGroup_group :: (Text -> f Text) -> DimensionGroup -> f DimensionGroup
dimensionGroup_group = (DimensionGroup -> Text)
-> (DimensionGroup -> Text -> DimensionGroup)
-> Lens DimensionGroup DimensionGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionGroup' {Text
group' :: Text
$sel:group':DimensionGroup' :: DimensionGroup -> Text
group'} -> Text
group') (\s :: DimensionGroup
s@DimensionGroup' {} Text
a -> DimensionGroup
s {$sel:group':DimensionGroup' :: Text
group' = Text
a} :: DimensionGroup)

instance Prelude.Hashable DimensionGroup

instance Prelude.NFData DimensionGroup

instance Core.ToJSON DimensionGroup where
  toJSON :: DimensionGroup -> Value
toJSON DimensionGroup' {Maybe Natural
Maybe (NonEmpty Text)
Text
group' :: Text
dimensions :: Maybe (NonEmpty Text)
limit :: Maybe Natural
$sel:group':DimensionGroup' :: DimensionGroup -> Text
$sel:dimensions:DimensionGroup' :: DimensionGroup -> Maybe (NonEmpty Text)
$sel:limit:DimensionGroup' :: DimensionGroup -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Limit" 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
limit,
            (Text
"Dimensions" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
dimensions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Group" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
group')
          ]
      )