{-# 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.WorkSpaces.Types.ImagePermission
-- 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.WorkSpaces.Types.ImagePermission where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the Amazon Web Services accounts that have been granted
-- permission to use a shared image. For more information about sharing
-- images, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/share-custom-image.html Share or Unshare a Custom WorkSpaces Image>.
--
-- /See:/ 'newImagePermission' smart constructor.
data ImagePermission = ImagePermission'
  { -- | The identifier of the Amazon Web Services account that an image has been
    -- shared with.
    ImagePermission -> Maybe Text
sharedAccountId :: Prelude.Maybe Prelude.Text
  }
  deriving (ImagePermission -> ImagePermission -> Bool
(ImagePermission -> ImagePermission -> Bool)
-> (ImagePermission -> ImagePermission -> Bool)
-> Eq ImagePermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImagePermission -> ImagePermission -> Bool
$c/= :: ImagePermission -> ImagePermission -> Bool
== :: ImagePermission -> ImagePermission -> Bool
$c== :: ImagePermission -> ImagePermission -> Bool
Prelude.Eq, ReadPrec [ImagePermission]
ReadPrec ImagePermission
Int -> ReadS ImagePermission
ReadS [ImagePermission]
(Int -> ReadS ImagePermission)
-> ReadS [ImagePermission]
-> ReadPrec ImagePermission
-> ReadPrec [ImagePermission]
-> Read ImagePermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImagePermission]
$creadListPrec :: ReadPrec [ImagePermission]
readPrec :: ReadPrec ImagePermission
$creadPrec :: ReadPrec ImagePermission
readList :: ReadS [ImagePermission]
$creadList :: ReadS [ImagePermission]
readsPrec :: Int -> ReadS ImagePermission
$creadsPrec :: Int -> ReadS ImagePermission
Prelude.Read, Int -> ImagePermission -> ShowS
[ImagePermission] -> ShowS
ImagePermission -> String
(Int -> ImagePermission -> ShowS)
-> (ImagePermission -> String)
-> ([ImagePermission] -> ShowS)
-> Show ImagePermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImagePermission] -> ShowS
$cshowList :: [ImagePermission] -> ShowS
show :: ImagePermission -> String
$cshow :: ImagePermission -> String
showsPrec :: Int -> ImagePermission -> ShowS
$cshowsPrec :: Int -> ImagePermission -> ShowS
Prelude.Show, (forall x. ImagePermission -> Rep ImagePermission x)
-> (forall x. Rep ImagePermission x -> ImagePermission)
-> Generic ImagePermission
forall x. Rep ImagePermission x -> ImagePermission
forall x. ImagePermission -> Rep ImagePermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImagePermission x -> ImagePermission
$cfrom :: forall x. ImagePermission -> Rep ImagePermission x
Prelude.Generic)

-- |
-- Create a value of 'ImagePermission' 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:
--
-- 'sharedAccountId', 'imagePermission_sharedAccountId' - The identifier of the Amazon Web Services account that an image has been
-- shared with.
newImagePermission ::
  ImagePermission
newImagePermission :: ImagePermission
newImagePermission =
  ImagePermission' :: Maybe Text -> ImagePermission
ImagePermission' {$sel:sharedAccountId:ImagePermission' :: Maybe Text
sharedAccountId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The identifier of the Amazon Web Services account that an image has been
-- shared with.
imagePermission_sharedAccountId :: Lens.Lens' ImagePermission (Prelude.Maybe Prelude.Text)
imagePermission_sharedAccountId :: (Maybe Text -> f (Maybe Text))
-> ImagePermission -> f ImagePermission
imagePermission_sharedAccountId = (ImagePermission -> Maybe Text)
-> (ImagePermission -> Maybe Text -> ImagePermission)
-> Lens ImagePermission ImagePermission (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImagePermission' {Maybe Text
sharedAccountId :: Maybe Text
$sel:sharedAccountId:ImagePermission' :: ImagePermission -> Maybe Text
sharedAccountId} -> Maybe Text
sharedAccountId) (\s :: ImagePermission
s@ImagePermission' {} Maybe Text
a -> ImagePermission
s {$sel:sharedAccountId:ImagePermission' :: Maybe Text
sharedAccountId = Maybe Text
a} :: ImagePermission)

instance Core.FromJSON ImagePermission where
  parseJSON :: Value -> Parser ImagePermission
parseJSON =
    String
-> (Object -> Parser ImagePermission)
-> Value
-> Parser ImagePermission
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImagePermission"
      ( \Object
x ->
          Maybe Text -> ImagePermission
ImagePermission'
            (Maybe Text -> ImagePermission)
-> Parser (Maybe Text) -> Parser ImagePermission
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SharedAccountId")
      )

instance Prelude.Hashable ImagePermission

instance Prelude.NFData ImagePermission