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

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.S3ContentLocation
import qualified Amazonka.Lens as Lens
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'
  { -- | The text-format code for a Flink-based Kinesis Data Analytics
    -- application.
    CodeContent -> Maybe Text
textContent :: Prelude.Maybe Prelude.Text,
    -- | Information about the Amazon S3 bucket that contains the application
    -- code.
    CodeContent -> Maybe S3ContentLocation
s3ContentLocation :: Prelude.Maybe S3ContentLocation,
    -- | The zip-format code for a Flink-based Kinesis Data Analytics
    -- application.
    CodeContent -> Maybe Base64
zipFileContent :: Prelude.Maybe Core.Base64
  }
  deriving (CodeContent -> CodeContent -> Bool
(CodeContent -> CodeContent -> Bool)
-> (CodeContent -> CodeContent -> Bool) -> Eq CodeContent
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]
(Int -> ReadS CodeContent)
-> ReadS [CodeContent]
-> ReadPrec CodeContent
-> ReadPrec [CodeContent]
-> Read 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
(Int -> CodeContent -> ShowS)
-> (CodeContent -> String)
-> ([CodeContent] -> ShowS)
-> Show CodeContent
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. CodeContent -> Rep CodeContent x)
-> (forall x. Rep CodeContent x -> CodeContent)
-> Generic CodeContent
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:
--
-- 'textContent', 'codeContent_textContent' - The text-format code for a Flink-based Kinesis Data Analytics
-- application.
--
-- 's3ContentLocation', 'codeContent_s3ContentLocation' - Information about the Amazon S3 bucket that contains the application
-- code.
--
-- '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' :: Maybe Text
-> Maybe S3ContentLocation -> Maybe Base64 -> CodeContent
CodeContent'
    { $sel:textContent:CodeContent' :: Maybe Text
textContent = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3ContentLocation:CodeContent' :: Maybe S3ContentLocation
s3ContentLocation = Maybe S3ContentLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:zipFileContent:CodeContent' :: Maybe Base64
zipFileContent = Maybe Base64
forall a. Maybe a
Prelude.Nothing
    }

-- | The text-format code for a Flink-based Kinesis Data Analytics
-- application.
codeContent_textContent :: Lens.Lens' CodeContent (Prelude.Maybe Prelude.Text)
codeContent_textContent :: (Maybe Text -> f (Maybe Text)) -> CodeContent -> f CodeContent
codeContent_textContent = (CodeContent -> Maybe Text)
-> (CodeContent -> Maybe Text -> CodeContent)
-> Lens CodeContent CodeContent (Maybe Text) (Maybe Text)
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)

-- | Information about the Amazon S3 bucket that contains the application
-- code.
codeContent_s3ContentLocation :: Lens.Lens' CodeContent (Prelude.Maybe S3ContentLocation)
codeContent_s3ContentLocation :: (Maybe S3ContentLocation -> f (Maybe S3ContentLocation))
-> CodeContent -> f CodeContent
codeContent_s3ContentLocation = (CodeContent -> Maybe S3ContentLocation)
-> (CodeContent -> Maybe S3ContentLocation -> CodeContent)
-> Lens
     CodeContent
     CodeContent
     (Maybe S3ContentLocation)
     (Maybe 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 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 :: (Maybe ByteString -> f (Maybe ByteString))
-> CodeContent -> f CodeContent
codeContent_zipFileContent = (CodeContent -> Maybe Base64)
-> (CodeContent -> Maybe Base64 -> CodeContent)
-> Lens CodeContent CodeContent (Maybe Base64) (Maybe Base64)
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) ((Maybe Base64 -> f (Maybe Base64))
 -> CodeContent -> f CodeContent)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> CodeContent
-> f CodeContent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
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 Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

instance Prelude.Hashable CodeContent

instance Prelude.NFData CodeContent

instance Core.ToJSON CodeContent where
  toJSON :: CodeContent -> Value
toJSON CodeContent' {Maybe Text
Maybe Base64
Maybe S3ContentLocation
zipFileContent :: Maybe Base64
s3ContentLocation :: Maybe S3ContentLocation
textContent :: Maybe Text
$sel:zipFileContent:CodeContent' :: CodeContent -> Maybe Base64
$sel:s3ContentLocation:CodeContent' :: CodeContent -> Maybe S3ContentLocation
$sel:textContent:CodeContent' :: CodeContent -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TextContent" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
textContent,
            (Text
"S3ContentLocation" Text -> S3ContentLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3ContentLocation -> Pair)
-> Maybe S3ContentLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3ContentLocation
s3ContentLocation,
            (Text
"ZipFileContent" Text -> Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Base64 -> Pair) -> Maybe Base64 -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Base64
zipFileContent
          ]
      )