{-# 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.ECRPublic.Types.LayerFailure
-- 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.ECRPublic.Types.LayerFailure where

import qualified Amazonka.Core as Core
import Amazonka.ECRPublic.Types.LayerFailureCode
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing an Amazon ECR image layer failure.
--
-- /See:/ 'newLayerFailure' smart constructor.
data LayerFailure = LayerFailure'
  { -- | The reason for the failure.
    LayerFailure -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | The failure code associated with the failure.
    LayerFailure -> Maybe LayerFailureCode
failureCode :: Prelude.Maybe LayerFailureCode,
    -- | The layer digest associated with the failure.
    LayerFailure -> Maybe Text
layerDigest :: Prelude.Maybe Prelude.Text
  }
  deriving (LayerFailure -> LayerFailure -> Bool
(LayerFailure -> LayerFailure -> Bool)
-> (LayerFailure -> LayerFailure -> Bool) -> Eq LayerFailure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LayerFailure -> LayerFailure -> Bool
$c/= :: LayerFailure -> LayerFailure -> Bool
== :: LayerFailure -> LayerFailure -> Bool
$c== :: LayerFailure -> LayerFailure -> Bool
Prelude.Eq, ReadPrec [LayerFailure]
ReadPrec LayerFailure
Int -> ReadS LayerFailure
ReadS [LayerFailure]
(Int -> ReadS LayerFailure)
-> ReadS [LayerFailure]
-> ReadPrec LayerFailure
-> ReadPrec [LayerFailure]
-> Read LayerFailure
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LayerFailure]
$creadListPrec :: ReadPrec [LayerFailure]
readPrec :: ReadPrec LayerFailure
$creadPrec :: ReadPrec LayerFailure
readList :: ReadS [LayerFailure]
$creadList :: ReadS [LayerFailure]
readsPrec :: Int -> ReadS LayerFailure
$creadsPrec :: Int -> ReadS LayerFailure
Prelude.Read, Int -> LayerFailure -> ShowS
[LayerFailure] -> ShowS
LayerFailure -> String
(Int -> LayerFailure -> ShowS)
-> (LayerFailure -> String)
-> ([LayerFailure] -> ShowS)
-> Show LayerFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LayerFailure] -> ShowS
$cshowList :: [LayerFailure] -> ShowS
show :: LayerFailure -> String
$cshow :: LayerFailure -> String
showsPrec :: Int -> LayerFailure -> ShowS
$cshowsPrec :: Int -> LayerFailure -> ShowS
Prelude.Show, (forall x. LayerFailure -> Rep LayerFailure x)
-> (forall x. Rep LayerFailure x -> LayerFailure)
-> Generic LayerFailure
forall x. Rep LayerFailure x -> LayerFailure
forall x. LayerFailure -> Rep LayerFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LayerFailure x -> LayerFailure
$cfrom :: forall x. LayerFailure -> Rep LayerFailure x
Prelude.Generic)

-- |
-- Create a value of 'LayerFailure' 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:
--
-- 'failureReason', 'layerFailure_failureReason' - The reason for the failure.
--
-- 'failureCode', 'layerFailure_failureCode' - The failure code associated with the failure.
--
-- 'layerDigest', 'layerFailure_layerDigest' - The layer digest associated with the failure.
newLayerFailure ::
  LayerFailure
newLayerFailure :: LayerFailure
newLayerFailure =
  LayerFailure' :: Maybe Text -> Maybe LayerFailureCode -> Maybe Text -> LayerFailure
LayerFailure'
    { $sel:failureReason:LayerFailure' :: Maybe Text
failureReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureCode:LayerFailure' :: Maybe LayerFailureCode
failureCode = Maybe LayerFailureCode
forall a. Maybe a
Prelude.Nothing,
      $sel:layerDigest:LayerFailure' :: Maybe Text
layerDigest = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The reason for the failure.
layerFailure_failureReason :: Lens.Lens' LayerFailure (Prelude.Maybe Prelude.Text)
layerFailure_failureReason :: (Maybe Text -> f (Maybe Text)) -> LayerFailure -> f LayerFailure
layerFailure_failureReason = (LayerFailure -> Maybe Text)
-> (LayerFailure -> Maybe Text -> LayerFailure)
-> Lens LayerFailure LayerFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayerFailure' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:LayerFailure' :: LayerFailure -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: LayerFailure
s@LayerFailure' {} Maybe Text
a -> LayerFailure
s {$sel:failureReason:LayerFailure' :: Maybe Text
failureReason = Maybe Text
a} :: LayerFailure)

-- | The failure code associated with the failure.
layerFailure_failureCode :: Lens.Lens' LayerFailure (Prelude.Maybe LayerFailureCode)
layerFailure_failureCode :: (Maybe LayerFailureCode -> f (Maybe LayerFailureCode))
-> LayerFailure -> f LayerFailure
layerFailure_failureCode = (LayerFailure -> Maybe LayerFailureCode)
-> (LayerFailure -> Maybe LayerFailureCode -> LayerFailure)
-> Lens
     LayerFailure
     LayerFailure
     (Maybe LayerFailureCode)
     (Maybe LayerFailureCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayerFailure' {Maybe LayerFailureCode
failureCode :: Maybe LayerFailureCode
$sel:failureCode:LayerFailure' :: LayerFailure -> Maybe LayerFailureCode
failureCode} -> Maybe LayerFailureCode
failureCode) (\s :: LayerFailure
s@LayerFailure' {} Maybe LayerFailureCode
a -> LayerFailure
s {$sel:failureCode:LayerFailure' :: Maybe LayerFailureCode
failureCode = Maybe LayerFailureCode
a} :: LayerFailure)

-- | The layer digest associated with the failure.
layerFailure_layerDigest :: Lens.Lens' LayerFailure (Prelude.Maybe Prelude.Text)
layerFailure_layerDigest :: (Maybe Text -> f (Maybe Text)) -> LayerFailure -> f LayerFailure
layerFailure_layerDigest = (LayerFailure -> Maybe Text)
-> (LayerFailure -> Maybe Text -> LayerFailure)
-> Lens LayerFailure LayerFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayerFailure' {Maybe Text
layerDigest :: Maybe Text
$sel:layerDigest:LayerFailure' :: LayerFailure -> Maybe Text
layerDigest} -> Maybe Text
layerDigest) (\s :: LayerFailure
s@LayerFailure' {} Maybe Text
a -> LayerFailure
s {$sel:layerDigest:LayerFailure' :: Maybe Text
layerDigest = Maybe Text
a} :: LayerFailure)

instance Core.FromJSON LayerFailure where
  parseJSON :: Value -> Parser LayerFailure
parseJSON =
    String
-> (Object -> Parser LayerFailure) -> Value -> Parser LayerFailure
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LayerFailure"
      ( \Object
x ->
          Maybe Text -> Maybe LayerFailureCode -> Maybe Text -> LayerFailure
LayerFailure'
            (Maybe Text
 -> Maybe LayerFailureCode -> Maybe Text -> LayerFailure)
-> Parser (Maybe Text)
-> Parser (Maybe LayerFailureCode -> Maybe Text -> LayerFailure)
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
"failureReason")
            Parser (Maybe LayerFailureCode -> Maybe Text -> LayerFailure)
-> Parser (Maybe LayerFailureCode)
-> Parser (Maybe Text -> LayerFailure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LayerFailureCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failureCode")
            Parser (Maybe Text -> LayerFailure)
-> Parser (Maybe Text) -> Parser LayerFailure
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
"layerDigest")
      )

instance Prelude.Hashable LayerFailure

instance Prelude.NFData LayerFailure