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

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

-- | An object representing an Amazon ECR image layer.
--
-- /See:/ 'newLayer' smart constructor.
data Layer = Layer'
  { -- | The media type of the layer, such as
    -- @application\/vnd.docker.image.rootfs.diff.tar.gzip@ or
    -- @application\/vnd.oci.image.layer.v1.tar+gzip@.
    Layer -> Maybe Text
mediaType :: Prelude.Maybe Prelude.Text,
    -- | The @sha256@ digest of the image layer.
    Layer -> Maybe Text
layerDigest :: Prelude.Maybe Prelude.Text,
    -- | The size, in bytes, of the image layer.
    Layer -> Maybe Integer
layerSize :: Prelude.Maybe Prelude.Integer,
    -- | The availability status of the image layer.
    Layer -> Maybe LayerAvailability
layerAvailability :: Prelude.Maybe LayerAvailability
  }
  deriving (Layer -> Layer -> Bool
(Layer -> Layer -> Bool) -> (Layer -> Layer -> Bool) -> Eq Layer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Layer -> Layer -> Bool
$c/= :: Layer -> Layer -> Bool
== :: Layer -> Layer -> Bool
$c== :: Layer -> Layer -> Bool
Prelude.Eq, ReadPrec [Layer]
ReadPrec Layer
Int -> ReadS Layer
ReadS [Layer]
(Int -> ReadS Layer)
-> ReadS [Layer]
-> ReadPrec Layer
-> ReadPrec [Layer]
-> Read Layer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Layer]
$creadListPrec :: ReadPrec [Layer]
readPrec :: ReadPrec Layer
$creadPrec :: ReadPrec Layer
readList :: ReadS [Layer]
$creadList :: ReadS [Layer]
readsPrec :: Int -> ReadS Layer
$creadsPrec :: Int -> ReadS Layer
Prelude.Read, Int -> Layer -> ShowS
[Layer] -> ShowS
Layer -> String
(Int -> Layer -> ShowS)
-> (Layer -> String) -> ([Layer] -> ShowS) -> Show Layer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Layer] -> ShowS
$cshowList :: [Layer] -> ShowS
show :: Layer -> String
$cshow :: Layer -> String
showsPrec :: Int -> Layer -> ShowS
$cshowsPrec :: Int -> Layer -> ShowS
Prelude.Show, (forall x. Layer -> Rep Layer x)
-> (forall x. Rep Layer x -> Layer) -> Generic Layer
forall x. Rep Layer x -> Layer
forall x. Layer -> Rep Layer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Layer x -> Layer
$cfrom :: forall x. Layer -> Rep Layer x
Prelude.Generic)

-- |
-- Create a value of 'Layer' 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:
--
-- 'mediaType', 'layer_mediaType' - The media type of the layer, such as
-- @application\/vnd.docker.image.rootfs.diff.tar.gzip@ or
-- @application\/vnd.oci.image.layer.v1.tar+gzip@.
--
-- 'layerDigest', 'layer_layerDigest' - The @sha256@ digest of the image layer.
--
-- 'layerSize', 'layer_layerSize' - The size, in bytes, of the image layer.
--
-- 'layerAvailability', 'layer_layerAvailability' - The availability status of the image layer.
newLayer ::
  Layer
newLayer :: Layer
newLayer =
  Layer' :: Maybe Text
-> Maybe Text -> Maybe Integer -> Maybe LayerAvailability -> Layer
Layer'
    { $sel:mediaType:Layer' :: Maybe Text
mediaType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:layerDigest:Layer' :: Maybe Text
layerDigest = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:layerSize:Layer' :: Maybe Integer
layerSize = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:layerAvailability:Layer' :: Maybe LayerAvailability
layerAvailability = Maybe LayerAvailability
forall a. Maybe a
Prelude.Nothing
    }

-- | The media type of the layer, such as
-- @application\/vnd.docker.image.rootfs.diff.tar.gzip@ or
-- @application\/vnd.oci.image.layer.v1.tar+gzip@.
layer_mediaType :: Lens.Lens' Layer (Prelude.Maybe Prelude.Text)
layer_mediaType :: (Maybe Text -> f (Maybe Text)) -> Layer -> f Layer
layer_mediaType = (Layer -> Maybe Text)
-> (Layer -> Maybe Text -> Layer)
-> Lens Layer Layer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Layer' {Maybe Text
mediaType :: Maybe Text
$sel:mediaType:Layer' :: Layer -> Maybe Text
mediaType} -> Maybe Text
mediaType) (\s :: Layer
s@Layer' {} Maybe Text
a -> Layer
s {$sel:mediaType:Layer' :: Maybe Text
mediaType = Maybe Text
a} :: Layer)

-- | The @sha256@ digest of the image layer.
layer_layerDigest :: Lens.Lens' Layer (Prelude.Maybe Prelude.Text)
layer_layerDigest :: (Maybe Text -> f (Maybe Text)) -> Layer -> f Layer
layer_layerDigest = (Layer -> Maybe Text)
-> (Layer -> Maybe Text -> Layer)
-> Lens Layer Layer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Layer' {Maybe Text
layerDigest :: Maybe Text
$sel:layerDigest:Layer' :: Layer -> Maybe Text
layerDigest} -> Maybe Text
layerDigest) (\s :: Layer
s@Layer' {} Maybe Text
a -> Layer
s {$sel:layerDigest:Layer' :: Maybe Text
layerDigest = Maybe Text
a} :: Layer)

-- | The size, in bytes, of the image layer.
layer_layerSize :: Lens.Lens' Layer (Prelude.Maybe Prelude.Integer)
layer_layerSize :: (Maybe Integer -> f (Maybe Integer)) -> Layer -> f Layer
layer_layerSize = (Layer -> Maybe Integer)
-> (Layer -> Maybe Integer -> Layer)
-> Lens Layer Layer (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Layer' {Maybe Integer
layerSize :: Maybe Integer
$sel:layerSize:Layer' :: Layer -> Maybe Integer
layerSize} -> Maybe Integer
layerSize) (\s :: Layer
s@Layer' {} Maybe Integer
a -> Layer
s {$sel:layerSize:Layer' :: Maybe Integer
layerSize = Maybe Integer
a} :: Layer)

-- | The availability status of the image layer.
layer_layerAvailability :: Lens.Lens' Layer (Prelude.Maybe LayerAvailability)
layer_layerAvailability :: (Maybe LayerAvailability -> f (Maybe LayerAvailability))
-> Layer -> f Layer
layer_layerAvailability = (Layer -> Maybe LayerAvailability)
-> (Layer -> Maybe LayerAvailability -> Layer)
-> Lens
     Layer Layer (Maybe LayerAvailability) (Maybe LayerAvailability)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Layer' {Maybe LayerAvailability
layerAvailability :: Maybe LayerAvailability
$sel:layerAvailability:Layer' :: Layer -> Maybe LayerAvailability
layerAvailability} -> Maybe LayerAvailability
layerAvailability) (\s :: Layer
s@Layer' {} Maybe LayerAvailability
a -> Layer
s {$sel:layerAvailability:Layer' :: Maybe LayerAvailability
layerAvailability = Maybe LayerAvailability
a} :: Layer)

instance Core.FromJSON Layer where
  parseJSON :: Value -> Parser Layer
parseJSON =
    String -> (Object -> Parser Layer) -> Value -> Parser Layer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Layer"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Integer -> Maybe LayerAvailability -> Layer
Layer'
            (Maybe Text
 -> Maybe Text -> Maybe Integer -> Maybe LayerAvailability -> Layer)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Integer -> Maybe LayerAvailability -> Layer)
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
"mediaType")
            Parser
  (Maybe Text -> Maybe Integer -> Maybe LayerAvailability -> Layer)
-> Parser (Maybe Text)
-> Parser (Maybe Integer -> Maybe LayerAvailability -> Layer)
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")
            Parser (Maybe Integer -> Maybe LayerAvailability -> Layer)
-> Parser (Maybe Integer)
-> Parser (Maybe LayerAvailability -> Layer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"layerSize")
            Parser (Maybe LayerAvailability -> Layer)
-> Parser (Maybe LayerAvailability) -> Parser Layer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LayerAvailability)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"layerAvailability")
      )

instance Prelude.Hashable Layer

instance Prelude.NFData Layer