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

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.CodeContent
import Amazonka.KinesisAnalyticsV2.Types.CodeContentType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes code configuration for an application.
--
-- /See:/ 'newApplicationCodeConfiguration' smart constructor.
data ApplicationCodeConfiguration = ApplicationCodeConfiguration'
  { -- | The location and type of the application code.
    ApplicationCodeConfiguration -> Maybe CodeContent
codeContent :: Prelude.Maybe CodeContent,
    -- | Specifies whether the code content is in text or zip format.
    ApplicationCodeConfiguration -> CodeContentType
codeContentType :: CodeContentType
  }
  deriving (ApplicationCodeConfiguration
-> ApplicationCodeConfiguration -> Bool
(ApplicationCodeConfiguration
 -> ApplicationCodeConfiguration -> Bool)
-> (ApplicationCodeConfiguration
    -> ApplicationCodeConfiguration -> Bool)
-> Eq ApplicationCodeConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationCodeConfiguration
-> ApplicationCodeConfiguration -> Bool
$c/= :: ApplicationCodeConfiguration
-> ApplicationCodeConfiguration -> Bool
== :: ApplicationCodeConfiguration
-> ApplicationCodeConfiguration -> Bool
$c== :: ApplicationCodeConfiguration
-> ApplicationCodeConfiguration -> Bool
Prelude.Eq, ReadPrec [ApplicationCodeConfiguration]
ReadPrec ApplicationCodeConfiguration
Int -> ReadS ApplicationCodeConfiguration
ReadS [ApplicationCodeConfiguration]
(Int -> ReadS ApplicationCodeConfiguration)
-> ReadS [ApplicationCodeConfiguration]
-> ReadPrec ApplicationCodeConfiguration
-> ReadPrec [ApplicationCodeConfiguration]
-> Read ApplicationCodeConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationCodeConfiguration]
$creadListPrec :: ReadPrec [ApplicationCodeConfiguration]
readPrec :: ReadPrec ApplicationCodeConfiguration
$creadPrec :: ReadPrec ApplicationCodeConfiguration
readList :: ReadS [ApplicationCodeConfiguration]
$creadList :: ReadS [ApplicationCodeConfiguration]
readsPrec :: Int -> ReadS ApplicationCodeConfiguration
$creadsPrec :: Int -> ReadS ApplicationCodeConfiguration
Prelude.Read, Int -> ApplicationCodeConfiguration -> ShowS
[ApplicationCodeConfiguration] -> ShowS
ApplicationCodeConfiguration -> String
(Int -> ApplicationCodeConfiguration -> ShowS)
-> (ApplicationCodeConfiguration -> String)
-> ([ApplicationCodeConfiguration] -> ShowS)
-> Show ApplicationCodeConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationCodeConfiguration] -> ShowS
$cshowList :: [ApplicationCodeConfiguration] -> ShowS
show :: ApplicationCodeConfiguration -> String
$cshow :: ApplicationCodeConfiguration -> String
showsPrec :: Int -> ApplicationCodeConfiguration -> ShowS
$cshowsPrec :: Int -> ApplicationCodeConfiguration -> ShowS
Prelude.Show, (forall x.
 ApplicationCodeConfiguration -> Rep ApplicationCodeConfiguration x)
-> (forall x.
    Rep ApplicationCodeConfiguration x -> ApplicationCodeConfiguration)
-> Generic ApplicationCodeConfiguration
forall x.
Rep ApplicationCodeConfiguration x -> ApplicationCodeConfiguration
forall x.
ApplicationCodeConfiguration -> Rep ApplicationCodeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ApplicationCodeConfiguration x -> ApplicationCodeConfiguration
$cfrom :: forall x.
ApplicationCodeConfiguration -> Rep ApplicationCodeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationCodeConfiguration' 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:
--
-- 'codeContent', 'applicationCodeConfiguration_codeContent' - The location and type of the application code.
--
-- 'codeContentType', 'applicationCodeConfiguration_codeContentType' - Specifies whether the code content is in text or zip format.
newApplicationCodeConfiguration ::
  -- | 'codeContentType'
  CodeContentType ->
  ApplicationCodeConfiguration
newApplicationCodeConfiguration :: CodeContentType -> ApplicationCodeConfiguration
newApplicationCodeConfiguration CodeContentType
pCodeContentType_ =
  ApplicationCodeConfiguration' :: Maybe CodeContent
-> CodeContentType -> ApplicationCodeConfiguration
ApplicationCodeConfiguration'
    { $sel:codeContent:ApplicationCodeConfiguration' :: Maybe CodeContent
codeContent =
        Maybe CodeContent
forall a. Maybe a
Prelude.Nothing,
      $sel:codeContentType:ApplicationCodeConfiguration' :: CodeContentType
codeContentType = CodeContentType
pCodeContentType_
    }

-- | The location and type of the application code.
applicationCodeConfiguration_codeContent :: Lens.Lens' ApplicationCodeConfiguration (Prelude.Maybe CodeContent)
applicationCodeConfiguration_codeContent :: (Maybe CodeContent -> f (Maybe CodeContent))
-> ApplicationCodeConfiguration -> f ApplicationCodeConfiguration
applicationCodeConfiguration_codeContent = (ApplicationCodeConfiguration -> Maybe CodeContent)
-> (ApplicationCodeConfiguration
    -> Maybe CodeContent -> ApplicationCodeConfiguration)
-> Lens
     ApplicationCodeConfiguration
     ApplicationCodeConfiguration
     (Maybe CodeContent)
     (Maybe CodeContent)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationCodeConfiguration' {Maybe CodeContent
codeContent :: Maybe CodeContent
$sel:codeContent:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> Maybe CodeContent
codeContent} -> Maybe CodeContent
codeContent) (\s :: ApplicationCodeConfiguration
s@ApplicationCodeConfiguration' {} Maybe CodeContent
a -> ApplicationCodeConfiguration
s {$sel:codeContent:ApplicationCodeConfiguration' :: Maybe CodeContent
codeContent = Maybe CodeContent
a} :: ApplicationCodeConfiguration)

-- | Specifies whether the code content is in text or zip format.
applicationCodeConfiguration_codeContentType :: Lens.Lens' ApplicationCodeConfiguration CodeContentType
applicationCodeConfiguration_codeContentType :: (CodeContentType -> f CodeContentType)
-> ApplicationCodeConfiguration -> f ApplicationCodeConfiguration
applicationCodeConfiguration_codeContentType = (ApplicationCodeConfiguration -> CodeContentType)
-> (ApplicationCodeConfiguration
    -> CodeContentType -> ApplicationCodeConfiguration)
-> Lens
     ApplicationCodeConfiguration
     ApplicationCodeConfiguration
     CodeContentType
     CodeContentType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationCodeConfiguration' {CodeContentType
codeContentType :: CodeContentType
$sel:codeContentType:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> CodeContentType
codeContentType} -> CodeContentType
codeContentType) (\s :: ApplicationCodeConfiguration
s@ApplicationCodeConfiguration' {} CodeContentType
a -> ApplicationCodeConfiguration
s {$sel:codeContentType:ApplicationCodeConfiguration' :: CodeContentType
codeContentType = CodeContentType
a} :: ApplicationCodeConfiguration)

instance
  Prelude.Hashable
    ApplicationCodeConfiguration

instance Prelude.NFData ApplicationCodeConfiguration

instance Core.ToJSON ApplicationCodeConfiguration where
  toJSON :: ApplicationCodeConfiguration -> Value
toJSON ApplicationCodeConfiguration' {Maybe CodeContent
CodeContentType
codeContentType :: CodeContentType
codeContent :: Maybe CodeContent
$sel:codeContentType:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> CodeContentType
$sel:codeContent:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> Maybe CodeContent
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CodeContent" Text -> CodeContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CodeContent -> Pair) -> Maybe CodeContent -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CodeContent
codeContent,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CodeContentType" Text -> CodeContentType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CodeContentType
codeContentType)
          ]
      )