{-# 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.Transcribe.Types.JobExecutionSettings
-- 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.Transcribe.Types.JobExecutionSettings 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

-- | Makes it possible to control how your transcription job is processed.
-- Currently, the only @JobExecutionSettings@ modification you can choose
-- is enabling job queueing using the @AllowDeferredExecution@
-- sub-parameter.
--
-- If you include @JobExecutionSettings@ in your request, you must also
-- include the sub-parameters: @AllowDeferredExecution@ and
-- @DataAccessRoleArn@.
--
-- /See:/ 'newJobExecutionSettings' smart constructor.
data JobExecutionSettings = JobExecutionSettings'
  { -- | Makes it possible to enable job queuing when your concurrent request
    -- limit is exceeded. When @AllowDeferredExecution@ is set to @true@,
    -- transcription job requests are placed in a queue until the number of
    -- jobs falls below the concurrent request limit. If
    -- @AllowDeferredExecution@ is set to @false@ and the number of
    -- transcription job requests exceed the concurrent request limit, you get
    -- a @LimitExceededException@ error.
    --
    -- Note that job queuing is enabled by default for Call Analytics jobs.
    --
    -- If you include @AllowDeferredExecution@ in your request, you must also
    -- include @DataAccessRoleArn@.
    JobExecutionSettings -> Maybe Bool
allowDeferredExecution :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of an IAM role that has permissions to
    -- access the Amazon S3 bucket that contains your input files. If the role
    -- that you specify doesn’t have the appropriate permissions to access the
    -- specified Amazon S3 location, your request fails.
    --
    -- IAM role ARNs have the format
    -- @arn:partition:iam::account:role\/role-name-with-path@. For example:
    -- @arn:aws:iam::111122223333:role\/Admin@. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns IAM ARNs>.
    --
    -- Note that if you include @DataAccessRoleArn@ in your request, you must
    -- also include @AllowDeferredExecution@.
    JobExecutionSettings -> Maybe Text
dataAccessRoleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (JobExecutionSettings -> JobExecutionSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobExecutionSettings -> JobExecutionSettings -> Bool
$c/= :: JobExecutionSettings -> JobExecutionSettings -> Bool
== :: JobExecutionSettings -> JobExecutionSettings -> Bool
$c== :: JobExecutionSettings -> JobExecutionSettings -> Bool
Prelude.Eq, ReadPrec [JobExecutionSettings]
ReadPrec JobExecutionSettings
Int -> ReadS JobExecutionSettings
ReadS [JobExecutionSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobExecutionSettings]
$creadListPrec :: ReadPrec [JobExecutionSettings]
readPrec :: ReadPrec JobExecutionSettings
$creadPrec :: ReadPrec JobExecutionSettings
readList :: ReadS [JobExecutionSettings]
$creadList :: ReadS [JobExecutionSettings]
readsPrec :: Int -> ReadS JobExecutionSettings
$creadsPrec :: Int -> ReadS JobExecutionSettings
Prelude.Read, Int -> JobExecutionSettings -> ShowS
[JobExecutionSettings] -> ShowS
JobExecutionSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobExecutionSettings] -> ShowS
$cshowList :: [JobExecutionSettings] -> ShowS
show :: JobExecutionSettings -> String
$cshow :: JobExecutionSettings -> String
showsPrec :: Int -> JobExecutionSettings -> ShowS
$cshowsPrec :: Int -> JobExecutionSettings -> ShowS
Prelude.Show, forall x. Rep JobExecutionSettings x -> JobExecutionSettings
forall x. JobExecutionSettings -> Rep JobExecutionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobExecutionSettings x -> JobExecutionSettings
$cfrom :: forall x. JobExecutionSettings -> Rep JobExecutionSettings x
Prelude.Generic)

-- |
-- Create a value of 'JobExecutionSettings' 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:
--
-- 'allowDeferredExecution', 'jobExecutionSettings_allowDeferredExecution' - Makes it possible to enable job queuing when your concurrent request
-- limit is exceeded. When @AllowDeferredExecution@ is set to @true@,
-- transcription job requests are placed in a queue until the number of
-- jobs falls below the concurrent request limit. If
-- @AllowDeferredExecution@ is set to @false@ and the number of
-- transcription job requests exceed the concurrent request limit, you get
-- a @LimitExceededException@ error.
--
-- Note that job queuing is enabled by default for Call Analytics jobs.
--
-- If you include @AllowDeferredExecution@ in your request, you must also
-- include @DataAccessRoleArn@.
--
-- 'dataAccessRoleArn', 'jobExecutionSettings_dataAccessRoleArn' - The Amazon Resource Name (ARN) of an IAM role that has permissions to
-- access the Amazon S3 bucket that contains your input files. If the role
-- that you specify doesn’t have the appropriate permissions to access the
-- specified Amazon S3 location, your request fails.
--
-- IAM role ARNs have the format
-- @arn:partition:iam::account:role\/role-name-with-path@. For example:
-- @arn:aws:iam::111122223333:role\/Admin@. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns IAM ARNs>.
--
-- Note that if you include @DataAccessRoleArn@ in your request, you must
-- also include @AllowDeferredExecution@.
newJobExecutionSettings ::
  JobExecutionSettings
newJobExecutionSettings :: JobExecutionSettings
newJobExecutionSettings =
  JobExecutionSettings'
    { $sel:allowDeferredExecution:JobExecutionSettings' :: Maybe Bool
allowDeferredExecution =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dataAccessRoleArn:JobExecutionSettings' :: Maybe Text
dataAccessRoleArn = forall a. Maybe a
Prelude.Nothing
    }

-- | Makes it possible to enable job queuing when your concurrent request
-- limit is exceeded. When @AllowDeferredExecution@ is set to @true@,
-- transcription job requests are placed in a queue until the number of
-- jobs falls below the concurrent request limit. If
-- @AllowDeferredExecution@ is set to @false@ and the number of
-- transcription job requests exceed the concurrent request limit, you get
-- a @LimitExceededException@ error.
--
-- Note that job queuing is enabled by default for Call Analytics jobs.
--
-- If you include @AllowDeferredExecution@ in your request, you must also
-- include @DataAccessRoleArn@.
jobExecutionSettings_allowDeferredExecution :: Lens.Lens' JobExecutionSettings (Prelude.Maybe Prelude.Bool)
jobExecutionSettings_allowDeferredExecution :: Lens' JobExecutionSettings (Maybe Bool)
jobExecutionSettings_allowDeferredExecution = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobExecutionSettings' {Maybe Bool
allowDeferredExecution :: Maybe Bool
$sel:allowDeferredExecution:JobExecutionSettings' :: JobExecutionSettings -> Maybe Bool
allowDeferredExecution} -> Maybe Bool
allowDeferredExecution) (\s :: JobExecutionSettings
s@JobExecutionSettings' {} Maybe Bool
a -> JobExecutionSettings
s {$sel:allowDeferredExecution:JobExecutionSettings' :: Maybe Bool
allowDeferredExecution = Maybe Bool
a} :: JobExecutionSettings)

-- | The Amazon Resource Name (ARN) of an IAM role that has permissions to
-- access the Amazon S3 bucket that contains your input files. If the role
-- that you specify doesn’t have the appropriate permissions to access the
-- specified Amazon S3 location, your request fails.
--
-- IAM role ARNs have the format
-- @arn:partition:iam::account:role\/role-name-with-path@. For example:
-- @arn:aws:iam::111122223333:role\/Admin@. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns IAM ARNs>.
--
-- Note that if you include @DataAccessRoleArn@ in your request, you must
-- also include @AllowDeferredExecution@.
jobExecutionSettings_dataAccessRoleArn :: Lens.Lens' JobExecutionSettings (Prelude.Maybe Prelude.Text)
jobExecutionSettings_dataAccessRoleArn :: Lens' JobExecutionSettings (Maybe Text)
jobExecutionSettings_dataAccessRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobExecutionSettings' {Maybe Text
dataAccessRoleArn :: Maybe Text
$sel:dataAccessRoleArn:JobExecutionSettings' :: JobExecutionSettings -> Maybe Text
dataAccessRoleArn} -> Maybe Text
dataAccessRoleArn) (\s :: JobExecutionSettings
s@JobExecutionSettings' {} Maybe Text
a -> JobExecutionSettings
s {$sel:dataAccessRoleArn:JobExecutionSettings' :: Maybe Text
dataAccessRoleArn = Maybe Text
a} :: JobExecutionSettings)

instance Data.FromJSON JobExecutionSettings where
  parseJSON :: Value -> Parser JobExecutionSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobExecutionSettings"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> JobExecutionSettings
JobExecutionSettings'
            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
"AllowDeferredExecution")
            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
"DataAccessRoleArn")
      )

instance Prelude.Hashable JobExecutionSettings where
  hashWithSalt :: Int -> JobExecutionSettings -> Int
hashWithSalt Int
_salt JobExecutionSettings' {Maybe Bool
Maybe Text
dataAccessRoleArn :: Maybe Text
allowDeferredExecution :: Maybe Bool
$sel:dataAccessRoleArn:JobExecutionSettings' :: JobExecutionSettings -> Maybe Text
$sel:allowDeferredExecution:JobExecutionSettings' :: JobExecutionSettings -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowDeferredExecution
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataAccessRoleArn

instance Prelude.NFData JobExecutionSettings where
  rnf :: JobExecutionSettings -> ()
rnf JobExecutionSettings' {Maybe Bool
Maybe Text
dataAccessRoleArn :: Maybe Text
allowDeferredExecution :: Maybe Bool
$sel:dataAccessRoleArn:JobExecutionSettings' :: JobExecutionSettings -> Maybe Text
$sel:allowDeferredExecution:JobExecutionSettings' :: JobExecutionSettings -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowDeferredExecution
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataAccessRoleArn

instance Data.ToJSON JobExecutionSettings where
  toJSON :: JobExecutionSettings -> Value
toJSON JobExecutionSettings' {Maybe Bool
Maybe Text
dataAccessRoleArn :: Maybe Text
allowDeferredExecution :: Maybe Bool
$sel:dataAccessRoleArn:JobExecutionSettings' :: JobExecutionSettings -> Maybe Text
$sel:allowDeferredExecution:JobExecutionSettings' :: JobExecutionSettings -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AllowDeferredExecution" 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 Bool
allowDeferredExecution,
            (Key
"DataAccessRoleArn" 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
dataAccessRoleArn
          ]
      )