{-# 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.Glacier.Types.SelectParameters
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glacier.Types.SelectParameters where

import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types.ExpressionType
import Amazonka.Glacier.Types.InputSerialization
import Amazonka.Glacier.Types.OutputSerialization
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the parameters used for a select.
--
-- /See:/ 'newSelectParameters' smart constructor.
data SelectParameters = SelectParameters'
  { -- | The type of the provided expression, for example @SQL@.
    SelectParameters -> Maybe ExpressionType
expressionType :: Prelude.Maybe ExpressionType,
    -- | Describes how the results of the select job are serialized.
    SelectParameters -> Maybe OutputSerialization
outputSerialization :: Prelude.Maybe OutputSerialization,
    -- | The expression that is used to select the object.
    SelectParameters -> Maybe Text
expression :: Prelude.Maybe Prelude.Text,
    -- | Describes the serialization format of the object.
    SelectParameters -> Maybe InputSerialization
inputSerialization :: Prelude.Maybe InputSerialization
  }
  deriving (SelectParameters -> SelectParameters -> Bool
(SelectParameters -> SelectParameters -> Bool)
-> (SelectParameters -> SelectParameters -> Bool)
-> Eq SelectParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectParameters -> SelectParameters -> Bool
$c/= :: SelectParameters -> SelectParameters -> Bool
== :: SelectParameters -> SelectParameters -> Bool
$c== :: SelectParameters -> SelectParameters -> Bool
Prelude.Eq, ReadPrec [SelectParameters]
ReadPrec SelectParameters
Int -> ReadS SelectParameters
ReadS [SelectParameters]
(Int -> ReadS SelectParameters)
-> ReadS [SelectParameters]
-> ReadPrec SelectParameters
-> ReadPrec [SelectParameters]
-> Read SelectParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelectParameters]
$creadListPrec :: ReadPrec [SelectParameters]
readPrec :: ReadPrec SelectParameters
$creadPrec :: ReadPrec SelectParameters
readList :: ReadS [SelectParameters]
$creadList :: ReadS [SelectParameters]
readsPrec :: Int -> ReadS SelectParameters
$creadsPrec :: Int -> ReadS SelectParameters
Prelude.Read, Int -> SelectParameters -> ShowS
[SelectParameters] -> ShowS
SelectParameters -> String
(Int -> SelectParameters -> ShowS)
-> (SelectParameters -> String)
-> ([SelectParameters] -> ShowS)
-> Show SelectParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectParameters] -> ShowS
$cshowList :: [SelectParameters] -> ShowS
show :: SelectParameters -> String
$cshow :: SelectParameters -> String
showsPrec :: Int -> SelectParameters -> ShowS
$cshowsPrec :: Int -> SelectParameters -> ShowS
Prelude.Show, (forall x. SelectParameters -> Rep SelectParameters x)
-> (forall x. Rep SelectParameters x -> SelectParameters)
-> Generic SelectParameters
forall x. Rep SelectParameters x -> SelectParameters
forall x. SelectParameters -> Rep SelectParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SelectParameters x -> SelectParameters
$cfrom :: forall x. SelectParameters -> Rep SelectParameters x
Prelude.Generic)

-- |
-- Create a value of 'SelectParameters' 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:
--
-- 'expressionType', 'selectParameters_expressionType' - The type of the provided expression, for example @SQL@.
--
-- 'outputSerialization', 'selectParameters_outputSerialization' - Describes how the results of the select job are serialized.
--
-- 'expression', 'selectParameters_expression' - The expression that is used to select the object.
--
-- 'inputSerialization', 'selectParameters_inputSerialization' - Describes the serialization format of the object.
newSelectParameters ::
  SelectParameters
newSelectParameters :: SelectParameters
newSelectParameters =
  SelectParameters' :: Maybe ExpressionType
-> Maybe OutputSerialization
-> Maybe Text
-> Maybe InputSerialization
-> SelectParameters
SelectParameters'
    { $sel:expressionType:SelectParameters' :: Maybe ExpressionType
expressionType = Maybe ExpressionType
forall a. Maybe a
Prelude.Nothing,
      $sel:outputSerialization:SelectParameters' :: Maybe OutputSerialization
outputSerialization = Maybe OutputSerialization
forall a. Maybe a
Prelude.Nothing,
      $sel:expression:SelectParameters' :: Maybe Text
expression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inputSerialization:SelectParameters' :: Maybe InputSerialization
inputSerialization = Maybe InputSerialization
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the provided expression, for example @SQL@.
selectParameters_expressionType :: Lens.Lens' SelectParameters (Prelude.Maybe ExpressionType)
selectParameters_expressionType :: (Maybe ExpressionType -> f (Maybe ExpressionType))
-> SelectParameters -> f SelectParameters
selectParameters_expressionType = (SelectParameters -> Maybe ExpressionType)
-> (SelectParameters -> Maybe ExpressionType -> SelectParameters)
-> Lens
     SelectParameters
     SelectParameters
     (Maybe ExpressionType)
     (Maybe ExpressionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectParameters' {Maybe ExpressionType
expressionType :: Maybe ExpressionType
$sel:expressionType:SelectParameters' :: SelectParameters -> Maybe ExpressionType
expressionType} -> Maybe ExpressionType
expressionType) (\s :: SelectParameters
s@SelectParameters' {} Maybe ExpressionType
a -> SelectParameters
s {$sel:expressionType:SelectParameters' :: Maybe ExpressionType
expressionType = Maybe ExpressionType
a} :: SelectParameters)

-- | Describes how the results of the select job are serialized.
selectParameters_outputSerialization :: Lens.Lens' SelectParameters (Prelude.Maybe OutputSerialization)
selectParameters_outputSerialization :: (Maybe OutputSerialization -> f (Maybe OutputSerialization))
-> SelectParameters -> f SelectParameters
selectParameters_outputSerialization = (SelectParameters -> Maybe OutputSerialization)
-> (SelectParameters
    -> Maybe OutputSerialization -> SelectParameters)
-> Lens
     SelectParameters
     SelectParameters
     (Maybe OutputSerialization)
     (Maybe OutputSerialization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectParameters' {Maybe OutputSerialization
outputSerialization :: Maybe OutputSerialization
$sel:outputSerialization:SelectParameters' :: SelectParameters -> Maybe OutputSerialization
outputSerialization} -> Maybe OutputSerialization
outputSerialization) (\s :: SelectParameters
s@SelectParameters' {} Maybe OutputSerialization
a -> SelectParameters
s {$sel:outputSerialization:SelectParameters' :: Maybe OutputSerialization
outputSerialization = Maybe OutputSerialization
a} :: SelectParameters)

-- | The expression that is used to select the object.
selectParameters_expression :: Lens.Lens' SelectParameters (Prelude.Maybe Prelude.Text)
selectParameters_expression :: (Maybe Text -> f (Maybe Text))
-> SelectParameters -> f SelectParameters
selectParameters_expression = (SelectParameters -> Maybe Text)
-> (SelectParameters -> Maybe Text -> SelectParameters)
-> Lens SelectParameters SelectParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectParameters' {Maybe Text
expression :: Maybe Text
$sel:expression:SelectParameters' :: SelectParameters -> Maybe Text
expression} -> Maybe Text
expression) (\s :: SelectParameters
s@SelectParameters' {} Maybe Text
a -> SelectParameters
s {$sel:expression:SelectParameters' :: Maybe Text
expression = Maybe Text
a} :: SelectParameters)

-- | Describes the serialization format of the object.
selectParameters_inputSerialization :: Lens.Lens' SelectParameters (Prelude.Maybe InputSerialization)
selectParameters_inputSerialization :: (Maybe InputSerialization -> f (Maybe InputSerialization))
-> SelectParameters -> f SelectParameters
selectParameters_inputSerialization = (SelectParameters -> Maybe InputSerialization)
-> (SelectParameters
    -> Maybe InputSerialization -> SelectParameters)
-> Lens
     SelectParameters
     SelectParameters
     (Maybe InputSerialization)
     (Maybe InputSerialization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectParameters' {Maybe InputSerialization
inputSerialization :: Maybe InputSerialization
$sel:inputSerialization:SelectParameters' :: SelectParameters -> Maybe InputSerialization
inputSerialization} -> Maybe InputSerialization
inputSerialization) (\s :: SelectParameters
s@SelectParameters' {} Maybe InputSerialization
a -> SelectParameters
s {$sel:inputSerialization:SelectParameters' :: Maybe InputSerialization
inputSerialization = Maybe InputSerialization
a} :: SelectParameters)

instance Core.FromJSON SelectParameters where
  parseJSON :: Value -> Parser SelectParameters
parseJSON =
    String
-> (Object -> Parser SelectParameters)
-> Value
-> Parser SelectParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SelectParameters"
      ( \Object
x ->
          Maybe ExpressionType
-> Maybe OutputSerialization
-> Maybe Text
-> Maybe InputSerialization
-> SelectParameters
SelectParameters'
            (Maybe ExpressionType
 -> Maybe OutputSerialization
 -> Maybe Text
 -> Maybe InputSerialization
 -> SelectParameters)
-> Parser (Maybe ExpressionType)
-> Parser
     (Maybe OutputSerialization
      -> Maybe Text -> Maybe InputSerialization -> SelectParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ExpressionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExpressionType")
            Parser
  (Maybe OutputSerialization
   -> Maybe Text -> Maybe InputSerialization -> SelectParameters)
-> Parser (Maybe OutputSerialization)
-> Parser
     (Maybe Text -> Maybe InputSerialization -> SelectParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OutputSerialization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OutputSerialization")
            Parser (Maybe Text -> Maybe InputSerialization -> SelectParameters)
-> Parser (Maybe Text)
-> Parser (Maybe InputSerialization -> SelectParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Expression")
            Parser (Maybe InputSerialization -> SelectParameters)
-> Parser (Maybe InputSerialization) -> Parser SelectParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputSerialization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InputSerialization")
      )

instance Prelude.Hashable SelectParameters

instance Prelude.NFData SelectParameters

instance Core.ToJSON SelectParameters where
  toJSON :: SelectParameters -> Value
toJSON SelectParameters' {Maybe Text
Maybe ExpressionType
Maybe InputSerialization
Maybe OutputSerialization
inputSerialization :: Maybe InputSerialization
expression :: Maybe Text
outputSerialization :: Maybe OutputSerialization
expressionType :: Maybe ExpressionType
$sel:inputSerialization:SelectParameters' :: SelectParameters -> Maybe InputSerialization
$sel:expression:SelectParameters' :: SelectParameters -> Maybe Text
$sel:outputSerialization:SelectParameters' :: SelectParameters -> Maybe OutputSerialization
$sel:expressionType:SelectParameters' :: SelectParameters -> Maybe ExpressionType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ExpressionType" Text -> ExpressionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ExpressionType -> Pair) -> Maybe ExpressionType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExpressionType
expressionType,
            (Text
"OutputSerialization" Text -> OutputSerialization -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OutputSerialization -> Pair)
-> Maybe OutputSerialization -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OutputSerialization
outputSerialization,
            (Text
"Expression" 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
expression,
            (Text
"InputSerialization" Text -> InputSerialization -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InputSerialization -> Pair)
-> Maybe InputSerialization -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputSerialization
inputSerialization
          ]
      )