{-# 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.EKS.Types.Update
-- 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.EKS.Types.Update where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EKS.Types.ErrorDetail
import Amazonka.EKS.Types.UpdateParam
import Amazonka.EKS.Types.UpdateStatus
import Amazonka.EKS.Types.UpdateType
import qualified Amazonka.Prelude as Prelude

-- | An object representing an asynchronous update.
--
-- /See:/ 'newUpdate' smart constructor.
data Update = Update'
  { -- | The Unix epoch timestamp in seconds for when the update was created.
    Update -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | Any errors associated with a @Failed@ update.
    Update -> Maybe [ErrorDetail]
errors :: Prelude.Maybe [ErrorDetail],
    -- | A UUID that is used to track the update.
    Update -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A key-value map that contains the parameters associated with the update.
    Update -> Maybe [UpdateParam]
params :: Prelude.Maybe [UpdateParam],
    -- | The current status of the update.
    Update -> Maybe UpdateStatus
status :: Prelude.Maybe UpdateStatus,
    -- | The type of the update.
    Update -> Maybe UpdateType
type' :: Prelude.Maybe UpdateType
  }
  deriving (Update -> Update -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Update -> Update -> Bool
$c/= :: Update -> Update -> Bool
== :: Update -> Update -> Bool
$c== :: Update -> Update -> Bool
Prelude.Eq, ReadPrec [Update]
ReadPrec Update
Int -> ReadS Update
ReadS [Update]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Update]
$creadListPrec :: ReadPrec [Update]
readPrec :: ReadPrec Update
$creadPrec :: ReadPrec Update
readList :: ReadS [Update]
$creadList :: ReadS [Update]
readsPrec :: Int -> ReadS Update
$creadsPrec :: Int -> ReadS Update
Prelude.Read, Int -> Update -> ShowS
[Update] -> ShowS
Update -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Update] -> ShowS
$cshowList :: [Update] -> ShowS
show :: Update -> String
$cshow :: Update -> String
showsPrec :: Int -> Update -> ShowS
$cshowsPrec :: Int -> Update -> ShowS
Prelude.Show, forall x. Rep Update x -> Update
forall x. Update -> Rep Update x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Update x -> Update
$cfrom :: forall x. Update -> Rep Update x
Prelude.Generic)

-- |
-- Create a value of 'Update' 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:
--
-- 'createdAt', 'update_createdAt' - The Unix epoch timestamp in seconds for when the update was created.
--
-- 'errors', 'update_errors' - Any errors associated with a @Failed@ update.
--
-- 'id', 'update_id' - A UUID that is used to track the update.
--
-- 'params', 'update_params' - A key-value map that contains the parameters associated with the update.
--
-- 'status', 'update_status' - The current status of the update.
--
-- 'type'', 'update_type' - The type of the update.
newUpdate ::
  Update
newUpdate :: Update
newUpdate =
  Update'
    { $sel:createdAt:Update' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:errors:Update' :: Maybe [ErrorDetail]
errors = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Update' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:params:Update' :: Maybe [UpdateParam]
params = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Update' :: Maybe UpdateStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Update' :: Maybe UpdateType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The Unix epoch timestamp in seconds for when the update was created.
update_createdAt :: Lens.Lens' Update (Prelude.Maybe Prelude.UTCTime)
update_createdAt :: Lens' Update (Maybe UTCTime)
update_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:Update' :: Update -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: Update
s@Update' {} Maybe POSIX
a -> Update
s {$sel:createdAt:Update' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: Update) 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

-- | Any errors associated with a @Failed@ update.
update_errors :: Lens.Lens' Update (Prelude.Maybe [ErrorDetail])
update_errors :: Lens' Update (Maybe [ErrorDetail])
update_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe [ErrorDetail]
errors :: Maybe [ErrorDetail]
$sel:errors:Update' :: Update -> Maybe [ErrorDetail]
errors} -> Maybe [ErrorDetail]
errors) (\s :: Update
s@Update' {} Maybe [ErrorDetail]
a -> Update
s {$sel:errors:Update' :: Maybe [ErrorDetail]
errors = Maybe [ErrorDetail]
a} :: Update) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A UUID that is used to track the update.
update_id :: Lens.Lens' Update (Prelude.Maybe Prelude.Text)
update_id :: Lens' Update (Maybe Text)
update_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe Text
id :: Maybe Text
$sel:id:Update' :: Update -> Maybe Text
id} -> Maybe Text
id) (\s :: Update
s@Update' {} Maybe Text
a -> Update
s {$sel:id:Update' :: Maybe Text
id = Maybe Text
a} :: Update)

-- | A key-value map that contains the parameters associated with the update.
update_params :: Lens.Lens' Update (Prelude.Maybe [UpdateParam])
update_params :: Lens' Update (Maybe [UpdateParam])
update_params = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe [UpdateParam]
params :: Maybe [UpdateParam]
$sel:params:Update' :: Update -> Maybe [UpdateParam]
params} -> Maybe [UpdateParam]
params) (\s :: Update
s@Update' {} Maybe [UpdateParam]
a -> Update
s {$sel:params:Update' :: Maybe [UpdateParam]
params = Maybe [UpdateParam]
a} :: Update) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The current status of the update.
update_status :: Lens.Lens' Update (Prelude.Maybe UpdateStatus)
update_status :: Lens' Update (Maybe UpdateStatus)
update_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe UpdateStatus
status :: Maybe UpdateStatus
$sel:status:Update' :: Update -> Maybe UpdateStatus
status} -> Maybe UpdateStatus
status) (\s :: Update
s@Update' {} Maybe UpdateStatus
a -> Update
s {$sel:status:Update' :: Maybe UpdateStatus
status = Maybe UpdateStatus
a} :: Update)

-- | The type of the update.
update_type :: Lens.Lens' Update (Prelude.Maybe UpdateType)
update_type :: Lens' Update (Maybe UpdateType)
update_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe UpdateType
type' :: Maybe UpdateType
$sel:type':Update' :: Update -> Maybe UpdateType
type'} -> Maybe UpdateType
type') (\s :: Update
s@Update' {} Maybe UpdateType
a -> Update
s {$sel:type':Update' :: Maybe UpdateType
type' = Maybe UpdateType
a} :: Update)

instance Data.FromJSON Update where
  parseJSON :: Value -> Parser Update
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Update"
      ( \Object
x ->
          Maybe POSIX
-> Maybe [ErrorDetail]
-> Maybe Text
-> Maybe [UpdateParam]
-> Maybe UpdateStatus
-> Maybe UpdateType
-> Update
Update'
            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
"createdAt")
            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
"errors" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"id")
            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
"params" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"status")
            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
"type")
      )

instance Prelude.Hashable Update where
  hashWithSalt :: Int -> Update -> Int
hashWithSalt Int
_salt Update' {Maybe [ErrorDetail]
Maybe [UpdateParam]
Maybe Text
Maybe POSIX
Maybe UpdateStatus
Maybe UpdateType
type' :: Maybe UpdateType
status :: Maybe UpdateStatus
params :: Maybe [UpdateParam]
id :: Maybe Text
errors :: Maybe [ErrorDetail]
createdAt :: Maybe POSIX
$sel:type':Update' :: Update -> Maybe UpdateType
$sel:status:Update' :: Update -> Maybe UpdateStatus
$sel:params:Update' :: Update -> Maybe [UpdateParam]
$sel:id:Update' :: Update -> Maybe Text
$sel:errors:Update' :: Update -> Maybe [ErrorDetail]
$sel:createdAt:Update' :: Update -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ErrorDetail]
errors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UpdateParam]
params
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateType
type'

instance Prelude.NFData Update where
  rnf :: Update -> ()
rnf Update' {Maybe [ErrorDetail]
Maybe [UpdateParam]
Maybe Text
Maybe POSIX
Maybe UpdateStatus
Maybe UpdateType
type' :: Maybe UpdateType
status :: Maybe UpdateStatus
params :: Maybe [UpdateParam]
id :: Maybe Text
errors :: Maybe [ErrorDetail]
createdAt :: Maybe POSIX
$sel:type':Update' :: Update -> Maybe UpdateType
$sel:status:Update' :: Update -> Maybe UpdateStatus
$sel:params:Update' :: Update -> Maybe [UpdateParam]
$sel:id:Update' :: Update -> Maybe Text
$sel:errors:Update' :: Update -> Maybe [ErrorDetail]
$sel:createdAt:Update' :: Update -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ErrorDetail]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UpdateParam]
params
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateType
type'