{-# 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.ECS.Types.ProtectedTask
-- 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.ECS.Types.ProtectedTask 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

-- | An object representing the protection status details for a task. You can
-- set the protection status with the UpdateTaskProtection API and get the
-- status of tasks with the GetTaskProtection API.
--
-- /See:/ 'newProtectedTask' smart constructor.
data ProtectedTask = ProtectedTask'
  { -- | The epoch time when protection for the task will expire.
    ProtectedTask -> Maybe POSIX
expirationDate :: Prelude.Maybe Data.POSIX,
    -- | The protection status of the task. If scale-in protection is enabled for
    -- a task, the value is @true@. Otherwise, it is @false@.
    ProtectedTask -> Maybe Bool
protectionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The task ARN.
    ProtectedTask -> Maybe Text
taskArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ProtectedTask -> ProtectedTask -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtectedTask -> ProtectedTask -> Bool
$c/= :: ProtectedTask -> ProtectedTask -> Bool
== :: ProtectedTask -> ProtectedTask -> Bool
$c== :: ProtectedTask -> ProtectedTask -> Bool
Prelude.Eq, ReadPrec [ProtectedTask]
ReadPrec ProtectedTask
Int -> ReadS ProtectedTask
ReadS [ProtectedTask]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProtectedTask]
$creadListPrec :: ReadPrec [ProtectedTask]
readPrec :: ReadPrec ProtectedTask
$creadPrec :: ReadPrec ProtectedTask
readList :: ReadS [ProtectedTask]
$creadList :: ReadS [ProtectedTask]
readsPrec :: Int -> ReadS ProtectedTask
$creadsPrec :: Int -> ReadS ProtectedTask
Prelude.Read, Int -> ProtectedTask -> ShowS
[ProtectedTask] -> ShowS
ProtectedTask -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtectedTask] -> ShowS
$cshowList :: [ProtectedTask] -> ShowS
show :: ProtectedTask -> String
$cshow :: ProtectedTask -> String
showsPrec :: Int -> ProtectedTask -> ShowS
$cshowsPrec :: Int -> ProtectedTask -> ShowS
Prelude.Show, forall x. Rep ProtectedTask x -> ProtectedTask
forall x. ProtectedTask -> Rep ProtectedTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProtectedTask x -> ProtectedTask
$cfrom :: forall x. ProtectedTask -> Rep ProtectedTask x
Prelude.Generic)

-- |
-- Create a value of 'ProtectedTask' 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:
--
-- 'expirationDate', 'protectedTask_expirationDate' - The epoch time when protection for the task will expire.
--
-- 'protectionEnabled', 'protectedTask_protectionEnabled' - The protection status of the task. If scale-in protection is enabled for
-- a task, the value is @true@. Otherwise, it is @false@.
--
-- 'taskArn', 'protectedTask_taskArn' - The task ARN.
newProtectedTask ::
  ProtectedTask
newProtectedTask :: ProtectedTask
newProtectedTask =
  ProtectedTask'
    { $sel:expirationDate:ProtectedTask' :: Maybe POSIX
expirationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:protectionEnabled:ProtectedTask' :: Maybe Bool
protectionEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:taskArn:ProtectedTask' :: Maybe Text
taskArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The epoch time when protection for the task will expire.
protectedTask_expirationDate :: Lens.Lens' ProtectedTask (Prelude.Maybe Prelude.UTCTime)
protectedTask_expirationDate :: Lens' ProtectedTask (Maybe UTCTime)
protectedTask_expirationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectedTask' {Maybe POSIX
expirationDate :: Maybe POSIX
$sel:expirationDate:ProtectedTask' :: ProtectedTask -> Maybe POSIX
expirationDate} -> Maybe POSIX
expirationDate) (\s :: ProtectedTask
s@ProtectedTask' {} Maybe POSIX
a -> ProtectedTask
s {$sel:expirationDate:ProtectedTask' :: Maybe POSIX
expirationDate = Maybe POSIX
a} :: ProtectedTask) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The protection status of the task. If scale-in protection is enabled for
-- a task, the value is @true@. Otherwise, it is @false@.
protectedTask_protectionEnabled :: Lens.Lens' ProtectedTask (Prelude.Maybe Prelude.Bool)
protectedTask_protectionEnabled :: Lens' ProtectedTask (Maybe Bool)
protectedTask_protectionEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectedTask' {Maybe Bool
protectionEnabled :: Maybe Bool
$sel:protectionEnabled:ProtectedTask' :: ProtectedTask -> Maybe Bool
protectionEnabled} -> Maybe Bool
protectionEnabled) (\s :: ProtectedTask
s@ProtectedTask' {} Maybe Bool
a -> ProtectedTask
s {$sel:protectionEnabled:ProtectedTask' :: Maybe Bool
protectionEnabled = Maybe Bool
a} :: ProtectedTask)

-- | The task ARN.
protectedTask_taskArn :: Lens.Lens' ProtectedTask (Prelude.Maybe Prelude.Text)
protectedTask_taskArn :: Lens' ProtectedTask (Maybe Text)
protectedTask_taskArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectedTask' {Maybe Text
taskArn :: Maybe Text
$sel:taskArn:ProtectedTask' :: ProtectedTask -> Maybe Text
taskArn} -> Maybe Text
taskArn) (\s :: ProtectedTask
s@ProtectedTask' {} Maybe Text
a -> ProtectedTask
s {$sel:taskArn:ProtectedTask' :: Maybe Text
taskArn = Maybe Text
a} :: ProtectedTask)

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

instance Prelude.Hashable ProtectedTask where
  hashWithSalt :: Int -> ProtectedTask -> Int
hashWithSalt Int
_salt ProtectedTask' {Maybe Bool
Maybe Text
Maybe POSIX
taskArn :: Maybe Text
protectionEnabled :: Maybe Bool
expirationDate :: Maybe POSIX
$sel:taskArn:ProtectedTask' :: ProtectedTask -> Maybe Text
$sel:protectionEnabled:ProtectedTask' :: ProtectedTask -> Maybe Bool
$sel:expirationDate:ProtectedTask' :: ProtectedTask -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expirationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
protectionEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
taskArn

instance Prelude.NFData ProtectedTask where
  rnf :: ProtectedTask -> ()
rnf ProtectedTask' {Maybe Bool
Maybe Text
Maybe POSIX
taskArn :: Maybe Text
protectionEnabled :: Maybe Bool
expirationDate :: Maybe POSIX
$sel:taskArn:ProtectedTask' :: ProtectedTask -> Maybe Text
$sel:protectionEnabled:ProtectedTask' :: ProtectedTask -> Maybe Bool
$sel:expirationDate:ProtectedTask' :: ProtectedTask -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expirationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
protectionEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
taskArn