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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ReplicationDestination -> ReplicationDestination -> Bool)
-> (ReplicationDestination -> ReplicationDestination -> Bool)
-> Eq ReplicationDestination
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]
(Int -> ReadS ReplicationDestination)
-> ReadS [ReplicationDestination]
-> ReadPrec ReplicationDestination
-> ReadPrec [ReplicationDestination]
-> Read 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
(Int -> ReplicationDestination -> ShowS)
-> (ReplicationDestination -> String)
-> ([ReplicationDestination] -> ShowS)
-> Show ReplicationDestination
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. ReplicationDestination -> Rep ReplicationDestination x)
-> (forall x.
    Rep ReplicationDestination x -> ReplicationDestination)
-> Generic ReplicationDestination
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' :: Text -> Text -> ReplicationDestination
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 :: (Text -> f Text)
-> ReplicationDestination -> f ReplicationDestination
replicationDestination_region = (ReplicationDestination -> Text)
-> (ReplicationDestination -> Text -> ReplicationDestination)
-> Lens ReplicationDestination ReplicationDestination Text Text
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 :: (Text -> f Text)
-> ReplicationDestination -> f ReplicationDestination
replicationDestination_registryId = (ReplicationDestination -> Text)
-> (ReplicationDestination -> Text -> ReplicationDestination)
-> Lens ReplicationDestination ReplicationDestination Text Text
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 Core.FromJSON ReplicationDestination where
  parseJSON :: Value -> Parser ReplicationDestination
parseJSON =
    String
-> (Object -> Parser ReplicationDestination)
-> Value
-> Parser ReplicationDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReplicationDestination"
      ( \Object
x ->
          Text -> Text -> ReplicationDestination
ReplicationDestination'
            (Text -> Text -> ReplicationDestination)
-> Parser Text -> Parser (Text -> ReplicationDestination)
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
"region")
            Parser (Text -> ReplicationDestination)
-> Parser Text -> Parser ReplicationDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"registryId")
      )

instance Prelude.Hashable ReplicationDestination

instance Prelude.NFData ReplicationDestination

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"region" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
region),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"registryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
registryId)
          ]
      )