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

import Amazonka.AppStream.Types.ImagePermissions
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 that are available to the specified AWS
-- account for a shared image.
--
-- /See:/ 'newSharedImagePermissions' smart constructor.
data SharedImagePermissions = SharedImagePermissions'
  { -- | The 12-digit identifier of the AWS account with which the image is
    -- shared.
    SharedImagePermissions -> Text
sharedAccountId :: Prelude.Text,
    -- | Describes the permissions for a shared image.
    SharedImagePermissions -> ImagePermissions
imagePermissions :: ImagePermissions
  }
  deriving (SharedImagePermissions -> SharedImagePermissions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SharedImagePermissions -> SharedImagePermissions -> Bool
$c/= :: SharedImagePermissions -> SharedImagePermissions -> Bool
== :: SharedImagePermissions -> SharedImagePermissions -> Bool
$c== :: SharedImagePermissions -> SharedImagePermissions -> Bool
Prelude.Eq, ReadPrec [SharedImagePermissions]
ReadPrec SharedImagePermissions
Int -> ReadS SharedImagePermissions
ReadS [SharedImagePermissions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SharedImagePermissions]
$creadListPrec :: ReadPrec [SharedImagePermissions]
readPrec :: ReadPrec SharedImagePermissions
$creadPrec :: ReadPrec SharedImagePermissions
readList :: ReadS [SharedImagePermissions]
$creadList :: ReadS [SharedImagePermissions]
readsPrec :: Int -> ReadS SharedImagePermissions
$creadsPrec :: Int -> ReadS SharedImagePermissions
Prelude.Read, Int -> SharedImagePermissions -> ShowS
[SharedImagePermissions] -> ShowS
SharedImagePermissions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SharedImagePermissions] -> ShowS
$cshowList :: [SharedImagePermissions] -> ShowS
show :: SharedImagePermissions -> String
$cshow :: SharedImagePermissions -> String
showsPrec :: Int -> SharedImagePermissions -> ShowS
$cshowsPrec :: Int -> SharedImagePermissions -> ShowS
Prelude.Show, forall x. Rep SharedImagePermissions x -> SharedImagePermissions
forall x. SharedImagePermissions -> Rep SharedImagePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SharedImagePermissions x -> SharedImagePermissions
$cfrom :: forall x. SharedImagePermissions -> Rep SharedImagePermissions x
Prelude.Generic)

-- |
-- Create a value of 'SharedImagePermissions' 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', 'sharedImagePermissions_sharedAccountId' - The 12-digit identifier of the AWS account with which the image is
-- shared.
--
-- 'imagePermissions', 'sharedImagePermissions_imagePermissions' - Describes the permissions for a shared image.
newSharedImagePermissions ::
  -- | 'sharedAccountId'
  Prelude.Text ->
  -- | 'imagePermissions'
  ImagePermissions ->
  SharedImagePermissions
newSharedImagePermissions :: Text -> ImagePermissions -> SharedImagePermissions
newSharedImagePermissions
  Text
pSharedAccountId_
  ImagePermissions
pImagePermissions_ =
    SharedImagePermissions'
      { $sel:sharedAccountId:SharedImagePermissions' :: Text
sharedAccountId =
          Text
pSharedAccountId_,
        $sel:imagePermissions:SharedImagePermissions' :: ImagePermissions
imagePermissions = ImagePermissions
pImagePermissions_
      }

-- | The 12-digit identifier of the AWS account with which the image is
-- shared.
sharedImagePermissions_sharedAccountId :: Lens.Lens' SharedImagePermissions Prelude.Text
sharedImagePermissions_sharedAccountId :: Lens' SharedImagePermissions Text
sharedImagePermissions_sharedAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SharedImagePermissions' {Text
sharedAccountId :: Text
$sel:sharedAccountId:SharedImagePermissions' :: SharedImagePermissions -> Text
sharedAccountId} -> Text
sharedAccountId) (\s :: SharedImagePermissions
s@SharedImagePermissions' {} Text
a -> SharedImagePermissions
s {$sel:sharedAccountId:SharedImagePermissions' :: Text
sharedAccountId = Text
a} :: SharedImagePermissions)

-- | Describes the permissions for a shared image.
sharedImagePermissions_imagePermissions :: Lens.Lens' SharedImagePermissions ImagePermissions
sharedImagePermissions_imagePermissions :: Lens' SharedImagePermissions ImagePermissions
sharedImagePermissions_imagePermissions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SharedImagePermissions' {ImagePermissions
imagePermissions :: ImagePermissions
$sel:imagePermissions:SharedImagePermissions' :: SharedImagePermissions -> ImagePermissions
imagePermissions} -> ImagePermissions
imagePermissions) (\s :: SharedImagePermissions
s@SharedImagePermissions' {} ImagePermissions
a -> SharedImagePermissions
s {$sel:imagePermissions:SharedImagePermissions' :: ImagePermissions
imagePermissions = ImagePermissions
a} :: SharedImagePermissions)

instance Data.FromJSON SharedImagePermissions where
  parseJSON :: Value -> Parser SharedImagePermissions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SharedImagePermissions"
      ( \Object
x ->
          Text -> ImagePermissions -> SharedImagePermissions
SharedImagePermissions'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"sharedAccountId")
            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
"imagePermissions")
      )

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

instance Prelude.NFData SharedImagePermissions where
  rnf :: SharedImagePermissions -> ()
rnf SharedImagePermissions' {Text
ImagePermissions
imagePermissions :: ImagePermissions
sharedAccountId :: Text
$sel:imagePermissions:SharedImagePermissions' :: SharedImagePermissions -> ImagePermissions
$sel:sharedAccountId:SharedImagePermissions' :: SharedImagePermissions -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
sharedAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ImagePermissions
imagePermissions