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

-- | The @Permission@ structure.
--
-- /See:/ 'newPermission' smart constructor.
data Permission = Permission'
  { -- | The permission that you want to give to the AWS user that is listed in
    -- Grantee. Valid values include:
    --
    -- -   @READ@: The grantee can read the thumbnails and metadata for
    --     thumbnails that Elastic Transcoder adds to the Amazon S3 bucket.
    --
    -- -   @READ_ACP@: The grantee can read the object ACL for thumbnails that
    --     Elastic Transcoder adds to the Amazon S3 bucket.
    --
    -- -   @WRITE_ACP@: The grantee can write the ACL for the thumbnails that
    --     Elastic Transcoder adds to the Amazon S3 bucket.
    --
    -- -   @FULL_CONTROL@: The grantee has READ, READ_ACP, and WRITE_ACP
    --     permissions for the thumbnails that Elastic Transcoder adds to the
    --     Amazon S3 bucket.
    Permission -> Maybe [Text]
access :: Prelude.Maybe [Prelude.Text],
    -- | The AWS user or group that you want to have access to transcoded files
    -- and playlists. To identify the user or group, you can specify the
    -- canonical user ID for an AWS account, an origin access identity for a
    -- CloudFront distribution, the registered email address of an AWS account,
    -- or a predefined Amazon S3 group.
    Permission -> Maybe Text
grantee :: Prelude.Maybe Prelude.Text,
    -- | The type of value that appears in the Grantee object:
    --
    -- -   @Canonical@: Either the canonical user ID for an AWS account or an
    --     origin access identity for an Amazon CloudFront distribution.
    --
    --     A canonical user ID is not the same as an AWS account number.
    --
    -- -   @Email@: The registered email address of an AWS account.
    --
    -- -   @Group@: One of the following predefined Amazon S3 groups:
    --     @AllUsers@, @AuthenticatedUsers@, or @LogDelivery@.
    Permission -> Maybe Text
granteeType :: 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:
--
-- 'access', 'permission_access' - The permission that you want to give to the AWS user that is listed in
-- Grantee. Valid values include:
--
-- -   @READ@: The grantee can read the thumbnails and metadata for
--     thumbnails that Elastic Transcoder adds to the Amazon S3 bucket.
--
-- -   @READ_ACP@: The grantee can read the object ACL for thumbnails that
--     Elastic Transcoder adds to the Amazon S3 bucket.
--
-- -   @WRITE_ACP@: The grantee can write the ACL for the thumbnails that
--     Elastic Transcoder adds to the Amazon S3 bucket.
--
-- -   @FULL_CONTROL@: The grantee has READ, READ_ACP, and WRITE_ACP
--     permissions for the thumbnails that Elastic Transcoder adds to the
--     Amazon S3 bucket.
--
-- 'grantee', 'permission_grantee' - The AWS user or group that you want to have access to transcoded files
-- and playlists. To identify the user or group, you can specify the
-- canonical user ID for an AWS account, an origin access identity for a
-- CloudFront distribution, the registered email address of an AWS account,
-- or a predefined Amazon S3 group.
--
-- 'granteeType', 'permission_granteeType' - The type of value that appears in the Grantee object:
--
-- -   @Canonical@: Either the canonical user ID for an AWS account or an
--     origin access identity for an Amazon CloudFront distribution.
--
--     A canonical user ID is not the same as an AWS account number.
--
-- -   @Email@: The registered email address of an AWS account.
--
-- -   @Group@: One of the following predefined Amazon S3 groups:
--     @AllUsers@, @AuthenticatedUsers@, or @LogDelivery@.
newPermission ::
  Permission
newPermission :: Permission
newPermission =
  Permission'
    { $sel:access:Permission' :: Maybe [Text]
access = forall a. Maybe a
Prelude.Nothing,
      $sel:grantee:Permission' :: Maybe Text
grantee = forall a. Maybe a
Prelude.Nothing,
      $sel:granteeType:Permission' :: Maybe Text
granteeType = forall a. Maybe a
Prelude.Nothing
    }

-- | The permission that you want to give to the AWS user that is listed in
-- Grantee. Valid values include:
--
-- -   @READ@: The grantee can read the thumbnails and metadata for
--     thumbnails that Elastic Transcoder adds to the Amazon S3 bucket.
--
-- -   @READ_ACP@: The grantee can read the object ACL for thumbnails that
--     Elastic Transcoder adds to the Amazon S3 bucket.
--
-- -   @WRITE_ACP@: The grantee can write the ACL for the thumbnails that
--     Elastic Transcoder adds to the Amazon S3 bucket.
--
-- -   @FULL_CONTROL@: The grantee has READ, READ_ACP, and WRITE_ACP
--     permissions for the thumbnails that Elastic Transcoder adds to the
--     Amazon S3 bucket.
permission_access :: Lens.Lens' Permission (Prelude.Maybe [Prelude.Text])
permission_access :: Lens' Permission (Maybe [Text])
permission_access = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe [Text]
access :: Maybe [Text]
$sel:access:Permission' :: Permission -> Maybe [Text]
access} -> Maybe [Text]
access) (\s :: Permission
s@Permission' {} Maybe [Text]
a -> Permission
s {$sel:access:Permission' :: Maybe [Text]
access = Maybe [Text]
a} :: Permission) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The AWS user or group that you want to have access to transcoded files
-- and playlists. To identify the user or group, you can specify the
-- canonical user ID for an AWS account, an origin access identity for a
-- CloudFront distribution, the registered email address of an AWS account,
-- or a predefined Amazon S3 group.
permission_grantee :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_grantee :: Lens' Permission (Maybe Text)
permission_grantee = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
grantee :: Maybe Text
$sel:grantee:Permission' :: Permission -> Maybe Text
grantee} -> Maybe Text
grantee) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:grantee:Permission' :: Maybe Text
grantee = Maybe Text
a} :: Permission)

-- | The type of value that appears in the Grantee object:
--
-- -   @Canonical@: Either the canonical user ID for an AWS account or an
--     origin access identity for an Amazon CloudFront distribution.
--
--     A canonical user ID is not the same as an AWS account number.
--
-- -   @Email@: The registered email address of an AWS account.
--
-- -   @Group@: One of the following predefined Amazon S3 groups:
--     @AllUsers@, @AuthenticatedUsers@, or @LogDelivery@.
permission_granteeType :: Lens.Lens' Permission (Prelude.Maybe Prelude.Text)
permission_granteeType :: Lens' Permission (Maybe Text)
permission_granteeType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Permission' {Maybe Text
granteeType :: Maybe Text
$sel:granteeType:Permission' :: Permission -> Maybe Text
granteeType} -> Maybe Text
granteeType) (\s :: Permission
s@Permission' {} Maybe Text
a -> Permission
s {$sel:granteeType:Permission' :: Maybe Text
granteeType = 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 -> 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
"Access" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Grantee")
            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
"GranteeType")
      )

instance Prelude.Hashable Permission where
  hashWithSalt :: Int -> Permission -> Int
hashWithSalt Int
_salt Permission' {Maybe [Text]
Maybe Text
granteeType :: Maybe Text
grantee :: Maybe Text
access :: Maybe [Text]
$sel:granteeType:Permission' :: Permission -> Maybe Text
$sel:grantee:Permission' :: Permission -> Maybe Text
$sel:access:Permission' :: Permission -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
access
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
grantee
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
granteeType

instance Prelude.NFData Permission where
  rnf :: Permission -> ()
rnf Permission' {Maybe [Text]
Maybe Text
granteeType :: Maybe Text
grantee :: Maybe Text
access :: Maybe [Text]
$sel:granteeType:Permission' :: Permission -> Maybe Text
$sel:grantee:Permission' :: Permission -> Maybe Text
$sel:access:Permission' :: Permission -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
access
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
grantee
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
granteeType

instance Data.ToJSON Permission where
  toJSON :: Permission -> Value
toJSON Permission' {Maybe [Text]
Maybe Text
granteeType :: Maybe Text
grantee :: Maybe Text
access :: Maybe [Text]
$sel:granteeType:Permission' :: Permission -> Maybe Text
$sel:grantee:Permission' :: Permission -> Maybe Text
$sel:access:Permission' :: Permission -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Access" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
access,
            (Key
"Grantee" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
grantee,
            (Key
"GranteeType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
granteeType
          ]
      )