{-# 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.HopDestination
-- 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.HopDestination where

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

-- | Optional. Configuration for a destination queue to which the job can hop
-- once a customer-defined minimum wait time has passed.
--
-- /See:/ 'newHopDestination' smart constructor.
data HopDestination = HopDestination'
  { -- | Optional. When you set up a job to use queue hopping, you can specify a
    -- different relative priority for the job in the destination queue. If you
    -- don\'t specify, the relative priority will remain the same as in the
    -- previous queue.
    HopDestination -> Maybe Int
priority :: Prelude.Maybe Prelude.Int,
    -- | Optional unless the job is submitted on the default queue. When you set
    -- up a job to use queue hopping, you can specify a destination queue. This
    -- queue cannot be the original queue to which the job is submitted. If the
    -- original queue isn\'t the default queue and you don\'t specify the
    -- destination queue, the job will move to the default queue.
    HopDestination -> Maybe Text
queue :: Prelude.Maybe Prelude.Text,
    -- | Required for setting up a job to use queue hopping. Minimum wait time in
    -- minutes until the job can hop to the destination queue. Valid range is 1
    -- to 1440 minutes, inclusive.
    HopDestination -> Maybe Int
waitMinutes :: Prelude.Maybe Prelude.Int
  }
  deriving (HopDestination -> HopDestination -> Bool
(HopDestination -> HopDestination -> Bool)
-> (HopDestination -> HopDestination -> Bool) -> Eq HopDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HopDestination -> HopDestination -> Bool
$c/= :: HopDestination -> HopDestination -> Bool
== :: HopDestination -> HopDestination -> Bool
$c== :: HopDestination -> HopDestination -> Bool
Prelude.Eq, ReadPrec [HopDestination]
ReadPrec HopDestination
Int -> ReadS HopDestination
ReadS [HopDestination]
(Int -> ReadS HopDestination)
-> ReadS [HopDestination]
-> ReadPrec HopDestination
-> ReadPrec [HopDestination]
-> Read HopDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HopDestination]
$creadListPrec :: ReadPrec [HopDestination]
readPrec :: ReadPrec HopDestination
$creadPrec :: ReadPrec HopDestination
readList :: ReadS [HopDestination]
$creadList :: ReadS [HopDestination]
readsPrec :: Int -> ReadS HopDestination
$creadsPrec :: Int -> ReadS HopDestination
Prelude.Read, Int -> HopDestination -> ShowS
[HopDestination] -> ShowS
HopDestination -> String
(Int -> HopDestination -> ShowS)
-> (HopDestination -> String)
-> ([HopDestination] -> ShowS)
-> Show HopDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HopDestination] -> ShowS
$cshowList :: [HopDestination] -> ShowS
show :: HopDestination -> String
$cshow :: HopDestination -> String
showsPrec :: Int -> HopDestination -> ShowS
$cshowsPrec :: Int -> HopDestination -> ShowS
Prelude.Show, (forall x. HopDestination -> Rep HopDestination x)
-> (forall x. Rep HopDestination x -> HopDestination)
-> Generic HopDestination
forall x. Rep HopDestination x -> HopDestination
forall x. HopDestination -> Rep HopDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HopDestination x -> HopDestination
$cfrom :: forall x. HopDestination -> Rep HopDestination x
Prelude.Generic)

-- |
-- Create a value of 'HopDestination' 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:
--
-- 'priority', 'hopDestination_priority' - Optional. When you set up a job to use queue hopping, you can specify a
-- different relative priority for the job in the destination queue. If you
-- don\'t specify, the relative priority will remain the same as in the
-- previous queue.
--
-- 'queue', 'hopDestination_queue' - Optional unless the job is submitted on the default queue. When you set
-- up a job to use queue hopping, you can specify a destination queue. This
-- queue cannot be the original queue to which the job is submitted. If the
-- original queue isn\'t the default queue and you don\'t specify the
-- destination queue, the job will move to the default queue.
--
-- 'waitMinutes', 'hopDestination_waitMinutes' - Required for setting up a job to use queue hopping. Minimum wait time in
-- minutes until the job can hop to the destination queue. Valid range is 1
-- to 1440 minutes, inclusive.
newHopDestination ::
  HopDestination
newHopDestination :: HopDestination
newHopDestination =
  HopDestination' :: Maybe Int -> Maybe Text -> Maybe Int -> HopDestination
HopDestination'
    { $sel:priority:HopDestination' :: Maybe Int
priority = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:queue:HopDestination' :: Maybe Text
queue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:waitMinutes:HopDestination' :: Maybe Int
waitMinutes = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Optional. When you set up a job to use queue hopping, you can specify a
-- different relative priority for the job in the destination queue. If you
-- don\'t specify, the relative priority will remain the same as in the
-- previous queue.
hopDestination_priority :: Lens.Lens' HopDestination (Prelude.Maybe Prelude.Int)
hopDestination_priority :: (Maybe Int -> f (Maybe Int)) -> HopDestination -> f HopDestination
hopDestination_priority = (HopDestination -> Maybe Int)
-> (HopDestination -> Maybe Int -> HopDestination)
-> Lens HopDestination HopDestination (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HopDestination' {Maybe Int
priority :: Maybe Int
$sel:priority:HopDestination' :: HopDestination -> Maybe Int
priority} -> Maybe Int
priority) (\s :: HopDestination
s@HopDestination' {} Maybe Int
a -> HopDestination
s {$sel:priority:HopDestination' :: Maybe Int
priority = Maybe Int
a} :: HopDestination)

-- | Optional unless the job is submitted on the default queue. When you set
-- up a job to use queue hopping, you can specify a destination queue. This
-- queue cannot be the original queue to which the job is submitted. If the
-- original queue isn\'t the default queue and you don\'t specify the
-- destination queue, the job will move to the default queue.
hopDestination_queue :: Lens.Lens' HopDestination (Prelude.Maybe Prelude.Text)
hopDestination_queue :: (Maybe Text -> f (Maybe Text))
-> HopDestination -> f HopDestination
hopDestination_queue = (HopDestination -> Maybe Text)
-> (HopDestination -> Maybe Text -> HopDestination)
-> Lens HopDestination HopDestination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HopDestination' {Maybe Text
queue :: Maybe Text
$sel:queue:HopDestination' :: HopDestination -> Maybe Text
queue} -> Maybe Text
queue) (\s :: HopDestination
s@HopDestination' {} Maybe Text
a -> HopDestination
s {$sel:queue:HopDestination' :: Maybe Text
queue = Maybe Text
a} :: HopDestination)

-- | Required for setting up a job to use queue hopping. Minimum wait time in
-- minutes until the job can hop to the destination queue. Valid range is 1
-- to 1440 minutes, inclusive.
hopDestination_waitMinutes :: Lens.Lens' HopDestination (Prelude.Maybe Prelude.Int)
hopDestination_waitMinutes :: (Maybe Int -> f (Maybe Int)) -> HopDestination -> f HopDestination
hopDestination_waitMinutes = (HopDestination -> Maybe Int)
-> (HopDestination -> Maybe Int -> HopDestination)
-> Lens HopDestination HopDestination (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HopDestination' {Maybe Int
waitMinutes :: Maybe Int
$sel:waitMinutes:HopDestination' :: HopDestination -> Maybe Int
waitMinutes} -> Maybe Int
waitMinutes) (\s :: HopDestination
s@HopDestination' {} Maybe Int
a -> HopDestination
s {$sel:waitMinutes:HopDestination' :: Maybe Int
waitMinutes = Maybe Int
a} :: HopDestination)

instance Core.FromJSON HopDestination where
  parseJSON :: Value -> Parser HopDestination
parseJSON =
    String
-> (Object -> Parser HopDestination)
-> Value
-> Parser HopDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HopDestination"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> Maybe Int -> HopDestination
HopDestination'
            (Maybe Int -> Maybe Text -> Maybe Int -> HopDestination)
-> Parser (Maybe Int)
-> Parser (Maybe Text -> Maybe Int -> HopDestination)
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
"priority")
            Parser (Maybe Text -> Maybe Int -> HopDestination)
-> Parser (Maybe Text) -> Parser (Maybe Int -> HopDestination)
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
"queue")
            Parser (Maybe Int -> HopDestination)
-> Parser (Maybe Int) -> Parser HopDestination
forall (f :: * -> *) a b. Applicative f => 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
"waitMinutes")
      )

instance Prelude.Hashable HopDestination

instance Prelude.NFData HopDestination

instance Core.ToJSON HopDestination where
  toJSON :: HopDestination -> Value
toJSON HopDestination' {Maybe Int
Maybe Text
waitMinutes :: Maybe Int
queue :: Maybe Text
priority :: Maybe Int
$sel:waitMinutes:HopDestination' :: HopDestination -> Maybe Int
$sel:queue:HopDestination' :: HopDestination -> Maybe Text
$sel:priority:HopDestination' :: HopDestination -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"priority" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
priority,
            (Text
"queue" 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
queue,
            (Text
"waitMinutes" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
waitMinutes
          ]
      )