{-# 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.IoTAnalytics.Types.ContainerDatasetAction
-- 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.IoTAnalytics.Types.ContainerDatasetAction where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.ResourceConfiguration
import Amazonka.IoTAnalytics.Types.Variable
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information required to run the @containerAction@ to produce dataset
-- contents.
--
-- /See:/ 'newContainerDatasetAction' smart constructor.
data ContainerDatasetAction = ContainerDatasetAction'
  { -- | The values of variables used in the context of the execution of the
    -- containerized application (basically, parameters passed to the
    -- application). Each variable must have a name and a value given by one of
    -- @stringValue@, @datasetContentVersionValue@, or @outputFileUriValue@.
    ContainerDatasetAction -> Maybe [Variable]
variables :: Prelude.Maybe [Variable],
    -- | The ARN of the Docker container stored in your account. The Docker
    -- container contains an application and required support libraries and is
    -- used to generate dataset contents.
    ContainerDatasetAction -> Text
image :: Prelude.Text,
    -- | The ARN of the role that gives permission to the system to access
    -- required resources to run the @containerAction@. This includes, at
    -- minimum, permission to retrieve the dataset contents that are the input
    -- to the containerized application.
    ContainerDatasetAction -> Text
executionRoleArn :: Prelude.Text,
    -- | Configuration of the resource that executes the @containerAction@.
    ContainerDatasetAction -> ResourceConfiguration
resourceConfiguration :: ResourceConfiguration
  }
  deriving (ContainerDatasetAction -> ContainerDatasetAction -> Bool
(ContainerDatasetAction -> ContainerDatasetAction -> Bool)
-> (ContainerDatasetAction -> ContainerDatasetAction -> Bool)
-> Eq ContainerDatasetAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerDatasetAction -> ContainerDatasetAction -> Bool
$c/= :: ContainerDatasetAction -> ContainerDatasetAction -> Bool
== :: ContainerDatasetAction -> ContainerDatasetAction -> Bool
$c== :: ContainerDatasetAction -> ContainerDatasetAction -> Bool
Prelude.Eq, ReadPrec [ContainerDatasetAction]
ReadPrec ContainerDatasetAction
Int -> ReadS ContainerDatasetAction
ReadS [ContainerDatasetAction]
(Int -> ReadS ContainerDatasetAction)
-> ReadS [ContainerDatasetAction]
-> ReadPrec ContainerDatasetAction
-> ReadPrec [ContainerDatasetAction]
-> Read ContainerDatasetAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerDatasetAction]
$creadListPrec :: ReadPrec [ContainerDatasetAction]
readPrec :: ReadPrec ContainerDatasetAction
$creadPrec :: ReadPrec ContainerDatasetAction
readList :: ReadS [ContainerDatasetAction]
$creadList :: ReadS [ContainerDatasetAction]
readsPrec :: Int -> ReadS ContainerDatasetAction
$creadsPrec :: Int -> ReadS ContainerDatasetAction
Prelude.Read, Int -> ContainerDatasetAction -> ShowS
[ContainerDatasetAction] -> ShowS
ContainerDatasetAction -> String
(Int -> ContainerDatasetAction -> ShowS)
-> (ContainerDatasetAction -> String)
-> ([ContainerDatasetAction] -> ShowS)
-> Show ContainerDatasetAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerDatasetAction] -> ShowS
$cshowList :: [ContainerDatasetAction] -> ShowS
show :: ContainerDatasetAction -> String
$cshow :: ContainerDatasetAction -> String
showsPrec :: Int -> ContainerDatasetAction -> ShowS
$cshowsPrec :: Int -> ContainerDatasetAction -> ShowS
Prelude.Show, (forall x. ContainerDatasetAction -> Rep ContainerDatasetAction x)
-> (forall x.
    Rep ContainerDatasetAction x -> ContainerDatasetAction)
-> Generic ContainerDatasetAction
forall x. Rep ContainerDatasetAction x -> ContainerDatasetAction
forall x. ContainerDatasetAction -> Rep ContainerDatasetAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContainerDatasetAction x -> ContainerDatasetAction
$cfrom :: forall x. ContainerDatasetAction -> Rep ContainerDatasetAction x
Prelude.Generic)

-- |
-- Create a value of 'ContainerDatasetAction' 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:
--
-- 'variables', 'containerDatasetAction_variables' - The values of variables used in the context of the execution of the
-- containerized application (basically, parameters passed to the
-- application). Each variable must have a name and a value given by one of
-- @stringValue@, @datasetContentVersionValue@, or @outputFileUriValue@.
--
-- 'image', 'containerDatasetAction_image' - The ARN of the Docker container stored in your account. The Docker
-- container contains an application and required support libraries and is
-- used to generate dataset contents.
--
-- 'executionRoleArn', 'containerDatasetAction_executionRoleArn' - The ARN of the role that gives permission to the system to access
-- required resources to run the @containerAction@. This includes, at
-- minimum, permission to retrieve the dataset contents that are the input
-- to the containerized application.
--
-- 'resourceConfiguration', 'containerDatasetAction_resourceConfiguration' - Configuration of the resource that executes the @containerAction@.
newContainerDatasetAction ::
  -- | 'image'
  Prelude.Text ->
  -- | 'executionRoleArn'
  Prelude.Text ->
  -- | 'resourceConfiguration'
  ResourceConfiguration ->
  ContainerDatasetAction
newContainerDatasetAction :: Text -> Text -> ResourceConfiguration -> ContainerDatasetAction
newContainerDatasetAction
  Text
pImage_
  Text
pExecutionRoleArn_
  ResourceConfiguration
pResourceConfiguration_ =
    ContainerDatasetAction' :: Maybe [Variable]
-> Text -> Text -> ResourceConfiguration -> ContainerDatasetAction
ContainerDatasetAction'
      { $sel:variables:ContainerDatasetAction' :: Maybe [Variable]
variables =
          Maybe [Variable]
forall a. Maybe a
Prelude.Nothing,
        $sel:image:ContainerDatasetAction' :: Text
image = Text
pImage_,
        $sel:executionRoleArn:ContainerDatasetAction' :: Text
executionRoleArn = Text
pExecutionRoleArn_,
        $sel:resourceConfiguration:ContainerDatasetAction' :: ResourceConfiguration
resourceConfiguration = ResourceConfiguration
pResourceConfiguration_
      }

-- | The values of variables used in the context of the execution of the
-- containerized application (basically, parameters passed to the
-- application). Each variable must have a name and a value given by one of
-- @stringValue@, @datasetContentVersionValue@, or @outputFileUriValue@.
containerDatasetAction_variables :: Lens.Lens' ContainerDatasetAction (Prelude.Maybe [Variable])
containerDatasetAction_variables :: (Maybe [Variable] -> f (Maybe [Variable]))
-> ContainerDatasetAction -> f ContainerDatasetAction
containerDatasetAction_variables = (ContainerDatasetAction -> Maybe [Variable])
-> (ContainerDatasetAction
    -> Maybe [Variable] -> ContainerDatasetAction)
-> Lens
     ContainerDatasetAction
     ContainerDatasetAction
     (Maybe [Variable])
     (Maybe [Variable])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDatasetAction' {Maybe [Variable]
variables :: Maybe [Variable]
$sel:variables:ContainerDatasetAction' :: ContainerDatasetAction -> Maybe [Variable]
variables} -> Maybe [Variable]
variables) (\s :: ContainerDatasetAction
s@ContainerDatasetAction' {} Maybe [Variable]
a -> ContainerDatasetAction
s {$sel:variables:ContainerDatasetAction' :: Maybe [Variable]
variables = Maybe [Variable]
a} :: ContainerDatasetAction) ((Maybe [Variable] -> f (Maybe [Variable]))
 -> ContainerDatasetAction -> f ContainerDatasetAction)
-> ((Maybe [Variable] -> f (Maybe [Variable]))
    -> Maybe [Variable] -> f (Maybe [Variable]))
-> (Maybe [Variable] -> f (Maybe [Variable]))
-> ContainerDatasetAction
-> f ContainerDatasetAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Variable] [Variable] [Variable] [Variable]
-> Iso
     (Maybe [Variable])
     (Maybe [Variable])
     (Maybe [Variable])
     (Maybe [Variable])
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 [Variable] [Variable] [Variable] [Variable]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the Docker container stored in your account. The Docker
-- container contains an application and required support libraries and is
-- used to generate dataset contents.
containerDatasetAction_image :: Lens.Lens' ContainerDatasetAction Prelude.Text
containerDatasetAction_image :: (Text -> f Text)
-> ContainerDatasetAction -> f ContainerDatasetAction
containerDatasetAction_image = (ContainerDatasetAction -> Text)
-> (ContainerDatasetAction -> Text -> ContainerDatasetAction)
-> Lens ContainerDatasetAction ContainerDatasetAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDatasetAction' {Text
image :: Text
$sel:image:ContainerDatasetAction' :: ContainerDatasetAction -> Text
image} -> Text
image) (\s :: ContainerDatasetAction
s@ContainerDatasetAction' {} Text
a -> ContainerDatasetAction
s {$sel:image:ContainerDatasetAction' :: Text
image = Text
a} :: ContainerDatasetAction)

-- | The ARN of the role that gives permission to the system to access
-- required resources to run the @containerAction@. This includes, at
-- minimum, permission to retrieve the dataset contents that are the input
-- to the containerized application.
containerDatasetAction_executionRoleArn :: Lens.Lens' ContainerDatasetAction Prelude.Text
containerDatasetAction_executionRoleArn :: (Text -> f Text)
-> ContainerDatasetAction -> f ContainerDatasetAction
containerDatasetAction_executionRoleArn = (ContainerDatasetAction -> Text)
-> (ContainerDatasetAction -> Text -> ContainerDatasetAction)
-> Lens ContainerDatasetAction ContainerDatasetAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDatasetAction' {Text
executionRoleArn :: Text
$sel:executionRoleArn:ContainerDatasetAction' :: ContainerDatasetAction -> Text
executionRoleArn} -> Text
executionRoleArn) (\s :: ContainerDatasetAction
s@ContainerDatasetAction' {} Text
a -> ContainerDatasetAction
s {$sel:executionRoleArn:ContainerDatasetAction' :: Text
executionRoleArn = Text
a} :: ContainerDatasetAction)

-- | Configuration of the resource that executes the @containerAction@.
containerDatasetAction_resourceConfiguration :: Lens.Lens' ContainerDatasetAction ResourceConfiguration
containerDatasetAction_resourceConfiguration :: (ResourceConfiguration -> f ResourceConfiguration)
-> ContainerDatasetAction -> f ContainerDatasetAction
containerDatasetAction_resourceConfiguration = (ContainerDatasetAction -> ResourceConfiguration)
-> (ContainerDatasetAction
    -> ResourceConfiguration -> ContainerDatasetAction)
-> Lens
     ContainerDatasetAction
     ContainerDatasetAction
     ResourceConfiguration
     ResourceConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDatasetAction' {ResourceConfiguration
resourceConfiguration :: ResourceConfiguration
$sel:resourceConfiguration:ContainerDatasetAction' :: ContainerDatasetAction -> ResourceConfiguration
resourceConfiguration} -> ResourceConfiguration
resourceConfiguration) (\s :: ContainerDatasetAction
s@ContainerDatasetAction' {} ResourceConfiguration
a -> ContainerDatasetAction
s {$sel:resourceConfiguration:ContainerDatasetAction' :: ResourceConfiguration
resourceConfiguration = ResourceConfiguration
a} :: ContainerDatasetAction)

instance Core.FromJSON ContainerDatasetAction where
  parseJSON :: Value -> Parser ContainerDatasetAction
parseJSON =
    String
-> (Object -> Parser ContainerDatasetAction)
-> Value
-> Parser ContainerDatasetAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerDatasetAction"
      ( \Object
x ->
          Maybe [Variable]
-> Text -> Text -> ResourceConfiguration -> ContainerDatasetAction
ContainerDatasetAction'
            (Maybe [Variable]
 -> Text -> Text -> ResourceConfiguration -> ContainerDatasetAction)
-> Parser (Maybe [Variable])
-> Parser
     (Text -> Text -> ResourceConfiguration -> ContainerDatasetAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Variable]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"variables" Parser (Maybe (Maybe [Variable]))
-> Maybe [Variable] -> Parser (Maybe [Variable])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Variable]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Text -> Text -> ResourceConfiguration -> ContainerDatasetAction)
-> Parser Text
-> Parser (Text -> ResourceConfiguration -> ContainerDatasetAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"image")
            Parser (Text -> ResourceConfiguration -> ContainerDatasetAction)
-> Parser Text
-> Parser (ResourceConfiguration -> ContainerDatasetAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"executionRoleArn")
            Parser (ResourceConfiguration -> ContainerDatasetAction)
-> Parser ResourceConfiguration -> Parser ContainerDatasetAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ResourceConfiguration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"resourceConfiguration")
      )

instance Prelude.Hashable ContainerDatasetAction

instance Prelude.NFData ContainerDatasetAction

instance Core.ToJSON ContainerDatasetAction where
  toJSON :: ContainerDatasetAction -> Value
toJSON ContainerDatasetAction' {Maybe [Variable]
Text
ResourceConfiguration
resourceConfiguration :: ResourceConfiguration
executionRoleArn :: Text
image :: Text
variables :: Maybe [Variable]
$sel:resourceConfiguration:ContainerDatasetAction' :: ContainerDatasetAction -> ResourceConfiguration
$sel:executionRoleArn:ContainerDatasetAction' :: ContainerDatasetAction -> Text
$sel:image:ContainerDatasetAction' :: ContainerDatasetAction -> Text
$sel:variables:ContainerDatasetAction' :: ContainerDatasetAction -> Maybe [Variable]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"variables" Text -> [Variable] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Variable] -> Pair) -> Maybe [Variable] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Variable]
variables,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"image" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
image),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"executionRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
executionRoleArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"resourceConfiguration"
                  Text -> ResourceConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceConfiguration
resourceConfiguration
              )
          ]
      )