{-# 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.MacieV2.Types.ReplicationDetails
-- 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.MacieV2.Types.ReplicationDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides information about settings that define whether one or more
-- objects in an S3 bucket are replicated to S3 buckets for other Amazon
-- Web Services accounts and, if so, which accounts.
--
-- /See:/ 'newReplicationDetails' smart constructor.
data ReplicationDetails = ReplicationDetails'
  { -- | Specifies whether the bucket is configured to replicate one or more
    -- objects to any destination.
    ReplicationDetails -> Maybe Bool
replicated :: Prelude.Maybe Prelude.Bool,
    -- | An array of Amazon Web Services account IDs, one for each Amazon Web
    -- Services account that the bucket is configured to replicate one or more
    -- objects to.
    ReplicationDetails -> Maybe [Text]
replicationAccounts :: Prelude.Maybe [Prelude.Text],
    -- | Specifies whether the bucket is configured to replicate one or more
    -- objects to an Amazon Web Services account that isn\'t part of the same
    -- Amazon Macie organization.
    ReplicationDetails -> Maybe Bool
replicatedExternally :: Prelude.Maybe Prelude.Bool
  }
  deriving (ReplicationDetails -> ReplicationDetails -> Bool
(ReplicationDetails -> ReplicationDetails -> Bool)
-> (ReplicationDetails -> ReplicationDetails -> Bool)
-> Eq ReplicationDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicationDetails -> ReplicationDetails -> Bool
$c/= :: ReplicationDetails -> ReplicationDetails -> Bool
== :: ReplicationDetails -> ReplicationDetails -> Bool
$c== :: ReplicationDetails -> ReplicationDetails -> Bool
Prelude.Eq, ReadPrec [ReplicationDetails]
ReadPrec ReplicationDetails
Int -> ReadS ReplicationDetails
ReadS [ReplicationDetails]
(Int -> ReadS ReplicationDetails)
-> ReadS [ReplicationDetails]
-> ReadPrec ReplicationDetails
-> ReadPrec [ReplicationDetails]
-> Read ReplicationDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicationDetails]
$creadListPrec :: ReadPrec [ReplicationDetails]
readPrec :: ReadPrec ReplicationDetails
$creadPrec :: ReadPrec ReplicationDetails
readList :: ReadS [ReplicationDetails]
$creadList :: ReadS [ReplicationDetails]
readsPrec :: Int -> ReadS ReplicationDetails
$creadsPrec :: Int -> ReadS ReplicationDetails
Prelude.Read, Int -> ReplicationDetails -> ShowS
[ReplicationDetails] -> ShowS
ReplicationDetails -> String
(Int -> ReplicationDetails -> ShowS)
-> (ReplicationDetails -> String)
-> ([ReplicationDetails] -> ShowS)
-> Show ReplicationDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicationDetails] -> ShowS
$cshowList :: [ReplicationDetails] -> ShowS
show :: ReplicationDetails -> String
$cshow :: ReplicationDetails -> String
showsPrec :: Int -> ReplicationDetails -> ShowS
$cshowsPrec :: Int -> ReplicationDetails -> ShowS
Prelude.Show, (forall x. ReplicationDetails -> Rep ReplicationDetails x)
-> (forall x. Rep ReplicationDetails x -> ReplicationDetails)
-> Generic ReplicationDetails
forall x. Rep ReplicationDetails x -> ReplicationDetails
forall x. ReplicationDetails -> Rep ReplicationDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplicationDetails x -> ReplicationDetails
$cfrom :: forall x. ReplicationDetails -> Rep ReplicationDetails x
Prelude.Generic)

-- |
-- Create a value of 'ReplicationDetails' 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:
--
-- 'replicated', 'replicationDetails_replicated' - Specifies whether the bucket is configured to replicate one or more
-- objects to any destination.
--
-- 'replicationAccounts', 'replicationDetails_replicationAccounts' - An array of Amazon Web Services account IDs, one for each Amazon Web
-- Services account that the bucket is configured to replicate one or more
-- objects to.
--
-- 'replicatedExternally', 'replicationDetails_replicatedExternally' - Specifies whether the bucket is configured to replicate one or more
-- objects to an Amazon Web Services account that isn\'t part of the same
-- Amazon Macie organization.
newReplicationDetails ::
  ReplicationDetails
newReplicationDetails :: ReplicationDetails
newReplicationDetails =
  ReplicationDetails' :: Maybe Bool -> Maybe [Text] -> Maybe Bool -> ReplicationDetails
ReplicationDetails'
    { $sel:replicated:ReplicationDetails' :: Maybe Bool
replicated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationAccounts:ReplicationDetails' :: Maybe [Text]
replicationAccounts = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:replicatedExternally:ReplicationDetails' :: Maybe Bool
replicatedExternally = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the bucket is configured to replicate one or more
-- objects to any destination.
replicationDetails_replicated :: Lens.Lens' ReplicationDetails (Prelude.Maybe Prelude.Bool)
replicationDetails_replicated :: (Maybe Bool -> f (Maybe Bool))
-> ReplicationDetails -> f ReplicationDetails
replicationDetails_replicated = (ReplicationDetails -> Maybe Bool)
-> (ReplicationDetails -> Maybe Bool -> ReplicationDetails)
-> Lens
     ReplicationDetails ReplicationDetails (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationDetails' {Maybe Bool
replicated :: Maybe Bool
$sel:replicated:ReplicationDetails' :: ReplicationDetails -> Maybe Bool
replicated} -> Maybe Bool
replicated) (\s :: ReplicationDetails
s@ReplicationDetails' {} Maybe Bool
a -> ReplicationDetails
s {$sel:replicated:ReplicationDetails' :: Maybe Bool
replicated = Maybe Bool
a} :: ReplicationDetails)

-- | An array of Amazon Web Services account IDs, one for each Amazon Web
-- Services account that the bucket is configured to replicate one or more
-- objects to.
replicationDetails_replicationAccounts :: Lens.Lens' ReplicationDetails (Prelude.Maybe [Prelude.Text])
replicationDetails_replicationAccounts :: (Maybe [Text] -> f (Maybe [Text]))
-> ReplicationDetails -> f ReplicationDetails
replicationDetails_replicationAccounts = (ReplicationDetails -> Maybe [Text])
-> (ReplicationDetails -> Maybe [Text] -> ReplicationDetails)
-> Lens
     ReplicationDetails ReplicationDetails (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationDetails' {Maybe [Text]
replicationAccounts :: Maybe [Text]
$sel:replicationAccounts:ReplicationDetails' :: ReplicationDetails -> Maybe [Text]
replicationAccounts} -> Maybe [Text]
replicationAccounts) (\s :: ReplicationDetails
s@ReplicationDetails' {} Maybe [Text]
a -> ReplicationDetails
s {$sel:replicationAccounts:ReplicationDetails' :: Maybe [Text]
replicationAccounts = Maybe [Text]
a} :: ReplicationDetails) ((Maybe [Text] -> f (Maybe [Text]))
 -> ReplicationDetails -> f ReplicationDetails)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ReplicationDetails
-> f ReplicationDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies whether the bucket is configured to replicate one or more
-- objects to an Amazon Web Services account that isn\'t part of the same
-- Amazon Macie organization.
replicationDetails_replicatedExternally :: Lens.Lens' ReplicationDetails (Prelude.Maybe Prelude.Bool)
replicationDetails_replicatedExternally :: (Maybe Bool -> f (Maybe Bool))
-> ReplicationDetails -> f ReplicationDetails
replicationDetails_replicatedExternally = (ReplicationDetails -> Maybe Bool)
-> (ReplicationDetails -> Maybe Bool -> ReplicationDetails)
-> Lens
     ReplicationDetails ReplicationDetails (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationDetails' {Maybe Bool
replicatedExternally :: Maybe Bool
$sel:replicatedExternally:ReplicationDetails' :: ReplicationDetails -> Maybe Bool
replicatedExternally} -> Maybe Bool
replicatedExternally) (\s :: ReplicationDetails
s@ReplicationDetails' {} Maybe Bool
a -> ReplicationDetails
s {$sel:replicatedExternally:ReplicationDetails' :: Maybe Bool
replicatedExternally = Maybe Bool
a} :: ReplicationDetails)

instance Core.FromJSON ReplicationDetails where
  parseJSON :: Value -> Parser ReplicationDetails
parseJSON =
    String
-> (Object -> Parser ReplicationDetails)
-> Value
-> Parser ReplicationDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReplicationDetails"
      ( \Object
x ->
          Maybe Bool -> Maybe [Text] -> Maybe Bool -> ReplicationDetails
ReplicationDetails'
            (Maybe Bool -> Maybe [Text] -> Maybe Bool -> ReplicationDetails)
-> Parser (Maybe Bool)
-> Parser (Maybe [Text] -> Maybe Bool -> ReplicationDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"replicated")
            Parser (Maybe [Text] -> Maybe Bool -> ReplicationDetails)
-> Parser (Maybe [Text])
-> Parser (Maybe Bool -> ReplicationDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"replicationAccounts"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Bool -> ReplicationDetails)
-> Parser (Maybe Bool) -> Parser ReplicationDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"replicatedExternally")
      )

instance Prelude.Hashable ReplicationDetails

instance Prelude.NFData ReplicationDetails