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

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

-- | An object representing an asynchronous update.
--
-- /See:/ 'newUpdate' smart constructor.
data Update = Update'
  { -- | The current status of the update.
    Update -> Maybe UpdateStatus
status :: Prelude.Maybe UpdateStatus,
    -- | The Unix epoch timestamp in seconds for when the update was created.
    Update -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | A key-value map that contains the parameters associated with the update.
    Update -> Maybe [UpdateParam]
params :: Prelude.Maybe [UpdateParam],
    -- | A UUID that is used to track the update.
    Update -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The type of the update.
    Update -> Maybe UpdateType
type' :: Prelude.Maybe UpdateType,
    -- | Any errors associated with a @Failed@ update.
    Update -> Maybe [ErrorDetail]
errors :: Prelude.Maybe [ErrorDetail]
  }
  deriving (Update -> Update -> Bool
(Update -> Update -> Bool)
-> (Update -> Update -> Bool) -> Eq Update
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]
(Int -> ReadS Update)
-> ReadS [Update]
-> ReadPrec Update
-> ReadPrec [Update]
-> Read 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
(Int -> Update -> ShowS)
-> (Update -> String) -> ([Update] -> ShowS) -> Show Update
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. Update -> Rep Update x)
-> (forall x. Rep Update x -> Update) -> Generic Update
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:
--
-- 'status', 'update_status' - The current status of the update.
--
-- 'createdAt', 'update_createdAt' - The Unix epoch timestamp in seconds for when the update was created.
--
-- 'params', 'update_params' - A key-value map that contains the parameters associated with the update.
--
-- 'id', 'update_id' - A UUID that is used to track the update.
--
-- 'type'', 'update_type' - The type of the update.
--
-- 'errors', 'update_errors' - Any errors associated with a @Failed@ update.
newUpdate ::
  Update
newUpdate :: Update
newUpdate =
  Update' :: Maybe UpdateStatus
-> Maybe POSIX
-> Maybe [UpdateParam]
-> Maybe Text
-> Maybe UpdateType
-> Maybe [ErrorDetail]
-> Update
Update'
    { $sel:status:Update' :: Maybe UpdateStatus
status = Maybe UpdateStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:Update' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:params:Update' :: Maybe [UpdateParam]
params = Maybe [UpdateParam]
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Update' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Update' :: Maybe UpdateType
type' = Maybe UpdateType
forall a. Maybe a
Prelude.Nothing,
      $sel:errors:Update' :: Maybe [ErrorDetail]
errors = Maybe [ErrorDetail]
forall a. Maybe a
Prelude.Nothing
    }

-- | The current status of the update.
update_status :: Lens.Lens' Update (Prelude.Maybe UpdateStatus)
update_status :: (Maybe UpdateStatus -> f (Maybe UpdateStatus))
-> Update -> f Update
update_status = (Update -> Maybe UpdateStatus)
-> (Update -> Maybe UpdateStatus -> Update)
-> Lens Update Update (Maybe UpdateStatus) (Maybe UpdateStatus)
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 Unix epoch timestamp in seconds for when the update was created.
update_createdAt :: Lens.Lens' Update (Prelude.Maybe Prelude.UTCTime)
update_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Update -> f Update
update_createdAt = (Update -> Maybe POSIX)
-> (Update -> Maybe POSIX -> Update)
-> Lens Update Update (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Update -> f Update)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Update
-> f Update
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A key-value map that contains the parameters associated with the update.
update_params :: Lens.Lens' Update (Prelude.Maybe [UpdateParam])
update_params :: (Maybe [UpdateParam] -> f (Maybe [UpdateParam]))
-> Update -> f Update
update_params = (Update -> Maybe [UpdateParam])
-> (Update -> Maybe [UpdateParam] -> Update)
-> Lens Update Update (Maybe [UpdateParam]) (Maybe [UpdateParam])
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) ((Maybe [UpdateParam] -> f (Maybe [UpdateParam]))
 -> Update -> f Update)
-> ((Maybe [UpdateParam] -> f (Maybe [UpdateParam]))
    -> Maybe [UpdateParam] -> f (Maybe [UpdateParam]))
-> (Maybe [UpdateParam] -> f (Maybe [UpdateParam]))
-> Update
-> f Update
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UpdateParam] [UpdateParam] [UpdateParam] [UpdateParam]
-> Iso
     (Maybe [UpdateParam])
     (Maybe [UpdateParam])
     (Maybe [UpdateParam])
     (Maybe [UpdateParam])
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 AnIso [UpdateParam] [UpdateParam] [UpdateParam] [UpdateParam]
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 :: (Maybe Text -> f (Maybe Text)) -> Update -> f Update
update_id = (Update -> Maybe Text)
-> (Update -> Maybe Text -> Update)
-> Lens Update Update (Maybe Text) (Maybe Text)
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)

-- | The type of the update.
update_type :: Lens.Lens' Update (Prelude.Maybe UpdateType)
update_type :: (Maybe UpdateType -> f (Maybe UpdateType)) -> Update -> f Update
update_type = (Update -> Maybe UpdateType)
-> (Update -> Maybe UpdateType -> Update)
-> Lens Update Update (Maybe UpdateType) (Maybe UpdateType)
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)

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

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

instance Prelude.Hashable Update

instance Prelude.NFData Update