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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ImagePermissions -> ImagePermissions -> Bool)
-> (ImagePermissions -> ImagePermissions -> Bool)
-> Eq ImagePermissions
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]
(Int -> ReadS ImagePermissions)
-> ReadS [ImagePermissions]
-> ReadPrec ImagePermissions
-> ReadPrec [ImagePermissions]
-> Read 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
(Int -> ImagePermissions -> ShowS)
-> (ImagePermissions -> String)
-> ([ImagePermissions] -> ShowS)
-> Show ImagePermissions
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. ImagePermissions -> Rep ImagePermissions x)
-> (forall x. Rep ImagePermissions x -> ImagePermissions)
-> Generic ImagePermissions
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' :: Maybe Bool -> Maybe Bool -> ImagePermissions
ImagePermissions'
    { $sel:allowFleet:ImagePermissions' :: Maybe Bool
allowFleet = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:allowImageBuilder:ImagePermissions' :: Maybe Bool
allowImageBuilder = Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> ImagePermissions -> f ImagePermissions
imagePermissions_allowFleet = (ImagePermissions -> Maybe Bool)
-> (ImagePermissions -> Maybe Bool -> ImagePermissions)
-> Lens ImagePermissions ImagePermissions (Maybe Bool) (Maybe Bool)
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 :: (Maybe Bool -> f (Maybe Bool))
-> ImagePermissions -> f ImagePermissions
imagePermissions_allowImageBuilder = (ImagePermissions -> Maybe Bool)
-> (ImagePermissions -> Maybe Bool -> ImagePermissions)
-> Lens ImagePermissions ImagePermissions (Maybe Bool) (Maybe Bool)
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 Core.FromJSON ImagePermissions where
  parseJSON :: Value -> Parser ImagePermissions
parseJSON =
    String
-> (Object -> Parser ImagePermissions)
-> Value
-> Parser ImagePermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImagePermissions"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> ImagePermissions
ImagePermissions'
            (Maybe Bool -> Maybe Bool -> ImagePermissions)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> ImagePermissions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowFleet")
            Parser (Maybe Bool -> ImagePermissions)
-> Parser (Maybe Bool) -> Parser ImagePermissions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowImageBuilder")
      )

instance Prelude.Hashable ImagePermissions

instance Prelude.NFData ImagePermissions

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"allowFleet" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowFleet,
            (Text
"allowImageBuilder" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowImageBuilder
          ]
      )