{-# 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.Glue.Types.TaskRunSortCriteria
-- 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.Glue.Types.TaskRunSortCriteria where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.SortDirectionType
import Amazonka.Glue.Types.TaskRunSortColumnType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The sorting criteria that are used to sort the list of task runs for the
-- machine learning transform.
--
-- /See:/ 'newTaskRunSortCriteria' smart constructor.
data TaskRunSortCriteria = TaskRunSortCriteria'
  { -- | The column to be used to sort the list of task runs for the machine
    -- learning transform.
    TaskRunSortCriteria -> TaskRunSortColumnType
column :: TaskRunSortColumnType,
    -- | The sort direction to be used to sort the list of task runs for the
    -- machine learning transform.
    TaskRunSortCriteria -> SortDirectionType
sortDirection :: SortDirectionType
  }
  deriving (TaskRunSortCriteria -> TaskRunSortCriteria -> Bool
(TaskRunSortCriteria -> TaskRunSortCriteria -> Bool)
-> (TaskRunSortCriteria -> TaskRunSortCriteria -> Bool)
-> Eq TaskRunSortCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaskRunSortCriteria -> TaskRunSortCriteria -> Bool
$c/= :: TaskRunSortCriteria -> TaskRunSortCriteria -> Bool
== :: TaskRunSortCriteria -> TaskRunSortCriteria -> Bool
$c== :: TaskRunSortCriteria -> TaskRunSortCriteria -> Bool
Prelude.Eq, ReadPrec [TaskRunSortCriteria]
ReadPrec TaskRunSortCriteria
Int -> ReadS TaskRunSortCriteria
ReadS [TaskRunSortCriteria]
(Int -> ReadS TaskRunSortCriteria)
-> ReadS [TaskRunSortCriteria]
-> ReadPrec TaskRunSortCriteria
-> ReadPrec [TaskRunSortCriteria]
-> Read TaskRunSortCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TaskRunSortCriteria]
$creadListPrec :: ReadPrec [TaskRunSortCriteria]
readPrec :: ReadPrec TaskRunSortCriteria
$creadPrec :: ReadPrec TaskRunSortCriteria
readList :: ReadS [TaskRunSortCriteria]
$creadList :: ReadS [TaskRunSortCriteria]
readsPrec :: Int -> ReadS TaskRunSortCriteria
$creadsPrec :: Int -> ReadS TaskRunSortCriteria
Prelude.Read, Int -> TaskRunSortCriteria -> ShowS
[TaskRunSortCriteria] -> ShowS
TaskRunSortCriteria -> String
(Int -> TaskRunSortCriteria -> ShowS)
-> (TaskRunSortCriteria -> String)
-> ([TaskRunSortCriteria] -> ShowS)
-> Show TaskRunSortCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaskRunSortCriteria] -> ShowS
$cshowList :: [TaskRunSortCriteria] -> ShowS
show :: TaskRunSortCriteria -> String
$cshow :: TaskRunSortCriteria -> String
showsPrec :: Int -> TaskRunSortCriteria -> ShowS
$cshowsPrec :: Int -> TaskRunSortCriteria -> ShowS
Prelude.Show, (forall x. TaskRunSortCriteria -> Rep TaskRunSortCriteria x)
-> (forall x. Rep TaskRunSortCriteria x -> TaskRunSortCriteria)
-> Generic TaskRunSortCriteria
forall x. Rep TaskRunSortCriteria x -> TaskRunSortCriteria
forall x. TaskRunSortCriteria -> Rep TaskRunSortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TaskRunSortCriteria x -> TaskRunSortCriteria
$cfrom :: forall x. TaskRunSortCriteria -> Rep TaskRunSortCriteria x
Prelude.Generic)

-- |
-- Create a value of 'TaskRunSortCriteria' 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:
--
-- 'column', 'taskRunSortCriteria_column' - The column to be used to sort the list of task runs for the machine
-- learning transform.
--
-- 'sortDirection', 'taskRunSortCriteria_sortDirection' - The sort direction to be used to sort the list of task runs for the
-- machine learning transform.
newTaskRunSortCriteria ::
  -- | 'column'
  TaskRunSortColumnType ->
  -- | 'sortDirection'
  SortDirectionType ->
  TaskRunSortCriteria
newTaskRunSortCriteria :: TaskRunSortColumnType -> SortDirectionType -> TaskRunSortCriteria
newTaskRunSortCriteria TaskRunSortColumnType
pColumn_ SortDirectionType
pSortDirection_ =
  TaskRunSortCriteria' :: TaskRunSortColumnType -> SortDirectionType -> TaskRunSortCriteria
TaskRunSortCriteria'
    { $sel:column:TaskRunSortCriteria' :: TaskRunSortColumnType
column = TaskRunSortColumnType
pColumn_,
      $sel:sortDirection:TaskRunSortCriteria' :: SortDirectionType
sortDirection = SortDirectionType
pSortDirection_
    }

-- | The column to be used to sort the list of task runs for the machine
-- learning transform.
taskRunSortCriteria_column :: Lens.Lens' TaskRunSortCriteria TaskRunSortColumnType
taskRunSortCriteria_column :: (TaskRunSortColumnType -> f TaskRunSortColumnType)
-> TaskRunSortCriteria -> f TaskRunSortCriteria
taskRunSortCriteria_column = (TaskRunSortCriteria -> TaskRunSortColumnType)
-> (TaskRunSortCriteria
    -> TaskRunSortColumnType -> TaskRunSortCriteria)
-> Lens
     TaskRunSortCriteria
     TaskRunSortCriteria
     TaskRunSortColumnType
     TaskRunSortColumnType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskRunSortCriteria' {TaskRunSortColumnType
column :: TaskRunSortColumnType
$sel:column:TaskRunSortCriteria' :: TaskRunSortCriteria -> TaskRunSortColumnType
column} -> TaskRunSortColumnType
column) (\s :: TaskRunSortCriteria
s@TaskRunSortCriteria' {} TaskRunSortColumnType
a -> TaskRunSortCriteria
s {$sel:column:TaskRunSortCriteria' :: TaskRunSortColumnType
column = TaskRunSortColumnType
a} :: TaskRunSortCriteria)

-- | The sort direction to be used to sort the list of task runs for the
-- machine learning transform.
taskRunSortCriteria_sortDirection :: Lens.Lens' TaskRunSortCriteria SortDirectionType
taskRunSortCriteria_sortDirection :: (SortDirectionType -> f SortDirectionType)
-> TaskRunSortCriteria -> f TaskRunSortCriteria
taskRunSortCriteria_sortDirection = (TaskRunSortCriteria -> SortDirectionType)
-> (TaskRunSortCriteria
    -> SortDirectionType -> TaskRunSortCriteria)
-> Lens
     TaskRunSortCriteria
     TaskRunSortCriteria
     SortDirectionType
     SortDirectionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskRunSortCriteria' {SortDirectionType
sortDirection :: SortDirectionType
$sel:sortDirection:TaskRunSortCriteria' :: TaskRunSortCriteria -> SortDirectionType
sortDirection} -> SortDirectionType
sortDirection) (\s :: TaskRunSortCriteria
s@TaskRunSortCriteria' {} SortDirectionType
a -> TaskRunSortCriteria
s {$sel:sortDirection:TaskRunSortCriteria' :: SortDirectionType
sortDirection = SortDirectionType
a} :: TaskRunSortCriteria)

instance Prelude.Hashable TaskRunSortCriteria

instance Prelude.NFData TaskRunSortCriteria

instance Core.ToJSON TaskRunSortCriteria where
  toJSON :: TaskRunSortCriteria -> Value
toJSON TaskRunSortCriteria' {SortDirectionType
TaskRunSortColumnType
sortDirection :: SortDirectionType
column :: TaskRunSortColumnType
$sel:sortDirection:TaskRunSortCriteria' :: TaskRunSortCriteria -> SortDirectionType
$sel:column:TaskRunSortCriteria' :: TaskRunSortCriteria -> TaskRunSortColumnType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Column" Text -> TaskRunSortColumnType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TaskRunSortColumnType
column),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SortDirection" Text -> SortDirectionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SortDirectionType
sortDirection)
          ]
      )