{-# 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.OpsWorks.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.OpsWorks.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

-- | Describes stack or user permissions.
--
-- /See:/ 'newPermission' smart constructor.
data Permission = Permission'
  { -- | Whether the user can use SSH.
    Permission -> Maybe Bool
allowSsh :: Prelude.Maybe Prelude.Bool,
    -- | Whether the user can use __sudo__.
    Permission -> Maybe Bool
allowSudo :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) for an AWS Identity and Access Management
    -- (IAM) role. For more information about IAM ARNs, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html Using Identifiers>.
    Permission -> Maybe Text
iamUserArn :: Prelude.Maybe Prelude.Text,
    -- | The user\'s permission level, which must be the following:
    --
    -- -   @deny@
    --
    -- -   @show@
    --
    -- -   @deploy@
    --
    -- -   @manage@
    --
    -- -   @iam_only@
    --
    -- For more information on the permissions associated with these levels,
    -- see
    -- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>
    Permission -> Maybe Text
level :: Prelude.Maybe Prelude.Text,
    -- | A stack ID.
    Permission -> Maybe Text
stackId :: 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:
--
-- 'allowSsh', 'permission_allowSsh' - Whether the user can use SSH.
--
-- 'allowSudo', 'permission_allowSudo' - Whether the user can use __sudo__.
--
-- 'iamUserArn', 'permission_iamUserArn' - The Amazon Resource Name (ARN) for an AWS Identity and Access Management
-- (IAM) role. For more information about IAM ARNs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html Using Identifiers>.
--
-- 'level', 'permission_level' - The user\'s permission level, which must be the following:
--
-- -   @deny@
--
-- -   @show@
--
-- -   @deploy@
--
-- -   @manage@
--
-- -   @iam_only@
--
-- For more information on the permissions associated with these levels,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>
--
-- 'stackId', 'permission_stackId' - A stack ID.
newPermission ::
  Permission
newPermission :: Permission
newPermission =
  Permission'
    { $sel:allowSsh:Permission' :: Maybe Bool
allowSsh = forall a. Maybe a
Prelude.Nothing,
      $sel:allowSudo:Permission' :: Maybe Bool
allowSudo = forall a. Maybe a
Prelude.Nothing,
      $sel:iamUserArn:Permission' :: Maybe Text
iamUserArn = forall a. Maybe a
Prelude.Nothing,
      $sel:level:Permission' :: Maybe Text
level = forall a. Maybe a
Prelude.Nothing,
      $sel:stackId:Permission' :: Maybe Text
stackId = forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the user can use SSH.
permission_allowSsh :: Lens.Lens' Permission (Prelude.Maybe Prelude.Bool)
permission_allowSsh :: Lens' Permission (Maybe Bool)
permission_allowSsh = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Bool
allowSsh :: Maybe Bool
$sel:allowSsh:Permission' :: Permission -> Maybe Bool
allowSsh} -> Maybe Bool
allowSsh) (\s :: Permission
s@Permission' {} Maybe Bool
a -> Permission
s {$sel:allowSsh:Permission' :: Maybe Bool
allowSsh = Maybe Bool
a} :: Permission)

-- | Whether the user can use __sudo__.
permission_allowSudo :: Lens.Lens' Permission (Prelude.Maybe Prelude.Bool)
permission_allowSudo :: Lens' Permission (Maybe Bool)
permission_allowSudo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Bool
allowSudo :: Maybe Bool
$sel:allowSudo:Permission' :: Permission -> Maybe Bool
allowSudo} -> Maybe Bool
allowSudo) (\s :: Permission
s@Permission' {} Maybe Bool
a -> Permission
s {$sel:allowSudo:Permission' :: Maybe Bool
allowSudo = Maybe Bool
a} :: Permission)

-- | The Amazon Resource Name (ARN) for an AWS Identity and Access Management
-- (IAM) role. For more information about IAM ARNs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html Using Identifiers>.
permission_iamUserArn :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_iamUserArn :: Lens' Permission (Maybe Text)
permission_iamUserArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
iamUserArn :: Maybe Text
$sel:iamUserArn:Permission' :: Permission -> Maybe Text
iamUserArn} -> Maybe Text
iamUserArn) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:iamUserArn:Permission' :: Maybe Text
iamUserArn = Maybe Text
a} :: Permission)

-- | The user\'s permission level, which must be the following:
--
-- -   @deny@
--
-- -   @show@
--
-- -   @deploy@
--
-- -   @manage@
--
-- -   @iam_only@
--
-- For more information on the permissions associated with these levels,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>
permission_level :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_level :: Lens' Permission (Maybe Text)
permission_level = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
level :: Maybe Text
$sel:level:Permission' :: Permission -> Maybe Text
level} -> Maybe Text
level) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:level:Permission' :: Maybe Text
level = Maybe Text
a} :: Permission)

-- | A stack ID.
permission_stackId :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_stackId :: Lens' Permission (Maybe Text)
permission_stackId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
stackId :: Maybe Text
$sel:stackId:Permission' :: Permission -> Maybe Text
stackId} -> Maybe Text
stackId) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:stackId:Permission' :: Maybe Text
stackId = 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 Bool
-> Maybe Bool
-> 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
"AllowSsh")
            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
"AllowSudo")
            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
"IamUserArn")
            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
"Level")
            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
"StackId")
      )

instance Prelude.Hashable Permission where
  hashWithSalt :: Int -> Permission -> Int
hashWithSalt Int
_salt Permission' {Maybe Bool
Maybe Text
stackId :: Maybe Text
level :: Maybe Text
iamUserArn :: Maybe Text
allowSudo :: Maybe Bool
allowSsh :: Maybe Bool
$sel:stackId:Permission' :: Permission -> Maybe Text
$sel:level:Permission' :: Permission -> Maybe Text
$sel:iamUserArn:Permission' :: Permission -> Maybe Text
$sel:allowSudo:Permission' :: Permission -> Maybe Bool
$sel:allowSsh:Permission' :: Permission -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowSsh
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowSudo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iamUserArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
level
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stackId

instance Prelude.NFData Permission where
  rnf :: Permission -> ()
rnf Permission' {Maybe Bool
Maybe Text
stackId :: Maybe Text
level :: Maybe Text
iamUserArn :: Maybe Text
allowSudo :: Maybe Bool
allowSsh :: Maybe Bool
$sel:stackId:Permission' :: Permission -> Maybe Text
$sel:level:Permission' :: Permission -> Maybe Text
$sel:iamUserArn:Permission' :: Permission -> Maybe Text
$sel:allowSudo:Permission' :: Permission -> Maybe Bool
$sel:allowSsh:Permission' :: Permission -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowSsh
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowSudo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iamUserArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
level
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stackId