packages feed

stratosphere-0.15.2: library-gen/Stratosphere/Resources/GlueTable.hs

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

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-table.html

module Stratosphere.Resources.GlueTable where

import Stratosphere.ResourceImports
import Stratosphere.ResourceProperties.GlueTableTableInput

-- | Full data type definition for GlueTable. See 'glueTable' for a more
-- convenient constructor.
data GlueTable =
  GlueTable
  { _glueTableCatalogId :: Val Text
  , _glueTableDatabaseName :: Val Text
  , _glueTableTableInput :: GlueTableTableInput
  } deriving (Show, Eq)

instance ToJSON GlueTable where
  toJSON GlueTable{..} =
    object $
    catMaybes
    [ (Just . ("CatalogId",) . toJSON) _glueTableCatalogId
    , (Just . ("DatabaseName",) . toJSON) _glueTableDatabaseName
    , (Just . ("TableInput",) . toJSON) _glueTableTableInput
    ]

instance FromJSON GlueTable where
  parseJSON (Object obj) =
    GlueTable <$>
      (obj .: "CatalogId") <*>
      (obj .: "DatabaseName") <*>
      (obj .: "TableInput")
  parseJSON _ = mempty

-- | Constructor for 'GlueTable' containing required fields as arguments.
glueTable
  :: Val Text -- ^ 'gtCatalogId'
  -> Val Text -- ^ 'gtDatabaseName'
  -> GlueTableTableInput -- ^ 'gtTableInput'
  -> GlueTable
glueTable catalogIdarg databaseNamearg tableInputarg =
  GlueTable
  { _glueTableCatalogId = catalogIdarg
  , _glueTableDatabaseName = databaseNamearg
  , _glueTableTableInput = tableInputarg
  }

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-table.html#cfn-glue-table-catalogid
gtCatalogId :: Lens' GlueTable (Val Text)
gtCatalogId = lens _glueTableCatalogId (\s a -> s { _glueTableCatalogId = a })

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-table.html#cfn-glue-table-databasename
gtDatabaseName :: Lens' GlueTable (Val Text)
gtDatabaseName = lens _glueTableDatabaseName (\s a -> s { _glueTableDatabaseName = a })

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-table.html#cfn-glue-table-tableinput
gtTableInput :: Lens' GlueTable GlueTableTableInput
gtTableInput = lens _glueTableTableInput (\s a -> s { _glueTableTableInput = a })