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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | 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,
    -- | A description of the entitlement.
    Entitlement -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | 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
(Entitlement -> Entitlement -> Bool)
-> (Entitlement -> Entitlement -> Bool) -> Eq Entitlement
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]
(Int -> ReadS Entitlement)
-> ReadS [Entitlement]
-> ReadPrec Entitlement
-> ReadPrec [Entitlement]
-> Read 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
(Int -> Entitlement -> ShowS)
-> (Entitlement -> String)
-> ([Entitlement] -> ShowS)
-> Show Entitlement
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. Entitlement -> Rep Entitlement x)
-> (forall x. Rep Entitlement x -> Entitlement)
-> Generic Entitlement
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.
--
-- '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.
--
-- 'description', 'entitlement_description' - A description of the entitlement.
--
-- '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' :: Maybe Int
-> Maybe Encryption
-> Maybe EntitlementStatus
-> Maybe Text
-> Text
-> [Text]
-> Text
-> Entitlement
Entitlement'
    { $sel:dataTransferSubscriberFeePercent:Entitlement' :: Maybe Int
dataTransferSubscriberFeePercent =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:Entitlement' :: Maybe Encryption
encryption = Maybe Encryption
forall a. Maybe a
Prelude.Nothing,
      $sel:entitlementStatus:Entitlement' :: Maybe EntitlementStatus
entitlementStatus = Maybe EntitlementStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Entitlement' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:entitlementArn:Entitlement' :: Text
entitlementArn = Text
pEntitlementArn_,
      $sel:subscribers:Entitlement' :: [Text]
subscribers = [Text]
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 :: (Maybe Int -> f (Maybe Int)) -> Entitlement -> f Entitlement
entitlement_dataTransferSubscriberFeePercent = (Entitlement -> Maybe Int)
-> (Entitlement -> Maybe Int -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Encryption -> f (Maybe Encryption))
-> Entitlement -> f Entitlement
entitlement_encryption = (Entitlement -> Maybe Encryption)
-> (Entitlement -> Maybe Encryption -> Entitlement)
-> Lens
     Entitlement Entitlement (Maybe Encryption) (Maybe 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 :: (Maybe EntitlementStatus -> f (Maybe EntitlementStatus))
-> Entitlement -> f Entitlement
entitlement_entitlementStatus = (Entitlement -> Maybe EntitlementStatus)
-> (Entitlement -> Maybe EntitlementStatus -> Entitlement)
-> Lens
     Entitlement
     Entitlement
     (Maybe EntitlementStatus)
     (Maybe 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)

-- | A description of the entitlement.
entitlement_description :: Lens.Lens' Entitlement (Prelude.Maybe Prelude.Text)
entitlement_description :: (Maybe Text -> f (Maybe Text)) -> Entitlement -> f Entitlement
entitlement_description = (Entitlement -> Maybe Text)
-> (Entitlement -> Maybe Text -> Entitlement)
-> Lens Entitlement Entitlement (Maybe Text) (Maybe Text)
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 ARN of the entitlement.
entitlement_entitlementArn :: Lens.Lens' Entitlement Prelude.Text
entitlement_entitlementArn :: (Text -> f Text) -> Entitlement -> f Entitlement
entitlement_entitlementArn = (Entitlement -> Text)
-> (Entitlement -> Text -> Entitlement)
-> Lens Entitlement Entitlement Text Text
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 :: ([Text] -> f [Text]) -> Entitlement -> f Entitlement
entitlement_subscribers = (Entitlement -> [Text])
-> (Entitlement -> [Text] -> Entitlement)
-> Lens Entitlement Entitlement [Text] [Text]
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) (([Text] -> f [Text]) -> Entitlement -> f Entitlement)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Entitlement
-> f Entitlement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
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 :: (Text -> f Text) -> Entitlement -> f Entitlement
entitlement_name = (Entitlement -> Text)
-> (Entitlement -> Text -> Entitlement)
-> Lens Entitlement Entitlement Text Text
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 Core.FromJSON Entitlement where
  parseJSON :: Value -> Parser Entitlement
parseJSON =
    String
-> (Object -> Parser Entitlement) -> Value -> Parser Entitlement
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Entitlement"
      ( \Object
x ->
          Maybe Int
-> Maybe Encryption
-> Maybe EntitlementStatus
-> Maybe Text
-> Text
-> [Text]
-> Text
-> Entitlement
Entitlement'
            (Maybe Int
 -> Maybe Encryption
 -> Maybe EntitlementStatus
 -> Maybe Text
 -> Text
 -> [Text]
 -> Text
 -> Entitlement)
-> Parser (Maybe Int)
-> Parser
     (Maybe Encryption
      -> Maybe EntitlementStatus
      -> Maybe Text
      -> Text
      -> [Text]
      -> Text
      -> Entitlement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dataTransferSubscriberFeePercent")
            Parser
  (Maybe Encryption
   -> Maybe EntitlementStatus
   -> Maybe Text
   -> Text
   -> [Text]
   -> Text
   -> Entitlement)
-> Parser (Maybe Encryption)
-> Parser
     (Maybe EntitlementStatus
      -> Maybe Text -> Text -> [Text] -> Text -> Entitlement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Encryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryption")
            Parser
  (Maybe EntitlementStatus
   -> Maybe Text -> Text -> [Text] -> Text -> Entitlement)
-> Parser (Maybe EntitlementStatus)
-> Parser (Maybe Text -> Text -> [Text] -> Text -> Entitlement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EntitlementStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"entitlementStatus")
            Parser (Maybe Text -> Text -> [Text] -> Text -> Entitlement)
-> Parser (Maybe Text)
-> Parser (Text -> [Text] -> Text -> Entitlement)
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
"description")
            Parser (Text -> [Text] -> Text -> Entitlement)
-> Parser Text -> Parser ([Text] -> Text -> Entitlement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"entitlementArn")
            Parser ([Text] -> Text -> Entitlement)
-> Parser [Text] -> Parser (Text -> Entitlement)
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
"subscribers" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Entitlement) -> Parser Text -> Parser Entitlement
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
      )

instance Prelude.Hashable Entitlement

instance Prelude.NFData Entitlement