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

import Amazonka.Athena.Types.WorkGroupConfiguration
import Amazonka.Athena.Types.WorkGroupState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 date and time the workgroup was created.
    WorkGroup -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The state of the workgroup: ENABLED or DISABLED.
    WorkGroup -> Maybe WorkGroupState
state :: Prelude.Maybe WorkGroupState,
    -- | 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 workgroup description.
    WorkGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The workgroup name.
    WorkGroup -> Text
name :: Prelude.Text
  }
  deriving (WorkGroup -> WorkGroup -> Bool
(WorkGroup -> WorkGroup -> Bool)
-> (WorkGroup -> WorkGroup -> Bool) -> Eq WorkGroup
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]
(Int -> ReadS WorkGroup)
-> ReadS [WorkGroup]
-> ReadPrec WorkGroup
-> ReadPrec [WorkGroup]
-> Read 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
(Int -> WorkGroup -> ShowS)
-> (WorkGroup -> String)
-> ([WorkGroup] -> ShowS)
-> Show WorkGroup
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. WorkGroup -> Rep WorkGroup x)
-> (forall x. Rep WorkGroup x -> WorkGroup) -> Generic WorkGroup
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:
--
-- 'creationTime', 'workGroup_creationTime' - The date and time the workgroup was created.
--
-- 'state', 'workGroup_state' - The state of the workgroup: ENABLED or DISABLED.
--
-- '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.
--
-- 'description', 'workGroup_description' - The workgroup description.
--
-- 'name', 'workGroup_name' - The workgroup name.
newWorkGroup ::
  -- | 'name'
  Prelude.Text ->
  WorkGroup
newWorkGroup :: Text -> WorkGroup
newWorkGroup Text
pName_ =
  WorkGroup' :: Maybe POSIX
-> Maybe WorkGroupState
-> Maybe WorkGroupConfiguration
-> Maybe Text
-> Text
-> WorkGroup
WorkGroup'
    { $sel:creationTime:WorkGroup' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:state:WorkGroup' :: Maybe WorkGroupState
state = Maybe WorkGroupState
forall a. Maybe a
Prelude.Nothing,
      $sel:configuration:WorkGroup' :: Maybe WorkGroupConfiguration
configuration = Maybe WorkGroupConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:description:WorkGroup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:WorkGroup' :: Text
name = Text
pName_
    }

-- | The date and time the workgroup was created.
workGroup_creationTime :: Lens.Lens' WorkGroup (Prelude.Maybe Prelude.UTCTime)
workGroup_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> WorkGroup -> f WorkGroup
workGroup_creationTime = (WorkGroup -> Maybe POSIX)
-> (WorkGroup -> Maybe POSIX -> WorkGroup)
-> Lens WorkGroup WorkGroup (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> WorkGroup -> f WorkGroup)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> WorkGroup
-> f WorkGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The state of the workgroup: ENABLED or DISABLED.
workGroup_state :: Lens.Lens' WorkGroup (Prelude.Maybe WorkGroupState)
workGroup_state :: (Maybe WorkGroupState -> f (Maybe WorkGroupState))
-> WorkGroup -> f WorkGroup
workGroup_state = (WorkGroup -> Maybe WorkGroupState)
-> (WorkGroup -> Maybe WorkGroupState -> WorkGroup)
-> Lens
     WorkGroup WorkGroup (Maybe WorkGroupState) (Maybe WorkGroupState)
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 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 :: (Maybe WorkGroupConfiguration -> f (Maybe WorkGroupConfiguration))
-> WorkGroup -> f WorkGroup
workGroup_configuration = (WorkGroup -> Maybe WorkGroupConfiguration)
-> (WorkGroup -> Maybe WorkGroupConfiguration -> WorkGroup)
-> Lens
     WorkGroup
     WorkGroup
     (Maybe WorkGroupConfiguration)
     (Maybe WorkGroupConfiguration)
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 workgroup description.
workGroup_description :: Lens.Lens' WorkGroup (Prelude.Maybe Prelude.Text)
workGroup_description :: (Maybe Text -> f (Maybe Text)) -> WorkGroup -> f WorkGroup
workGroup_description = (WorkGroup -> Maybe Text)
-> (WorkGroup -> Maybe Text -> WorkGroup)
-> Lens WorkGroup WorkGroup (Maybe Text) (Maybe Text)
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 workgroup name.
workGroup_name :: Lens.Lens' WorkGroup Prelude.Text
workGroup_name :: (Text -> f Text) -> WorkGroup -> f WorkGroup
workGroup_name = (WorkGroup -> Text)
-> (WorkGroup -> Text -> WorkGroup)
-> Lens WorkGroup WorkGroup Text Text
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 Core.FromJSON WorkGroup where
  parseJSON :: Value -> Parser WorkGroup
parseJSON =
    String -> (Object -> Parser WorkGroup) -> Value -> Parser WorkGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkGroup"
      ( \Object
x ->
          Maybe POSIX
-> Maybe WorkGroupState
-> Maybe WorkGroupConfiguration
-> Maybe Text
-> Text
-> WorkGroup
WorkGroup'
            (Maybe POSIX
 -> Maybe WorkGroupState
 -> Maybe WorkGroupConfiguration
 -> Maybe Text
 -> Text
 -> WorkGroup)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe WorkGroupState
      -> Maybe WorkGroupConfiguration -> Maybe Text -> Text -> WorkGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationTime")
            Parser
  (Maybe WorkGroupState
   -> Maybe WorkGroupConfiguration -> Maybe Text -> Text -> WorkGroup)
-> Parser (Maybe WorkGroupState)
-> Parser
     (Maybe WorkGroupConfiguration -> Maybe Text -> Text -> WorkGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WorkGroupState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe WorkGroupConfiguration -> Maybe Text -> Text -> WorkGroup)
-> Parser (Maybe WorkGroupConfiguration)
-> Parser (Maybe Text -> Text -> WorkGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WorkGroupConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Configuration")
            Parser (Maybe Text -> Text -> WorkGroup)
-> Parser (Maybe Text) -> Parser (Text -> WorkGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Description")
            Parser (Text -> WorkGroup) -> Parser Text -> Parser WorkGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
      )

instance Prelude.Hashable WorkGroup

instance Prelude.NFData WorkGroup