{-# 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.ResultConfiguration
-- 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.ResultConfiguration where

import Amazonka.Athena.Types.AclConfiguration
import Amazonka.Athena.Types.EncryptionConfiguration
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

-- | The location in Amazon S3 where query results are stored and the
-- encryption option, if any, used for query results. These are known as
-- \"client-side settings\". If workgroup settings override client-side
-- settings, then the query uses the workgroup settings.
--
-- /See:/ 'newResultConfiguration' smart constructor.
data ResultConfiguration = ResultConfiguration'
  { -- | Indicates that an Amazon S3 canned ACL should be set to control
    -- ownership of stored query results. Currently the only supported canned
    -- ACL is @BUCKET_OWNER_FULL_CONTROL@. This is a client-side setting. If
    -- workgroup settings override client-side settings, then the query uses
    -- the ACL configuration that is specified for the workgroup, and also uses
    -- the location for storing query results specified in the workgroup. For
    -- more information, see
    -- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
    -- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
    ResultConfiguration -> Maybe AclConfiguration
aclConfiguration :: Prelude.Maybe AclConfiguration,
    -- | If query results are encrypted in Amazon S3, indicates the encryption
    -- option used (for example, @SSE_KMS@ or @CSE_KMS@) and key information.
    -- This is a client-side setting. If workgroup settings override
    -- client-side settings, then the query uses the encryption configuration
    -- that is specified for the workgroup, and also uses the location for
    -- storing query results specified in the workgroup. See
    -- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
    -- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
    ResultConfiguration -> Maybe EncryptionConfiguration
encryptionConfiguration :: Prelude.Maybe EncryptionConfiguration,
    -- | The Amazon Web Services account ID that you expect to be the owner of
    -- the Amazon S3 bucket specified by ResultConfiguration$OutputLocation. If
    -- set, Athena uses the value for @ExpectedBucketOwner@ when it makes
    -- Amazon S3 calls to your specified output location. If the
    -- @ExpectedBucketOwner@ Amazon Web Services account ID does not match the
    -- actual owner of the Amazon S3 bucket, the call fails with a permissions
    -- error.
    --
    -- This is a client-side setting. If workgroup settings override
    -- client-side settings, then the query uses the @ExpectedBucketOwner@
    -- setting that is specified for the workgroup, and also uses the location
    -- for storing query results specified in the workgroup. See
    -- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
    -- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
    ResultConfiguration -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The location in Amazon S3 where your query results are stored, such as
    -- @s3:\/\/path\/to\/query\/bucket\/@. To run the query, you must specify
    -- the query results location using one of the ways: either for individual
    -- queries using either this setting (client-side), or in the workgroup,
    -- using WorkGroupConfiguration. If none of them is set, Athena issues an
    -- error that no output location is provided. For more information, see
    -- <https://docs.aws.amazon.com/athena/latest/ug/querying.html Query Results>.
    -- If workgroup settings override client-side settings, then the query uses
    -- the settings specified for the workgroup. See
    -- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
    ResultConfiguration -> Maybe Text
outputLocation :: Prelude.Maybe Prelude.Text
  }
  deriving (ResultConfiguration -> ResultConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultConfiguration -> ResultConfiguration -> Bool
$c/= :: ResultConfiguration -> ResultConfiguration -> Bool
== :: ResultConfiguration -> ResultConfiguration -> Bool
$c== :: ResultConfiguration -> ResultConfiguration -> Bool
Prelude.Eq, ReadPrec [ResultConfiguration]
ReadPrec ResultConfiguration
Int -> ReadS ResultConfiguration
ReadS [ResultConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultConfiguration]
$creadListPrec :: ReadPrec [ResultConfiguration]
readPrec :: ReadPrec ResultConfiguration
$creadPrec :: ReadPrec ResultConfiguration
readList :: ReadS [ResultConfiguration]
$creadList :: ReadS [ResultConfiguration]
readsPrec :: Int -> ReadS ResultConfiguration
$creadsPrec :: Int -> ReadS ResultConfiguration
Prelude.Read, Int -> ResultConfiguration -> ShowS
[ResultConfiguration] -> ShowS
ResultConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultConfiguration] -> ShowS
$cshowList :: [ResultConfiguration] -> ShowS
show :: ResultConfiguration -> String
$cshow :: ResultConfiguration -> String
showsPrec :: Int -> ResultConfiguration -> ShowS
$cshowsPrec :: Int -> ResultConfiguration -> ShowS
Prelude.Show, forall x. Rep ResultConfiguration x -> ResultConfiguration
forall x. ResultConfiguration -> Rep ResultConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultConfiguration x -> ResultConfiguration
$cfrom :: forall x. ResultConfiguration -> Rep ResultConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ResultConfiguration' 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:
--
-- 'aclConfiguration', 'resultConfiguration_aclConfiguration' - Indicates that an Amazon S3 canned ACL should be set to control
-- ownership of stored query results. Currently the only supported canned
-- ACL is @BUCKET_OWNER_FULL_CONTROL@. This is a client-side setting. If
-- workgroup settings override client-side settings, then the query uses
-- the ACL configuration that is specified for the workgroup, and also uses
-- the location for storing query results specified in the workgroup. For
-- more information, see
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
-- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
--
-- 'encryptionConfiguration', 'resultConfiguration_encryptionConfiguration' - If query results are encrypted in Amazon S3, indicates the encryption
-- option used (for example, @SSE_KMS@ or @CSE_KMS@) and key information.
-- This is a client-side setting. If workgroup settings override
-- client-side settings, then the query uses the encryption configuration
-- that is specified for the workgroup, and also uses the location for
-- storing query results specified in the workgroup. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
-- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
--
-- 'expectedBucketOwner', 'resultConfiguration_expectedBucketOwner' - The Amazon Web Services account ID that you expect to be the owner of
-- the Amazon S3 bucket specified by ResultConfiguration$OutputLocation. If
-- set, Athena uses the value for @ExpectedBucketOwner@ when it makes
-- Amazon S3 calls to your specified output location. If the
-- @ExpectedBucketOwner@ Amazon Web Services account ID does not match the
-- actual owner of the Amazon S3 bucket, the call fails with a permissions
-- error.
--
-- This is a client-side setting. If workgroup settings override
-- client-side settings, then the query uses the @ExpectedBucketOwner@
-- setting that is specified for the workgroup, and also uses the location
-- for storing query results specified in the workgroup. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
-- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
--
-- 'outputLocation', 'resultConfiguration_outputLocation' - The location in Amazon S3 where your query results are stored, such as
-- @s3:\/\/path\/to\/query\/bucket\/@. To run the query, you must specify
-- the query results location using one of the ways: either for individual
-- queries using either this setting (client-side), or in the workgroup,
-- using WorkGroupConfiguration. If none of them is set, Athena issues an
-- error that no output location is provided. For more information, see
-- <https://docs.aws.amazon.com/athena/latest/ug/querying.html Query Results>.
-- If workgroup settings override client-side settings, then the query uses
-- the settings specified for the workgroup. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
newResultConfiguration ::
  ResultConfiguration
newResultConfiguration :: ResultConfiguration
newResultConfiguration =
  ResultConfiguration'
    { $sel:aclConfiguration:ResultConfiguration' :: Maybe AclConfiguration
aclConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionConfiguration:ResultConfiguration' :: Maybe EncryptionConfiguration
encryptionConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:expectedBucketOwner:ResultConfiguration' :: Maybe Text
expectedBucketOwner = forall a. Maybe a
Prelude.Nothing,
      $sel:outputLocation:ResultConfiguration' :: Maybe Text
outputLocation = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates that an Amazon S3 canned ACL should be set to control
-- ownership of stored query results. Currently the only supported canned
-- ACL is @BUCKET_OWNER_FULL_CONTROL@. This is a client-side setting. If
-- workgroup settings override client-side settings, then the query uses
-- the ACL configuration that is specified for the workgroup, and also uses
-- the location for storing query results specified in the workgroup. For
-- more information, see
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
-- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
resultConfiguration_aclConfiguration :: Lens.Lens' ResultConfiguration (Prelude.Maybe AclConfiguration)
resultConfiguration_aclConfiguration :: Lens' ResultConfiguration (Maybe AclConfiguration)
resultConfiguration_aclConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultConfiguration' {Maybe AclConfiguration
aclConfiguration :: Maybe AclConfiguration
$sel:aclConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe AclConfiguration
aclConfiguration} -> Maybe AclConfiguration
aclConfiguration) (\s :: ResultConfiguration
s@ResultConfiguration' {} Maybe AclConfiguration
a -> ResultConfiguration
s {$sel:aclConfiguration:ResultConfiguration' :: Maybe AclConfiguration
aclConfiguration = Maybe AclConfiguration
a} :: ResultConfiguration)

-- | If query results are encrypted in Amazon S3, indicates the encryption
-- option used (for example, @SSE_KMS@ or @CSE_KMS@) and key information.
-- This is a client-side setting. If workgroup settings override
-- client-side settings, then the query uses the encryption configuration
-- that is specified for the workgroup, and also uses the location for
-- storing query results specified in the workgroup. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
-- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
resultConfiguration_encryptionConfiguration :: Lens.Lens' ResultConfiguration (Prelude.Maybe EncryptionConfiguration)
resultConfiguration_encryptionConfiguration :: Lens' ResultConfiguration (Maybe EncryptionConfiguration)
resultConfiguration_encryptionConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultConfiguration' {Maybe EncryptionConfiguration
encryptionConfiguration :: Maybe EncryptionConfiguration
$sel:encryptionConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe EncryptionConfiguration
encryptionConfiguration} -> Maybe EncryptionConfiguration
encryptionConfiguration) (\s :: ResultConfiguration
s@ResultConfiguration' {} Maybe EncryptionConfiguration
a -> ResultConfiguration
s {$sel:encryptionConfiguration:ResultConfiguration' :: Maybe EncryptionConfiguration
encryptionConfiguration = Maybe EncryptionConfiguration
a} :: ResultConfiguration)

-- | The Amazon Web Services account ID that you expect to be the owner of
-- the Amazon S3 bucket specified by ResultConfiguration$OutputLocation. If
-- set, Athena uses the value for @ExpectedBucketOwner@ when it makes
-- Amazon S3 calls to your specified output location. If the
-- @ExpectedBucketOwner@ Amazon Web Services account ID does not match the
-- actual owner of the Amazon S3 bucket, the call fails with a permissions
-- error.
--
-- This is a client-side setting. If workgroup settings override
-- client-side settings, then the query uses the @ExpectedBucketOwner@
-- setting that is specified for the workgroup, and also uses the location
-- for storing query results specified in the workgroup. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration and
-- <https://docs.aws.amazon.com/athena/latest/ug/workgroups-settings-override.html Workgroup Settings Override Client-Side Settings>.
resultConfiguration_expectedBucketOwner :: Lens.Lens' ResultConfiguration (Prelude.Maybe Prelude.Text)
resultConfiguration_expectedBucketOwner :: Lens' ResultConfiguration (Maybe Text)
resultConfiguration_expectedBucketOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultConfiguration' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:ResultConfiguration' :: ResultConfiguration -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: ResultConfiguration
s@ResultConfiguration' {} Maybe Text
a -> ResultConfiguration
s {$sel:expectedBucketOwner:ResultConfiguration' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: ResultConfiguration)

-- | The location in Amazon S3 where your query results are stored, such as
-- @s3:\/\/path\/to\/query\/bucket\/@. To run the query, you must specify
-- the query results location using one of the ways: either for individual
-- queries using either this setting (client-side), or in the workgroup,
-- using WorkGroupConfiguration. If none of them is set, Athena issues an
-- error that no output location is provided. For more information, see
-- <https://docs.aws.amazon.com/athena/latest/ug/querying.html Query Results>.
-- If workgroup settings override client-side settings, then the query uses
-- the settings specified for the workgroup. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
resultConfiguration_outputLocation :: Lens.Lens' ResultConfiguration (Prelude.Maybe Prelude.Text)
resultConfiguration_outputLocation :: Lens' ResultConfiguration (Maybe Text)
resultConfiguration_outputLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultConfiguration' {Maybe Text
outputLocation :: Maybe Text
$sel:outputLocation:ResultConfiguration' :: ResultConfiguration -> Maybe Text
outputLocation} -> Maybe Text
outputLocation) (\s :: ResultConfiguration
s@ResultConfiguration' {} Maybe Text
a -> ResultConfiguration
s {$sel:outputLocation:ResultConfiguration' :: Maybe Text
outputLocation = Maybe Text
a} :: ResultConfiguration)

instance Data.FromJSON ResultConfiguration where
  parseJSON :: Value -> Parser ResultConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResultConfiguration"
      ( \Object
x ->
          Maybe AclConfiguration
-> Maybe EncryptionConfiguration
-> Maybe Text
-> Maybe Text
-> ResultConfiguration
ResultConfiguration'
            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
"AclConfiguration")
            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
"EncryptionConfiguration")
            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
"ExpectedBucketOwner")
            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
"OutputLocation")
      )

instance Prelude.Hashable ResultConfiguration where
  hashWithSalt :: Int -> ResultConfiguration -> Int
hashWithSalt Int
_salt ResultConfiguration' {Maybe Text
Maybe EncryptionConfiguration
Maybe AclConfiguration
outputLocation :: Maybe Text
expectedBucketOwner :: Maybe Text
encryptionConfiguration :: Maybe EncryptionConfiguration
aclConfiguration :: Maybe AclConfiguration
$sel:outputLocation:ResultConfiguration' :: ResultConfiguration -> Maybe Text
$sel:expectedBucketOwner:ResultConfiguration' :: ResultConfiguration -> Maybe Text
$sel:encryptionConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe EncryptionConfiguration
$sel:aclConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe AclConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AclConfiguration
aclConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EncryptionConfiguration
encryptionConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expectedBucketOwner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
outputLocation

instance Prelude.NFData ResultConfiguration where
  rnf :: ResultConfiguration -> ()
rnf ResultConfiguration' {Maybe Text
Maybe EncryptionConfiguration
Maybe AclConfiguration
outputLocation :: Maybe Text
expectedBucketOwner :: Maybe Text
encryptionConfiguration :: Maybe EncryptionConfiguration
aclConfiguration :: Maybe AclConfiguration
$sel:outputLocation:ResultConfiguration' :: ResultConfiguration -> Maybe Text
$sel:expectedBucketOwner:ResultConfiguration' :: ResultConfiguration -> Maybe Text
$sel:encryptionConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe EncryptionConfiguration
$sel:aclConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe AclConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AclConfiguration
aclConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionConfiguration
encryptionConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expectedBucketOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
outputLocation

instance Data.ToJSON ResultConfiguration where
  toJSON :: ResultConfiguration -> Value
toJSON ResultConfiguration' {Maybe Text
Maybe EncryptionConfiguration
Maybe AclConfiguration
outputLocation :: Maybe Text
expectedBucketOwner :: Maybe Text
encryptionConfiguration :: Maybe EncryptionConfiguration
aclConfiguration :: Maybe AclConfiguration
$sel:outputLocation:ResultConfiguration' :: ResultConfiguration -> Maybe Text
$sel:expectedBucketOwner:ResultConfiguration' :: ResultConfiguration -> Maybe Text
$sel:encryptionConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe EncryptionConfiguration
$sel:aclConfiguration:ResultConfiguration' :: ResultConfiguration -> Maybe AclConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AclConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AclConfiguration
aclConfiguration,
            (Key
"EncryptionConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionConfiguration
encryptionConfiguration,
            (Key
"ExpectedBucketOwner" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
expectedBucketOwner,
            (Key
"OutputLocation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
outputLocation
          ]
      )