{-# 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.ECR.Types.PullThroughCacheRule
-- 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.ECR.Types.PullThroughCacheRule 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

-- | The details of a pull through cache rule.
--
-- /See:/ 'newPullThroughCacheRule' smart constructor.
data PullThroughCacheRule = PullThroughCacheRule'
  { -- | The date and time the pull through cache was created.
    PullThroughCacheRule -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | The Amazon ECR repository prefix associated with the pull through cache
    -- rule.
    PullThroughCacheRule -> Maybe Text
ecrRepositoryPrefix :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services account ID associated with the registry the pull
    -- through cache rule is associated with.
    PullThroughCacheRule -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
    -- | The upstream registry URL associated with the pull through cache rule.
    PullThroughCacheRule -> Maybe Text
upstreamRegistryUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (PullThroughCacheRule -> PullThroughCacheRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PullThroughCacheRule -> PullThroughCacheRule -> Bool
$c/= :: PullThroughCacheRule -> PullThroughCacheRule -> Bool
== :: PullThroughCacheRule -> PullThroughCacheRule -> Bool
$c== :: PullThroughCacheRule -> PullThroughCacheRule -> Bool
Prelude.Eq, ReadPrec [PullThroughCacheRule]
ReadPrec PullThroughCacheRule
Int -> ReadS PullThroughCacheRule
ReadS [PullThroughCacheRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PullThroughCacheRule]
$creadListPrec :: ReadPrec [PullThroughCacheRule]
readPrec :: ReadPrec PullThroughCacheRule
$creadPrec :: ReadPrec PullThroughCacheRule
readList :: ReadS [PullThroughCacheRule]
$creadList :: ReadS [PullThroughCacheRule]
readsPrec :: Int -> ReadS PullThroughCacheRule
$creadsPrec :: Int -> ReadS PullThroughCacheRule
Prelude.Read, Int -> PullThroughCacheRule -> ShowS
[PullThroughCacheRule] -> ShowS
PullThroughCacheRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PullThroughCacheRule] -> ShowS
$cshowList :: [PullThroughCacheRule] -> ShowS
show :: PullThroughCacheRule -> String
$cshow :: PullThroughCacheRule -> String
showsPrec :: Int -> PullThroughCacheRule -> ShowS
$cshowsPrec :: Int -> PullThroughCacheRule -> ShowS
Prelude.Show, forall x. Rep PullThroughCacheRule x -> PullThroughCacheRule
forall x. PullThroughCacheRule -> Rep PullThroughCacheRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PullThroughCacheRule x -> PullThroughCacheRule
$cfrom :: forall x. PullThroughCacheRule -> Rep PullThroughCacheRule x
Prelude.Generic)

-- |
-- Create a value of 'PullThroughCacheRule' 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', 'pullThroughCacheRule_createdAt' - The date and time the pull through cache was created.
--
-- 'ecrRepositoryPrefix', 'pullThroughCacheRule_ecrRepositoryPrefix' - The Amazon ECR repository prefix associated with the pull through cache
-- rule.
--
-- 'registryId', 'pullThroughCacheRule_registryId' - The Amazon Web Services account ID associated with the registry the pull
-- through cache rule is associated with.
--
-- 'upstreamRegistryUrl', 'pullThroughCacheRule_upstreamRegistryUrl' - The upstream registry URL associated with the pull through cache rule.
newPullThroughCacheRule ::
  PullThroughCacheRule
newPullThroughCacheRule :: PullThroughCacheRule
newPullThroughCacheRule =
  PullThroughCacheRule'
    { $sel:createdAt:PullThroughCacheRule' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:ecrRepositoryPrefix:PullThroughCacheRule' :: Maybe Text
ecrRepositoryPrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:registryId:PullThroughCacheRule' :: Maybe Text
registryId = forall a. Maybe a
Prelude.Nothing,
      $sel:upstreamRegistryUrl:PullThroughCacheRule' :: Maybe Text
upstreamRegistryUrl = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time the pull through cache was created.
pullThroughCacheRule_createdAt :: Lens.Lens' PullThroughCacheRule (Prelude.Maybe Prelude.UTCTime)
pullThroughCacheRule_createdAt :: Lens' PullThroughCacheRule (Maybe UTCTime)
pullThroughCacheRule_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullThroughCacheRule' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: PullThroughCacheRule
s@PullThroughCacheRule' {} Maybe POSIX
a -> PullThroughCacheRule
s {$sel:createdAt:PullThroughCacheRule' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: PullThroughCacheRule) 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 Amazon ECR repository prefix associated with the pull through cache
-- rule.
pullThroughCacheRule_ecrRepositoryPrefix :: Lens.Lens' PullThroughCacheRule (Prelude.Maybe Prelude.Text)
pullThroughCacheRule_ecrRepositoryPrefix :: Lens' PullThroughCacheRule (Maybe Text)
pullThroughCacheRule_ecrRepositoryPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullThroughCacheRule' {Maybe Text
ecrRepositoryPrefix :: Maybe Text
$sel:ecrRepositoryPrefix:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
ecrRepositoryPrefix} -> Maybe Text
ecrRepositoryPrefix) (\s :: PullThroughCacheRule
s@PullThroughCacheRule' {} Maybe Text
a -> PullThroughCacheRule
s {$sel:ecrRepositoryPrefix:PullThroughCacheRule' :: Maybe Text
ecrRepositoryPrefix = Maybe Text
a} :: PullThroughCacheRule)

-- | The Amazon Web Services account ID associated with the registry the pull
-- through cache rule is associated with.
pullThroughCacheRule_registryId :: Lens.Lens' PullThroughCacheRule (Prelude.Maybe Prelude.Text)
pullThroughCacheRule_registryId :: Lens' PullThroughCacheRule (Maybe Text)
pullThroughCacheRule_registryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullThroughCacheRule' {Maybe Text
registryId :: Maybe Text
$sel:registryId:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: PullThroughCacheRule
s@PullThroughCacheRule' {} Maybe Text
a -> PullThroughCacheRule
s {$sel:registryId:PullThroughCacheRule' :: Maybe Text
registryId = Maybe Text
a} :: PullThroughCacheRule)

-- | The upstream registry URL associated with the pull through cache rule.
pullThroughCacheRule_upstreamRegistryUrl :: Lens.Lens' PullThroughCacheRule (Prelude.Maybe Prelude.Text)
pullThroughCacheRule_upstreamRegistryUrl :: Lens' PullThroughCacheRule (Maybe Text)
pullThroughCacheRule_upstreamRegistryUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullThroughCacheRule' {Maybe Text
upstreamRegistryUrl :: Maybe Text
$sel:upstreamRegistryUrl:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
upstreamRegistryUrl} -> Maybe Text
upstreamRegistryUrl) (\s :: PullThroughCacheRule
s@PullThroughCacheRule' {} Maybe Text
a -> PullThroughCacheRule
s {$sel:upstreamRegistryUrl:PullThroughCacheRule' :: Maybe Text
upstreamRegistryUrl = Maybe Text
a} :: PullThroughCacheRule)

instance Data.FromJSON PullThroughCacheRule where
  parseJSON :: Value -> Parser PullThroughCacheRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PullThroughCacheRule"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe Text -> Maybe Text -> PullThroughCacheRule
PullThroughCacheRule'
            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
"ecrRepositoryPrefix")
            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
"registryId")
            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
"upstreamRegistryUrl")
      )

instance Prelude.Hashable PullThroughCacheRule where
  hashWithSalt :: Int -> PullThroughCacheRule -> Int
hashWithSalt Int
_salt PullThroughCacheRule' {Maybe Text
Maybe POSIX
upstreamRegistryUrl :: Maybe Text
registryId :: Maybe Text
ecrRepositoryPrefix :: Maybe Text
createdAt :: Maybe POSIX
$sel:upstreamRegistryUrl:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
$sel:registryId:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
$sel:ecrRepositoryPrefix:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
$sel:createdAt:PullThroughCacheRule' :: PullThroughCacheRule -> 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 Text
ecrRepositoryPrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
registryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
upstreamRegistryUrl

instance Prelude.NFData PullThroughCacheRule where
  rnf :: PullThroughCacheRule -> ()
rnf PullThroughCacheRule' {Maybe Text
Maybe POSIX
upstreamRegistryUrl :: Maybe Text
registryId :: Maybe Text
ecrRepositoryPrefix :: Maybe Text
createdAt :: Maybe POSIX
$sel:upstreamRegistryUrl:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
$sel:registryId:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
$sel:ecrRepositoryPrefix:PullThroughCacheRule' :: PullThroughCacheRule -> Maybe Text
$sel:createdAt:PullThroughCacheRule' :: PullThroughCacheRule -> 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 Text
ecrRepositoryPrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
registryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
upstreamRegistryUrl