{-# 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.KinesisAnalyticsV2.Types.CodeContentDescription
-- 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.KinesisAnalyticsV2.Types.CodeContentDescription where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.S3ApplicationCodeLocationDescription
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes details about the code of a Kinesis Data Analytics
-- application.
--
-- /See:/ 'newCodeContentDescription' smart constructor.
data CodeContentDescription = CodeContentDescription'
  { -- | The S3 bucket Amazon Resource Name (ARN), file key, and object version
    -- of the application code stored in Amazon S3.
    CodeContentDescription
-> Maybe S3ApplicationCodeLocationDescription
s3ApplicationCodeLocationDescription :: Prelude.Maybe S3ApplicationCodeLocationDescription,
    -- | The checksum that can be used to validate zip-format code.
    CodeContentDescription -> Maybe Text
codeMD5 :: Prelude.Maybe Prelude.Text,
    -- | The text-format code
    CodeContentDescription -> Maybe Text
textContent :: Prelude.Maybe Prelude.Text,
    -- | The size in bytes of the application code. Can be used to validate
    -- zip-format code.
    CodeContentDescription -> Maybe Natural
codeSize :: Prelude.Maybe Prelude.Natural
  }
  deriving (CodeContentDescription -> CodeContentDescription -> Bool
(CodeContentDescription -> CodeContentDescription -> Bool)
-> (CodeContentDescription -> CodeContentDescription -> Bool)
-> Eq CodeContentDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeContentDescription -> CodeContentDescription -> Bool
$c/= :: CodeContentDescription -> CodeContentDescription -> Bool
== :: CodeContentDescription -> CodeContentDescription -> Bool
$c== :: CodeContentDescription -> CodeContentDescription -> Bool
Prelude.Eq, ReadPrec [CodeContentDescription]
ReadPrec CodeContentDescription
Int -> ReadS CodeContentDescription
ReadS [CodeContentDescription]
(Int -> ReadS CodeContentDescription)
-> ReadS [CodeContentDescription]
-> ReadPrec CodeContentDescription
-> ReadPrec [CodeContentDescription]
-> Read CodeContentDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeContentDescription]
$creadListPrec :: ReadPrec [CodeContentDescription]
readPrec :: ReadPrec CodeContentDescription
$creadPrec :: ReadPrec CodeContentDescription
readList :: ReadS [CodeContentDescription]
$creadList :: ReadS [CodeContentDescription]
readsPrec :: Int -> ReadS CodeContentDescription
$creadsPrec :: Int -> ReadS CodeContentDescription
Prelude.Read, Int -> CodeContentDescription -> ShowS
[CodeContentDescription] -> ShowS
CodeContentDescription -> String
(Int -> CodeContentDescription -> ShowS)
-> (CodeContentDescription -> String)
-> ([CodeContentDescription] -> ShowS)
-> Show CodeContentDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeContentDescription] -> ShowS
$cshowList :: [CodeContentDescription] -> ShowS
show :: CodeContentDescription -> String
$cshow :: CodeContentDescription -> String
showsPrec :: Int -> CodeContentDescription -> ShowS
$cshowsPrec :: Int -> CodeContentDescription -> ShowS
Prelude.Show, (forall x. CodeContentDescription -> Rep CodeContentDescription x)
-> (forall x.
    Rep CodeContentDescription x -> CodeContentDescription)
-> Generic CodeContentDescription
forall x. Rep CodeContentDescription x -> CodeContentDescription
forall x. CodeContentDescription -> Rep CodeContentDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeContentDescription x -> CodeContentDescription
$cfrom :: forall x. CodeContentDescription -> Rep CodeContentDescription x
Prelude.Generic)

-- |
-- Create a value of 'CodeContentDescription' 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:
--
-- 's3ApplicationCodeLocationDescription', 'codeContentDescription_s3ApplicationCodeLocationDescription' - The S3 bucket Amazon Resource Name (ARN), file key, and object version
-- of the application code stored in Amazon S3.
--
-- 'codeMD5', 'codeContentDescription_codeMD5' - The checksum that can be used to validate zip-format code.
--
-- 'textContent', 'codeContentDescription_textContent' - The text-format code
--
-- 'codeSize', 'codeContentDescription_codeSize' - The size in bytes of the application code. Can be used to validate
-- zip-format code.
newCodeContentDescription ::
  CodeContentDescription
newCodeContentDescription :: CodeContentDescription
newCodeContentDescription =
  CodeContentDescription' :: Maybe S3ApplicationCodeLocationDescription
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> CodeContentDescription
CodeContentDescription'
    { $sel:s3ApplicationCodeLocationDescription:CodeContentDescription' :: Maybe S3ApplicationCodeLocationDescription
s3ApplicationCodeLocationDescription =
        Maybe S3ApplicationCodeLocationDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:codeMD5:CodeContentDescription' :: Maybe Text
codeMD5 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:textContent:CodeContentDescription' :: Maybe Text
textContent = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:codeSize:CodeContentDescription' :: Maybe Natural
codeSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The S3 bucket Amazon Resource Name (ARN), file key, and object version
-- of the application code stored in Amazon S3.
codeContentDescription_s3ApplicationCodeLocationDescription :: Lens.Lens' CodeContentDescription (Prelude.Maybe S3ApplicationCodeLocationDescription)
codeContentDescription_s3ApplicationCodeLocationDescription :: (Maybe S3ApplicationCodeLocationDescription
 -> f (Maybe S3ApplicationCodeLocationDescription))
-> CodeContentDescription -> f CodeContentDescription
codeContentDescription_s3ApplicationCodeLocationDescription = (CodeContentDescription
 -> Maybe S3ApplicationCodeLocationDescription)
-> (CodeContentDescription
    -> Maybe S3ApplicationCodeLocationDescription
    -> CodeContentDescription)
-> Lens
     CodeContentDescription
     CodeContentDescription
     (Maybe S3ApplicationCodeLocationDescription)
     (Maybe S3ApplicationCodeLocationDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentDescription' {Maybe S3ApplicationCodeLocationDescription
s3ApplicationCodeLocationDescription :: Maybe S3ApplicationCodeLocationDescription
$sel:s3ApplicationCodeLocationDescription:CodeContentDescription' :: CodeContentDescription
-> Maybe S3ApplicationCodeLocationDescription
s3ApplicationCodeLocationDescription} -> Maybe S3ApplicationCodeLocationDescription
s3ApplicationCodeLocationDescription) (\s :: CodeContentDescription
s@CodeContentDescription' {} Maybe S3ApplicationCodeLocationDescription
a -> CodeContentDescription
s {$sel:s3ApplicationCodeLocationDescription:CodeContentDescription' :: Maybe S3ApplicationCodeLocationDescription
s3ApplicationCodeLocationDescription = Maybe S3ApplicationCodeLocationDescription
a} :: CodeContentDescription)

-- | The checksum that can be used to validate zip-format code.
codeContentDescription_codeMD5 :: Lens.Lens' CodeContentDescription (Prelude.Maybe Prelude.Text)
codeContentDescription_codeMD5 :: (Maybe Text -> f (Maybe Text))
-> CodeContentDescription -> f CodeContentDescription
codeContentDescription_codeMD5 = (CodeContentDescription -> Maybe Text)
-> (CodeContentDescription -> Maybe Text -> CodeContentDescription)
-> Lens
     CodeContentDescription
     CodeContentDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentDescription' {Maybe Text
codeMD5 :: Maybe Text
$sel:codeMD5:CodeContentDescription' :: CodeContentDescription -> Maybe Text
codeMD5} -> Maybe Text
codeMD5) (\s :: CodeContentDescription
s@CodeContentDescription' {} Maybe Text
a -> CodeContentDescription
s {$sel:codeMD5:CodeContentDescription' :: Maybe Text
codeMD5 = Maybe Text
a} :: CodeContentDescription)

-- | The text-format code
codeContentDescription_textContent :: Lens.Lens' CodeContentDescription (Prelude.Maybe Prelude.Text)
codeContentDescription_textContent :: (Maybe Text -> f (Maybe Text))
-> CodeContentDescription -> f CodeContentDescription
codeContentDescription_textContent = (CodeContentDescription -> Maybe Text)
-> (CodeContentDescription -> Maybe Text -> CodeContentDescription)
-> Lens
     CodeContentDescription
     CodeContentDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentDescription' {Maybe Text
textContent :: Maybe Text
$sel:textContent:CodeContentDescription' :: CodeContentDescription -> Maybe Text
textContent} -> Maybe Text
textContent) (\s :: CodeContentDescription
s@CodeContentDescription' {} Maybe Text
a -> CodeContentDescription
s {$sel:textContent:CodeContentDescription' :: Maybe Text
textContent = Maybe Text
a} :: CodeContentDescription)

-- | The size in bytes of the application code. Can be used to validate
-- zip-format code.
codeContentDescription_codeSize :: Lens.Lens' CodeContentDescription (Prelude.Maybe Prelude.Natural)
codeContentDescription_codeSize :: (Maybe Natural -> f (Maybe Natural))
-> CodeContentDescription -> f CodeContentDescription
codeContentDescription_codeSize = (CodeContentDescription -> Maybe Natural)
-> (CodeContentDescription
    -> Maybe Natural -> CodeContentDescription)
-> Lens
     CodeContentDescription
     CodeContentDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentDescription' {Maybe Natural
codeSize :: Maybe Natural
$sel:codeSize:CodeContentDescription' :: CodeContentDescription -> Maybe Natural
codeSize} -> Maybe Natural
codeSize) (\s :: CodeContentDescription
s@CodeContentDescription' {} Maybe Natural
a -> CodeContentDescription
s {$sel:codeSize:CodeContentDescription' :: Maybe Natural
codeSize = Maybe Natural
a} :: CodeContentDescription)

instance Core.FromJSON CodeContentDescription where
  parseJSON :: Value -> Parser CodeContentDescription
parseJSON =
    String
-> (Object -> Parser CodeContentDescription)
-> Value
-> Parser CodeContentDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeContentDescription"
      ( \Object
x ->
          Maybe S3ApplicationCodeLocationDescription
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> CodeContentDescription
CodeContentDescription'
            (Maybe S3ApplicationCodeLocationDescription
 -> Maybe Text
 -> Maybe Text
 -> Maybe Natural
 -> CodeContentDescription)
-> Parser (Maybe S3ApplicationCodeLocationDescription)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Natural -> CodeContentDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe S3ApplicationCodeLocationDescription)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3ApplicationCodeLocationDescription")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Natural -> CodeContentDescription)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Natural -> CodeContentDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CodeMD5")
            Parser (Maybe Text -> Maybe Natural -> CodeContentDescription)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> CodeContentDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TextContent")
            Parser (Maybe Natural -> CodeContentDescription)
-> Parser (Maybe Natural) -> Parser CodeContentDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CodeSize")
      )

instance Prelude.Hashable CodeContentDescription

instance Prelude.NFData CodeContentDescription