{-# 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.EMR.Types.Application
-- 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.EMR.Types.Application 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

-- | With Amazon EMR release version 4.0 and later, the only accepted
-- parameter is the application name. To pass arguments to applications,
-- you use configuration classifications specified using configuration JSON
-- objects. For more information, see
-- <https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps.html Configuring Applications>.
--
-- With earlier Amazon EMR releases, the application is any Amazon or
-- third-party software that you can add to the cluster. This structure
-- contains a list of strings that indicates the software to use with the
-- cluster and accepts a user argument list. Amazon EMR accepts and
-- forwards the argument list to the corresponding installation script as
-- bootstrap action argument.
--
-- /See:/ 'newApplication' smart constructor.
data Application = Application'
  { -- | This option is for advanced users only. This is meta information about
    -- third-party applications that third-party vendors use for testing
    -- purposes.
    Application -> Maybe (HashMap Text Text)
additionalInfo :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Arguments for Amazon EMR to pass to the application.
    Application -> Maybe [Text]
args :: Prelude.Maybe [Prelude.Text],
    -- | The name of the application.
    Application -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The version of the application.
    Application -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (Application -> Application -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Application -> Application -> Bool
$c/= :: Application -> Application -> Bool
== :: Application -> Application -> Bool
$c== :: Application -> Application -> Bool
Prelude.Eq, ReadPrec [Application]
ReadPrec Application
Int -> ReadS Application
ReadS [Application]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Application]
$creadListPrec :: ReadPrec [Application]
readPrec :: ReadPrec Application
$creadPrec :: ReadPrec Application
readList :: ReadS [Application]
$creadList :: ReadS [Application]
readsPrec :: Int -> ReadS Application
$creadsPrec :: Int -> ReadS Application
Prelude.Read, Int -> Application -> ShowS
[Application] -> ShowS
Application -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Application] -> ShowS
$cshowList :: [Application] -> ShowS
show :: Application -> String
$cshow :: Application -> String
showsPrec :: Int -> Application -> ShowS
$cshowsPrec :: Int -> Application -> ShowS
Prelude.Show, forall x. Rep Application x -> Application
forall x. Application -> Rep Application x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Application x -> Application
$cfrom :: forall x. Application -> Rep Application x
Prelude.Generic)

-- |
-- Create a value of 'Application' 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:
--
-- 'additionalInfo', 'application_additionalInfo' - This option is for advanced users only. This is meta information about
-- third-party applications that third-party vendors use for testing
-- purposes.
--
-- 'args', 'application_args' - Arguments for Amazon EMR to pass to the application.
--
-- 'name', 'application_name' - The name of the application.
--
-- 'version', 'application_version' - The version of the application.
newApplication ::
  Application
newApplication :: Application
newApplication =
  Application'
    { $sel:additionalInfo:Application' :: Maybe (HashMap Text Text)
additionalInfo = forall a. Maybe a
Prelude.Nothing,
      $sel:args:Application' :: Maybe [Text]
args = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Application' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:version:Application' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing
    }

-- | This option is for advanced users only. This is meta information about
-- third-party applications that third-party vendors use for testing
-- purposes.
application_additionalInfo :: Lens.Lens' Application (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
application_additionalInfo :: Lens' Application (Maybe (HashMap Text Text))
application_additionalInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Application' {Maybe (HashMap Text Text)
additionalInfo :: Maybe (HashMap Text Text)
$sel:additionalInfo:Application' :: Application -> Maybe (HashMap Text Text)
additionalInfo} -> Maybe (HashMap Text Text)
additionalInfo) (\s :: Application
s@Application' {} Maybe (HashMap Text Text)
a -> Application
s {$sel:additionalInfo:Application' :: Maybe (HashMap Text Text)
additionalInfo = Maybe (HashMap Text Text)
a} :: Application) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Arguments for Amazon EMR to pass to the application.
application_args :: Lens.Lens' Application (Prelude.Maybe [Prelude.Text])
application_args :: Lens' Application (Maybe [Text])
application_args = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Application' {Maybe [Text]
args :: Maybe [Text]
$sel:args:Application' :: Application -> Maybe [Text]
args} -> Maybe [Text]
args) (\s :: Application
s@Application' {} Maybe [Text]
a -> Application
s {$sel:args:Application' :: Maybe [Text]
args = Maybe [Text]
a} :: Application) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The version of the application.
application_version :: Lens.Lens' Application (Prelude.Maybe Prelude.Text)
application_version :: Lens' Application (Maybe Text)
application_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Application' {Maybe Text
version :: Maybe Text
$sel:version:Application' :: Application -> Maybe Text
version} -> Maybe Text
version) (\s :: Application
s@Application' {} Maybe Text
a -> Application
s {$sel:version:Application' :: Maybe Text
version = Maybe Text
a} :: Application)

instance Data.FromJSON Application where
  parseJSON :: Value -> Parser Application
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Application"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe [Text] -> Maybe Text -> Maybe Text -> Application
Application'
            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
"AdditionalInfo" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Args" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Version")
      )

instance Prelude.Hashable Application where
  hashWithSalt :: Int -> Application -> Int
hashWithSalt Int
_salt Application' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
version :: Maybe Text
name :: Maybe Text
args :: Maybe [Text]
additionalInfo :: Maybe (HashMap Text Text)
$sel:version:Application' :: Application -> Maybe Text
$sel:name:Application' :: Application -> Maybe Text
$sel:args:Application' :: Application -> Maybe [Text]
$sel:additionalInfo:Application' :: Application -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
additionalInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
args
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version

instance Prelude.NFData Application where
  rnf :: Application -> ()
rnf Application' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
version :: Maybe Text
name :: Maybe Text
args :: Maybe [Text]
additionalInfo :: Maybe (HashMap Text Text)
$sel:version:Application' :: Application -> Maybe Text
$sel:name:Application' :: Application -> Maybe Text
$sel:args:Application' :: Application -> Maybe [Text]
$sel:additionalInfo:Application' :: Application -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
additionalInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
args
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version

instance Data.ToJSON Application where
  toJSON :: Application -> Value
toJSON Application' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
version :: Maybe Text
name :: Maybe Text
args :: Maybe [Text]
additionalInfo :: Maybe (HashMap Text Text)
$sel:version:Application' :: Application -> Maybe Text
$sel:name:Application' :: Application -> Maybe Text
$sel:args:Application' :: Application -> Maybe [Text]
$sel:additionalInfo:Application' :: Application -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdditionalInfo" 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 (HashMap Text Text)
additionalInfo,
            (Key
"Args" 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 [Text]
args,
            (Key
"Name" 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 Text
name,
            (Key
"Version" 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 Text
version
          ]
      )