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

import Amazonka.AppStream.Types.ImagePermissions
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SharedImagePermissions -> SharedImagePermissions -> Bool)
-> (SharedImagePermissions -> SharedImagePermissions -> Bool)
-> Eq SharedImagePermissions
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]
(Int -> ReadS SharedImagePermissions)
-> ReadS [SharedImagePermissions]
-> ReadPrec SharedImagePermissions
-> ReadPrec [SharedImagePermissions]
-> Read 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
(Int -> SharedImagePermissions -> ShowS)
-> (SharedImagePermissions -> String)
-> ([SharedImagePermissions] -> ShowS)
-> Show SharedImagePermissions
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. SharedImagePermissions -> Rep SharedImagePermissions x)
-> (forall x.
    Rep SharedImagePermissions x -> SharedImagePermissions)
-> Generic SharedImagePermissions
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' :: Text -> ImagePermissions -> SharedImagePermissions
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 :: (Text -> f Text)
-> SharedImagePermissions -> f SharedImagePermissions
sharedImagePermissions_sharedAccountId = (SharedImagePermissions -> Text)
-> (SharedImagePermissions -> Text -> SharedImagePermissions)
-> Lens SharedImagePermissions SharedImagePermissions Text Text
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 :: (ImagePermissions -> f ImagePermissions)
-> SharedImagePermissions -> f SharedImagePermissions
sharedImagePermissions_imagePermissions = (SharedImagePermissions -> ImagePermissions)
-> (SharedImagePermissions
    -> ImagePermissions -> SharedImagePermissions)
-> Lens
     SharedImagePermissions
     SharedImagePermissions
     ImagePermissions
     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 Core.FromJSON SharedImagePermissions where
  parseJSON :: Value -> Parser SharedImagePermissions
parseJSON =
    String
-> (Object -> Parser SharedImagePermissions)
-> Value
-> Parser SharedImagePermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SharedImagePermissions"
      ( \Object
x ->
          Text -> ImagePermissions -> SharedImagePermissions
SharedImagePermissions'
            (Text -> ImagePermissions -> SharedImagePermissions)
-> Parser Text
-> Parser (ImagePermissions -> SharedImagePermissions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"sharedAccountId")
            Parser (ImagePermissions -> SharedImagePermissions)
-> Parser ImagePermissions -> Parser SharedImagePermissions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ImagePermissions
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"imagePermissions")
      )

instance Prelude.Hashable SharedImagePermissions

instance Prelude.NFData SharedImagePermissions