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

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

-- | An object representing the aliases for a public registry. A public
-- registry is given an alias upon creation but a custom alias can be set
-- using the Amazon ECR console. For more information, see
-- <https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html Registries>
-- in the /Amazon Elastic Container Registry User Guide/.
--
-- /See:/ 'newRegistryAlias' smart constructor.
data RegistryAlias = RegistryAlias'
  { -- | The name of the registry alias.
    RegistryAlias -> Text
name :: Prelude.Text,
    -- | The status of the registry alias.
    RegistryAlias -> RegistryAliasStatus
status :: RegistryAliasStatus,
    -- | Whether or not the registry alias is the primary alias for the registry.
    -- If true, the alias is the primary registry alias and is displayed in
    -- both the repository URL and the image URI used in the @docker pull@
    -- commands on the Amazon ECR Public Gallery.
    --
    -- A registry alias that is not the primary registry alias can be used in
    -- the repository URI in a @docker pull@ command.
    RegistryAlias -> Bool
primaryRegistryAlias :: Prelude.Bool,
    -- | Whether or not the registry alias is the default alias for the registry.
    -- When the first public repository is created, your public registry is
    -- assigned a default registry alias.
    RegistryAlias -> Bool
defaultRegistryAlias :: Prelude.Bool
  }
  deriving (RegistryAlias -> RegistryAlias -> Bool
(RegistryAlias -> RegistryAlias -> Bool)
-> (RegistryAlias -> RegistryAlias -> Bool) -> Eq RegistryAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegistryAlias -> RegistryAlias -> Bool
$c/= :: RegistryAlias -> RegistryAlias -> Bool
== :: RegistryAlias -> RegistryAlias -> Bool
$c== :: RegistryAlias -> RegistryAlias -> Bool
Prelude.Eq, ReadPrec [RegistryAlias]
ReadPrec RegistryAlias
Int -> ReadS RegistryAlias
ReadS [RegistryAlias]
(Int -> ReadS RegistryAlias)
-> ReadS [RegistryAlias]
-> ReadPrec RegistryAlias
-> ReadPrec [RegistryAlias]
-> Read RegistryAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegistryAlias]
$creadListPrec :: ReadPrec [RegistryAlias]
readPrec :: ReadPrec RegistryAlias
$creadPrec :: ReadPrec RegistryAlias
readList :: ReadS [RegistryAlias]
$creadList :: ReadS [RegistryAlias]
readsPrec :: Int -> ReadS RegistryAlias
$creadsPrec :: Int -> ReadS RegistryAlias
Prelude.Read, Int -> RegistryAlias -> ShowS
[RegistryAlias] -> ShowS
RegistryAlias -> String
(Int -> RegistryAlias -> ShowS)
-> (RegistryAlias -> String)
-> ([RegistryAlias] -> ShowS)
-> Show RegistryAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegistryAlias] -> ShowS
$cshowList :: [RegistryAlias] -> ShowS
show :: RegistryAlias -> String
$cshow :: RegistryAlias -> String
showsPrec :: Int -> RegistryAlias -> ShowS
$cshowsPrec :: Int -> RegistryAlias -> ShowS
Prelude.Show, (forall x. RegistryAlias -> Rep RegistryAlias x)
-> (forall x. Rep RegistryAlias x -> RegistryAlias)
-> Generic RegistryAlias
forall x. Rep RegistryAlias x -> RegistryAlias
forall x. RegistryAlias -> Rep RegistryAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegistryAlias x -> RegistryAlias
$cfrom :: forall x. RegistryAlias -> Rep RegistryAlias x
Prelude.Generic)

-- |
-- Create a value of 'RegistryAlias' 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:
--
-- 'name', 'registryAlias_name' - The name of the registry alias.
--
-- 'status', 'registryAlias_status' - The status of the registry alias.
--
-- 'primaryRegistryAlias', 'registryAlias_primaryRegistryAlias' - Whether or not the registry alias is the primary alias for the registry.
-- If true, the alias is the primary registry alias and is displayed in
-- both the repository URL and the image URI used in the @docker pull@
-- commands on the Amazon ECR Public Gallery.
--
-- A registry alias that is not the primary registry alias can be used in
-- the repository URI in a @docker pull@ command.
--
-- 'defaultRegistryAlias', 'registryAlias_defaultRegistryAlias' - Whether or not the registry alias is the default alias for the registry.
-- When the first public repository is created, your public registry is
-- assigned a default registry alias.
newRegistryAlias ::
  -- | 'name'
  Prelude.Text ->
  -- | 'status'
  RegistryAliasStatus ->
  -- | 'primaryRegistryAlias'
  Prelude.Bool ->
  -- | 'defaultRegistryAlias'
  Prelude.Bool ->
  RegistryAlias
newRegistryAlias :: Text -> RegistryAliasStatus -> Bool -> Bool -> RegistryAlias
newRegistryAlias
  Text
pName_
  RegistryAliasStatus
pStatus_
  Bool
pPrimaryRegistryAlias_
  Bool
pDefaultRegistryAlias_ =
    RegistryAlias' :: Text -> RegistryAliasStatus -> Bool -> Bool -> RegistryAlias
RegistryAlias'
      { $sel:name:RegistryAlias' :: Text
name = Text
pName_,
        $sel:status:RegistryAlias' :: RegistryAliasStatus
status = RegistryAliasStatus
pStatus_,
        $sel:primaryRegistryAlias:RegistryAlias' :: Bool
primaryRegistryAlias = Bool
pPrimaryRegistryAlias_,
        $sel:defaultRegistryAlias:RegistryAlias' :: Bool
defaultRegistryAlias = Bool
pDefaultRegistryAlias_
      }

-- | The name of the registry alias.
registryAlias_name :: Lens.Lens' RegistryAlias Prelude.Text
registryAlias_name :: (Text -> f Text) -> RegistryAlias -> f RegistryAlias
registryAlias_name = (RegistryAlias -> Text)
-> (RegistryAlias -> Text -> RegistryAlias)
-> Lens RegistryAlias RegistryAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistryAlias' {Text
name :: Text
$sel:name:RegistryAlias' :: RegistryAlias -> Text
name} -> Text
name) (\s :: RegistryAlias
s@RegistryAlias' {} Text
a -> RegistryAlias
s {$sel:name:RegistryAlias' :: Text
name = Text
a} :: RegistryAlias)

-- | The status of the registry alias.
registryAlias_status :: Lens.Lens' RegistryAlias RegistryAliasStatus
registryAlias_status :: (RegistryAliasStatus -> f RegistryAliasStatus)
-> RegistryAlias -> f RegistryAlias
registryAlias_status = (RegistryAlias -> RegistryAliasStatus)
-> (RegistryAlias -> RegistryAliasStatus -> RegistryAlias)
-> Lens
     RegistryAlias RegistryAlias RegistryAliasStatus RegistryAliasStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistryAlias' {RegistryAliasStatus
status :: RegistryAliasStatus
$sel:status:RegistryAlias' :: RegistryAlias -> RegistryAliasStatus
status} -> RegistryAliasStatus
status) (\s :: RegistryAlias
s@RegistryAlias' {} RegistryAliasStatus
a -> RegistryAlias
s {$sel:status:RegistryAlias' :: RegistryAliasStatus
status = RegistryAliasStatus
a} :: RegistryAlias)

-- | Whether or not the registry alias is the primary alias for the registry.
-- If true, the alias is the primary registry alias and is displayed in
-- both the repository URL and the image URI used in the @docker pull@
-- commands on the Amazon ECR Public Gallery.
--
-- A registry alias that is not the primary registry alias can be used in
-- the repository URI in a @docker pull@ command.
registryAlias_primaryRegistryAlias :: Lens.Lens' RegistryAlias Prelude.Bool
registryAlias_primaryRegistryAlias :: (Bool -> f Bool) -> RegistryAlias -> f RegistryAlias
registryAlias_primaryRegistryAlias = (RegistryAlias -> Bool)
-> (RegistryAlias -> Bool -> RegistryAlias)
-> Lens RegistryAlias RegistryAlias Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistryAlias' {Bool
primaryRegistryAlias :: Bool
$sel:primaryRegistryAlias:RegistryAlias' :: RegistryAlias -> Bool
primaryRegistryAlias} -> Bool
primaryRegistryAlias) (\s :: RegistryAlias
s@RegistryAlias' {} Bool
a -> RegistryAlias
s {$sel:primaryRegistryAlias:RegistryAlias' :: Bool
primaryRegistryAlias = Bool
a} :: RegistryAlias)

-- | Whether or not the registry alias is the default alias for the registry.
-- When the first public repository is created, your public registry is
-- assigned a default registry alias.
registryAlias_defaultRegistryAlias :: Lens.Lens' RegistryAlias Prelude.Bool
registryAlias_defaultRegistryAlias :: (Bool -> f Bool) -> RegistryAlias -> f RegistryAlias
registryAlias_defaultRegistryAlias = (RegistryAlias -> Bool)
-> (RegistryAlias -> Bool -> RegistryAlias)
-> Lens RegistryAlias RegistryAlias Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistryAlias' {Bool
defaultRegistryAlias :: Bool
$sel:defaultRegistryAlias:RegistryAlias' :: RegistryAlias -> Bool
defaultRegistryAlias} -> Bool
defaultRegistryAlias) (\s :: RegistryAlias
s@RegistryAlias' {} Bool
a -> RegistryAlias
s {$sel:defaultRegistryAlias:RegistryAlias' :: Bool
defaultRegistryAlias = Bool
a} :: RegistryAlias)

instance Core.FromJSON RegistryAlias where
  parseJSON :: Value -> Parser RegistryAlias
parseJSON =
    String
-> (Object -> Parser RegistryAlias)
-> Value
-> Parser RegistryAlias
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RegistryAlias"
      ( \Object
x ->
          Text -> RegistryAliasStatus -> Bool -> Bool -> RegistryAlias
RegistryAlias'
            (Text -> RegistryAliasStatus -> Bool -> Bool -> RegistryAlias)
-> Parser Text
-> Parser (RegistryAliasStatus -> Bool -> Bool -> RegistryAlias)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
            Parser (RegistryAliasStatus -> Bool -> Bool -> RegistryAlias)
-> Parser RegistryAliasStatus
-> Parser (Bool -> Bool -> RegistryAlias)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RegistryAliasStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"status")
            Parser (Bool -> Bool -> RegistryAlias)
-> Parser Bool -> Parser (Bool -> RegistryAlias)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"primaryRegistryAlias")
            Parser (Bool -> RegistryAlias)
-> Parser Bool -> Parser RegistryAlias
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"defaultRegistryAlias")
      )

instance Prelude.Hashable RegistryAlias

instance Prelude.NFData RegistryAlias