{-# 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.LakeFormation.GetQueryStatistics
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves statistics on the planning and execution of a query.
module Amazonka.LakeFormation.GetQueryStatistics
  ( -- * Creating a Request
    GetQueryStatistics (..),
    newGetQueryStatistics,

    -- * Request Lenses
    getQueryStatistics_queryId,

    -- * Destructuring the Response
    GetQueryStatisticsResponse (..),
    newGetQueryStatisticsResponse,

    -- * Response Lenses
    getQueryStatisticsResponse_executionStatistics,
    getQueryStatisticsResponse_planningStatistics,
    getQueryStatisticsResponse_querySubmissionTime,
    getQueryStatisticsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LakeFormation.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetQueryStatistics' smart constructor.
data GetQueryStatistics = GetQueryStatistics'
  { -- | The ID of the plan query operation.
    GetQueryStatistics -> Text
queryId :: Prelude.Text
  }
  deriving (GetQueryStatistics -> GetQueryStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetQueryStatistics -> GetQueryStatistics -> Bool
$c/= :: GetQueryStatistics -> GetQueryStatistics -> Bool
== :: GetQueryStatistics -> GetQueryStatistics -> Bool
$c== :: GetQueryStatistics -> GetQueryStatistics -> Bool
Prelude.Eq, ReadPrec [GetQueryStatistics]
ReadPrec GetQueryStatistics
Int -> ReadS GetQueryStatistics
ReadS [GetQueryStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetQueryStatistics]
$creadListPrec :: ReadPrec [GetQueryStatistics]
readPrec :: ReadPrec GetQueryStatistics
$creadPrec :: ReadPrec GetQueryStatistics
readList :: ReadS [GetQueryStatistics]
$creadList :: ReadS [GetQueryStatistics]
readsPrec :: Int -> ReadS GetQueryStatistics
$creadsPrec :: Int -> ReadS GetQueryStatistics
Prelude.Read, Int -> GetQueryStatistics -> ShowS
[GetQueryStatistics] -> ShowS
GetQueryStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetQueryStatistics] -> ShowS
$cshowList :: [GetQueryStatistics] -> ShowS
show :: GetQueryStatistics -> String
$cshow :: GetQueryStatistics -> String
showsPrec :: Int -> GetQueryStatistics -> ShowS
$cshowsPrec :: Int -> GetQueryStatistics -> ShowS
Prelude.Show, forall x. Rep GetQueryStatistics x -> GetQueryStatistics
forall x. GetQueryStatistics -> Rep GetQueryStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetQueryStatistics x -> GetQueryStatistics
$cfrom :: forall x. GetQueryStatistics -> Rep GetQueryStatistics x
Prelude.Generic)

-- |
-- Create a value of 'GetQueryStatistics' 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:
--
-- 'queryId', 'getQueryStatistics_queryId' - The ID of the plan query operation.
newGetQueryStatistics ::
  -- | 'queryId'
  Prelude.Text ->
  GetQueryStatistics
newGetQueryStatistics :: Text -> GetQueryStatistics
newGetQueryStatistics Text
pQueryId_ =
  GetQueryStatistics' {$sel:queryId:GetQueryStatistics' :: Text
queryId = Text
pQueryId_}

-- | The ID of the plan query operation.
getQueryStatistics_queryId :: Lens.Lens' GetQueryStatistics Prelude.Text
getQueryStatistics_queryId :: Lens' GetQueryStatistics Text
getQueryStatistics_queryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQueryStatistics' {Text
queryId :: Text
$sel:queryId:GetQueryStatistics' :: GetQueryStatistics -> Text
queryId} -> Text
queryId) (\s :: GetQueryStatistics
s@GetQueryStatistics' {} Text
a -> GetQueryStatistics
s {$sel:queryId:GetQueryStatistics' :: Text
queryId = Text
a} :: GetQueryStatistics)

instance Core.AWSRequest GetQueryStatistics where
  type
    AWSResponse GetQueryStatistics =
      GetQueryStatisticsResponse
  request :: (Service -> Service)
-> GetQueryStatistics -> Request GetQueryStatistics
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 GetQueryStatistics
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetQueryStatistics)))
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 ExecutionStatistics
-> Maybe PlanningStatistics
-> Maybe ISO8601
-> Int
-> GetQueryStatisticsResponse
GetQueryStatisticsResponse'
            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
"ExecutionStatistics")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PlanningStatistics")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"QuerySubmissionTime")
            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 GetQueryStatistics where
  hashWithSalt :: Int -> GetQueryStatistics -> Int
hashWithSalt Int
_salt GetQueryStatistics' {Text
queryId :: Text
$sel:queryId:GetQueryStatistics' :: GetQueryStatistics -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
queryId

instance Prelude.NFData GetQueryStatistics where
  rnf :: GetQueryStatistics -> ()
rnf GetQueryStatistics' {Text
queryId :: Text
$sel:queryId:GetQueryStatistics' :: GetQueryStatistics -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
queryId

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

instance Data.ToJSON GetQueryStatistics where
  toJSON :: GetQueryStatistics -> Value
toJSON GetQueryStatistics' {Text
queryId :: Text
$sel:queryId:GetQueryStatistics' :: GetQueryStatistics -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"QueryId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
queryId)]
      )

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

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

-- | /See:/ 'newGetQueryStatisticsResponse' smart constructor.
data GetQueryStatisticsResponse = GetQueryStatisticsResponse'
  { -- | An @ExecutionStatistics@ structure containing execution statistics.
    GetQueryStatisticsResponse -> Maybe ExecutionStatistics
executionStatistics :: Prelude.Maybe ExecutionStatistics,
    -- | A @PlanningStatistics@ structure containing query planning statistics.
    GetQueryStatisticsResponse -> Maybe PlanningStatistics
planningStatistics :: Prelude.Maybe PlanningStatistics,
    -- | The time that the query was submitted.
    GetQueryStatisticsResponse -> Maybe ISO8601
querySubmissionTime :: Prelude.Maybe Data.ISO8601,
    -- | The response's http status code.
    GetQueryStatisticsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetQueryStatisticsResponse -> GetQueryStatisticsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetQueryStatisticsResponse -> GetQueryStatisticsResponse -> Bool
$c/= :: GetQueryStatisticsResponse -> GetQueryStatisticsResponse -> Bool
== :: GetQueryStatisticsResponse -> GetQueryStatisticsResponse -> Bool
$c== :: GetQueryStatisticsResponse -> GetQueryStatisticsResponse -> Bool
Prelude.Eq, ReadPrec [GetQueryStatisticsResponse]
ReadPrec GetQueryStatisticsResponse
Int -> ReadS GetQueryStatisticsResponse
ReadS [GetQueryStatisticsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetQueryStatisticsResponse]
$creadListPrec :: ReadPrec [GetQueryStatisticsResponse]
readPrec :: ReadPrec GetQueryStatisticsResponse
$creadPrec :: ReadPrec GetQueryStatisticsResponse
readList :: ReadS [GetQueryStatisticsResponse]
$creadList :: ReadS [GetQueryStatisticsResponse]
readsPrec :: Int -> ReadS GetQueryStatisticsResponse
$creadsPrec :: Int -> ReadS GetQueryStatisticsResponse
Prelude.Read, Int -> GetQueryStatisticsResponse -> ShowS
[GetQueryStatisticsResponse] -> ShowS
GetQueryStatisticsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetQueryStatisticsResponse] -> ShowS
$cshowList :: [GetQueryStatisticsResponse] -> ShowS
show :: GetQueryStatisticsResponse -> String
$cshow :: GetQueryStatisticsResponse -> String
showsPrec :: Int -> GetQueryStatisticsResponse -> ShowS
$cshowsPrec :: Int -> GetQueryStatisticsResponse -> ShowS
Prelude.Show, forall x.
Rep GetQueryStatisticsResponse x -> GetQueryStatisticsResponse
forall x.
GetQueryStatisticsResponse -> Rep GetQueryStatisticsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetQueryStatisticsResponse x -> GetQueryStatisticsResponse
$cfrom :: forall x.
GetQueryStatisticsResponse -> Rep GetQueryStatisticsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetQueryStatisticsResponse' 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:
--
-- 'executionStatistics', 'getQueryStatisticsResponse_executionStatistics' - An @ExecutionStatistics@ structure containing execution statistics.
--
-- 'planningStatistics', 'getQueryStatisticsResponse_planningStatistics' - A @PlanningStatistics@ structure containing query planning statistics.
--
-- 'querySubmissionTime', 'getQueryStatisticsResponse_querySubmissionTime' - The time that the query was submitted.
--
-- 'httpStatus', 'getQueryStatisticsResponse_httpStatus' - The response's http status code.
newGetQueryStatisticsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetQueryStatisticsResponse
newGetQueryStatisticsResponse :: Int -> GetQueryStatisticsResponse
newGetQueryStatisticsResponse Int
pHttpStatus_ =
  GetQueryStatisticsResponse'
    { $sel:executionStatistics:GetQueryStatisticsResponse' :: Maybe ExecutionStatistics
executionStatistics =
        forall a. Maybe a
Prelude.Nothing,
      $sel:planningStatistics:GetQueryStatisticsResponse' :: Maybe PlanningStatistics
planningStatistics = forall a. Maybe a
Prelude.Nothing,
      $sel:querySubmissionTime:GetQueryStatisticsResponse' :: Maybe ISO8601
querySubmissionTime = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetQueryStatisticsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An @ExecutionStatistics@ structure containing execution statistics.
getQueryStatisticsResponse_executionStatistics :: Lens.Lens' GetQueryStatisticsResponse (Prelude.Maybe ExecutionStatistics)
getQueryStatisticsResponse_executionStatistics :: Lens' GetQueryStatisticsResponse (Maybe ExecutionStatistics)
getQueryStatisticsResponse_executionStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQueryStatisticsResponse' {Maybe ExecutionStatistics
executionStatistics :: Maybe ExecutionStatistics
$sel:executionStatistics:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Maybe ExecutionStatistics
executionStatistics} -> Maybe ExecutionStatistics
executionStatistics) (\s :: GetQueryStatisticsResponse
s@GetQueryStatisticsResponse' {} Maybe ExecutionStatistics
a -> GetQueryStatisticsResponse
s {$sel:executionStatistics:GetQueryStatisticsResponse' :: Maybe ExecutionStatistics
executionStatistics = Maybe ExecutionStatistics
a} :: GetQueryStatisticsResponse)

-- | A @PlanningStatistics@ structure containing query planning statistics.
getQueryStatisticsResponse_planningStatistics :: Lens.Lens' GetQueryStatisticsResponse (Prelude.Maybe PlanningStatistics)
getQueryStatisticsResponse_planningStatistics :: Lens' GetQueryStatisticsResponse (Maybe PlanningStatistics)
getQueryStatisticsResponse_planningStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQueryStatisticsResponse' {Maybe PlanningStatistics
planningStatistics :: Maybe PlanningStatistics
$sel:planningStatistics:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Maybe PlanningStatistics
planningStatistics} -> Maybe PlanningStatistics
planningStatistics) (\s :: GetQueryStatisticsResponse
s@GetQueryStatisticsResponse' {} Maybe PlanningStatistics
a -> GetQueryStatisticsResponse
s {$sel:planningStatistics:GetQueryStatisticsResponse' :: Maybe PlanningStatistics
planningStatistics = Maybe PlanningStatistics
a} :: GetQueryStatisticsResponse)

-- | The time that the query was submitted.
getQueryStatisticsResponse_querySubmissionTime :: Lens.Lens' GetQueryStatisticsResponse (Prelude.Maybe Prelude.UTCTime)
getQueryStatisticsResponse_querySubmissionTime :: Lens' GetQueryStatisticsResponse (Maybe UTCTime)
getQueryStatisticsResponse_querySubmissionTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQueryStatisticsResponse' {Maybe ISO8601
querySubmissionTime :: Maybe ISO8601
$sel:querySubmissionTime:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Maybe ISO8601
querySubmissionTime} -> Maybe ISO8601
querySubmissionTime) (\s :: GetQueryStatisticsResponse
s@GetQueryStatisticsResponse' {} Maybe ISO8601
a -> GetQueryStatisticsResponse
s {$sel:querySubmissionTime:GetQueryStatisticsResponse' :: Maybe ISO8601
querySubmissionTime = Maybe ISO8601
a} :: GetQueryStatisticsResponse) 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 response's http status code.
getQueryStatisticsResponse_httpStatus :: Lens.Lens' GetQueryStatisticsResponse Prelude.Int
getQueryStatisticsResponse_httpStatus :: Lens' GetQueryStatisticsResponse Int
getQueryStatisticsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQueryStatisticsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetQueryStatisticsResponse
s@GetQueryStatisticsResponse' {} Int
a -> GetQueryStatisticsResponse
s {$sel:httpStatus:GetQueryStatisticsResponse' :: Int
httpStatus = Int
a} :: GetQueryStatisticsResponse)

instance Prelude.NFData GetQueryStatisticsResponse where
  rnf :: GetQueryStatisticsResponse -> ()
rnf GetQueryStatisticsResponse' {Int
Maybe ISO8601
Maybe ExecutionStatistics
Maybe PlanningStatistics
httpStatus :: Int
querySubmissionTime :: Maybe ISO8601
planningStatistics :: Maybe PlanningStatistics
executionStatistics :: Maybe ExecutionStatistics
$sel:httpStatus:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Int
$sel:querySubmissionTime:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Maybe ISO8601
$sel:planningStatistics:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Maybe PlanningStatistics
$sel:executionStatistics:GetQueryStatisticsResponse' :: GetQueryStatisticsResponse -> Maybe ExecutionStatistics
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ExecutionStatistics
executionStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PlanningStatistics
planningStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
querySubmissionTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus