packages feed

stratosphere-0.11.0: library-gen/Stratosphere/ResourceProperties/GlueJobJobCommand.hs

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-job-jobcommand.html

module Stratosphere.ResourceProperties.GlueJobJobCommand where

import Control.Lens hiding ((.=))
import Data.Aeson
import Data.Maybe (catMaybes)
import Data.Monoid (mempty)
import Data.Text

import Stratosphere.Values


-- | Full data type definition for GlueJobJobCommand. See 'glueJobJobCommand'
-- for a more convenient constructor.
data GlueJobJobCommand =
  GlueJobJobCommand
  { _glueJobJobCommandName :: Maybe (Val Text)
  , _glueJobJobCommandScriptLocation :: Maybe (Val Text)
  } deriving (Show, Eq)

instance ToJSON GlueJobJobCommand where
  toJSON GlueJobJobCommand{..} =
    object $
    catMaybes
    [ fmap (("Name",) . toJSON) _glueJobJobCommandName
    , fmap (("ScriptLocation",) . toJSON) _glueJobJobCommandScriptLocation
    ]

instance FromJSON GlueJobJobCommand where
  parseJSON (Object obj) =
    GlueJobJobCommand <$>
      (obj .:? "Name") <*>
      (obj .:? "ScriptLocation")
  parseJSON _ = mempty

-- | Constructor for 'GlueJobJobCommand' containing required fields as
-- arguments.
glueJobJobCommand
  :: GlueJobJobCommand
glueJobJobCommand  =
  GlueJobJobCommand
  { _glueJobJobCommandName = Nothing
  , _glueJobJobCommandScriptLocation = Nothing
  }

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-job-jobcommand.html#cfn-glue-job-jobcommand-name
gjjcName :: Lens' GlueJobJobCommand (Maybe (Val Text))
gjjcName = lens _glueJobJobCommandName (\s a -> s { _glueJobJobCommandName = a })

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-job-jobcommand.html#cfn-glue-job-jobcommand-scriptlocation
gjjcScriptLocation :: Lens' GlueJobJobCommand (Maybe (Val Text))
gjjcScriptLocation = lens _glueJobJobCommandScriptLocation (\s a -> s { _glueJobJobCommandScriptLocation = a })