{-# 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.ReplicationDestination
-- 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.ReplicationDestination 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

-- | An array of objects representing the destination for a replication rule.
--
-- /See:/ 'newReplicationDestination' smart constructor.
data ReplicationDestination = ReplicationDestination'
  { -- | The Region to replicate to.
    ReplicationDestination -> Text
region :: Prelude.Text,
    -- | The Amazon Web Services account ID of the Amazon ECR private registry to
    -- replicate to. When configuring cross-Region replication within your own
    -- registry, specify your own account ID.
    ReplicationDestination -> Text
registryId :: Prelude.Text
  }
  deriving (ReplicationDestination -> ReplicationDestination -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicationDestination -> ReplicationDestination -> Bool
$c/= :: ReplicationDestination -> ReplicationDestination -> Bool
== :: ReplicationDestination -> ReplicationDestination -> Bool
$c== :: ReplicationDestination -> ReplicationDestination -> Bool
Prelude.Eq, ReadPrec [ReplicationDestination]
ReadPrec ReplicationDestination
Int -> ReadS ReplicationDestination
ReadS [ReplicationDestination]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicationDestination]
$creadListPrec :: ReadPrec [ReplicationDestination]
readPrec :: ReadPrec ReplicationDestination
$creadPrec :: ReadPrec ReplicationDestination
readList :: ReadS [ReplicationDestination]
$creadList :: ReadS [ReplicationDestination]
readsPrec :: Int -> ReadS ReplicationDestination
$creadsPrec :: Int -> ReadS ReplicationDestination
Prelude.Read, Int -> ReplicationDestination -> ShowS
[ReplicationDestination] -> ShowS
ReplicationDestination -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicationDestination] -> ShowS
$cshowList :: [ReplicationDestination] -> ShowS
show :: ReplicationDestination -> String
$cshow :: ReplicationDestination -> String
showsPrec :: Int -> ReplicationDestination -> ShowS
$cshowsPrec :: Int -> ReplicationDestination -> ShowS
Prelude.Show, forall x. Rep ReplicationDestination x -> ReplicationDestination
forall x. ReplicationDestination -> Rep ReplicationDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplicationDestination x -> ReplicationDestination
$cfrom :: forall x. ReplicationDestination -> Rep ReplicationDestination x
Prelude.Generic)

-- |
-- Create a value of 'ReplicationDestination' 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:
--
-- 'region', 'replicationDestination_region' - The Region to replicate to.
--
-- 'registryId', 'replicationDestination_registryId' - The Amazon Web Services account ID of the Amazon ECR private registry to
-- replicate to. When configuring cross-Region replication within your own
-- registry, specify your own account ID.
newReplicationDestination ::
  -- | 'region'
  Prelude.Text ->
  -- | 'registryId'
  Prelude.Text ->
  ReplicationDestination
newReplicationDestination :: Text -> Text -> ReplicationDestination
newReplicationDestination Text
pRegion_ Text
pRegistryId_ =
  ReplicationDestination'
    { $sel:region:ReplicationDestination' :: Text
region = Text
pRegion_,
      $sel:registryId:ReplicationDestination' :: Text
registryId = Text
pRegistryId_
    }

-- | The Region to replicate to.
replicationDestination_region :: Lens.Lens' ReplicationDestination Prelude.Text
replicationDestination_region :: Lens' ReplicationDestination Text
replicationDestination_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationDestination' {Text
region :: Text
$sel:region:ReplicationDestination' :: ReplicationDestination -> Text
region} -> Text
region) (\s :: ReplicationDestination
s@ReplicationDestination' {} Text
a -> ReplicationDestination
s {$sel:region:ReplicationDestination' :: Text
region = Text
a} :: ReplicationDestination)

-- | The Amazon Web Services account ID of the Amazon ECR private registry to
-- replicate to. When configuring cross-Region replication within your own
-- registry, specify your own account ID.
replicationDestination_registryId :: Lens.Lens' ReplicationDestination Prelude.Text
replicationDestination_registryId :: Lens' ReplicationDestination Text
replicationDestination_registryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationDestination' {Text
registryId :: Text
$sel:registryId:ReplicationDestination' :: ReplicationDestination -> Text
registryId} -> Text
registryId) (\s :: ReplicationDestination
s@ReplicationDestination' {} Text
a -> ReplicationDestination
s {$sel:registryId:ReplicationDestination' :: Text
registryId = Text
a} :: ReplicationDestination)

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

instance Prelude.Hashable ReplicationDestination where
  hashWithSalt :: Int -> ReplicationDestination -> Int
hashWithSalt Int
_salt ReplicationDestination' {Text
registryId :: Text
region :: Text
$sel:registryId:ReplicationDestination' :: ReplicationDestination -> Text
$sel:region:ReplicationDestination' :: ReplicationDestination -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
registryId

instance Prelude.NFData ReplicationDestination where
  rnf :: ReplicationDestination -> ()
rnf ReplicationDestination' {Text
registryId :: Text
region :: Text
$sel:registryId:ReplicationDestination' :: ReplicationDestination -> Text
$sel:region:ReplicationDestination' :: ReplicationDestination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
registryId

instance Data.ToJSON ReplicationDestination where
  toJSON :: ReplicationDestination -> Value
toJSON ReplicationDestination' {Text
registryId :: Text
region :: Text
$sel:registryId:ReplicationDestination' :: ReplicationDestination -> Text
$sel:region:ReplicationDestination' :: ReplicationDestination -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"region" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
region),
            forall a. a -> Maybe a
Prelude.Just (Key
"registryId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
registryId)
          ]
      )