{-# 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-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.ApplicationCodeConfiguration 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.CodeContent
import Amazonka.KinesisAnalyticsV2.Types.CodeContentType
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
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]
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
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.
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'
    { $sel:codeContent:ApplicationCodeConfiguration' :: Maybe CodeContent
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 :: Lens' ApplicationCodeConfiguration (Maybe CodeContent)
applicationCodeConfiguration_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 :: Lens' ApplicationCodeConfiguration CodeContentType
applicationCodeConfiguration_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
  where
  hashWithSalt :: Int -> ApplicationCodeConfiguration -> Int
hashWithSalt Int
_salt ApplicationCodeConfiguration' {Maybe CodeContent
CodeContentType
codeContentType :: CodeContentType
codeContent :: Maybe CodeContent
$sel:codeContentType:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> CodeContentType
$sel:codeContent:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> Maybe CodeContent
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CodeContent
codeContent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CodeContentType
codeContentType

instance Prelude.NFData ApplicationCodeConfiguration where
  rnf :: ApplicationCodeConfiguration -> ()
rnf ApplicationCodeConfiguration' {Maybe CodeContent
CodeContentType
codeContentType :: CodeContentType
codeContent :: Maybe CodeContent
$sel:codeContentType:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> CodeContentType
$sel:codeContent:ApplicationCodeConfiguration' :: ApplicationCodeConfiguration -> Maybe CodeContent
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CodeContent
codeContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CodeContentType
codeContentType

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CodeContent" 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 CodeContent
codeContent,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"CodeContentType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CodeContentType
codeContentType)
          ]
      )