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

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

-- | Describes an update to the code of an application. Not supported for
-- Apache Zeppelin.
--
-- /See:/ 'newCodeContentUpdate' smart constructor.
data CodeContentUpdate = CodeContentUpdate'
  { -- | Describes an update to the text code for an application.
    CodeContentUpdate -> Maybe Text
textContentUpdate :: Prelude.Maybe Prelude.Text,
    -- | Describes an update to the zipped code for an application.
    CodeContentUpdate -> Maybe Base64
zipFileContentUpdate :: Prelude.Maybe Core.Base64,
    -- | Describes an update to the location of code for an application.
    CodeContentUpdate -> Maybe S3ContentLocationUpdate
s3ContentLocationUpdate :: Prelude.Maybe S3ContentLocationUpdate
  }
  deriving (CodeContentUpdate -> CodeContentUpdate -> Bool
(CodeContentUpdate -> CodeContentUpdate -> Bool)
-> (CodeContentUpdate -> CodeContentUpdate -> Bool)
-> Eq CodeContentUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeContentUpdate -> CodeContentUpdate -> Bool
$c/= :: CodeContentUpdate -> CodeContentUpdate -> Bool
== :: CodeContentUpdate -> CodeContentUpdate -> Bool
$c== :: CodeContentUpdate -> CodeContentUpdate -> Bool
Prelude.Eq, ReadPrec [CodeContentUpdate]
ReadPrec CodeContentUpdate
Int -> ReadS CodeContentUpdate
ReadS [CodeContentUpdate]
(Int -> ReadS CodeContentUpdate)
-> ReadS [CodeContentUpdate]
-> ReadPrec CodeContentUpdate
-> ReadPrec [CodeContentUpdate]
-> Read CodeContentUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeContentUpdate]
$creadListPrec :: ReadPrec [CodeContentUpdate]
readPrec :: ReadPrec CodeContentUpdate
$creadPrec :: ReadPrec CodeContentUpdate
readList :: ReadS [CodeContentUpdate]
$creadList :: ReadS [CodeContentUpdate]
readsPrec :: Int -> ReadS CodeContentUpdate
$creadsPrec :: Int -> ReadS CodeContentUpdate
Prelude.Read, Int -> CodeContentUpdate -> ShowS
[CodeContentUpdate] -> ShowS
CodeContentUpdate -> String
(Int -> CodeContentUpdate -> ShowS)
-> (CodeContentUpdate -> String)
-> ([CodeContentUpdate] -> ShowS)
-> Show CodeContentUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeContentUpdate] -> ShowS
$cshowList :: [CodeContentUpdate] -> ShowS
show :: CodeContentUpdate -> String
$cshow :: CodeContentUpdate -> String
showsPrec :: Int -> CodeContentUpdate -> ShowS
$cshowsPrec :: Int -> CodeContentUpdate -> ShowS
Prelude.Show, (forall x. CodeContentUpdate -> Rep CodeContentUpdate x)
-> (forall x. Rep CodeContentUpdate x -> CodeContentUpdate)
-> Generic CodeContentUpdate
forall x. Rep CodeContentUpdate x -> CodeContentUpdate
forall x. CodeContentUpdate -> Rep CodeContentUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeContentUpdate x -> CodeContentUpdate
$cfrom :: forall x. CodeContentUpdate -> Rep CodeContentUpdate x
Prelude.Generic)

-- |
-- Create a value of 'CodeContentUpdate' 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:
--
-- 'textContentUpdate', 'codeContentUpdate_textContentUpdate' - Describes an update to the text code for an application.
--
-- 'zipFileContentUpdate', 'codeContentUpdate_zipFileContentUpdate' - Describes an update to the zipped code for an 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.
--
-- 's3ContentLocationUpdate', 'codeContentUpdate_s3ContentLocationUpdate' - Describes an update to the location of code for an application.
newCodeContentUpdate ::
  CodeContentUpdate
newCodeContentUpdate :: CodeContentUpdate
newCodeContentUpdate =
  CodeContentUpdate' :: Maybe Text
-> Maybe Base64
-> Maybe S3ContentLocationUpdate
-> CodeContentUpdate
CodeContentUpdate'
    { $sel:textContentUpdate:CodeContentUpdate' :: Maybe Text
textContentUpdate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:zipFileContentUpdate:CodeContentUpdate' :: Maybe Base64
zipFileContentUpdate = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:s3ContentLocationUpdate:CodeContentUpdate' :: Maybe S3ContentLocationUpdate
s3ContentLocationUpdate = Maybe S3ContentLocationUpdate
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes an update to the text code for an application.
codeContentUpdate_textContentUpdate :: Lens.Lens' CodeContentUpdate (Prelude.Maybe Prelude.Text)
codeContentUpdate_textContentUpdate :: (Maybe Text -> f (Maybe Text))
-> CodeContentUpdate -> f CodeContentUpdate
codeContentUpdate_textContentUpdate = (CodeContentUpdate -> Maybe Text)
-> (CodeContentUpdate -> Maybe Text -> CodeContentUpdate)
-> Lens
     CodeContentUpdate CodeContentUpdate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentUpdate' {Maybe Text
textContentUpdate :: Maybe Text
$sel:textContentUpdate:CodeContentUpdate' :: CodeContentUpdate -> Maybe Text
textContentUpdate} -> Maybe Text
textContentUpdate) (\s :: CodeContentUpdate
s@CodeContentUpdate' {} Maybe Text
a -> CodeContentUpdate
s {$sel:textContentUpdate:CodeContentUpdate' :: Maybe Text
textContentUpdate = Maybe Text
a} :: CodeContentUpdate)

-- | Describes an update to the zipped code for an 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.
codeContentUpdate_zipFileContentUpdate :: Lens.Lens' CodeContentUpdate (Prelude.Maybe Prelude.ByteString)
codeContentUpdate_zipFileContentUpdate :: (Maybe ByteString -> f (Maybe ByteString))
-> CodeContentUpdate -> f CodeContentUpdate
codeContentUpdate_zipFileContentUpdate = (CodeContentUpdate -> Maybe Base64)
-> (CodeContentUpdate -> Maybe Base64 -> CodeContentUpdate)
-> Lens
     CodeContentUpdate CodeContentUpdate (Maybe Base64) (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentUpdate' {Maybe Base64
zipFileContentUpdate :: Maybe Base64
$sel:zipFileContentUpdate:CodeContentUpdate' :: CodeContentUpdate -> Maybe Base64
zipFileContentUpdate} -> Maybe Base64
zipFileContentUpdate) (\s :: CodeContentUpdate
s@CodeContentUpdate' {} Maybe Base64
a -> CodeContentUpdate
s {$sel:zipFileContentUpdate:CodeContentUpdate' :: Maybe Base64
zipFileContentUpdate = Maybe Base64
a} :: CodeContentUpdate) ((Maybe Base64 -> f (Maybe Base64))
 -> CodeContentUpdate -> f CodeContentUpdate)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> CodeContentUpdate
-> f CodeContentUpdate
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

-- | Describes an update to the location of code for an application.
codeContentUpdate_s3ContentLocationUpdate :: Lens.Lens' CodeContentUpdate (Prelude.Maybe S3ContentLocationUpdate)
codeContentUpdate_s3ContentLocationUpdate :: (Maybe S3ContentLocationUpdate
 -> f (Maybe S3ContentLocationUpdate))
-> CodeContentUpdate -> f CodeContentUpdate
codeContentUpdate_s3ContentLocationUpdate = (CodeContentUpdate -> Maybe S3ContentLocationUpdate)
-> (CodeContentUpdate
    -> Maybe S3ContentLocationUpdate -> CodeContentUpdate)
-> Lens
     CodeContentUpdate
     CodeContentUpdate
     (Maybe S3ContentLocationUpdate)
     (Maybe S3ContentLocationUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeContentUpdate' {Maybe S3ContentLocationUpdate
s3ContentLocationUpdate :: Maybe S3ContentLocationUpdate
$sel:s3ContentLocationUpdate:CodeContentUpdate' :: CodeContentUpdate -> Maybe S3ContentLocationUpdate
s3ContentLocationUpdate} -> Maybe S3ContentLocationUpdate
s3ContentLocationUpdate) (\s :: CodeContentUpdate
s@CodeContentUpdate' {} Maybe S3ContentLocationUpdate
a -> CodeContentUpdate
s {$sel:s3ContentLocationUpdate:CodeContentUpdate' :: Maybe S3ContentLocationUpdate
s3ContentLocationUpdate = Maybe S3ContentLocationUpdate
a} :: CodeContentUpdate)

instance Prelude.Hashable CodeContentUpdate

instance Prelude.NFData CodeContentUpdate

instance Core.ToJSON CodeContentUpdate where
  toJSON :: CodeContentUpdate -> Value
toJSON CodeContentUpdate' {Maybe Text
Maybe Base64
Maybe S3ContentLocationUpdate
s3ContentLocationUpdate :: Maybe S3ContentLocationUpdate
zipFileContentUpdate :: Maybe Base64
textContentUpdate :: Maybe Text
$sel:s3ContentLocationUpdate:CodeContentUpdate' :: CodeContentUpdate -> Maybe S3ContentLocationUpdate
$sel:zipFileContentUpdate:CodeContentUpdate' :: CodeContentUpdate -> Maybe Base64
$sel:textContentUpdate:CodeContentUpdate' :: CodeContentUpdate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TextContentUpdate" 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
textContentUpdate,
            (Text
"ZipFileContentUpdate" 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
zipFileContentUpdate,
            (Text
"S3ContentLocationUpdate" Text -> S3ContentLocationUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3ContentLocationUpdate -> Pair)
-> Maybe S3ContentLocationUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3ContentLocationUpdate
s3ContentLocationUpdate
          ]
      )