{-# 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.SageMakerGeoSpatial.Types.Operation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMakerGeoSpatial.Types.Operation where

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 Amazonka.SageMakerGeoSpatial.Types.OutputType

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

-- |
-- Create a value of 'Operation' 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:
--
-- 'outputType', 'operation_outputType' - The type of the operation.
--
-- 'equation', 'operation_equation' -
--
-- 'name', 'operation_name' - The name of the operation.
newOperation ::
  -- | 'equation'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  Operation
newOperation :: Text -> Text -> Operation
newOperation Text
pEquation_ Text
pName_ =
  Operation'
    { $sel:outputType:Operation' :: Maybe OutputType
outputType = forall a. Maybe a
Prelude.Nothing,
      $sel:equation:Operation' :: Text
equation = Text
pEquation_,
      $sel:name:Operation' :: Text
name = Text
pName_
    }

-- | The type of the operation.
operation_outputType :: Lens.Lens' Operation (Prelude.Maybe OutputType)
operation_outputType :: Lens' Operation (Maybe OutputType)
operation_outputType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Operation' {Maybe OutputType
outputType :: Maybe OutputType
$sel:outputType:Operation' :: Operation -> Maybe OutputType
outputType} -> Maybe OutputType
outputType) (\s :: Operation
s@Operation' {} Maybe OutputType
a -> Operation
s {$sel:outputType:Operation' :: Maybe OutputType
outputType = Maybe OutputType
a} :: Operation)

operation_equation :: Lens.Lens' Operation Prelude.Text
operation_equation :: Lens' Operation Text
operation_equation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Operation' {Text
equation :: Text
$sel:equation:Operation' :: Operation -> Text
equation} -> Text
equation) (\s :: Operation
s@Operation' {} Text
a -> Operation
s {$sel:equation:Operation' :: Text
equation = Text
a} :: Operation)

-- | The name of the operation.
operation_name :: Lens.Lens' Operation Prelude.Text
operation_name :: Lens' Operation Text
operation_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Operation' {Text
name :: Text
$sel:name:Operation' :: Operation -> Text
name} -> Text
name) (\s :: Operation
s@Operation' {} Text
a -> Operation
s {$sel:name:Operation' :: Text
name = Text
a} :: Operation)

instance Data.FromJSON Operation where
  parseJSON :: Value -> Parser Operation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Operation"
      ( \Object
x ->
          Maybe OutputType -> Text -> Text -> Operation
Operation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"OutputType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Equation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable Operation where
  hashWithSalt :: Int -> Operation -> Int
hashWithSalt Int
_salt Operation' {Maybe OutputType
Text
name :: Text
equation :: Text
outputType :: Maybe OutputType
$sel:name:Operation' :: Operation -> Text
$sel:equation:Operation' :: Operation -> Text
$sel:outputType:Operation' :: Operation -> Maybe OutputType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OutputType
outputType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
equation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData Operation where
  rnf :: Operation -> ()
rnf Operation' {Maybe OutputType
Text
name :: Text
equation :: Text
outputType :: Maybe OutputType
$sel:name:Operation' :: Operation -> Text
$sel:equation:Operation' :: Operation -> Text
$sel:outputType:Operation' :: Operation -> Maybe OutputType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe OutputType
outputType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
equation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON Operation where
  toJSON :: Operation -> Value
toJSON Operation' {Maybe OutputType
Text
name :: Text
equation :: Text
outputType :: Maybe OutputType
$sel:name:Operation' :: Operation -> Text
$sel:equation:Operation' :: Operation -> Text
$sel:outputType:Operation' :: Operation -> Maybe OutputType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"OutputType" 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 OutputType
outputType,
            forall a. a -> Maybe a
Prelude.Just (Key
"Equation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
equation),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )