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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes stack or user permissions.
--
-- /See:/ 'newPermission' smart constructor.
data Permission = 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 -> Maybe Text
iamUserArn :: Prelude.Maybe Prelude.Text,
    -- | Whether the user can use __sudo__.
    Permission -> Maybe Bool
allowSudo :: Prelude.Maybe Prelude.Bool,
    -- | A stack ID.
    Permission -> Maybe Text
stackId :: 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,
    -- | Whether the user can use SSH.
    Permission -> Maybe Bool
allowSsh :: Prelude.Maybe Prelude.Bool
  }
  deriving (Permission -> Permission -> Bool
(Permission -> Permission -> Bool)
-> (Permission -> Permission -> Bool) -> Eq Permission
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]
(Int -> ReadS Permission)
-> ReadS [Permission]
-> ReadPrec Permission
-> ReadPrec [Permission]
-> Read 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
(Int -> Permission -> ShowS)
-> (Permission -> String)
-> ([Permission] -> ShowS)
-> Show Permission
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. Permission -> Rep Permission x)
-> (forall x. Rep Permission x -> Permission) -> Generic Permission
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:
--
-- '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>.
--
-- 'allowSudo', 'permission_allowSudo' - Whether the user can use __sudo__.
--
-- 'stackId', 'permission_stackId' - A stack ID.
--
-- '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>
--
-- 'allowSsh', 'permission_allowSsh' - Whether the user can use SSH.
newPermission ::
  Permission
newPermission :: Permission
newPermission =
  Permission' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Permission
Permission'
    { $sel:iamUserArn:Permission' :: Maybe Text
iamUserArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowSudo:Permission' :: Maybe Bool
allowSudo = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:stackId:Permission' :: Maybe Text
stackId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:level:Permission' :: Maybe Text
level = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowSsh:Permission' :: Maybe Bool
allowSsh = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Permission -> f Permission
permission_iamUserArn = (Permission -> Maybe Text)
-> (Permission -> Maybe Text -> Permission)
-> Lens Permission Permission (Maybe Text) (Maybe Text)
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)

-- | Whether the user can use __sudo__.
permission_allowSudo :: Lens.Lens' Permission (Prelude.Maybe Prelude.Bool)
permission_allowSudo :: (Maybe Bool -> f (Maybe Bool)) -> Permission -> f Permission
permission_allowSudo = (Permission -> Maybe Bool)
-> (Permission -> Maybe Bool -> Permission)
-> Lens Permission Permission (Maybe Bool) (Maybe Bool)
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)

-- | A stack ID.
permission_stackId :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_stackId :: (Maybe Text -> f (Maybe Text)) -> Permission -> f Permission
permission_stackId = (Permission -> Maybe Text)
-> (Permission -> Maybe Text -> Permission)
-> Lens Permission Permission (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Permission -> f Permission
permission_level = (Permission -> Maybe Text)
-> (Permission -> Maybe Text -> Permission)
-> Lens Permission Permission (Maybe Text) (Maybe Text)
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)

-- | Whether the user can use SSH.
permission_allowSsh :: Lens.Lens' Permission (Prelude.Maybe Prelude.Bool)
permission_allowSsh :: (Maybe Bool -> f (Maybe Bool)) -> Permission -> f Permission
permission_allowSsh = (Permission -> Maybe Bool)
-> (Permission -> Maybe Bool -> Permission)
-> Lens Permission Permission (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON Permission where
  parseJSON :: Value -> Parser Permission
parseJSON =
    String
-> (Object -> Parser Permission) -> Value -> Parser Permission
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Permission"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Permission
Permission'
            (Maybe Text
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe Bool
 -> Permission)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe Text -> Maybe Text -> Maybe Bool -> Permission)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IamUserArn")
            Parser
  (Maybe Bool
   -> Maybe Text -> Maybe Text -> Maybe Bool -> Permission)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> Maybe Text -> Maybe Bool -> Permission)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowSudo")
            Parser (Maybe Text -> Maybe Text -> Maybe Bool -> Permission)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Bool -> Permission)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StackId")
            Parser (Maybe Text -> Maybe Bool -> Permission)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> Permission)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Level")
            Parser (Maybe Bool -> Permission)
-> Parser (Maybe Bool) -> Parser Permission
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowSsh")
      )

instance Prelude.Hashable Permission

instance Prelude.NFData Permission