{-# 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.Athena.Types.WorkGroup
-- 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.Athena.Types.WorkGroup where

import Amazonka.Athena.Types.WorkGroupConfiguration
import Amazonka.Athena.Types.WorkGroupState
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

-- | A workgroup, which contains a name, description, creation time, state,
-- and other configuration, listed under WorkGroup$Configuration. Each
-- workgroup enables you to isolate queries for you or your group of users
-- from other queries in the same account, to configure the query results
-- location and the encryption configuration (known as workgroup settings),
-- to enable sending query metrics to Amazon CloudWatch, and to establish
-- per-query data usage control limits for all queries in a workgroup. The
-- workgroup settings override is specified in
-- @EnforceWorkGroupConfiguration@ (true\/false) in the
-- @WorkGroupConfiguration@. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
--
-- /See:/ 'newWorkGroup' smart constructor.
data WorkGroup = WorkGroup'
  { -- | The configuration of the workgroup, which includes the location in
    -- Amazon S3 where query results are stored, the encryption configuration,
    -- if any, used for query results; whether the Amazon CloudWatch Metrics
    -- are enabled for the workgroup; whether workgroup settings override
    -- client-side settings; and the data usage limits for the amount of data
    -- scanned per query or per workgroup. The workgroup settings override is
    -- specified in @EnforceWorkGroupConfiguration@ (true\/false) in the
    -- @WorkGroupConfiguration@. See
    -- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
    WorkGroup -> Maybe WorkGroupConfiguration
configuration :: Prelude.Maybe WorkGroupConfiguration,
    -- | The date and time the workgroup was created.
    WorkGroup -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The workgroup description.
    WorkGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The state of the workgroup: ENABLED or DISABLED.
    WorkGroup -> Maybe WorkGroupState
state :: Prelude.Maybe WorkGroupState,
    -- | The workgroup name.
    WorkGroup -> Text
name :: Prelude.Text
  }
  deriving (WorkGroup -> WorkGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkGroup -> WorkGroup -> Bool
$c/= :: WorkGroup -> WorkGroup -> Bool
== :: WorkGroup -> WorkGroup -> Bool
$c== :: WorkGroup -> WorkGroup -> Bool
Prelude.Eq, ReadPrec [WorkGroup]
ReadPrec WorkGroup
Int -> ReadS WorkGroup
ReadS [WorkGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkGroup]
$creadListPrec :: ReadPrec [WorkGroup]
readPrec :: ReadPrec WorkGroup
$creadPrec :: ReadPrec WorkGroup
readList :: ReadS [WorkGroup]
$creadList :: ReadS [WorkGroup]
readsPrec :: Int -> ReadS WorkGroup
$creadsPrec :: Int -> ReadS WorkGroup
Prelude.Read, Int -> WorkGroup -> ShowS
[WorkGroup] -> ShowS
WorkGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkGroup] -> ShowS
$cshowList :: [WorkGroup] -> ShowS
show :: WorkGroup -> String
$cshow :: WorkGroup -> String
showsPrec :: Int -> WorkGroup -> ShowS
$cshowsPrec :: Int -> WorkGroup -> ShowS
Prelude.Show, forall x. Rep WorkGroup x -> WorkGroup
forall x. WorkGroup -> Rep WorkGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkGroup x -> WorkGroup
$cfrom :: forall x. WorkGroup -> Rep WorkGroup x
Prelude.Generic)

-- |
-- Create a value of 'WorkGroup' 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:
--
-- 'configuration', 'workGroup_configuration' - The configuration of the workgroup, which includes the location in
-- Amazon S3 where query results are stored, the encryption configuration,
-- if any, used for query results; whether the Amazon CloudWatch Metrics
-- are enabled for the workgroup; whether workgroup settings override
-- client-side settings; and the data usage limits for the amount of data
-- scanned per query or per workgroup. The workgroup settings override is
-- specified in @EnforceWorkGroupConfiguration@ (true\/false) in the
-- @WorkGroupConfiguration@. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
--
-- 'creationTime', 'workGroup_creationTime' - The date and time the workgroup was created.
--
-- 'description', 'workGroup_description' - The workgroup description.
--
-- 'state', 'workGroup_state' - The state of the workgroup: ENABLED or DISABLED.
--
-- 'name', 'workGroup_name' - The workgroup name.
newWorkGroup ::
  -- | 'name'
  Prelude.Text ->
  WorkGroup
newWorkGroup :: Text -> WorkGroup
newWorkGroup Text
pName_ =
  WorkGroup'
    { $sel:configuration:WorkGroup' :: Maybe WorkGroupConfiguration
configuration = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:WorkGroup' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:description:WorkGroup' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:state:WorkGroup' :: Maybe WorkGroupState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:name:WorkGroup' :: Text
name = Text
pName_
    }

-- | The configuration of the workgroup, which includes the location in
-- Amazon S3 where query results are stored, the encryption configuration,
-- if any, used for query results; whether the Amazon CloudWatch Metrics
-- are enabled for the workgroup; whether workgroup settings override
-- client-side settings; and the data usage limits for the amount of data
-- scanned per query or per workgroup. The workgroup settings override is
-- specified in @EnforceWorkGroupConfiguration@ (true\/false) in the
-- @WorkGroupConfiguration@. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
workGroup_configuration :: Lens.Lens' WorkGroup (Prelude.Maybe WorkGroupConfiguration)
workGroup_configuration :: Lens' WorkGroup (Maybe WorkGroupConfiguration)
workGroup_configuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkGroup' {Maybe WorkGroupConfiguration
configuration :: Maybe WorkGroupConfiguration
$sel:configuration:WorkGroup' :: WorkGroup -> Maybe WorkGroupConfiguration
configuration} -> Maybe WorkGroupConfiguration
configuration) (\s :: WorkGroup
s@WorkGroup' {} Maybe WorkGroupConfiguration
a -> WorkGroup
s {$sel:configuration:WorkGroup' :: Maybe WorkGroupConfiguration
configuration = Maybe WorkGroupConfiguration
a} :: WorkGroup)

-- | The date and time the workgroup was created.
workGroup_creationTime :: Lens.Lens' WorkGroup (Prelude.Maybe Prelude.UTCTime)
workGroup_creationTime :: Lens' WorkGroup (Maybe UTCTime)
workGroup_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkGroup' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:WorkGroup' :: WorkGroup -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: WorkGroup
s@WorkGroup' {} Maybe POSIX
a -> WorkGroup
s {$sel:creationTime:WorkGroup' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: WorkGroup) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The workgroup description.
workGroup_description :: Lens.Lens' WorkGroup (Prelude.Maybe Prelude.Text)
workGroup_description :: Lens' WorkGroup (Maybe Text)
workGroup_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkGroup' {Maybe Text
description :: Maybe Text
$sel:description:WorkGroup' :: WorkGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: WorkGroup
s@WorkGroup' {} Maybe Text
a -> WorkGroup
s {$sel:description:WorkGroup' :: Maybe Text
description = Maybe Text
a} :: WorkGroup)

-- | The state of the workgroup: ENABLED or DISABLED.
workGroup_state :: Lens.Lens' WorkGroup (Prelude.Maybe WorkGroupState)
workGroup_state :: Lens' WorkGroup (Maybe WorkGroupState)
workGroup_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkGroup' {Maybe WorkGroupState
state :: Maybe WorkGroupState
$sel:state:WorkGroup' :: WorkGroup -> Maybe WorkGroupState
state} -> Maybe WorkGroupState
state) (\s :: WorkGroup
s@WorkGroup' {} Maybe WorkGroupState
a -> WorkGroup
s {$sel:state:WorkGroup' :: Maybe WorkGroupState
state = Maybe WorkGroupState
a} :: WorkGroup)

-- | The workgroup name.
workGroup_name :: Lens.Lens' WorkGroup Prelude.Text
workGroup_name :: Lens' WorkGroup Text
workGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkGroup' {Text
name :: Text
$sel:name:WorkGroup' :: WorkGroup -> Text
name} -> Text
name) (\s :: WorkGroup
s@WorkGroup' {} Text
a -> WorkGroup
s {$sel:name:WorkGroup' :: Text
name = Text
a} :: WorkGroup)

instance Data.FromJSON WorkGroup where
  parseJSON :: Value -> Parser WorkGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkGroup"
      ( \Object
x ->
          Maybe WorkGroupConfiguration
-> Maybe POSIX
-> Maybe Text
-> Maybe WorkGroupState
-> Text
-> WorkGroup
WorkGroup'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Configuration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"State")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable WorkGroup where
  hashWithSalt :: Int -> WorkGroup -> Int
hashWithSalt Int
_salt WorkGroup' {Maybe Text
Maybe POSIX
Maybe WorkGroupConfiguration
Maybe WorkGroupState
Text
name :: Text
state :: Maybe WorkGroupState
description :: Maybe Text
creationTime :: Maybe POSIX
configuration :: Maybe WorkGroupConfiguration
$sel:name:WorkGroup' :: WorkGroup -> Text
$sel:state:WorkGroup' :: WorkGroup -> Maybe WorkGroupState
$sel:description:WorkGroup' :: WorkGroup -> Maybe Text
$sel:creationTime:WorkGroup' :: WorkGroup -> Maybe POSIX
$sel:configuration:WorkGroup' :: WorkGroup -> Maybe WorkGroupConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WorkGroupConfiguration
configuration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WorkGroupState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData WorkGroup where
  rnf :: WorkGroup -> ()
rnf WorkGroup' {Maybe Text
Maybe POSIX
Maybe WorkGroupConfiguration
Maybe WorkGroupState
Text
name :: Text
state :: Maybe WorkGroupState
description :: Maybe Text
creationTime :: Maybe POSIX
configuration :: Maybe WorkGroupConfiguration
$sel:name:WorkGroup' :: WorkGroup -> Text
$sel:state:WorkGroup' :: WorkGroup -> Maybe WorkGroupState
$sel:description:WorkGroup' :: WorkGroup -> Maybe Text
$sel:creationTime:WorkGroup' :: WorkGroup -> Maybe POSIX
$sel:configuration:WorkGroup' :: WorkGroup -> Maybe WorkGroupConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe WorkGroupConfiguration
configuration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe WorkGroupState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name