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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisAnalyticsV2.Types.S3ContentLocation
import qualified Amazonka.Prelude as Prelude

-- | Specifies either the application code, or the location of the
-- application code, for a Flink-based Kinesis Data Analytics application.
--
-- /See:/ 'newCodeContent' smart constructor.
data CodeContent = CodeContent'
  { -- | Information about the Amazon S3 bucket that contains the application
    -- code.
    CodeContent -> Maybe S3ContentLocation
s3ContentLocation :: Prelude.Maybe S3ContentLocation,
    -- | The text-format code for a Flink-based Kinesis Data Analytics
    -- application.
    CodeContent -> Maybe Text
textContent :: Prelude.Maybe Prelude.Text,
    -- | The zip-format code for a Flink-based Kinesis Data Analytics
    -- application.
    CodeContent -> Maybe Base64
zipFileContent :: Prelude.Maybe Data.Base64
  }
  deriving (CodeContent -> CodeContent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeContent -> CodeContent -> Bool
$c/= :: CodeContent -> CodeContent -> Bool
== :: CodeContent -> CodeContent -> Bool
$c== :: CodeContent -> CodeContent -> Bool
Prelude.Eq, ReadPrec [CodeContent]
ReadPrec CodeContent
Int -> ReadS CodeContent
ReadS [CodeContent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeContent]
$creadListPrec :: ReadPrec [CodeContent]
readPrec :: ReadPrec CodeContent
$creadPrec :: ReadPrec CodeContent
readList :: ReadS [CodeContent]
$creadList :: ReadS [CodeContent]
readsPrec :: Int -> ReadS CodeContent
$creadsPrec :: Int -> ReadS CodeContent
Prelude.Read, Int -> CodeContent -> ShowS
[CodeContent] -> ShowS
CodeContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeContent] -> ShowS
$cshowList :: [CodeContent] -> ShowS
show :: CodeContent -> String
$cshow :: CodeContent -> String
showsPrec :: Int -> CodeContent -> ShowS
$cshowsPrec :: Int -> CodeContent -> ShowS
Prelude.Show, forall x. Rep CodeContent x -> CodeContent
forall x. CodeContent -> Rep CodeContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeContent x -> CodeContent
$cfrom :: forall x. CodeContent -> Rep CodeContent x
Prelude.Generic)

-- |
-- Create a value of 'CodeContent' 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:
--
-- 's3ContentLocation', 'codeContent_s3ContentLocation' - Information about the Amazon S3 bucket that contains the application
-- code.
--
-- 'textContent', 'codeContent_textContent' - The text-format code for a Flink-based Kinesis Data Analytics
-- application.
--
-- 'zipFileContent', 'codeContent_zipFileContent' - The zip-format code for a Flink-based Kinesis Data Analytics
-- application.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
newCodeContent ::
  CodeContent
newCodeContent :: CodeContent
newCodeContent =
  CodeContent'
    { $sel:s3ContentLocation:CodeContent' :: Maybe S3ContentLocation
s3ContentLocation = forall a. Maybe a
Prelude.Nothing,
      $sel:textContent:CodeContent' :: Maybe Text
textContent = forall a. Maybe a
Prelude.Nothing,
      $sel:zipFileContent:CodeContent' :: Maybe Base64
zipFileContent = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the Amazon S3 bucket that contains the application
-- code.
codeContent_s3ContentLocation :: Lens.Lens' CodeContent (Prelude.Maybe S3ContentLocation)
codeContent_s3ContentLocation :: Lens' CodeContent (Maybe S3ContentLocation)
codeContent_s3ContentLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContent' {Maybe S3ContentLocation
s3ContentLocation :: Maybe S3ContentLocation
$sel:s3ContentLocation:CodeContent' :: CodeContent -> Maybe S3ContentLocation
s3ContentLocation} -> Maybe S3ContentLocation
s3ContentLocation) (\s :: CodeContent
s@CodeContent' {} Maybe S3ContentLocation
a -> CodeContent
s {$sel:s3ContentLocation:CodeContent' :: Maybe S3ContentLocation
s3ContentLocation = Maybe S3ContentLocation
a} :: CodeContent)

-- | The text-format code for a Flink-based Kinesis Data Analytics
-- application.
codeContent_textContent :: Lens.Lens' CodeContent (Prelude.Maybe Prelude.Text)
codeContent_textContent :: Lens' CodeContent (Maybe Text)
codeContent_textContent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContent' {Maybe Text
textContent :: Maybe Text
$sel:textContent:CodeContent' :: CodeContent -> Maybe Text
textContent} -> Maybe Text
textContent) (\s :: CodeContent
s@CodeContent' {} Maybe Text
a -> CodeContent
s {$sel:textContent:CodeContent' :: Maybe Text
textContent = Maybe Text
a} :: CodeContent)

-- | The zip-format code for a Flink-based Kinesis Data Analytics
-- application.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
codeContent_zipFileContent :: Lens.Lens' CodeContent (Prelude.Maybe Prelude.ByteString)
codeContent_zipFileContent :: Lens' CodeContent (Maybe ByteString)
codeContent_zipFileContent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContent' {Maybe Base64
zipFileContent :: Maybe Base64
$sel:zipFileContent:CodeContent' :: CodeContent -> Maybe Base64
zipFileContent} -> Maybe Base64
zipFileContent) (\s :: CodeContent
s@CodeContent' {} Maybe Base64
a -> CodeContent
s {$sel:zipFileContent:CodeContent' :: Maybe Base64
zipFileContent = Maybe Base64
a} :: CodeContent) 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 Iso' Base64 ByteString
Data._Base64

instance Prelude.Hashable CodeContent where
  hashWithSalt :: Int -> CodeContent -> Int
hashWithSalt Int
_salt CodeContent' {Maybe Text
Maybe Base64
Maybe S3ContentLocation
zipFileContent :: Maybe Base64
textContent :: Maybe Text
s3ContentLocation :: Maybe S3ContentLocation
$sel:zipFileContent:CodeContent' :: CodeContent -> Maybe Base64
$sel:textContent:CodeContent' :: CodeContent -> Maybe Text
$sel:s3ContentLocation:CodeContent' :: CodeContent -> Maybe S3ContentLocation
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3ContentLocation
s3ContentLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
textContent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Base64
zipFileContent

instance Prelude.NFData CodeContent where
  rnf :: CodeContent -> ()
rnf CodeContent' {Maybe Text
Maybe Base64
Maybe S3ContentLocation
zipFileContent :: Maybe Base64
textContent :: Maybe Text
s3ContentLocation :: Maybe S3ContentLocation
$sel:zipFileContent:CodeContent' :: CodeContent -> Maybe Base64
$sel:textContent:CodeContent' :: CodeContent -> Maybe Text
$sel:s3ContentLocation:CodeContent' :: CodeContent -> Maybe S3ContentLocation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe S3ContentLocation
s3ContentLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
textContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
zipFileContent

instance Data.ToJSON CodeContent where
  toJSON :: CodeContent -> Value
toJSON CodeContent' {Maybe Text
Maybe Base64
Maybe S3ContentLocation
zipFileContent :: Maybe Base64
textContent :: Maybe Text
s3ContentLocation :: Maybe S3ContentLocation
$sel:zipFileContent:CodeContent' :: CodeContent -> Maybe Base64
$sel:textContent:CodeContent' :: CodeContent -> Maybe Text
$sel:s3ContentLocation:CodeContent' :: CodeContent -> Maybe S3ContentLocation
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"S3ContentLocation" 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 S3ContentLocation
s3ContentLocation,
            (Key
"TextContent" 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
textContent,
            (Key
"ZipFileContent" 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 Base64
zipFileContent
          ]
      )