{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WorkSpaces.Types.ImagePermission 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 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
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]
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
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. 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' {$sel:sharedAccountId:ImagePermission' :: Maybe Text
sharedAccountId = 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 :: Lens' ImagePermission (Maybe Text)
imagePermission_sharedAccountId = 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 Data.FromJSON ImagePermission where
  parseJSON :: Value -> Parser ImagePermission
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImagePermission"
      ( \Object
x ->
          Maybe Text -> ImagePermission
ImagePermission'
            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
"SharedAccountId")
      )

instance Prelude.Hashable ImagePermission where
  hashWithSalt :: Int -> ImagePermission -> Int
hashWithSalt Int
_salt ImagePermission' {Maybe Text
sharedAccountId :: Maybe Text
$sel:sharedAccountId:ImagePermission' :: ImagePermission -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sharedAccountId

instance Prelude.NFData ImagePermission where
  rnf :: ImagePermission -> ()
rnf ImagePermission' {Maybe Text
sharedAccountId :: Maybe Text
$sel:sharedAccountId:ImagePermission' :: ImagePermission -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sharedAccountId