{-# 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.Signer.Types.Permission
-- 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.Signer.Types.Permission 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

-- | A cross-account permission for a signing profile.
--
-- /See:/ 'newPermission' smart constructor.
data Permission = Permission'
  { -- | An AWS Signer action permitted as part of cross-account permissions.
    Permission -> Maybe Text
action :: Prelude.Maybe Prelude.Text,
    -- | The AWS principal that has been granted a cross-account permission.
    Permission -> Maybe Text
principal :: Prelude.Maybe Prelude.Text,
    -- | The signing profile version that a permission applies to.
    Permission -> Maybe Text
profileVersion :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for a cross-account permission statement.
    Permission -> Maybe Text
statementId :: Prelude.Maybe Prelude.Text
  }
  deriving (Permission -> Permission -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Permission -> Permission -> Bool
$c/= :: Permission -> Permission -> Bool
== :: Permission -> Permission -> Bool
$c== :: Permission -> Permission -> Bool
Prelude.Eq, ReadPrec [Permission]
ReadPrec Permission
Int -> ReadS Permission
ReadS [Permission]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Permission]
$creadListPrec :: ReadPrec [Permission]
readPrec :: ReadPrec Permission
$creadPrec :: ReadPrec Permission
readList :: ReadS [Permission]
$creadList :: ReadS [Permission]
readsPrec :: Int -> ReadS Permission
$creadsPrec :: Int -> ReadS Permission
Prelude.Read, Int -> Permission -> ShowS
[Permission] -> ShowS
Permission -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Permission] -> ShowS
$cshowList :: [Permission] -> ShowS
show :: Permission -> String
$cshow :: Permission -> String
showsPrec :: Int -> Permission -> ShowS
$cshowsPrec :: Int -> Permission -> ShowS
Prelude.Show, forall x. Rep Permission x -> Permission
forall x. Permission -> Rep Permission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Permission x -> Permission
$cfrom :: forall x. Permission -> Rep Permission x
Prelude.Generic)

-- |
-- Create a value of 'Permission' 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:
--
-- 'action', 'permission_action' - An AWS Signer action permitted as part of cross-account permissions.
--
-- 'principal', 'permission_principal' - The AWS principal that has been granted a cross-account permission.
--
-- 'profileVersion', 'permission_profileVersion' - The signing profile version that a permission applies to.
--
-- 'statementId', 'permission_statementId' - A unique identifier for a cross-account permission statement.
newPermission ::
  Permission
newPermission :: Permission
newPermission =
  Permission'
    { $sel:action:Permission' :: Maybe Text
action = forall a. Maybe a
Prelude.Nothing,
      $sel:principal:Permission' :: Maybe Text
principal = forall a. Maybe a
Prelude.Nothing,
      $sel:profileVersion:Permission' :: Maybe Text
profileVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:statementId:Permission' :: Maybe Text
statementId = forall a. Maybe a
Prelude.Nothing
    }

-- | An AWS Signer action permitted as part of cross-account permissions.
permission_action :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_action :: Lens' Permission (Maybe Text)
permission_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
action :: Maybe Text
$sel:action:Permission' :: Permission -> Maybe Text
action} -> Maybe Text
action) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:action:Permission' :: Maybe Text
action = Maybe Text
a} :: Permission)

-- | The AWS principal that has been granted a cross-account permission.
permission_principal :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_principal :: Lens' Permission (Maybe Text)
permission_principal = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
principal :: Maybe Text
$sel:principal:Permission' :: Permission -> Maybe Text
principal} -> Maybe Text
principal) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:principal:Permission' :: Maybe Text
principal = Maybe Text
a} :: Permission)

-- | The signing profile version that a permission applies to.
permission_profileVersion :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_profileVersion :: Lens' Permission (Maybe Text)
permission_profileVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
profileVersion :: Maybe Text
$sel:profileVersion:Permission' :: Permission -> Maybe Text
profileVersion} -> Maybe Text
profileVersion) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:profileVersion:Permission' :: Maybe Text
profileVersion = Maybe Text
a} :: Permission)

-- | A unique identifier for a cross-account permission statement.
permission_statementId :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_statementId :: Lens' Permission (Maybe Text)
permission_statementId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
statementId :: Maybe Text
$sel:statementId:Permission' :: Permission -> Maybe Text
statementId} -> Maybe Text
statementId) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:statementId:Permission' :: Maybe Text
statementId = Maybe Text
a} :: Permission)

instance Data.FromJSON Permission where
  parseJSON :: Value -> Parser Permission
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Permission"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Permission
Permission'
            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
"action")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"principal")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"profileVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"statementId")
      )

instance Prelude.Hashable Permission where
  hashWithSalt :: Int -> Permission -> Int
hashWithSalt Int
_salt Permission' {Maybe Text
statementId :: Maybe Text
profileVersion :: Maybe Text
principal :: Maybe Text
action :: Maybe Text
$sel:statementId:Permission' :: Permission -> Maybe Text
$sel:profileVersion:Permission' :: Permission -> Maybe Text
$sel:principal:Permission' :: Permission -> Maybe Text
$sel:action:Permission' :: Permission -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principal
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
profileVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statementId

instance Prelude.NFData Permission where
  rnf :: Permission -> ()
rnf Permission' {Maybe Text
statementId :: Maybe Text
profileVersion :: Maybe Text
principal :: Maybe Text
action :: Maybe Text
$sel:statementId:Permission' :: Permission -> Maybe Text
$sel:profileVersion:Permission' :: Permission -> Maybe Text
$sel:principal:Permission' :: Permission -> Maybe Text
$sel:action:Permission' :: Permission -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principal
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
profileVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statementId