{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECRPublic.Types.RegistryAlias where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECRPublic.Types.RegistryAliasStatus
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
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]
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
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. 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'
      { $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 :: Lens' RegistryAlias Text
registryAlias_name = 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 :: Lens' RegistryAlias RegistryAliasStatus
registryAlias_status = 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 :: Lens' RegistryAlias Bool
registryAlias_primaryRegistryAlias = 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 :: Lens' RegistryAlias Bool
registryAlias_defaultRegistryAlias = 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 Data.FromJSON RegistryAlias where
  parseJSON :: Value -> Parser RegistryAlias
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RegistryAlias"
      ( \Object
x ->
          Text -> RegistryAliasStatus -> Bool -> Bool -> RegistryAlias
RegistryAlias'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"primaryRegistryAlias")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"defaultRegistryAlias")
      )

instance Prelude.Hashable RegistryAlias where
  hashWithSalt :: Int -> RegistryAlias -> Int
hashWithSalt Int
_salt RegistryAlias' {Bool
Text
RegistryAliasStatus
defaultRegistryAlias :: Bool
primaryRegistryAlias :: Bool
status :: RegistryAliasStatus
name :: Text
$sel:defaultRegistryAlias:RegistryAlias' :: RegistryAlias -> Bool
$sel:primaryRegistryAlias:RegistryAlias' :: RegistryAlias -> Bool
$sel:status:RegistryAlias' :: RegistryAlias -> RegistryAliasStatus
$sel:name:RegistryAlias' :: RegistryAlias -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RegistryAliasStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
primaryRegistryAlias
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
defaultRegistryAlias

instance Prelude.NFData RegistryAlias where
  rnf :: RegistryAlias -> ()
rnf RegistryAlias' {Bool
Text
RegistryAliasStatus
defaultRegistryAlias :: Bool
primaryRegistryAlias :: Bool
status :: RegistryAliasStatus
name :: Text
$sel:defaultRegistryAlias:RegistryAlias' :: RegistryAlias -> Bool
$sel:primaryRegistryAlias:RegistryAlias' :: RegistryAlias -> Bool
$sel:status:RegistryAlias' :: RegistryAlias -> RegistryAliasStatus
$sel:name:RegistryAlias' :: RegistryAlias -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RegistryAliasStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
primaryRegistryAlias
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
defaultRegistryAlias