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

-- | /See:/ 'newDataShare' smart constructor.
data DataShare = DataShare'
  { -- | A value that specifies whether the datashare can be shared to a publicly
    -- accessible cluster.
    DataShare -> Maybe Bool
allowPubliclyAccessibleConsumers :: Prelude.Maybe Prelude.Bool,
    -- | 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 when the datashare has an association between
    -- producer and data consumers.
    DataShare -> Maybe [DataShareAssociation]
dataShareAssociations :: Prelude.Maybe [DataShareAssociation],
    -- | The identifier of a datashare to show its managing entity.
    DataShare -> Maybe Text
managedBy :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the producer.
    DataShare -> Maybe Text
producerArn :: Prelude.Maybe Prelude.Text
  }
  deriving (DataShare -> DataShare -> Bool
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]
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
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. 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:
--
-- 'allowPubliclyAccessibleConsumers', 'dataShare_allowPubliclyAccessibleConsumers' - A value that specifies whether the datashare can be shared to a publicly
-- accessible cluster.
--
-- '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.
--
-- 'dataShareAssociations', 'dataShare_dataShareAssociations' - A value that specifies when the datashare has an association between
-- producer and data consumers.
--
-- 'managedBy', 'dataShare_managedBy' - The identifier of a datashare to show its managing entity.
--
-- 'producerArn', 'dataShare_producerArn' - The Amazon Resource Name (ARN) of the producer.
newDataShare ::
  DataShare
newDataShare :: DataShare
newDataShare =
  DataShare'
    { $sel:allowPubliclyAccessibleConsumers:DataShare' :: Maybe Bool
allowPubliclyAccessibleConsumers =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dataShareArn:DataShare' :: Maybe Text
dataShareArn = forall a. Maybe a
Prelude.Nothing,
      $sel:dataShareAssociations:DataShare' :: Maybe [DataShareAssociation]
dataShareAssociations = forall a. Maybe a
Prelude.Nothing,
      $sel:managedBy:DataShare' :: Maybe Text
managedBy = forall a. Maybe a
Prelude.Nothing,
      $sel:producerArn:DataShare' :: Maybe Text
producerArn = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' DataShare (Maybe Bool)
dataShare_allowPubliclyAccessibleConsumers = 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)

-- | 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 :: Lens' DataShare (Maybe Text)
dataShare_dataShareArn = 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 when the datashare has an association between
-- producer and data consumers.
dataShare_dataShareAssociations :: Lens.Lens' DataShare (Prelude.Maybe [DataShareAssociation])
dataShare_dataShareAssociations :: Lens' DataShare (Maybe [DataShareAssociation])
dataShare_dataShareAssociations = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of a datashare to show its managing entity.
dataShare_managedBy :: Lens.Lens' DataShare (Prelude.Maybe Prelude.Text)
dataShare_managedBy :: Lens' DataShare (Maybe Text)
dataShare_managedBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShare' {Maybe Text
managedBy :: Maybe Text
$sel:managedBy:DataShare' :: DataShare -> Maybe Text
managedBy} -> Maybe Text
managedBy) (\s :: DataShare
s@DataShare' {} Maybe Text
a -> DataShare
s {$sel:managedBy:DataShare' :: Maybe Text
managedBy = Maybe Text
a} :: DataShare)

-- | The Amazon Resource Name (ARN) of the producer.
dataShare_producerArn :: Lens.Lens' DataShare (Prelude.Maybe Prelude.Text)
dataShare_producerArn :: Lens' DataShare (Maybe Text)
dataShare_producerArn = 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)

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

instance Prelude.Hashable DataShare where
  hashWithSalt :: Int -> DataShare -> Int
hashWithSalt Int
_salt DataShare' {Maybe Bool
Maybe [DataShareAssociation]
Maybe Text
producerArn :: Maybe Text
managedBy :: Maybe Text
dataShareAssociations :: Maybe [DataShareAssociation]
dataShareArn :: Maybe Text
allowPubliclyAccessibleConsumers :: Maybe Bool
$sel:producerArn:DataShare' :: DataShare -> Maybe Text
$sel:managedBy:DataShare' :: DataShare -> Maybe Text
$sel:dataShareAssociations:DataShare' :: DataShare -> Maybe [DataShareAssociation]
$sel:dataShareArn:DataShare' :: DataShare -> Maybe Text
$sel:allowPubliclyAccessibleConsumers:DataShare' :: DataShare -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowPubliclyAccessibleConsumers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataShareArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DataShareAssociation]
dataShareAssociations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
managedBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
producerArn

instance Prelude.NFData DataShare where
  rnf :: DataShare -> ()
rnf DataShare' {Maybe Bool
Maybe [DataShareAssociation]
Maybe Text
producerArn :: Maybe Text
managedBy :: Maybe Text
dataShareAssociations :: Maybe [DataShareAssociation]
dataShareArn :: Maybe Text
allowPubliclyAccessibleConsumers :: Maybe Bool
$sel:producerArn:DataShare' :: DataShare -> Maybe Text
$sel:managedBy:DataShare' :: DataShare -> Maybe Text
$sel:dataShareAssociations:DataShare' :: DataShare -> Maybe [DataShareAssociation]
$sel:dataShareArn:DataShare' :: DataShare -> Maybe Text
$sel:allowPubliclyAccessibleConsumers:DataShare' :: DataShare -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowPubliclyAccessibleConsumers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataShareArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [DataShareAssociation]
dataShareAssociations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
managedBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
producerArn