{-# 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.MediaConnect.Types.Entitlement
-- 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.MediaConnect.Types.Entitlement where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConnect.Types.Encryption
import Amazonka.MediaConnect.Types.EntitlementStatus
import qualified Amazonka.Prelude as Prelude

-- | The settings for a flow entitlement.
--
-- /See:/ 'newEntitlement' smart constructor.
data Entitlement = Entitlement'
  { -- | Percentage from 0-100 of the data transfer cost to be billed to the
    -- subscriber.
    Entitlement -> Maybe Int
dataTransferSubscriberFeePercent :: Prelude.Maybe Prelude.Int,
    -- | A description of the entitlement.
    Entitlement -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The type of encryption that will be used on the output that is
    -- associated with this entitlement.
    Entitlement -> Maybe Encryption
encryption :: Prelude.Maybe Encryption,
    -- | An indication of whether the entitlement is enabled.
    Entitlement -> Maybe EntitlementStatus
entitlementStatus :: Prelude.Maybe EntitlementStatus,
    -- | The ARN of the entitlement.
    Entitlement -> Text
entitlementArn :: Prelude.Text,
    -- | The AWS account IDs that you want to share your content with. The
    -- receiving accounts (subscribers) will be allowed to create their own
    -- flow using your content as the source.
    Entitlement -> [Text]
subscribers :: [Prelude.Text],
    -- | The name of the entitlement.
    Entitlement -> Text
name :: Prelude.Text
  }
  deriving (Entitlement -> Entitlement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Entitlement -> Entitlement -> Bool
$c/= :: Entitlement -> Entitlement -> Bool
== :: Entitlement -> Entitlement -> Bool
$c== :: Entitlement -> Entitlement -> Bool
Prelude.Eq, ReadPrec [Entitlement]
ReadPrec Entitlement
Int -> ReadS Entitlement
ReadS [Entitlement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Entitlement]
$creadListPrec :: ReadPrec [Entitlement]
readPrec :: ReadPrec Entitlement
$creadPrec :: ReadPrec Entitlement
readList :: ReadS [Entitlement]
$creadList :: ReadS [Entitlement]
readsPrec :: Int -> ReadS Entitlement
$creadsPrec :: Int -> ReadS Entitlement
Prelude.Read, Int -> Entitlement -> ShowS
[Entitlement] -> ShowS
Entitlement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Entitlement] -> ShowS
$cshowList :: [Entitlement] -> ShowS
show :: Entitlement -> String
$cshow :: Entitlement -> String
showsPrec :: Int -> Entitlement -> ShowS
$cshowsPrec :: Int -> Entitlement -> ShowS
Prelude.Show, forall x. Rep Entitlement x -> Entitlement
forall x. Entitlement -> Rep Entitlement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Entitlement x -> Entitlement
$cfrom :: forall x. Entitlement -> Rep Entitlement x
Prelude.Generic)

-- |
-- Create a value of 'Entitlement' 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:
--
-- 'dataTransferSubscriberFeePercent', 'entitlement_dataTransferSubscriberFeePercent' - Percentage from 0-100 of the data transfer cost to be billed to the
-- subscriber.
--
-- 'description', 'entitlement_description' - A description of the entitlement.
--
-- 'encryption', 'entitlement_encryption' - The type of encryption that will be used on the output that is
-- associated with this entitlement.
--
-- 'entitlementStatus', 'entitlement_entitlementStatus' - An indication of whether the entitlement is enabled.
--
-- 'entitlementArn', 'entitlement_entitlementArn' - The ARN of the entitlement.
--
-- 'subscribers', 'entitlement_subscribers' - The AWS account IDs that you want to share your content with. The
-- receiving accounts (subscribers) will be allowed to create their own
-- flow using your content as the source.
--
-- 'name', 'entitlement_name' - The name of the entitlement.
newEntitlement ::
  -- | 'entitlementArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  Entitlement
newEntitlement :: Text -> Text -> Entitlement
newEntitlement Text
pEntitlementArn_ Text
pName_ =
  Entitlement'
    { $sel:dataTransferSubscriberFeePercent:Entitlement' :: Maybe Int
dataTransferSubscriberFeePercent =
        forall a. Maybe a
Prelude.Nothing,
      $sel:description:Entitlement' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:Entitlement' :: Maybe Encryption
encryption = forall a. Maybe a
Prelude.Nothing,
      $sel:entitlementStatus:Entitlement' :: Maybe EntitlementStatus
entitlementStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:entitlementArn:Entitlement' :: Text
entitlementArn = Text
pEntitlementArn_,
      $sel:subscribers:Entitlement' :: [Text]
subscribers = forall a. Monoid a => a
Prelude.mempty,
      $sel:name:Entitlement' :: Text
name = Text
pName_
    }

-- | Percentage from 0-100 of the data transfer cost to be billed to the
-- subscriber.
entitlement_dataTransferSubscriberFeePercent :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Int)
entitlement_dataTransferSubscriberFeePercent :: Lens' Entitlement (Maybe Int)
entitlement_dataTransferSubscriberFeePercent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Int
dataTransferSubscriberFeePercent :: Maybe Int
$sel:dataTransferSubscriberFeePercent:Entitlement' :: Entitlement -> Maybe Int
dataTransferSubscriberFeePercent} -> Maybe Int
dataTransferSubscriberFeePercent) (\s :: Entitlement
s@Entitlement' {} Maybe Int
a -> Entitlement
s {$sel:dataTransferSubscriberFeePercent:Entitlement' :: Maybe Int
dataTransferSubscriberFeePercent = Maybe Int
a} :: Entitlement)

-- | A description of the entitlement.
entitlement_description :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Text)
entitlement_description :: Lens' Entitlement (Maybe Text)
entitlement_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Text
description :: Maybe Text
$sel:description:Entitlement' :: Entitlement -> Maybe Text
description} -> Maybe Text
description) (\s :: Entitlement
s@Entitlement' {} Maybe Text
a -> Entitlement
s {$sel:description:Entitlement' :: Maybe Text
description = Maybe Text
a} :: Entitlement)

-- | The type of encryption that will be used on the output that is
-- associated with this entitlement.
entitlement_encryption :: Lens.Lens' Entitlement (Prelude.Maybe Encryption)
entitlement_encryption :: Lens' Entitlement (Maybe Encryption)
entitlement_encryption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe Encryption
encryption :: Maybe Encryption
$sel:encryption:Entitlement' :: Entitlement -> Maybe Encryption
encryption} -> Maybe Encryption
encryption) (\s :: Entitlement
s@Entitlement' {} Maybe Encryption
a -> Entitlement
s {$sel:encryption:Entitlement' :: Maybe Encryption
encryption = Maybe Encryption
a} :: Entitlement)

-- | An indication of whether the entitlement is enabled.
entitlement_entitlementStatus :: Lens.Lens' Entitlement (Prelude.Maybe EntitlementStatus)
entitlement_entitlementStatus :: Lens' Entitlement (Maybe EntitlementStatus)
entitlement_entitlementStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Maybe EntitlementStatus
entitlementStatus :: Maybe EntitlementStatus
$sel:entitlementStatus:Entitlement' :: Entitlement -> Maybe EntitlementStatus
entitlementStatus} -> Maybe EntitlementStatus
entitlementStatus) (\s :: Entitlement
s@Entitlement' {} Maybe EntitlementStatus
a -> Entitlement
s {$sel:entitlementStatus:Entitlement' :: Maybe EntitlementStatus
entitlementStatus = Maybe EntitlementStatus
a} :: Entitlement)

-- | The ARN of the entitlement.
entitlement_entitlementArn :: Lens.Lens' Entitlement Prelude.Text
entitlement_entitlementArn :: Lens' Entitlement Text
entitlement_entitlementArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Text
entitlementArn :: Text
$sel:entitlementArn:Entitlement' :: Entitlement -> Text
entitlementArn} -> Text
entitlementArn) (\s :: Entitlement
s@Entitlement' {} Text
a -> Entitlement
s {$sel:entitlementArn:Entitlement' :: Text
entitlementArn = Text
a} :: Entitlement)

-- | The AWS account IDs that you want to share your content with. The
-- receiving accounts (subscribers) will be allowed to create their own
-- flow using your content as the source.
entitlement_subscribers :: Lens.Lens' Entitlement [Prelude.Text]
entitlement_subscribers :: Lens' Entitlement [Text]
entitlement_subscribers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {[Text]
subscribers :: [Text]
$sel:subscribers:Entitlement' :: Entitlement -> [Text]
subscribers} -> [Text]
subscribers) (\s :: Entitlement
s@Entitlement' {} [Text]
a -> Entitlement
s {$sel:subscribers:Entitlement' :: [Text]
subscribers = [Text]
a} :: Entitlement) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the entitlement.
entitlement_name :: Lens.Lens' Entitlement Prelude.Text
entitlement_name :: Lens' Entitlement Text
entitlement_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entitlement' {Text
name :: Text
$sel:name:Entitlement' :: Entitlement -> Text
name} -> Text
name) (\s :: Entitlement
s@Entitlement' {} Text
a -> Entitlement
s {$sel:name:Entitlement' :: Text
name = Text
a} :: Entitlement)

instance Data.FromJSON Entitlement where
  parseJSON :: Value -> Parser Entitlement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Entitlement"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe Encryption
-> Maybe EntitlementStatus
-> Text
-> [Text]
-> Text
-> Entitlement
Entitlement'
            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
"dataTransferSubscriberFeePercent")
            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
"description")
            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
"encryption")
            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
"entitlementStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"entitlementArn")
            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
"subscribers" 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 a
Data..: Key
"name")
      )

instance Prelude.Hashable Entitlement where
  hashWithSalt :: Int -> Entitlement -> Int
hashWithSalt Int
_salt Entitlement' {[Text]
Maybe Int
Maybe Text
Maybe EntitlementStatus
Maybe Encryption
Text
name :: Text
subscribers :: [Text]
entitlementArn :: Text
entitlementStatus :: Maybe EntitlementStatus
encryption :: Maybe Encryption
description :: Maybe Text
dataTransferSubscriberFeePercent :: Maybe Int
$sel:name:Entitlement' :: Entitlement -> Text
$sel:subscribers:Entitlement' :: Entitlement -> [Text]
$sel:entitlementArn:Entitlement' :: Entitlement -> Text
$sel:entitlementStatus:Entitlement' :: Entitlement -> Maybe EntitlementStatus
$sel:encryption:Entitlement' :: Entitlement -> Maybe Encryption
$sel:description:Entitlement' :: Entitlement -> Maybe Text
$sel:dataTransferSubscriberFeePercent:Entitlement' :: Entitlement -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
dataTransferSubscriberFeePercent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Encryption
encryption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EntitlementStatus
entitlementStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entitlementArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
subscribers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData Entitlement where
  rnf :: Entitlement -> ()
rnf Entitlement' {[Text]
Maybe Int
Maybe Text
Maybe EntitlementStatus
Maybe Encryption
Text
name :: Text
subscribers :: [Text]
entitlementArn :: Text
entitlementStatus :: Maybe EntitlementStatus
encryption :: Maybe Encryption
description :: Maybe Text
dataTransferSubscriberFeePercent :: Maybe Int
$sel:name:Entitlement' :: Entitlement -> Text
$sel:subscribers:Entitlement' :: Entitlement -> [Text]
$sel:entitlementArn:Entitlement' :: Entitlement -> Text
$sel:entitlementStatus:Entitlement' :: Entitlement -> Maybe EntitlementStatus
$sel:encryption:Entitlement' :: Entitlement -> Maybe Encryption
$sel:description:Entitlement' :: Entitlement -> Maybe Text
$sel:dataTransferSubscriberFeePercent:Entitlement' :: Entitlement -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
dataTransferSubscriberFeePercent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Encryption
encryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EntitlementStatus
entitlementStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entitlementArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
subscribers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name