{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.StartQueryExecution
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Runs the SQL query statements contained in the @Query@. Requires you to
-- have access to the workgroup in which the query ran. Running queries
-- against an external catalog requires GetDataCatalog permission to the
-- catalog. For code samples using the Amazon Web Services SDK for Java,
-- see
-- <http://docs.aws.amazon.com/athena/latest/ug/code-samples.html Examples and Code Samples>
-- in the /Amazon Athena User Guide/.
module Amazonka.Athena.StartQueryExecution
  ( -- * Creating a Request
    StartQueryExecution (..),
    newStartQueryExecution,

    -- * Request Lenses
    startQueryExecution_clientRequestToken,
    startQueryExecution_executionParameters,
    startQueryExecution_queryExecutionContext,
    startQueryExecution_resultConfiguration,
    startQueryExecution_resultReuseConfiguration,
    startQueryExecution_workGroup,
    startQueryExecution_queryString,

    -- * Destructuring the Response
    StartQueryExecutionResponse (..),
    newStartQueryExecutionResponse,

    -- * Response Lenses
    startQueryExecutionResponse_queryExecutionId,
    startQueryExecutionResponse_httpStatus,
  )
where

import Amazonka.Athena.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartQueryExecution' smart constructor.
data StartQueryExecution = StartQueryExecution'
  { -- | A unique case-sensitive string used to ensure the request to create the
    -- query is idempotent (executes only once). If another
    -- @StartQueryExecution@ request is received, the same response is returned
    -- and another query is not created. If a parameter has changed, for
    -- example, the @QueryString@, an error is returned.
    --
    -- This token is listed as not required because Amazon Web Services SDKs
    -- (for example the Amazon Web Services SDK for Java) auto-generate the
    -- token for users. If you are not using the Amazon Web Services SDK or the
    -- Amazon Web Services CLI, you must provide this token or the action will
    -- fail.
    StartQueryExecution -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | A list of values for the parameters in a query. The values are applied
    -- sequentially to the parameters in the query in the order in which the
    -- parameters occur.
    StartQueryExecution -> Maybe (NonEmpty Text)
executionParameters :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The database within which the query executes.
    StartQueryExecution -> Maybe QueryExecutionContext
queryExecutionContext :: Prelude.Maybe QueryExecutionContext,
    -- | Specifies information about where and how to save the results of the
    -- query execution. If the query runs in a workgroup, then workgroup\'s
    -- settings may override query settings. This affects the query results
    -- location. The workgroup settings override is specified in
    -- EnforceWorkGroupConfiguration (true\/false) in the
    -- WorkGroupConfiguration. See
    -- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
    StartQueryExecution -> Maybe ResultConfiguration
resultConfiguration :: Prelude.Maybe ResultConfiguration,
    -- | Specifies the query result reuse behavior for the query.
    StartQueryExecution -> Maybe ResultReuseConfiguration
resultReuseConfiguration :: Prelude.Maybe ResultReuseConfiguration,
    -- | The name of the workgroup in which the query is being started.
    StartQueryExecution -> Maybe Text
workGroup :: Prelude.Maybe Prelude.Text,
    -- | The SQL query statements to be executed.
    StartQueryExecution -> Text
queryString :: Prelude.Text
  }
  deriving (StartQueryExecution -> StartQueryExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartQueryExecution -> StartQueryExecution -> Bool
$c/= :: StartQueryExecution -> StartQueryExecution -> Bool
== :: StartQueryExecution -> StartQueryExecution -> Bool
$c== :: StartQueryExecution -> StartQueryExecution -> Bool
Prelude.Eq, ReadPrec [StartQueryExecution]
ReadPrec StartQueryExecution
Int -> ReadS StartQueryExecution
ReadS [StartQueryExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartQueryExecution]
$creadListPrec :: ReadPrec [StartQueryExecution]
readPrec :: ReadPrec StartQueryExecution
$creadPrec :: ReadPrec StartQueryExecution
readList :: ReadS [StartQueryExecution]
$creadList :: ReadS [StartQueryExecution]
readsPrec :: Int -> ReadS StartQueryExecution
$creadsPrec :: Int -> ReadS StartQueryExecution
Prelude.Read, Int -> StartQueryExecution -> ShowS
[StartQueryExecution] -> ShowS
StartQueryExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartQueryExecution] -> ShowS
$cshowList :: [StartQueryExecution] -> ShowS
show :: StartQueryExecution -> String
$cshow :: StartQueryExecution -> String
showsPrec :: Int -> StartQueryExecution -> ShowS
$cshowsPrec :: Int -> StartQueryExecution -> ShowS
Prelude.Show, forall x. Rep StartQueryExecution x -> StartQueryExecution
forall x. StartQueryExecution -> Rep StartQueryExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartQueryExecution x -> StartQueryExecution
$cfrom :: forall x. StartQueryExecution -> Rep StartQueryExecution x
Prelude.Generic)

-- |
-- Create a value of 'StartQueryExecution' 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:
--
-- 'clientRequestToken', 'startQueryExecution_clientRequestToken' - A unique case-sensitive string used to ensure the request to create the
-- query is idempotent (executes only once). If another
-- @StartQueryExecution@ request is received, the same response is returned
-- and another query is not created. If a parameter has changed, for
-- example, the @QueryString@, an error is returned.
--
-- This token is listed as not required because Amazon Web Services SDKs
-- (for example the Amazon Web Services SDK for Java) auto-generate the
-- token for users. If you are not using the Amazon Web Services SDK or the
-- Amazon Web Services CLI, you must provide this token or the action will
-- fail.
--
-- 'executionParameters', 'startQueryExecution_executionParameters' - A list of values for the parameters in a query. The values are applied
-- sequentially to the parameters in the query in the order in which the
-- parameters occur.
--
-- 'queryExecutionContext', 'startQueryExecution_queryExecutionContext' - The database within which the query executes.
--
-- 'resultConfiguration', 'startQueryExecution_resultConfiguration' - Specifies information about where and how to save the results of the
-- query execution. If the query runs in a workgroup, then workgroup\'s
-- settings may override query settings. This affects the query results
-- location. The workgroup settings override is specified in
-- EnforceWorkGroupConfiguration (true\/false) in the
-- WorkGroupConfiguration. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
--
-- 'resultReuseConfiguration', 'startQueryExecution_resultReuseConfiguration' - Specifies the query result reuse behavior for the query.
--
-- 'workGroup', 'startQueryExecution_workGroup' - The name of the workgroup in which the query is being started.
--
-- 'queryString', 'startQueryExecution_queryString' - The SQL query statements to be executed.
newStartQueryExecution ::
  -- | 'queryString'
  Prelude.Text ->
  StartQueryExecution
newStartQueryExecution :: Text -> StartQueryExecution
newStartQueryExecution Text
pQueryString_ =
  StartQueryExecution'
    { $sel:clientRequestToken:StartQueryExecution' :: Maybe Text
clientRequestToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:executionParameters:StartQueryExecution' :: Maybe (NonEmpty Text)
executionParameters = forall a. Maybe a
Prelude.Nothing,
      $sel:queryExecutionContext:StartQueryExecution' :: Maybe QueryExecutionContext
queryExecutionContext = forall a. Maybe a
Prelude.Nothing,
      $sel:resultConfiguration:StartQueryExecution' :: Maybe ResultConfiguration
resultConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:resultReuseConfiguration:StartQueryExecution' :: Maybe ResultReuseConfiguration
resultReuseConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:workGroup:StartQueryExecution' :: Maybe Text
workGroup = forall a. Maybe a
Prelude.Nothing,
      $sel:queryString:StartQueryExecution' :: Text
queryString = Text
pQueryString_
    }

-- | A unique case-sensitive string used to ensure the request to create the
-- query is idempotent (executes only once). If another
-- @StartQueryExecution@ request is received, the same response is returned
-- and another query is not created. If a parameter has changed, for
-- example, the @QueryString@, an error is returned.
--
-- This token is listed as not required because Amazon Web Services SDKs
-- (for example the Amazon Web Services SDK for Java) auto-generate the
-- token for users. If you are not using the Amazon Web Services SDK or the
-- Amazon Web Services CLI, you must provide this token or the action will
-- fail.
startQueryExecution_clientRequestToken :: Lens.Lens' StartQueryExecution (Prelude.Maybe Prelude.Text)
startQueryExecution_clientRequestToken :: Lens' StartQueryExecution (Maybe Text)
startQueryExecution_clientRequestToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:StartQueryExecution' :: StartQueryExecution -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: StartQueryExecution
s@StartQueryExecution' {} Maybe Text
a -> StartQueryExecution
s {$sel:clientRequestToken:StartQueryExecution' :: Maybe Text
clientRequestToken = Maybe Text
a} :: StartQueryExecution)

-- | A list of values for the parameters in a query. The values are applied
-- sequentially to the parameters in the query in the order in which the
-- parameters occur.
startQueryExecution_executionParameters :: Lens.Lens' StartQueryExecution (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
startQueryExecution_executionParameters :: Lens' StartQueryExecution (Maybe (NonEmpty Text))
startQueryExecution_executionParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Maybe (NonEmpty Text)
executionParameters :: Maybe (NonEmpty Text)
$sel:executionParameters:StartQueryExecution' :: StartQueryExecution -> Maybe (NonEmpty Text)
executionParameters} -> Maybe (NonEmpty Text)
executionParameters) (\s :: StartQueryExecution
s@StartQueryExecution' {} Maybe (NonEmpty Text)
a -> StartQueryExecution
s {$sel:executionParameters:StartQueryExecution' :: Maybe (NonEmpty Text)
executionParameters = Maybe (NonEmpty Text)
a} :: StartQueryExecution) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The database within which the query executes.
startQueryExecution_queryExecutionContext :: Lens.Lens' StartQueryExecution (Prelude.Maybe QueryExecutionContext)
startQueryExecution_queryExecutionContext :: Lens' StartQueryExecution (Maybe QueryExecutionContext)
startQueryExecution_queryExecutionContext = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Maybe QueryExecutionContext
queryExecutionContext :: Maybe QueryExecutionContext
$sel:queryExecutionContext:StartQueryExecution' :: StartQueryExecution -> Maybe QueryExecutionContext
queryExecutionContext} -> Maybe QueryExecutionContext
queryExecutionContext) (\s :: StartQueryExecution
s@StartQueryExecution' {} Maybe QueryExecutionContext
a -> StartQueryExecution
s {$sel:queryExecutionContext:StartQueryExecution' :: Maybe QueryExecutionContext
queryExecutionContext = Maybe QueryExecutionContext
a} :: StartQueryExecution)

-- | Specifies information about where and how to save the results of the
-- query execution. If the query runs in a workgroup, then workgroup\'s
-- settings may override query settings. This affects the query results
-- location. The workgroup settings override is specified in
-- EnforceWorkGroupConfiguration (true\/false) in the
-- WorkGroupConfiguration. See
-- WorkGroupConfiguration$EnforceWorkGroupConfiguration.
startQueryExecution_resultConfiguration :: Lens.Lens' StartQueryExecution (Prelude.Maybe ResultConfiguration)
startQueryExecution_resultConfiguration :: Lens' StartQueryExecution (Maybe ResultConfiguration)
startQueryExecution_resultConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Maybe ResultConfiguration
resultConfiguration :: Maybe ResultConfiguration
$sel:resultConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultConfiguration
resultConfiguration} -> Maybe ResultConfiguration
resultConfiguration) (\s :: StartQueryExecution
s@StartQueryExecution' {} Maybe ResultConfiguration
a -> StartQueryExecution
s {$sel:resultConfiguration:StartQueryExecution' :: Maybe ResultConfiguration
resultConfiguration = Maybe ResultConfiguration
a} :: StartQueryExecution)

-- | Specifies the query result reuse behavior for the query.
startQueryExecution_resultReuseConfiguration :: Lens.Lens' StartQueryExecution (Prelude.Maybe ResultReuseConfiguration)
startQueryExecution_resultReuseConfiguration :: Lens' StartQueryExecution (Maybe ResultReuseConfiguration)
startQueryExecution_resultReuseConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Maybe ResultReuseConfiguration
resultReuseConfiguration :: Maybe ResultReuseConfiguration
$sel:resultReuseConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultReuseConfiguration
resultReuseConfiguration} -> Maybe ResultReuseConfiguration
resultReuseConfiguration) (\s :: StartQueryExecution
s@StartQueryExecution' {} Maybe ResultReuseConfiguration
a -> StartQueryExecution
s {$sel:resultReuseConfiguration:StartQueryExecution' :: Maybe ResultReuseConfiguration
resultReuseConfiguration = Maybe ResultReuseConfiguration
a} :: StartQueryExecution)

-- | The name of the workgroup in which the query is being started.
startQueryExecution_workGroup :: Lens.Lens' StartQueryExecution (Prelude.Maybe Prelude.Text)
startQueryExecution_workGroup :: Lens' StartQueryExecution (Maybe Text)
startQueryExecution_workGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Maybe Text
workGroup :: Maybe Text
$sel:workGroup:StartQueryExecution' :: StartQueryExecution -> Maybe Text
workGroup} -> Maybe Text
workGroup) (\s :: StartQueryExecution
s@StartQueryExecution' {} Maybe Text
a -> StartQueryExecution
s {$sel:workGroup:StartQueryExecution' :: Maybe Text
workGroup = Maybe Text
a} :: StartQueryExecution)

-- | The SQL query statements to be executed.
startQueryExecution_queryString :: Lens.Lens' StartQueryExecution Prelude.Text
startQueryExecution_queryString :: Lens' StartQueryExecution Text
startQueryExecution_queryString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecution' {Text
queryString :: Text
$sel:queryString:StartQueryExecution' :: StartQueryExecution -> Text
queryString} -> Text
queryString) (\s :: StartQueryExecution
s@StartQueryExecution' {} Text
a -> StartQueryExecution
s {$sel:queryString:StartQueryExecution' :: Text
queryString = Text
a} :: StartQueryExecution)

instance Core.AWSRequest StartQueryExecution where
  type
    AWSResponse StartQueryExecution =
      StartQueryExecutionResponse
  request :: (Service -> Service)
-> StartQueryExecution -> Request StartQueryExecution
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartQueryExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartQueryExecution)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> StartQueryExecutionResponse
StartQueryExecutionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"QueryExecutionId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartQueryExecution where
  hashWithSalt :: Int -> StartQueryExecution -> Int
hashWithSalt Int
_salt StartQueryExecution' {Maybe (NonEmpty Text)
Maybe Text
Maybe QueryExecutionContext
Maybe ResultReuseConfiguration
Maybe ResultConfiguration
Text
queryString :: Text
workGroup :: Maybe Text
resultReuseConfiguration :: Maybe ResultReuseConfiguration
resultConfiguration :: Maybe ResultConfiguration
queryExecutionContext :: Maybe QueryExecutionContext
executionParameters :: Maybe (NonEmpty Text)
clientRequestToken :: Maybe Text
$sel:queryString:StartQueryExecution' :: StartQueryExecution -> Text
$sel:workGroup:StartQueryExecution' :: StartQueryExecution -> Maybe Text
$sel:resultReuseConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultReuseConfiguration
$sel:resultConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultConfiguration
$sel:queryExecutionContext:StartQueryExecution' :: StartQueryExecution -> Maybe QueryExecutionContext
$sel:executionParameters:StartQueryExecution' :: StartQueryExecution -> Maybe (NonEmpty Text)
$sel:clientRequestToken:StartQueryExecution' :: StartQueryExecution -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientRequestToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
executionParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueryExecutionContext
queryExecutionContext
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResultConfiguration
resultConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResultReuseConfiguration
resultReuseConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workGroup
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
queryString

instance Prelude.NFData StartQueryExecution where
  rnf :: StartQueryExecution -> ()
rnf StartQueryExecution' {Maybe (NonEmpty Text)
Maybe Text
Maybe QueryExecutionContext
Maybe ResultReuseConfiguration
Maybe ResultConfiguration
Text
queryString :: Text
workGroup :: Maybe Text
resultReuseConfiguration :: Maybe ResultReuseConfiguration
resultConfiguration :: Maybe ResultConfiguration
queryExecutionContext :: Maybe QueryExecutionContext
executionParameters :: Maybe (NonEmpty Text)
clientRequestToken :: Maybe Text
$sel:queryString:StartQueryExecution' :: StartQueryExecution -> Text
$sel:workGroup:StartQueryExecution' :: StartQueryExecution -> Maybe Text
$sel:resultReuseConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultReuseConfiguration
$sel:resultConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultConfiguration
$sel:queryExecutionContext:StartQueryExecution' :: StartQueryExecution -> Maybe QueryExecutionContext
$sel:executionParameters:StartQueryExecution' :: StartQueryExecution -> Maybe (NonEmpty Text)
$sel:clientRequestToken:StartQueryExecution' :: StartQueryExecution -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientRequestToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
executionParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QueryExecutionContext
queryExecutionContext
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResultConfiguration
resultConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResultReuseConfiguration
resultReuseConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
workGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
queryString

instance Data.ToHeaders StartQueryExecution where
  toHeaders :: StartQueryExecution -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AmazonAthena.StartQueryExecution" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartQueryExecution where
  toJSON :: StartQueryExecution -> Value
toJSON StartQueryExecution' {Maybe (NonEmpty Text)
Maybe Text
Maybe QueryExecutionContext
Maybe ResultReuseConfiguration
Maybe ResultConfiguration
Text
queryString :: Text
workGroup :: Maybe Text
resultReuseConfiguration :: Maybe ResultReuseConfiguration
resultConfiguration :: Maybe ResultConfiguration
queryExecutionContext :: Maybe QueryExecutionContext
executionParameters :: Maybe (NonEmpty Text)
clientRequestToken :: Maybe Text
$sel:queryString:StartQueryExecution' :: StartQueryExecution -> Text
$sel:workGroup:StartQueryExecution' :: StartQueryExecution -> Maybe Text
$sel:resultReuseConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultReuseConfiguration
$sel:resultConfiguration:StartQueryExecution' :: StartQueryExecution -> Maybe ResultConfiguration
$sel:queryExecutionContext:StartQueryExecution' :: StartQueryExecution -> Maybe QueryExecutionContext
$sel:executionParameters:StartQueryExecution' :: StartQueryExecution -> Maybe (NonEmpty Text)
$sel:clientRequestToken:StartQueryExecution' :: StartQueryExecution -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientRequestToken" 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
clientRequestToken,
            (Key
"ExecutionParameters" 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 (NonEmpty Text)
executionParameters,
            (Key
"QueryExecutionContext" 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 QueryExecutionContext
queryExecutionContext,
            (Key
"ResultConfiguration" 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 ResultConfiguration
resultConfiguration,
            (Key
"ResultReuseConfiguration" 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 ResultReuseConfiguration
resultReuseConfiguration,
            (Key
"WorkGroup" 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
workGroup,
            forall a. a -> Maybe a
Prelude.Just (Key
"QueryString" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
queryString)
          ]
      )

instance Data.ToPath StartQueryExecution where
  toPath :: StartQueryExecution -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery StartQueryExecution where
  toQuery :: StartQueryExecution -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newStartQueryExecutionResponse' smart constructor.
data StartQueryExecutionResponse = StartQueryExecutionResponse'
  { -- | The unique ID of the query that ran as a result of this request.
    StartQueryExecutionResponse -> Maybe Text
queryExecutionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartQueryExecutionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartQueryExecutionResponse -> StartQueryExecutionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartQueryExecutionResponse -> StartQueryExecutionResponse -> Bool
$c/= :: StartQueryExecutionResponse -> StartQueryExecutionResponse -> Bool
== :: StartQueryExecutionResponse -> StartQueryExecutionResponse -> Bool
$c== :: StartQueryExecutionResponse -> StartQueryExecutionResponse -> Bool
Prelude.Eq, ReadPrec [StartQueryExecutionResponse]
ReadPrec StartQueryExecutionResponse
Int -> ReadS StartQueryExecutionResponse
ReadS [StartQueryExecutionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartQueryExecutionResponse]
$creadListPrec :: ReadPrec [StartQueryExecutionResponse]
readPrec :: ReadPrec StartQueryExecutionResponse
$creadPrec :: ReadPrec StartQueryExecutionResponse
readList :: ReadS [StartQueryExecutionResponse]
$creadList :: ReadS [StartQueryExecutionResponse]
readsPrec :: Int -> ReadS StartQueryExecutionResponse
$creadsPrec :: Int -> ReadS StartQueryExecutionResponse
Prelude.Read, Int -> StartQueryExecutionResponse -> ShowS
[StartQueryExecutionResponse] -> ShowS
StartQueryExecutionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartQueryExecutionResponse] -> ShowS
$cshowList :: [StartQueryExecutionResponse] -> ShowS
show :: StartQueryExecutionResponse -> String
$cshow :: StartQueryExecutionResponse -> String
showsPrec :: Int -> StartQueryExecutionResponse -> ShowS
$cshowsPrec :: Int -> StartQueryExecutionResponse -> ShowS
Prelude.Show, forall x.
Rep StartQueryExecutionResponse x -> StartQueryExecutionResponse
forall x.
StartQueryExecutionResponse -> Rep StartQueryExecutionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartQueryExecutionResponse x -> StartQueryExecutionResponse
$cfrom :: forall x.
StartQueryExecutionResponse -> Rep StartQueryExecutionResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartQueryExecutionResponse' 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:
--
-- 'queryExecutionId', 'startQueryExecutionResponse_queryExecutionId' - The unique ID of the query that ran as a result of this request.
--
-- 'httpStatus', 'startQueryExecutionResponse_httpStatus' - The response's http status code.
newStartQueryExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartQueryExecutionResponse
newStartQueryExecutionResponse :: Int -> StartQueryExecutionResponse
newStartQueryExecutionResponse Int
pHttpStatus_ =
  StartQueryExecutionResponse'
    { $sel:queryExecutionId:StartQueryExecutionResponse' :: Maybe Text
queryExecutionId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartQueryExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique ID of the query that ran as a result of this request.
startQueryExecutionResponse_queryExecutionId :: Lens.Lens' StartQueryExecutionResponse (Prelude.Maybe Prelude.Text)
startQueryExecutionResponse_queryExecutionId :: Lens' StartQueryExecutionResponse (Maybe Text)
startQueryExecutionResponse_queryExecutionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecutionResponse' {Maybe Text
queryExecutionId :: Maybe Text
$sel:queryExecutionId:StartQueryExecutionResponse' :: StartQueryExecutionResponse -> Maybe Text
queryExecutionId} -> Maybe Text
queryExecutionId) (\s :: StartQueryExecutionResponse
s@StartQueryExecutionResponse' {} Maybe Text
a -> StartQueryExecutionResponse
s {$sel:queryExecutionId:StartQueryExecutionResponse' :: Maybe Text
queryExecutionId = Maybe Text
a} :: StartQueryExecutionResponse)

-- | The response's http status code.
startQueryExecutionResponse_httpStatus :: Lens.Lens' StartQueryExecutionResponse Prelude.Int
startQueryExecutionResponse_httpStatus :: Lens' StartQueryExecutionResponse Int
startQueryExecutionResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryExecutionResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartQueryExecutionResponse' :: StartQueryExecutionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StartQueryExecutionResponse
s@StartQueryExecutionResponse' {} Int
a -> StartQueryExecutionResponse
s {$sel:httpStatus:StartQueryExecutionResponse' :: Int
httpStatus = Int
a} :: StartQueryExecutionResponse)

instance Prelude.NFData StartQueryExecutionResponse where
  rnf :: StartQueryExecutionResponse -> ()
rnf StartQueryExecutionResponse' {Int
Maybe Text
httpStatus :: Int
queryExecutionId :: Maybe Text
$sel:httpStatus:StartQueryExecutionResponse' :: StartQueryExecutionResponse -> Int
$sel:queryExecutionId:StartQueryExecutionResponse' :: StartQueryExecutionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
queryExecutionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus