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

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 the permissions for an image.
--
-- /See:/ 'newImagePermissions' smart constructor.
data ImagePermissions = ImagePermissions'
  { -- | Indicates whether the image can be used for a fleet.
    ImagePermissions -> Maybe Bool
allowFleet :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether the image can be used for an image builder.
    ImagePermissions -> Maybe Bool
allowImageBuilder :: Prelude.Maybe Prelude.Bool
  }
  deriving (ImagePermissions -> ImagePermissions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImagePermissions -> ImagePermissions -> Bool
$c/= :: ImagePermissions -> ImagePermissions -> Bool
== :: ImagePermissions -> ImagePermissions -> Bool
$c== :: ImagePermissions -> ImagePermissions -> Bool
Prelude.Eq, ReadPrec [ImagePermissions]
ReadPrec ImagePermissions
Int -> ReadS ImagePermissions
ReadS [ImagePermissions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImagePermissions]
$creadListPrec :: ReadPrec [ImagePermissions]
readPrec :: ReadPrec ImagePermissions
$creadPrec :: ReadPrec ImagePermissions
readList :: ReadS [ImagePermissions]
$creadList :: ReadS [ImagePermissions]
readsPrec :: Int -> ReadS ImagePermissions
$creadsPrec :: Int -> ReadS ImagePermissions
Prelude.Read, Int -> ImagePermissions -> ShowS
[ImagePermissions] -> ShowS
ImagePermissions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImagePermissions] -> ShowS
$cshowList :: [ImagePermissions] -> ShowS
show :: ImagePermissions -> String
$cshow :: ImagePermissions -> String
showsPrec :: Int -> ImagePermissions -> ShowS
$cshowsPrec :: Int -> ImagePermissions -> ShowS
Prelude.Show, forall x. Rep ImagePermissions x -> ImagePermissions
forall x. ImagePermissions -> Rep ImagePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImagePermissions x -> ImagePermissions
$cfrom :: forall x. ImagePermissions -> Rep ImagePermissions x
Prelude.Generic)

-- |
-- Create a value of 'ImagePermissions' 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:
--
-- 'allowFleet', 'imagePermissions_allowFleet' - Indicates whether the image can be used for a fleet.
--
-- 'allowImageBuilder', 'imagePermissions_allowImageBuilder' - Indicates whether the image can be used for an image builder.
newImagePermissions ::
  ImagePermissions
newImagePermissions :: ImagePermissions
newImagePermissions =
  ImagePermissions'
    { $sel:allowFleet:ImagePermissions' :: Maybe Bool
allowFleet = forall a. Maybe a
Prelude.Nothing,
      $sel:allowImageBuilder:ImagePermissions' :: Maybe Bool
allowImageBuilder = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the image can be used for a fleet.
imagePermissions_allowFleet :: Lens.Lens' ImagePermissions (Prelude.Maybe Prelude.Bool)
imagePermissions_allowFleet :: Lens' ImagePermissions (Maybe Bool)
imagePermissions_allowFleet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImagePermissions' {Maybe Bool
allowFleet :: Maybe Bool
$sel:allowFleet:ImagePermissions' :: ImagePermissions -> Maybe Bool
allowFleet} -> Maybe Bool
allowFleet) (\s :: ImagePermissions
s@ImagePermissions' {} Maybe Bool
a -> ImagePermissions
s {$sel:allowFleet:ImagePermissions' :: Maybe Bool
allowFleet = Maybe Bool
a} :: ImagePermissions)

-- | Indicates whether the image can be used for an image builder.
imagePermissions_allowImageBuilder :: Lens.Lens' ImagePermissions (Prelude.Maybe Prelude.Bool)
imagePermissions_allowImageBuilder :: Lens' ImagePermissions (Maybe Bool)
imagePermissions_allowImageBuilder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImagePermissions' {Maybe Bool
allowImageBuilder :: Maybe Bool
$sel:allowImageBuilder:ImagePermissions' :: ImagePermissions -> Maybe Bool
allowImageBuilder} -> Maybe Bool
allowImageBuilder) (\s :: ImagePermissions
s@ImagePermissions' {} Maybe Bool
a -> ImagePermissions
s {$sel:allowImageBuilder:ImagePermissions' :: Maybe Bool
allowImageBuilder = Maybe Bool
a} :: ImagePermissions)

instance Data.FromJSON ImagePermissions where
  parseJSON :: Value -> Parser ImagePermissions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImagePermissions"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> ImagePermissions
ImagePermissions'
            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
"allowFleet")
            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
"allowImageBuilder")
      )

instance Prelude.Hashable ImagePermissions where
  hashWithSalt :: Int -> ImagePermissions -> Int
hashWithSalt Int
_salt ImagePermissions' {Maybe Bool
allowImageBuilder :: Maybe Bool
allowFleet :: Maybe Bool
$sel:allowImageBuilder:ImagePermissions' :: ImagePermissions -> Maybe Bool
$sel:allowFleet:ImagePermissions' :: ImagePermissions -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowFleet
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowImageBuilder

instance Prelude.NFData ImagePermissions where
  rnf :: ImagePermissions -> ()
rnf ImagePermissions' {Maybe Bool
allowImageBuilder :: Maybe Bool
allowFleet :: Maybe Bool
$sel:allowImageBuilder:ImagePermissions' :: ImagePermissions -> Maybe Bool
$sel:allowFleet:ImagePermissions' :: ImagePermissions -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowFleet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowImageBuilder

instance Data.ToJSON ImagePermissions where
  toJSON :: ImagePermissions -> Value
toJSON ImagePermissions' {Maybe Bool
allowImageBuilder :: Maybe Bool
allowFleet :: Maybe Bool
$sel:allowImageBuilder:ImagePermissions' :: ImagePermissions -> Maybe Bool
$sel:allowFleet:ImagePermissions' :: ImagePermissions -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"allowFleet" 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 Bool
allowFleet,
            (Key
"allowImageBuilder" 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 Bool
allowImageBuilder
          ]
      )