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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides information about when a transcription job should be executed.
--
-- /See:/ 'newJobExecutionSettings' smart constructor.
data JobExecutionSettings = JobExecutionSettings'
  { -- | The Amazon Resource Name (ARN) of a role that has access to the S3
    -- bucket that contains the input files. Amazon Transcribe assumes this
    -- role to read queued media files. If you have specified an output S3
    -- bucket for the transcription results, this role should have access to
    -- the output bucket as well.
    --
    -- If you specify the @AllowDeferredExecution@ field, you must specify the
    -- @DataAccessRoleArn@ field.
    JobExecutionSettings -> Maybe Text
dataAccessRoleArn :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether a job should be queued by Amazon Transcribe when the
    -- concurrent execution limit is exceeded. When the
    -- @AllowDeferredExecution@ field is true, jobs are queued and executed
    -- when the number of executing jobs falls below the concurrent execution
    -- limit. If the field is false, Amazon Transcribe returns a
    -- @LimitExceededException@ exception.
    --
    -- Note that job queuing is enabled by default for call analytics jobs.
    --
    -- If you specify the @AllowDeferredExecution@ field, you must specify the
    -- @DataAccessRoleArn@ field.
    JobExecutionSettings -> Maybe Bool
allowDeferredExecution :: Prelude.Maybe Prelude.Bool
  }
  deriving (JobExecutionSettings -> JobExecutionSettings -> Bool
(JobExecutionSettings -> JobExecutionSettings -> Bool)
-> (JobExecutionSettings -> JobExecutionSettings -> Bool)
-> Eq JobExecutionSettings
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]
(Int -> ReadS JobExecutionSettings)
-> ReadS [JobExecutionSettings]
-> ReadPrec JobExecutionSettings
-> ReadPrec [JobExecutionSettings]
-> Read 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
(Int -> JobExecutionSettings -> ShowS)
-> (JobExecutionSettings -> String)
-> ([JobExecutionSettings] -> ShowS)
-> Show JobExecutionSettings
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. JobExecutionSettings -> Rep JobExecutionSettings x)
-> (forall x. Rep JobExecutionSettings x -> JobExecutionSettings)
-> Generic JobExecutionSettings
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:
--
-- 'dataAccessRoleArn', 'jobExecutionSettings_dataAccessRoleArn' - The Amazon Resource Name (ARN) of a role that has access to the S3
-- bucket that contains the input files. Amazon Transcribe assumes this
-- role to read queued media files. If you have specified an output S3
-- bucket for the transcription results, this role should have access to
-- the output bucket as well.
--
-- If you specify the @AllowDeferredExecution@ field, you must specify the
-- @DataAccessRoleArn@ field.
--
-- 'allowDeferredExecution', 'jobExecutionSettings_allowDeferredExecution' - Indicates whether a job should be queued by Amazon Transcribe when the
-- concurrent execution limit is exceeded. When the
-- @AllowDeferredExecution@ field is true, jobs are queued and executed
-- when the number of executing jobs falls below the concurrent execution
-- limit. If the field is false, Amazon Transcribe returns a
-- @LimitExceededException@ exception.
--
-- Note that job queuing is enabled by default for call analytics jobs.
--
-- If you specify the @AllowDeferredExecution@ field, you must specify the
-- @DataAccessRoleArn@ field.
newJobExecutionSettings ::
  JobExecutionSettings
newJobExecutionSettings :: JobExecutionSettings
newJobExecutionSettings =
  JobExecutionSettings' :: Maybe Text -> Maybe Bool -> JobExecutionSettings
JobExecutionSettings'
    { $sel:dataAccessRoleArn:JobExecutionSettings' :: Maybe Text
dataAccessRoleArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowDeferredExecution:JobExecutionSettings' :: Maybe Bool
allowDeferredExecution = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of a role that has access to the S3
-- bucket that contains the input files. Amazon Transcribe assumes this
-- role to read queued media files. If you have specified an output S3
-- bucket for the transcription results, this role should have access to
-- the output bucket as well.
--
-- If you specify the @AllowDeferredExecution@ field, you must specify the
-- @DataAccessRoleArn@ field.
jobExecutionSettings_dataAccessRoleArn :: Lens.Lens' JobExecutionSettings (Prelude.Maybe Prelude.Text)
jobExecutionSettings_dataAccessRoleArn :: (Maybe Text -> f (Maybe Text))
-> JobExecutionSettings -> f JobExecutionSettings
jobExecutionSettings_dataAccessRoleArn = (JobExecutionSettings -> Maybe Text)
-> (JobExecutionSettings -> Maybe Text -> JobExecutionSettings)
-> Lens
     JobExecutionSettings JobExecutionSettings (Maybe Text) (Maybe Text)
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)

-- | Indicates whether a job should be queued by Amazon Transcribe when the
-- concurrent execution limit is exceeded. When the
-- @AllowDeferredExecution@ field is true, jobs are queued and executed
-- when the number of executing jobs falls below the concurrent execution
-- limit. If the field is false, Amazon Transcribe returns a
-- @LimitExceededException@ exception.
--
-- Note that job queuing is enabled by default for call analytics jobs.
--
-- If you specify the @AllowDeferredExecution@ field, you must specify the
-- @DataAccessRoleArn@ field.
jobExecutionSettings_allowDeferredExecution :: Lens.Lens' JobExecutionSettings (Prelude.Maybe Prelude.Bool)
jobExecutionSettings_allowDeferredExecution :: (Maybe Bool -> f (Maybe Bool))
-> JobExecutionSettings -> f JobExecutionSettings
jobExecutionSettings_allowDeferredExecution = (JobExecutionSettings -> Maybe Bool)
-> (JobExecutionSettings -> Maybe Bool -> JobExecutionSettings)
-> Lens
     JobExecutionSettings JobExecutionSettings (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON JobExecutionSettings where
  parseJSON :: Value -> Parser JobExecutionSettings
parseJSON =
    String
-> (Object -> Parser JobExecutionSettings)
-> Value
-> Parser JobExecutionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JobExecutionSettings"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> JobExecutionSettings
JobExecutionSettings'
            (Maybe Text -> Maybe Bool -> JobExecutionSettings)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> JobExecutionSettings)
forall (f :: * -> *) a b. Functor 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
"DataAccessRoleArn")
            Parser (Maybe Bool -> JobExecutionSettings)
-> Parser (Maybe Bool) -> Parser JobExecutionSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowDeferredExecution")
      )

instance Prelude.Hashable JobExecutionSettings

instance Prelude.NFData JobExecutionSettings

instance Core.ToJSON JobExecutionSettings where
  toJSON :: JobExecutionSettings -> Value
toJSON JobExecutionSettings' {Maybe Bool
Maybe Text
allowDeferredExecution :: Maybe Bool
dataAccessRoleArn :: Maybe Text
$sel:allowDeferredExecution:JobExecutionSettings' :: JobExecutionSettings -> Maybe Bool
$sel:dataAccessRoleArn:JobExecutionSettings' :: JobExecutionSettings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DataAccessRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataAccessRoleArn,
            (Text
"AllowDeferredExecution" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowDeferredExecution
          ]
      )