{-# 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.AppStream.Types.AppBlock
-- 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.AppStream.Types.AppBlock where

import Amazonka.AppStream.Types.S3Location
import Amazonka.AppStream.Types.ScriptDetails
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes an app block.
--
-- App blocks are an Amazon AppStream 2.0 resource that stores the details
-- about the virtual hard disk in an S3 bucket. It also stores the setup
-- script with details about how to mount the virtual hard disk. The
-- virtual hard disk includes the application binaries and other files
-- necessary to launch your applications. Multiple applications can be
-- assigned to a single app block.
--
-- This is only supported for Elastic fleets.
--
-- /See:/ 'newAppBlock' smart constructor.
data AppBlock = AppBlock'
  { -- | The created time of the app block.
    AppBlock -> Maybe POSIX
createdTime :: Prelude.Maybe Data.POSIX,
    -- | The description of the app block.
    AppBlock -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The display name of the app block.
    AppBlock -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The source S3 location of the app block.
    AppBlock -> Maybe S3Location
sourceS3Location :: Prelude.Maybe S3Location,
    -- | The name of the app block.
    AppBlock -> Text
name :: Prelude.Text,
    -- | The ARN of the app block.
    AppBlock -> Text
arn :: Prelude.Text,
    -- | The setup script details of the app block.
    AppBlock -> ScriptDetails
setupScriptDetails :: ScriptDetails
  }
  deriving (AppBlock -> AppBlock -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppBlock -> AppBlock -> Bool
$c/= :: AppBlock -> AppBlock -> Bool
== :: AppBlock -> AppBlock -> Bool
$c== :: AppBlock -> AppBlock -> Bool
Prelude.Eq, ReadPrec [AppBlock]
ReadPrec AppBlock
Int -> ReadS AppBlock
ReadS [AppBlock]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppBlock]
$creadListPrec :: ReadPrec [AppBlock]
readPrec :: ReadPrec AppBlock
$creadPrec :: ReadPrec AppBlock
readList :: ReadS [AppBlock]
$creadList :: ReadS [AppBlock]
readsPrec :: Int -> ReadS AppBlock
$creadsPrec :: Int -> ReadS AppBlock
Prelude.Read, Int -> AppBlock -> ShowS
[AppBlock] -> ShowS
AppBlock -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppBlock] -> ShowS
$cshowList :: [AppBlock] -> ShowS
show :: AppBlock -> String
$cshow :: AppBlock -> String
showsPrec :: Int -> AppBlock -> ShowS
$cshowsPrec :: Int -> AppBlock -> ShowS
Prelude.Show, forall x. Rep AppBlock x -> AppBlock
forall x. AppBlock -> Rep AppBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AppBlock x -> AppBlock
$cfrom :: forall x. AppBlock -> Rep AppBlock x
Prelude.Generic)

-- |
-- Create a value of 'AppBlock' 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:
--
-- 'createdTime', 'appBlock_createdTime' - The created time of the app block.
--
-- 'description', 'appBlock_description' - The description of the app block.
--
-- 'displayName', 'appBlock_displayName' - The display name of the app block.
--
-- 'sourceS3Location', 'appBlock_sourceS3Location' - The source S3 location of the app block.
--
-- 'name', 'appBlock_name' - The name of the app block.
--
-- 'arn', 'appBlock_arn' - The ARN of the app block.
--
-- 'setupScriptDetails', 'appBlock_setupScriptDetails' - The setup script details of the app block.
newAppBlock ::
  -- | 'name'
  Prelude.Text ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'setupScriptDetails'
  ScriptDetails ->
  AppBlock
newAppBlock :: Text -> Text -> ScriptDetails -> AppBlock
newAppBlock Text
pName_ Text
pArn_ ScriptDetails
pSetupScriptDetails_ =
  AppBlock'
    { $sel:createdTime:AppBlock' :: Maybe POSIX
createdTime = forall a. Maybe a
Prelude.Nothing,
      $sel:description:AppBlock' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:AppBlock' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceS3Location:AppBlock' :: Maybe S3Location
sourceS3Location = forall a. Maybe a
Prelude.Nothing,
      $sel:name:AppBlock' :: Text
name = Text
pName_,
      $sel:arn:AppBlock' :: Text
arn = Text
pArn_,
      $sel:setupScriptDetails:AppBlock' :: ScriptDetails
setupScriptDetails = ScriptDetails
pSetupScriptDetails_
    }

-- | The created time of the app block.
appBlock_createdTime :: Lens.Lens' AppBlock (Prelude.Maybe Prelude.UTCTime)
appBlock_createdTime :: Lens' AppBlock (Maybe UTCTime)
appBlock_createdTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {Maybe POSIX
createdTime :: Maybe POSIX
$sel:createdTime:AppBlock' :: AppBlock -> Maybe POSIX
createdTime} -> Maybe POSIX
createdTime) (\s :: AppBlock
s@AppBlock' {} Maybe POSIX
a -> AppBlock
s {$sel:createdTime:AppBlock' :: Maybe POSIX
createdTime = Maybe POSIX
a} :: AppBlock) 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The description of the app block.
appBlock_description :: Lens.Lens' AppBlock (Prelude.Maybe Prelude.Text)
appBlock_description :: Lens' AppBlock (Maybe Text)
appBlock_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {Maybe Text
description :: Maybe Text
$sel:description:AppBlock' :: AppBlock -> Maybe Text
description} -> Maybe Text
description) (\s :: AppBlock
s@AppBlock' {} Maybe Text
a -> AppBlock
s {$sel:description:AppBlock' :: Maybe Text
description = Maybe Text
a} :: AppBlock)

-- | The display name of the app block.
appBlock_displayName :: Lens.Lens' AppBlock (Prelude.Maybe Prelude.Text)
appBlock_displayName :: Lens' AppBlock (Maybe Text)
appBlock_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {Maybe Text
displayName :: Maybe Text
$sel:displayName:AppBlock' :: AppBlock -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: AppBlock
s@AppBlock' {} Maybe Text
a -> AppBlock
s {$sel:displayName:AppBlock' :: Maybe Text
displayName = Maybe Text
a} :: AppBlock)

-- | The source S3 location of the app block.
appBlock_sourceS3Location :: Lens.Lens' AppBlock (Prelude.Maybe S3Location)
appBlock_sourceS3Location :: Lens' AppBlock (Maybe S3Location)
appBlock_sourceS3Location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {Maybe S3Location
sourceS3Location :: Maybe S3Location
$sel:sourceS3Location:AppBlock' :: AppBlock -> Maybe S3Location
sourceS3Location} -> Maybe S3Location
sourceS3Location) (\s :: AppBlock
s@AppBlock' {} Maybe S3Location
a -> AppBlock
s {$sel:sourceS3Location:AppBlock' :: Maybe S3Location
sourceS3Location = Maybe S3Location
a} :: AppBlock)

-- | The name of the app block.
appBlock_name :: Lens.Lens' AppBlock Prelude.Text
appBlock_name :: Lens' AppBlock Text
appBlock_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {Text
name :: Text
$sel:name:AppBlock' :: AppBlock -> Text
name} -> Text
name) (\s :: AppBlock
s@AppBlock' {} Text
a -> AppBlock
s {$sel:name:AppBlock' :: Text
name = Text
a} :: AppBlock)

-- | The ARN of the app block.
appBlock_arn :: Lens.Lens' AppBlock Prelude.Text
appBlock_arn :: Lens' AppBlock Text
appBlock_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {Text
arn :: Text
$sel:arn:AppBlock' :: AppBlock -> Text
arn} -> Text
arn) (\s :: AppBlock
s@AppBlock' {} Text
a -> AppBlock
s {$sel:arn:AppBlock' :: Text
arn = Text
a} :: AppBlock)

-- | The setup script details of the app block.
appBlock_setupScriptDetails :: Lens.Lens' AppBlock ScriptDetails
appBlock_setupScriptDetails :: Lens' AppBlock ScriptDetails
appBlock_setupScriptDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppBlock' {ScriptDetails
setupScriptDetails :: ScriptDetails
$sel:setupScriptDetails:AppBlock' :: AppBlock -> ScriptDetails
setupScriptDetails} -> ScriptDetails
setupScriptDetails) (\s :: AppBlock
s@AppBlock' {} ScriptDetails
a -> AppBlock
s {$sel:setupScriptDetails:AppBlock' :: ScriptDetails
setupScriptDetails = ScriptDetails
a} :: AppBlock)

instance Data.FromJSON AppBlock where
  parseJSON :: Value -> Parser AppBlock
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AppBlock"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe S3Location
-> Text
-> Text
-> ScriptDetails
-> AppBlock
AppBlock'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreatedTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DisplayName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SourceS3Location")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SetupScriptDetails")
      )

instance Prelude.Hashable AppBlock where
  hashWithSalt :: Int -> AppBlock -> Int
hashWithSalt Int
_salt AppBlock' {Maybe Text
Maybe POSIX
Maybe S3Location
Text
ScriptDetails
setupScriptDetails :: ScriptDetails
arn :: Text
name :: Text
sourceS3Location :: Maybe S3Location
displayName :: Maybe Text
description :: Maybe Text
createdTime :: Maybe POSIX
$sel:setupScriptDetails:AppBlock' :: AppBlock -> ScriptDetails
$sel:arn:AppBlock' :: AppBlock -> Text
$sel:name:AppBlock' :: AppBlock -> Text
$sel:sourceS3Location:AppBlock' :: AppBlock -> Maybe S3Location
$sel:displayName:AppBlock' :: AppBlock -> Maybe Text
$sel:description:AppBlock' :: AppBlock -> Maybe Text
$sel:createdTime:AppBlock' :: AppBlock -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3Location
sourceS3Location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ScriptDetails
setupScriptDetails

instance Prelude.NFData AppBlock where
  rnf :: AppBlock -> ()
rnf AppBlock' {Maybe Text
Maybe POSIX
Maybe S3Location
Text
ScriptDetails
setupScriptDetails :: ScriptDetails
arn :: Text
name :: Text
sourceS3Location :: Maybe S3Location
displayName :: Maybe Text
description :: Maybe Text
createdTime :: Maybe POSIX
$sel:setupScriptDetails:AppBlock' :: AppBlock -> ScriptDetails
$sel:arn:AppBlock' :: AppBlock -> Text
$sel:name:AppBlock' :: AppBlock -> Text
$sel:sourceS3Location:AppBlock' :: AppBlock -> Maybe S3Location
$sel:displayName:AppBlock' :: AppBlock -> Maybe Text
$sel:description:AppBlock' :: AppBlock -> Maybe Text
$sel:createdTime:AppBlock' :: AppBlock -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3Location
sourceS3Location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScriptDetails
setupScriptDetails