{-# 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.MediaConvert.Types.Policy
-- 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.MediaConvert.Types.Policy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConvert.Types.InputPolicy
import qualified Amazonka.Prelude as Prelude

-- | A policy configures behavior that you allow or disallow for your
-- account. For information about MediaConvert policies, see the user guide
-- at http:\/\/docs.aws.amazon.com\/mediaconvert\/latest\/ug\/what-is.html
--
-- /See:/ 'newPolicy' smart constructor.
data Policy = Policy'
  { -- | Allow or disallow jobs that specify Amazon S3 inputs.
    Policy -> Maybe InputPolicy
s3Inputs :: Prelude.Maybe InputPolicy,
    -- | Allow or disallow jobs that specify HTTP inputs.
    Policy -> Maybe InputPolicy
httpInputs :: Prelude.Maybe InputPolicy,
    -- | Allow or disallow jobs that specify HTTPS inputs.
    Policy -> Maybe InputPolicy
httpsInputs :: Prelude.Maybe InputPolicy
  }
  deriving (Policy -> Policy -> Bool
(Policy -> Policy -> Bool)
-> (Policy -> Policy -> Bool) -> Eq Policy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Policy -> Policy -> Bool
$c/= :: Policy -> Policy -> Bool
== :: Policy -> Policy -> Bool
$c== :: Policy -> Policy -> Bool
Prelude.Eq, ReadPrec [Policy]
ReadPrec Policy
Int -> ReadS Policy
ReadS [Policy]
(Int -> ReadS Policy)
-> ReadS [Policy]
-> ReadPrec Policy
-> ReadPrec [Policy]
-> Read Policy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Policy]
$creadListPrec :: ReadPrec [Policy]
readPrec :: ReadPrec Policy
$creadPrec :: ReadPrec Policy
readList :: ReadS [Policy]
$creadList :: ReadS [Policy]
readsPrec :: Int -> ReadS Policy
$creadsPrec :: Int -> ReadS Policy
Prelude.Read, Int -> Policy -> ShowS
[Policy] -> ShowS
Policy -> String
(Int -> Policy -> ShowS)
-> (Policy -> String) -> ([Policy] -> ShowS) -> Show Policy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Policy] -> ShowS
$cshowList :: [Policy] -> ShowS
show :: Policy -> String
$cshow :: Policy -> String
showsPrec :: Int -> Policy -> ShowS
$cshowsPrec :: Int -> Policy -> ShowS
Prelude.Show, (forall x. Policy -> Rep Policy x)
-> (forall x. Rep Policy x -> Policy) -> Generic Policy
forall x. Rep Policy x -> Policy
forall x. Policy -> Rep Policy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Policy x -> Policy
$cfrom :: forall x. Policy -> Rep Policy x
Prelude.Generic)

-- |
-- Create a value of 'Policy' 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:
--
-- 's3Inputs', 'policy_s3Inputs' - Allow or disallow jobs that specify Amazon S3 inputs.
--
-- 'httpInputs', 'policy_httpInputs' - Allow or disallow jobs that specify HTTP inputs.
--
-- 'httpsInputs', 'policy_httpsInputs' - Allow or disallow jobs that specify HTTPS inputs.
newPolicy ::
  Policy
newPolicy :: Policy
newPolicy =
  Policy' :: Maybe InputPolicy
-> Maybe InputPolicy -> Maybe InputPolicy -> Policy
Policy'
    { $sel:s3Inputs:Policy' :: Maybe InputPolicy
s3Inputs = Maybe InputPolicy
forall a. Maybe a
Prelude.Nothing,
      $sel:httpInputs:Policy' :: Maybe InputPolicy
httpInputs = Maybe InputPolicy
forall a. Maybe a
Prelude.Nothing,
      $sel:httpsInputs:Policy' :: Maybe InputPolicy
httpsInputs = Maybe InputPolicy
forall a. Maybe a
Prelude.Nothing
    }

-- | Allow or disallow jobs that specify Amazon S3 inputs.
policy_s3Inputs :: Lens.Lens' Policy (Prelude.Maybe InputPolicy)
policy_s3Inputs :: (Maybe InputPolicy -> f (Maybe InputPolicy)) -> Policy -> f Policy
policy_s3Inputs = (Policy -> Maybe InputPolicy)
-> (Policy -> Maybe InputPolicy -> Policy)
-> Lens Policy Policy (Maybe InputPolicy) (Maybe InputPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Policy' {Maybe InputPolicy
s3Inputs :: Maybe InputPolicy
$sel:s3Inputs:Policy' :: Policy -> Maybe InputPolicy
s3Inputs} -> Maybe InputPolicy
s3Inputs) (\s :: Policy
s@Policy' {} Maybe InputPolicy
a -> Policy
s {$sel:s3Inputs:Policy' :: Maybe InputPolicy
s3Inputs = Maybe InputPolicy
a} :: Policy)

-- | Allow or disallow jobs that specify HTTP inputs.
policy_httpInputs :: Lens.Lens' Policy (Prelude.Maybe InputPolicy)
policy_httpInputs :: (Maybe InputPolicy -> f (Maybe InputPolicy)) -> Policy -> f Policy
policy_httpInputs = (Policy -> Maybe InputPolicy)
-> (Policy -> Maybe InputPolicy -> Policy)
-> Lens Policy Policy (Maybe InputPolicy) (Maybe InputPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Policy' {Maybe InputPolicy
httpInputs :: Maybe InputPolicy
$sel:httpInputs:Policy' :: Policy -> Maybe InputPolicy
httpInputs} -> Maybe InputPolicy
httpInputs) (\s :: Policy
s@Policy' {} Maybe InputPolicy
a -> Policy
s {$sel:httpInputs:Policy' :: Maybe InputPolicy
httpInputs = Maybe InputPolicy
a} :: Policy)

-- | Allow or disallow jobs that specify HTTPS inputs.
policy_httpsInputs :: Lens.Lens' Policy (Prelude.Maybe InputPolicy)
policy_httpsInputs :: (Maybe InputPolicy -> f (Maybe InputPolicy)) -> Policy -> f Policy
policy_httpsInputs = (Policy -> Maybe InputPolicy)
-> (Policy -> Maybe InputPolicy -> Policy)
-> Lens Policy Policy (Maybe InputPolicy) (Maybe InputPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Policy' {Maybe InputPolicy
httpsInputs :: Maybe InputPolicy
$sel:httpsInputs:Policy' :: Policy -> Maybe InputPolicy
httpsInputs} -> Maybe InputPolicy
httpsInputs) (\s :: Policy
s@Policy' {} Maybe InputPolicy
a -> Policy
s {$sel:httpsInputs:Policy' :: Maybe InputPolicy
httpsInputs = Maybe InputPolicy
a} :: Policy)

instance Core.FromJSON Policy where
  parseJSON :: Value -> Parser Policy
parseJSON =
    String -> (Object -> Parser Policy) -> Value -> Parser Policy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Policy"
      ( \Object
x ->
          Maybe InputPolicy
-> Maybe InputPolicy -> Maybe InputPolicy -> Policy
Policy'
            (Maybe InputPolicy
 -> Maybe InputPolicy -> Maybe InputPolicy -> Policy)
-> Parser (Maybe InputPolicy)
-> Parser (Maybe InputPolicy -> Maybe InputPolicy -> Policy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InputPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Inputs")
            Parser (Maybe InputPolicy -> Maybe InputPolicy -> Policy)
-> Parser (Maybe InputPolicy)
-> Parser (Maybe InputPolicy -> Policy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"httpInputs")
            Parser (Maybe InputPolicy -> Policy)
-> Parser (Maybe InputPolicy) -> Parser Policy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"httpsInputs")
      )

instance Prelude.Hashable Policy

instance Prelude.NFData Policy

instance Core.ToJSON Policy where
  toJSON :: Policy -> Value
toJSON Policy' {Maybe InputPolicy
httpsInputs :: Maybe InputPolicy
httpInputs :: Maybe InputPolicy
s3Inputs :: Maybe InputPolicy
$sel:httpsInputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpInputs:Policy' :: Policy -> Maybe InputPolicy
$sel:s3Inputs:Policy' :: Policy -> Maybe InputPolicy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"s3Inputs" Text -> InputPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputPolicy -> Pair) -> Maybe InputPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputPolicy
s3Inputs,
            (Text
"httpInputs" Text -> InputPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputPolicy -> Pair) -> Maybe InputPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputPolicy
httpInputs,
            (Text
"httpsInputs" Text -> InputPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputPolicy -> Pair) -> Maybe InputPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputPolicy
httpsInputs
          ]
      )