{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.Types.Policy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 HTTP inputs.
    Policy -> Maybe InputPolicy
httpInputs :: Prelude.Maybe InputPolicy,
    -- | Allow or disallow jobs that specify HTTPS inputs.
    Policy -> Maybe InputPolicy
httpsInputs :: Prelude.Maybe InputPolicy,
    -- | Allow or disallow jobs that specify Amazon S3 inputs.
    Policy -> Maybe InputPolicy
s3Inputs :: Prelude.Maybe InputPolicy
  }
  deriving (Policy -> Policy -> Bool
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]
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
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. 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:
--
-- 'httpInputs', 'policy_httpInputs' - Allow or disallow jobs that specify HTTP inputs.
--
-- 'httpsInputs', 'policy_httpsInputs' - Allow or disallow jobs that specify HTTPS inputs.
--
-- 's3Inputs', 'policy_s3Inputs' - Allow or disallow jobs that specify Amazon S3 inputs.
newPolicy ::
  Policy
newPolicy :: Policy
newPolicy =
  Policy'
    { $sel:httpInputs:Policy' :: Maybe InputPolicy
httpInputs = forall a. Maybe a
Prelude.Nothing,
      $sel:httpsInputs:Policy' :: Maybe InputPolicy
httpsInputs = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Inputs:Policy' :: Maybe InputPolicy
s3Inputs = forall a. Maybe a
Prelude.Nothing
    }

-- | Allow or disallow jobs that specify HTTP inputs.
policy_httpInputs :: Lens.Lens' Policy (Prelude.Maybe InputPolicy)
policy_httpInputs :: Lens' Policy (Maybe InputPolicy)
policy_httpInputs = 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 :: Lens' Policy (Maybe InputPolicy)
policy_httpsInputs = 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)

-- | Allow or disallow jobs that specify Amazon S3 inputs.
policy_s3Inputs :: Lens.Lens' Policy (Prelude.Maybe InputPolicy)
policy_s3Inputs :: Lens' Policy (Maybe InputPolicy)
policy_s3Inputs = 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)

instance Data.FromJSON Policy where
  parseJSON :: Value -> Parser Policy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Policy"
      ( \Object
x ->
          Maybe InputPolicy
-> Maybe InputPolicy -> Maybe InputPolicy -> Policy
Policy'
            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
"httpInputs")
            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
"httpsInputs")
            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
"s3Inputs")
      )

instance Prelude.Hashable Policy where
  hashWithSalt :: Int -> Policy -> Int
hashWithSalt Int
_salt Policy' {Maybe InputPolicy
s3Inputs :: Maybe InputPolicy
httpsInputs :: Maybe InputPolicy
httpInputs :: Maybe InputPolicy
$sel:s3Inputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpsInputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpInputs:Policy' :: Policy -> Maybe InputPolicy
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputPolicy
httpInputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputPolicy
httpsInputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputPolicy
s3Inputs

instance Prelude.NFData Policy where
  rnf :: Policy -> ()
rnf Policy' {Maybe InputPolicy
s3Inputs :: Maybe InputPolicy
httpsInputs :: Maybe InputPolicy
httpInputs :: Maybe InputPolicy
$sel:s3Inputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpsInputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpInputs:Policy' :: Policy -> Maybe InputPolicy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InputPolicy
httpInputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InputPolicy
httpsInputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InputPolicy
s3Inputs

instance Data.ToJSON Policy where
  toJSON :: Policy -> Value
toJSON Policy' {Maybe InputPolicy
s3Inputs :: Maybe InputPolicy
httpsInputs :: Maybe InputPolicy
httpInputs :: Maybe InputPolicy
$sel:s3Inputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpsInputs:Policy' :: Policy -> Maybe InputPolicy
$sel:httpInputs:Policy' :: Policy -> Maybe InputPolicy
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"httpInputs" 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 InputPolicy
httpInputs,
            (Key
"httpsInputs" 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 InputPolicy
httpsInputs,
            (Key
"s3Inputs" 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 InputPolicy
s3Inputs
          ]
      )