{-# 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.Config.SelectAggregateResourceConfig
-- 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)
--
-- Accepts a structured query language (SQL) SELECT command and an
-- aggregator to query configuration state of Amazon Web Services resources
-- across multiple accounts and regions, performs the corresponding search,
-- and returns resource configurations matching the properties.
--
-- For more information about query components, see the
-- <https://docs.aws.amazon.com/config/latest/developerguide/query-components.html Query Components>
-- section in the Config Developer Guide.
--
-- If you run an aggregation query (i.e., using @GROUP BY@ or using
-- aggregate functions such as @COUNT@; e.g.,
-- @SELECT resourceId, COUNT(*) WHERE resourceType = \'AWS::IAM::Role\' GROUP BY resourceId@)
-- and do not specify the @MaxResults@ or the @Limit@ query parameters, the
-- default page size is set to 500.
--
-- If you run a non-aggregation query (i.e., not using @GROUP BY@ or
-- aggregate function; e.g.,
-- @SELECT * WHERE resourceType = \'AWS::IAM::Role\'@) and do not specify
-- the @MaxResults@ or the @Limit@ query parameters, the default page size
-- is set to 25.
--
-- This operation returns paginated results.
module Amazonka.Config.SelectAggregateResourceConfig
  ( -- * Creating a Request
    SelectAggregateResourceConfig (..),
    newSelectAggregateResourceConfig,

    -- * Request Lenses
    selectAggregateResourceConfig_nextToken,
    selectAggregateResourceConfig_limit,
    selectAggregateResourceConfig_maxResults,
    selectAggregateResourceConfig_expression,
    selectAggregateResourceConfig_configurationAggregatorName,

    -- * Destructuring the Response
    SelectAggregateResourceConfigResponse (..),
    newSelectAggregateResourceConfigResponse,

    -- * Response Lenses
    selectAggregateResourceConfigResponse_results,
    selectAggregateResourceConfigResponse_queryInfo,
    selectAggregateResourceConfigResponse_nextToken,
    selectAggregateResourceConfigResponse_httpStatus,
  )
where

import Amazonka.Config.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSelectAggregateResourceConfig' smart constructor.
data SelectAggregateResourceConfig = SelectAggregateResourceConfig'
  { -- | The nextToken string returned in a previous request that you use to
    -- request the next page of results in a paginated response.
    SelectAggregateResourceConfig -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of query results returned on each page.
    SelectAggregateResourceConfig -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of query results returned on each page. Config also
    -- allows the Limit request parameter.
    SelectAggregateResourceConfig -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The SQL query SELECT command.
    SelectAggregateResourceConfig -> Text
expression :: Prelude.Text,
    -- | The name of the configuration aggregator.
    SelectAggregateResourceConfig -> Text
configurationAggregatorName :: Prelude.Text
  }
  deriving (SelectAggregateResourceConfig
-> SelectAggregateResourceConfig -> Bool
(SelectAggregateResourceConfig
 -> SelectAggregateResourceConfig -> Bool)
-> (SelectAggregateResourceConfig
    -> SelectAggregateResourceConfig -> Bool)
-> Eq SelectAggregateResourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectAggregateResourceConfig
-> SelectAggregateResourceConfig -> Bool
$c/= :: SelectAggregateResourceConfig
-> SelectAggregateResourceConfig -> Bool
== :: SelectAggregateResourceConfig
-> SelectAggregateResourceConfig -> Bool
$c== :: SelectAggregateResourceConfig
-> SelectAggregateResourceConfig -> Bool
Prelude.Eq, ReadPrec [SelectAggregateResourceConfig]
ReadPrec SelectAggregateResourceConfig
Int -> ReadS SelectAggregateResourceConfig
ReadS [SelectAggregateResourceConfig]
(Int -> ReadS SelectAggregateResourceConfig)
-> ReadS [SelectAggregateResourceConfig]
-> ReadPrec SelectAggregateResourceConfig
-> ReadPrec [SelectAggregateResourceConfig]
-> Read SelectAggregateResourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelectAggregateResourceConfig]
$creadListPrec :: ReadPrec [SelectAggregateResourceConfig]
readPrec :: ReadPrec SelectAggregateResourceConfig
$creadPrec :: ReadPrec SelectAggregateResourceConfig
readList :: ReadS [SelectAggregateResourceConfig]
$creadList :: ReadS [SelectAggregateResourceConfig]
readsPrec :: Int -> ReadS SelectAggregateResourceConfig
$creadsPrec :: Int -> ReadS SelectAggregateResourceConfig
Prelude.Read, Int -> SelectAggregateResourceConfig -> ShowS
[SelectAggregateResourceConfig] -> ShowS
SelectAggregateResourceConfig -> String
(Int -> SelectAggregateResourceConfig -> ShowS)
-> (SelectAggregateResourceConfig -> String)
-> ([SelectAggregateResourceConfig] -> ShowS)
-> Show SelectAggregateResourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectAggregateResourceConfig] -> ShowS
$cshowList :: [SelectAggregateResourceConfig] -> ShowS
show :: SelectAggregateResourceConfig -> String
$cshow :: SelectAggregateResourceConfig -> String
showsPrec :: Int -> SelectAggregateResourceConfig -> ShowS
$cshowsPrec :: Int -> SelectAggregateResourceConfig -> ShowS
Prelude.Show, (forall x.
 SelectAggregateResourceConfig
 -> Rep SelectAggregateResourceConfig x)
-> (forall x.
    Rep SelectAggregateResourceConfig x
    -> SelectAggregateResourceConfig)
-> Generic SelectAggregateResourceConfig
forall x.
Rep SelectAggregateResourceConfig x
-> SelectAggregateResourceConfig
forall x.
SelectAggregateResourceConfig
-> Rep SelectAggregateResourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SelectAggregateResourceConfig x
-> SelectAggregateResourceConfig
$cfrom :: forall x.
SelectAggregateResourceConfig
-> Rep SelectAggregateResourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'SelectAggregateResourceConfig' 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:
--
-- 'nextToken', 'selectAggregateResourceConfig_nextToken' - The nextToken string returned in a previous request that you use to
-- request the next page of results in a paginated response.
--
-- 'limit', 'selectAggregateResourceConfig_limit' - The maximum number of query results returned on each page.
--
-- 'maxResults', 'selectAggregateResourceConfig_maxResults' - The maximum number of query results returned on each page. Config also
-- allows the Limit request parameter.
--
-- 'expression', 'selectAggregateResourceConfig_expression' - The SQL query SELECT command.
--
-- 'configurationAggregatorName', 'selectAggregateResourceConfig_configurationAggregatorName' - The name of the configuration aggregator.
newSelectAggregateResourceConfig ::
  -- | 'expression'
  Prelude.Text ->
  -- | 'configurationAggregatorName'
  Prelude.Text ->
  SelectAggregateResourceConfig
newSelectAggregateResourceConfig :: Text -> Text -> SelectAggregateResourceConfig
newSelectAggregateResourceConfig
  Text
pExpression_
  Text
pConfigurationAggregatorName_ =
    SelectAggregateResourceConfig' :: Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Text
-> Text
-> SelectAggregateResourceConfig
SelectAggregateResourceConfig'
      { $sel:nextToken:SelectAggregateResourceConfig' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:limit:SelectAggregateResourceConfig' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:SelectAggregateResourceConfig' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:expression:SelectAggregateResourceConfig' :: Text
expression = Text
pExpression_,
        $sel:configurationAggregatorName:SelectAggregateResourceConfig' :: Text
configurationAggregatorName =
          Text
pConfigurationAggregatorName_
      }

-- | The nextToken string returned in a previous request that you use to
-- request the next page of results in a paginated response.
selectAggregateResourceConfig_nextToken :: Lens.Lens' SelectAggregateResourceConfig (Prelude.Maybe Prelude.Text)
selectAggregateResourceConfig_nextToken :: (Maybe Text -> f (Maybe Text))
-> SelectAggregateResourceConfig -> f SelectAggregateResourceConfig
selectAggregateResourceConfig_nextToken = (SelectAggregateResourceConfig -> Maybe Text)
-> (SelectAggregateResourceConfig
    -> Maybe Text -> SelectAggregateResourceConfig)
-> Lens
     SelectAggregateResourceConfig
     SelectAggregateResourceConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfig' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SelectAggregateResourceConfig
s@SelectAggregateResourceConfig' {} Maybe Text
a -> SelectAggregateResourceConfig
s {$sel:nextToken:SelectAggregateResourceConfig' :: Maybe Text
nextToken = Maybe Text
a} :: SelectAggregateResourceConfig)

-- | The maximum number of query results returned on each page.
selectAggregateResourceConfig_limit :: Lens.Lens' SelectAggregateResourceConfig (Prelude.Maybe Prelude.Natural)
selectAggregateResourceConfig_limit :: (Maybe Natural -> f (Maybe Natural))
-> SelectAggregateResourceConfig -> f SelectAggregateResourceConfig
selectAggregateResourceConfig_limit = (SelectAggregateResourceConfig -> Maybe Natural)
-> (SelectAggregateResourceConfig
    -> Maybe Natural -> SelectAggregateResourceConfig)
-> Lens
     SelectAggregateResourceConfig
     SelectAggregateResourceConfig
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfig' {Maybe Natural
limit :: Maybe Natural
$sel:limit:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: SelectAggregateResourceConfig
s@SelectAggregateResourceConfig' {} Maybe Natural
a -> SelectAggregateResourceConfig
s {$sel:limit:SelectAggregateResourceConfig' :: Maybe Natural
limit = Maybe Natural
a} :: SelectAggregateResourceConfig)

-- | The maximum number of query results returned on each page. Config also
-- allows the Limit request parameter.
selectAggregateResourceConfig_maxResults :: Lens.Lens' SelectAggregateResourceConfig (Prelude.Maybe Prelude.Natural)
selectAggregateResourceConfig_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> SelectAggregateResourceConfig -> f SelectAggregateResourceConfig
selectAggregateResourceConfig_maxResults = (SelectAggregateResourceConfig -> Maybe Natural)
-> (SelectAggregateResourceConfig
    -> Maybe Natural -> SelectAggregateResourceConfig)
-> Lens
     SelectAggregateResourceConfig
     SelectAggregateResourceConfig
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfig' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SelectAggregateResourceConfig
s@SelectAggregateResourceConfig' {} Maybe Natural
a -> SelectAggregateResourceConfig
s {$sel:maxResults:SelectAggregateResourceConfig' :: Maybe Natural
maxResults = Maybe Natural
a} :: SelectAggregateResourceConfig)

-- | The SQL query SELECT command.
selectAggregateResourceConfig_expression :: Lens.Lens' SelectAggregateResourceConfig Prelude.Text
selectAggregateResourceConfig_expression :: (Text -> f Text)
-> SelectAggregateResourceConfig -> f SelectAggregateResourceConfig
selectAggregateResourceConfig_expression = (SelectAggregateResourceConfig -> Text)
-> (SelectAggregateResourceConfig
    -> Text -> SelectAggregateResourceConfig)
-> Lens
     SelectAggregateResourceConfig
     SelectAggregateResourceConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfig' {Text
expression :: Text
$sel:expression:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Text
expression} -> Text
expression) (\s :: SelectAggregateResourceConfig
s@SelectAggregateResourceConfig' {} Text
a -> SelectAggregateResourceConfig
s {$sel:expression:SelectAggregateResourceConfig' :: Text
expression = Text
a} :: SelectAggregateResourceConfig)

-- | The name of the configuration aggregator.
selectAggregateResourceConfig_configurationAggregatorName :: Lens.Lens' SelectAggregateResourceConfig Prelude.Text
selectAggregateResourceConfig_configurationAggregatorName :: (Text -> f Text)
-> SelectAggregateResourceConfig -> f SelectAggregateResourceConfig
selectAggregateResourceConfig_configurationAggregatorName = (SelectAggregateResourceConfig -> Text)
-> (SelectAggregateResourceConfig
    -> Text -> SelectAggregateResourceConfig)
-> Lens
     SelectAggregateResourceConfig
     SelectAggregateResourceConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfig' {Text
configurationAggregatorName :: Text
$sel:configurationAggregatorName:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Text
configurationAggregatorName} -> Text
configurationAggregatorName) (\s :: SelectAggregateResourceConfig
s@SelectAggregateResourceConfig' {} Text
a -> SelectAggregateResourceConfig
s {$sel:configurationAggregatorName:SelectAggregateResourceConfig' :: Text
configurationAggregatorName = Text
a} :: SelectAggregateResourceConfig)

instance Core.AWSPager SelectAggregateResourceConfig where
  page :: SelectAggregateResourceConfig
-> AWSResponse SelectAggregateResourceConfig
-> Maybe SelectAggregateResourceConfig
page SelectAggregateResourceConfig
rq AWSResponse SelectAggregateResourceConfig
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse SelectAggregateResourceConfig
SelectAggregateResourceConfigResponse
rs
            SelectAggregateResourceConfigResponse
-> Getting (First Text) SelectAggregateResourceConfigResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> SelectAggregateResourceConfigResponse
-> Const (First Text) SelectAggregateResourceConfigResponse
Lens' SelectAggregateResourceConfigResponse (Maybe Text)
selectAggregateResourceConfigResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> SelectAggregateResourceConfigResponse
 -> Const (First Text) SelectAggregateResourceConfigResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) SelectAggregateResourceConfigResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe SelectAggregateResourceConfig
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse SelectAggregateResourceConfig
SelectAggregateResourceConfigResponse
rs
            SelectAggregateResourceConfigResponse
-> Getting
     (First [Text]) SelectAggregateResourceConfigResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> SelectAggregateResourceConfigResponse
-> Const (First [Text]) SelectAggregateResourceConfigResponse
Lens' SelectAggregateResourceConfigResponse (Maybe [Text])
selectAggregateResourceConfigResponse_results
              ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> SelectAggregateResourceConfigResponse
 -> Const (First [Text]) SelectAggregateResourceConfigResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting
     (First [Text]) SelectAggregateResourceConfigResponse [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> Const (First [Text]) [Text])
-> Maybe [Text] -> Const (First [Text]) (Maybe [Text])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe SelectAggregateResourceConfig
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      SelectAggregateResourceConfig
-> Maybe SelectAggregateResourceConfig
forall a. a -> Maybe a
Prelude.Just (SelectAggregateResourceConfig
 -> Maybe SelectAggregateResourceConfig)
-> SelectAggregateResourceConfig
-> Maybe SelectAggregateResourceConfig
forall a b. (a -> b) -> a -> b
Prelude.$
        SelectAggregateResourceConfig
rq
          SelectAggregateResourceConfig
-> (SelectAggregateResourceConfig -> SelectAggregateResourceConfig)
-> SelectAggregateResourceConfig
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> SelectAggregateResourceConfig
-> Identity SelectAggregateResourceConfig
Lens
  SelectAggregateResourceConfig
  SelectAggregateResourceConfig
  (Maybe Text)
  (Maybe Text)
selectAggregateResourceConfig_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> SelectAggregateResourceConfig
 -> Identity SelectAggregateResourceConfig)
-> Maybe Text
-> SelectAggregateResourceConfig
-> SelectAggregateResourceConfig
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse SelectAggregateResourceConfig
SelectAggregateResourceConfigResponse
rs
          SelectAggregateResourceConfigResponse
-> Getting (First Text) SelectAggregateResourceConfigResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> SelectAggregateResourceConfigResponse
-> Const (First Text) SelectAggregateResourceConfigResponse
Lens' SelectAggregateResourceConfigResponse (Maybe Text)
selectAggregateResourceConfigResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> SelectAggregateResourceConfigResponse
 -> Const (First Text) SelectAggregateResourceConfigResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) SelectAggregateResourceConfigResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance
  Core.AWSRequest
    SelectAggregateResourceConfig
  where
  type
    AWSResponse SelectAggregateResourceConfig =
      SelectAggregateResourceConfigResponse
  request :: SelectAggregateResourceConfig
-> Request SelectAggregateResourceConfig
request = Service
-> SelectAggregateResourceConfig
-> Request SelectAggregateResourceConfig
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SelectAggregateResourceConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SelectAggregateResourceConfig)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse SelectAggregateResourceConfig))
-> Logger
-> Service
-> Proxy SelectAggregateResourceConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SelectAggregateResourceConfig)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Text]
-> Maybe QueryInfo
-> Maybe Text
-> Int
-> SelectAggregateResourceConfigResponse
SelectAggregateResourceConfigResponse'
            (Maybe [Text]
 -> Maybe QueryInfo
 -> Maybe Text
 -> Int
 -> SelectAggregateResourceConfigResponse)
-> Either String (Maybe [Text])
-> Either
     String
     (Maybe QueryInfo
      -> Maybe Text -> Int -> SelectAggregateResourceConfigResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Results" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe QueryInfo
   -> Maybe Text -> Int -> SelectAggregateResourceConfigResponse)
-> Either String (Maybe QueryInfo)
-> Either
     String (Maybe Text -> Int -> SelectAggregateResourceConfigResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe QueryInfo)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"QueryInfo")
            Either
  String (Maybe Text -> Int -> SelectAggregateResourceConfigResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SelectAggregateResourceConfigResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> SelectAggregateResourceConfigResponse)
-> Either String Int
-> Either String SelectAggregateResourceConfigResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    SelectAggregateResourceConfig

instance Prelude.NFData SelectAggregateResourceConfig

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

instance Core.ToJSON SelectAggregateResourceConfig where
  toJSON :: SelectAggregateResourceConfig -> Value
toJSON SelectAggregateResourceConfig' {Maybe Natural
Maybe Text
Text
configurationAggregatorName :: Text
expression :: Text
maxResults :: Maybe Natural
limit :: Maybe Natural
nextToken :: Maybe Text
$sel:configurationAggregatorName:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Text
$sel:expression:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Text
$sel:maxResults:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Maybe Natural
$sel:limit:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Maybe Natural
$sel:nextToken:SelectAggregateResourceConfig' :: SelectAggregateResourceConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Expression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
expression),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ConfigurationAggregatorName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
configurationAggregatorName
              )
          ]
      )

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

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

-- | /See:/ 'newSelectAggregateResourceConfigResponse' smart constructor.
data SelectAggregateResourceConfigResponse = SelectAggregateResourceConfigResponse'
  { -- | Returns the results for the SQL query.
    SelectAggregateResourceConfigResponse -> Maybe [Text]
results :: Prelude.Maybe [Prelude.Text],
    SelectAggregateResourceConfigResponse -> Maybe QueryInfo
queryInfo :: Prelude.Maybe QueryInfo,
    -- | The nextToken string returned in a previous request that you use to
    -- request the next page of results in a paginated response.
    SelectAggregateResourceConfigResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SelectAggregateResourceConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SelectAggregateResourceConfigResponse
-> SelectAggregateResourceConfigResponse -> Bool
(SelectAggregateResourceConfigResponse
 -> SelectAggregateResourceConfigResponse -> Bool)
-> (SelectAggregateResourceConfigResponse
    -> SelectAggregateResourceConfigResponse -> Bool)
-> Eq SelectAggregateResourceConfigResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectAggregateResourceConfigResponse
-> SelectAggregateResourceConfigResponse -> Bool
$c/= :: SelectAggregateResourceConfigResponse
-> SelectAggregateResourceConfigResponse -> Bool
== :: SelectAggregateResourceConfigResponse
-> SelectAggregateResourceConfigResponse -> Bool
$c== :: SelectAggregateResourceConfigResponse
-> SelectAggregateResourceConfigResponse -> Bool
Prelude.Eq, ReadPrec [SelectAggregateResourceConfigResponse]
ReadPrec SelectAggregateResourceConfigResponse
Int -> ReadS SelectAggregateResourceConfigResponse
ReadS [SelectAggregateResourceConfigResponse]
(Int -> ReadS SelectAggregateResourceConfigResponse)
-> ReadS [SelectAggregateResourceConfigResponse]
-> ReadPrec SelectAggregateResourceConfigResponse
-> ReadPrec [SelectAggregateResourceConfigResponse]
-> Read SelectAggregateResourceConfigResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelectAggregateResourceConfigResponse]
$creadListPrec :: ReadPrec [SelectAggregateResourceConfigResponse]
readPrec :: ReadPrec SelectAggregateResourceConfigResponse
$creadPrec :: ReadPrec SelectAggregateResourceConfigResponse
readList :: ReadS [SelectAggregateResourceConfigResponse]
$creadList :: ReadS [SelectAggregateResourceConfigResponse]
readsPrec :: Int -> ReadS SelectAggregateResourceConfigResponse
$creadsPrec :: Int -> ReadS SelectAggregateResourceConfigResponse
Prelude.Read, Int -> SelectAggregateResourceConfigResponse -> ShowS
[SelectAggregateResourceConfigResponse] -> ShowS
SelectAggregateResourceConfigResponse -> String
(Int -> SelectAggregateResourceConfigResponse -> ShowS)
-> (SelectAggregateResourceConfigResponse -> String)
-> ([SelectAggregateResourceConfigResponse] -> ShowS)
-> Show SelectAggregateResourceConfigResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectAggregateResourceConfigResponse] -> ShowS
$cshowList :: [SelectAggregateResourceConfigResponse] -> ShowS
show :: SelectAggregateResourceConfigResponse -> String
$cshow :: SelectAggregateResourceConfigResponse -> String
showsPrec :: Int -> SelectAggregateResourceConfigResponse -> ShowS
$cshowsPrec :: Int -> SelectAggregateResourceConfigResponse -> ShowS
Prelude.Show, (forall x.
 SelectAggregateResourceConfigResponse
 -> Rep SelectAggregateResourceConfigResponse x)
-> (forall x.
    Rep SelectAggregateResourceConfigResponse x
    -> SelectAggregateResourceConfigResponse)
-> Generic SelectAggregateResourceConfigResponse
forall x.
Rep SelectAggregateResourceConfigResponse x
-> SelectAggregateResourceConfigResponse
forall x.
SelectAggregateResourceConfigResponse
-> Rep SelectAggregateResourceConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SelectAggregateResourceConfigResponse x
-> SelectAggregateResourceConfigResponse
$cfrom :: forall x.
SelectAggregateResourceConfigResponse
-> Rep SelectAggregateResourceConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'SelectAggregateResourceConfigResponse' 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:
--
-- 'results', 'selectAggregateResourceConfigResponse_results' - Returns the results for the SQL query.
--
-- 'queryInfo', 'selectAggregateResourceConfigResponse_queryInfo' - Undocumented member.
--
-- 'nextToken', 'selectAggregateResourceConfigResponse_nextToken' - The nextToken string returned in a previous request that you use to
-- request the next page of results in a paginated response.
--
-- 'httpStatus', 'selectAggregateResourceConfigResponse_httpStatus' - The response's http status code.
newSelectAggregateResourceConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SelectAggregateResourceConfigResponse
newSelectAggregateResourceConfigResponse :: Int -> SelectAggregateResourceConfigResponse
newSelectAggregateResourceConfigResponse Int
pHttpStatus_ =
  SelectAggregateResourceConfigResponse' :: Maybe [Text]
-> Maybe QueryInfo
-> Maybe Text
-> Int
-> SelectAggregateResourceConfigResponse
SelectAggregateResourceConfigResponse'
    { $sel:results:SelectAggregateResourceConfigResponse' :: Maybe [Text]
results =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:queryInfo:SelectAggregateResourceConfigResponse' :: Maybe QueryInfo
queryInfo = Maybe QueryInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SelectAggregateResourceConfigResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SelectAggregateResourceConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns the results for the SQL query.
selectAggregateResourceConfigResponse_results :: Lens.Lens' SelectAggregateResourceConfigResponse (Prelude.Maybe [Prelude.Text])
selectAggregateResourceConfigResponse_results :: (Maybe [Text] -> f (Maybe [Text]))
-> SelectAggregateResourceConfigResponse
-> f SelectAggregateResourceConfigResponse
selectAggregateResourceConfigResponse_results = (SelectAggregateResourceConfigResponse -> Maybe [Text])
-> (SelectAggregateResourceConfigResponse
    -> Maybe [Text] -> SelectAggregateResourceConfigResponse)
-> Lens' SelectAggregateResourceConfigResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfigResponse' {Maybe [Text]
results :: Maybe [Text]
$sel:results:SelectAggregateResourceConfigResponse' :: SelectAggregateResourceConfigResponse -> Maybe [Text]
results} -> Maybe [Text]
results) (\s :: SelectAggregateResourceConfigResponse
s@SelectAggregateResourceConfigResponse' {} Maybe [Text]
a -> SelectAggregateResourceConfigResponse
s {$sel:results:SelectAggregateResourceConfigResponse' :: Maybe [Text]
results = Maybe [Text]
a} :: SelectAggregateResourceConfigResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> SelectAggregateResourceConfigResponse
 -> f SelectAggregateResourceConfigResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SelectAggregateResourceConfigResponse
-> f SelectAggregateResourceConfigResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
selectAggregateResourceConfigResponse_queryInfo :: Lens.Lens' SelectAggregateResourceConfigResponse (Prelude.Maybe QueryInfo)
selectAggregateResourceConfigResponse_queryInfo :: (Maybe QueryInfo -> f (Maybe QueryInfo))
-> SelectAggregateResourceConfigResponse
-> f SelectAggregateResourceConfigResponse
selectAggregateResourceConfigResponse_queryInfo = (SelectAggregateResourceConfigResponse -> Maybe QueryInfo)
-> (SelectAggregateResourceConfigResponse
    -> Maybe QueryInfo -> SelectAggregateResourceConfigResponse)
-> Lens
     SelectAggregateResourceConfigResponse
     SelectAggregateResourceConfigResponse
     (Maybe QueryInfo)
     (Maybe QueryInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfigResponse' {Maybe QueryInfo
queryInfo :: Maybe QueryInfo
$sel:queryInfo:SelectAggregateResourceConfigResponse' :: SelectAggregateResourceConfigResponse -> Maybe QueryInfo
queryInfo} -> Maybe QueryInfo
queryInfo) (\s :: SelectAggregateResourceConfigResponse
s@SelectAggregateResourceConfigResponse' {} Maybe QueryInfo
a -> SelectAggregateResourceConfigResponse
s {$sel:queryInfo:SelectAggregateResourceConfigResponse' :: Maybe QueryInfo
queryInfo = Maybe QueryInfo
a} :: SelectAggregateResourceConfigResponse)

-- | The nextToken string returned in a previous request that you use to
-- request the next page of results in a paginated response.
selectAggregateResourceConfigResponse_nextToken :: Lens.Lens' SelectAggregateResourceConfigResponse (Prelude.Maybe Prelude.Text)
selectAggregateResourceConfigResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SelectAggregateResourceConfigResponse
-> f SelectAggregateResourceConfigResponse
selectAggregateResourceConfigResponse_nextToken = (SelectAggregateResourceConfigResponse -> Maybe Text)
-> (SelectAggregateResourceConfigResponse
    -> Maybe Text -> SelectAggregateResourceConfigResponse)
-> Lens' SelectAggregateResourceConfigResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAggregateResourceConfigResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SelectAggregateResourceConfigResponse' :: SelectAggregateResourceConfigResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SelectAggregateResourceConfigResponse
s@SelectAggregateResourceConfigResponse' {} Maybe Text
a -> SelectAggregateResourceConfigResponse
s {$sel:nextToken:SelectAggregateResourceConfigResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SelectAggregateResourceConfigResponse)

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

instance
  Prelude.NFData
    SelectAggregateResourceConfigResponse