{-# 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.Redshift.Types.DataShare
-- 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.Redshift.Types.DataShare where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.DataShareAssociation

-- | /See:/ 'newDataShare' smart constructor.
data DataShare = DataShare'
  { -- | The Amazon Resource Name (ARN) of the producer.
    DataShare -> Maybe Text
producerArn :: Prelude.Maybe Prelude.Text,
    -- | A value that specifies when the datashare has an association between a
    -- producer and data consumers.
    DataShare -> Maybe [DataShareAssociation]
dataShareAssociations :: Prelude.Maybe [DataShareAssociation],
    -- | An Amazon Resource Name (ARN) that references the datashare that is
    -- owned by a specific namespace of the producer cluster. A datashare ARN
    -- is in the
    -- @arn:aws:redshift:{region}:{account-id}:{datashare}:{namespace-guid}\/{datashare-name}@
    -- format.
    DataShare -> Maybe Text
dataShareArn :: Prelude.Maybe Prelude.Text,
    -- | A value that specifies whether the datashare can be shared to a publicly
    -- accessible cluster.
    DataShare -> Maybe Bool
allowPubliclyAccessibleConsumers :: Prelude.Maybe Prelude.Bool
  }
  deriving (DataShare -> DataShare -> Bool
(DataShare -> DataShare -> Bool)
-> (DataShare -> DataShare -> Bool) -> Eq DataShare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataShare -> DataShare -> Bool
$c/= :: DataShare -> DataShare -> Bool
== :: DataShare -> DataShare -> Bool
$c== :: DataShare -> DataShare -> Bool
Prelude.Eq, ReadPrec [DataShare]
ReadPrec DataShare
Int -> ReadS DataShare
ReadS [DataShare]
(Int -> ReadS DataShare)
-> ReadS [DataShare]
-> ReadPrec DataShare
-> ReadPrec [DataShare]
-> Read DataShare
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataShare]
$creadListPrec :: ReadPrec [DataShare]
readPrec :: ReadPrec DataShare
$creadPrec :: ReadPrec DataShare
readList :: ReadS [DataShare]
$creadList :: ReadS [DataShare]
readsPrec :: Int -> ReadS DataShare
$creadsPrec :: Int -> ReadS DataShare
Prelude.Read, Int -> DataShare -> ShowS
[DataShare] -> ShowS
DataShare -> String
(Int -> DataShare -> ShowS)
-> (DataShare -> String)
-> ([DataShare] -> ShowS)
-> Show DataShare
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataShare] -> ShowS
$cshowList :: [DataShare] -> ShowS
show :: DataShare -> String
$cshow :: DataShare -> String
showsPrec :: Int -> DataShare -> ShowS
$cshowsPrec :: Int -> DataShare -> ShowS
Prelude.Show, (forall x. DataShare -> Rep DataShare x)
-> (forall x. Rep DataShare x -> DataShare) -> Generic DataShare
forall x. Rep DataShare x -> DataShare
forall x. DataShare -> Rep DataShare x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataShare x -> DataShare
$cfrom :: forall x. DataShare -> Rep DataShare x
Prelude.Generic)

-- |
-- Create a value of 'DataShare' 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:
--
-- 'producerArn', 'dataShare_producerArn' - The Amazon Resource Name (ARN) of the producer.
--
-- 'dataShareAssociations', 'dataShare_dataShareAssociations' - A value that specifies when the datashare has an association between a
-- producer and data consumers.
--
-- 'dataShareArn', 'dataShare_dataShareArn' - An Amazon Resource Name (ARN) that references the datashare that is
-- owned by a specific namespace of the producer cluster. A datashare ARN
-- is in the
-- @arn:aws:redshift:{region}:{account-id}:{datashare}:{namespace-guid}\/{datashare-name}@
-- format.
--
-- 'allowPubliclyAccessibleConsumers', 'dataShare_allowPubliclyAccessibleConsumers' - A value that specifies whether the datashare can be shared to a publicly
-- accessible cluster.
newDataShare ::
  DataShare
newDataShare :: DataShare
newDataShare =
  DataShare' :: Maybe Text
-> Maybe [DataShareAssociation]
-> Maybe Text
-> Maybe Bool
-> DataShare
DataShare'
    { $sel:producerArn:DataShare' :: Maybe Text
producerArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dataShareAssociations:DataShare' :: Maybe [DataShareAssociation]
dataShareAssociations = Maybe [DataShareAssociation]
forall a. Maybe a
Prelude.Nothing,
      $sel:dataShareArn:DataShare' :: Maybe Text
dataShareArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowPubliclyAccessibleConsumers:DataShare' :: Maybe Bool
allowPubliclyAccessibleConsumers = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the producer.
dataShare_producerArn :: Lens.Lens' DataShare (Prelude.Maybe Prelude.Text)
dataShare_producerArn :: (Maybe Text -> f (Maybe Text)) -> DataShare -> f DataShare
dataShare_producerArn = (DataShare -> Maybe Text)
-> (DataShare -> Maybe Text -> DataShare)
-> Lens DataShare DataShare (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShare' {Maybe Text
producerArn :: Maybe Text
$sel:producerArn:DataShare' :: DataShare -> Maybe Text
producerArn} -> Maybe Text
producerArn) (\s :: DataShare
s@DataShare' {} Maybe Text
a -> DataShare
s {$sel:producerArn:DataShare' :: Maybe Text
producerArn = Maybe Text
a} :: DataShare)

-- | A value that specifies when the datashare has an association between a
-- producer and data consumers.
dataShare_dataShareAssociations :: Lens.Lens' DataShare (Prelude.Maybe [DataShareAssociation])
dataShare_dataShareAssociations :: (Maybe [DataShareAssociation] -> f (Maybe [DataShareAssociation]))
-> DataShare -> f DataShare
dataShare_dataShareAssociations = (DataShare -> Maybe [DataShareAssociation])
-> (DataShare -> Maybe [DataShareAssociation] -> DataShare)
-> Lens
     DataShare
     DataShare
     (Maybe [DataShareAssociation])
     (Maybe [DataShareAssociation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShare' {Maybe [DataShareAssociation]
dataShareAssociations :: Maybe [DataShareAssociation]
$sel:dataShareAssociations:DataShare' :: DataShare -> Maybe [DataShareAssociation]
dataShareAssociations} -> Maybe [DataShareAssociation]
dataShareAssociations) (\s :: DataShare
s@DataShare' {} Maybe [DataShareAssociation]
a -> DataShare
s {$sel:dataShareAssociations:DataShare' :: Maybe [DataShareAssociation]
dataShareAssociations = Maybe [DataShareAssociation]
a} :: DataShare) ((Maybe [DataShareAssociation] -> f (Maybe [DataShareAssociation]))
 -> DataShare -> f DataShare)
-> ((Maybe [DataShareAssociation]
     -> f (Maybe [DataShareAssociation]))
    -> Maybe [DataShareAssociation]
    -> f (Maybe [DataShareAssociation]))
-> (Maybe [DataShareAssociation]
    -> f (Maybe [DataShareAssociation]))
-> DataShare
-> f DataShare
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DataShareAssociation]
  [DataShareAssociation]
  [DataShareAssociation]
  [DataShareAssociation]
-> Iso
     (Maybe [DataShareAssociation])
     (Maybe [DataShareAssociation])
     (Maybe [DataShareAssociation])
     (Maybe [DataShareAssociation])
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
  [DataShareAssociation]
  [DataShareAssociation]
  [DataShareAssociation]
  [DataShareAssociation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An Amazon Resource Name (ARN) that references the datashare that is
-- owned by a specific namespace of the producer cluster. A datashare ARN
-- is in the
-- @arn:aws:redshift:{region}:{account-id}:{datashare}:{namespace-guid}\/{datashare-name}@
-- format.
dataShare_dataShareArn :: Lens.Lens' DataShare (Prelude.Maybe Prelude.Text)
dataShare_dataShareArn :: (Maybe Text -> f (Maybe Text)) -> DataShare -> f DataShare
dataShare_dataShareArn = (DataShare -> Maybe Text)
-> (DataShare -> Maybe Text -> DataShare)
-> Lens DataShare DataShare (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShare' {Maybe Text
dataShareArn :: Maybe Text
$sel:dataShareArn:DataShare' :: DataShare -> Maybe Text
dataShareArn} -> Maybe Text
dataShareArn) (\s :: DataShare
s@DataShare' {} Maybe Text
a -> DataShare
s {$sel:dataShareArn:DataShare' :: Maybe Text
dataShareArn = Maybe Text
a} :: DataShare)

-- | A value that specifies whether the datashare can be shared to a publicly
-- accessible cluster.
dataShare_allowPubliclyAccessibleConsumers :: Lens.Lens' DataShare (Prelude.Maybe Prelude.Bool)
dataShare_allowPubliclyAccessibleConsumers :: (Maybe Bool -> f (Maybe Bool)) -> DataShare -> f DataShare
dataShare_allowPubliclyAccessibleConsumers = (DataShare -> Maybe Bool)
-> (DataShare -> Maybe Bool -> DataShare)
-> Lens DataShare DataShare (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShare' {Maybe Bool
allowPubliclyAccessibleConsumers :: Maybe Bool
$sel:allowPubliclyAccessibleConsumers:DataShare' :: DataShare -> Maybe Bool
allowPubliclyAccessibleConsumers} -> Maybe Bool
allowPubliclyAccessibleConsumers) (\s :: DataShare
s@DataShare' {} Maybe Bool
a -> DataShare
s {$sel:allowPubliclyAccessibleConsumers:DataShare' :: Maybe Bool
allowPubliclyAccessibleConsumers = Maybe Bool
a} :: DataShare)

instance Core.FromXML DataShare where
  parseXML :: [Node] -> Either String DataShare
parseXML [Node]
x =
    Maybe Text
-> Maybe [DataShareAssociation]
-> Maybe Text
-> Maybe Bool
-> DataShare
DataShare'
      (Maybe Text
 -> Maybe [DataShareAssociation]
 -> Maybe Text
 -> Maybe Bool
 -> DataShare)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [DataShareAssociation]
      -> Maybe Text -> Maybe Bool -> DataShare)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ProducerArn")
      Either
  String
  (Maybe [DataShareAssociation]
   -> Maybe Text -> Maybe Bool -> DataShare)
-> Either String (Maybe [DataShareAssociation])
-> Either String (Maybe Text -> Maybe Bool -> DataShare)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DataShareAssociations"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [DataShareAssociation]))
-> Either String (Maybe [DataShareAssociation])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [DataShareAssociation])
-> [Node] -> Either String (Maybe [DataShareAssociation])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [DataShareAssociation]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe Text -> Maybe Bool -> DataShare)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> DataShare)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DataShareArn")
      Either String (Maybe Bool -> DataShare)
-> Either String (Maybe Bool) -> Either String DataShare
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AllowPubliclyAccessibleConsumers")

instance Prelude.Hashable DataShare

instance Prelude.NFData DataShare