{-# 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.DataShareAssociation
-- 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.DataShareAssociation 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.DataShareStatus

-- | The association of a datashare from a producer account with a data
-- consumer.
--
-- /See:/ 'newDataShareAssociation' smart constructor.
data DataShareAssociation = DataShareAssociation'
  { -- | The status of the datashare that is associated.
    DataShareAssociation -> Maybe DataShareStatus
status :: Prelude.Maybe DataShareStatus,
    -- | The name of the consumer accounts that have an association with a
    -- producer datashare.
    DataShareAssociation -> Maybe Text
consumerIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The creation date of the datashare that is associated.
    DataShareAssociation -> Maybe ISO8601
createdDate :: Prelude.Maybe Core.ISO8601,
    -- | The status change data of the datashare that is associated.
    DataShareAssociation -> Maybe ISO8601
statusChangeDate :: Prelude.Maybe Core.ISO8601
  }
  deriving (DataShareAssociation -> DataShareAssociation -> Bool
(DataShareAssociation -> DataShareAssociation -> Bool)
-> (DataShareAssociation -> DataShareAssociation -> Bool)
-> Eq DataShareAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataShareAssociation -> DataShareAssociation -> Bool
$c/= :: DataShareAssociation -> DataShareAssociation -> Bool
== :: DataShareAssociation -> DataShareAssociation -> Bool
$c== :: DataShareAssociation -> DataShareAssociation -> Bool
Prelude.Eq, ReadPrec [DataShareAssociation]
ReadPrec DataShareAssociation
Int -> ReadS DataShareAssociation
ReadS [DataShareAssociation]
(Int -> ReadS DataShareAssociation)
-> ReadS [DataShareAssociation]
-> ReadPrec DataShareAssociation
-> ReadPrec [DataShareAssociation]
-> Read DataShareAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataShareAssociation]
$creadListPrec :: ReadPrec [DataShareAssociation]
readPrec :: ReadPrec DataShareAssociation
$creadPrec :: ReadPrec DataShareAssociation
readList :: ReadS [DataShareAssociation]
$creadList :: ReadS [DataShareAssociation]
readsPrec :: Int -> ReadS DataShareAssociation
$creadsPrec :: Int -> ReadS DataShareAssociation
Prelude.Read, Int -> DataShareAssociation -> ShowS
[DataShareAssociation] -> ShowS
DataShareAssociation -> String
(Int -> DataShareAssociation -> ShowS)
-> (DataShareAssociation -> String)
-> ([DataShareAssociation] -> ShowS)
-> Show DataShareAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataShareAssociation] -> ShowS
$cshowList :: [DataShareAssociation] -> ShowS
show :: DataShareAssociation -> String
$cshow :: DataShareAssociation -> String
showsPrec :: Int -> DataShareAssociation -> ShowS
$cshowsPrec :: Int -> DataShareAssociation -> ShowS
Prelude.Show, (forall x. DataShareAssociation -> Rep DataShareAssociation x)
-> (forall x. Rep DataShareAssociation x -> DataShareAssociation)
-> Generic DataShareAssociation
forall x. Rep DataShareAssociation x -> DataShareAssociation
forall x. DataShareAssociation -> Rep DataShareAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataShareAssociation x -> DataShareAssociation
$cfrom :: forall x. DataShareAssociation -> Rep DataShareAssociation x
Prelude.Generic)

-- |
-- Create a value of 'DataShareAssociation' 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:
--
-- 'status', 'dataShareAssociation_status' - The status of the datashare that is associated.
--
-- 'consumerIdentifier', 'dataShareAssociation_consumerIdentifier' - The name of the consumer accounts that have an association with a
-- producer datashare.
--
-- 'createdDate', 'dataShareAssociation_createdDate' - The creation date of the datashare that is associated.
--
-- 'statusChangeDate', 'dataShareAssociation_statusChangeDate' - The status change data of the datashare that is associated.
newDataShareAssociation ::
  DataShareAssociation
newDataShareAssociation :: DataShareAssociation
newDataShareAssociation =
  DataShareAssociation' :: Maybe DataShareStatus
-> Maybe Text
-> Maybe ISO8601
-> Maybe ISO8601
-> DataShareAssociation
DataShareAssociation'
    { $sel:status:DataShareAssociation' :: Maybe DataShareStatus
status = Maybe DataShareStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:consumerIdentifier:DataShareAssociation' :: Maybe Text
consumerIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdDate:DataShareAssociation' :: Maybe ISO8601
createdDate = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:statusChangeDate:DataShareAssociation' :: Maybe ISO8601
statusChangeDate = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the datashare that is associated.
dataShareAssociation_status :: Lens.Lens' DataShareAssociation (Prelude.Maybe DataShareStatus)
dataShareAssociation_status :: (Maybe DataShareStatus -> f (Maybe DataShareStatus))
-> DataShareAssociation -> f DataShareAssociation
dataShareAssociation_status = (DataShareAssociation -> Maybe DataShareStatus)
-> (DataShareAssociation
    -> Maybe DataShareStatus -> DataShareAssociation)
-> Lens
     DataShareAssociation
     DataShareAssociation
     (Maybe DataShareStatus)
     (Maybe DataShareStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShareAssociation' {Maybe DataShareStatus
status :: Maybe DataShareStatus
$sel:status:DataShareAssociation' :: DataShareAssociation -> Maybe DataShareStatus
status} -> Maybe DataShareStatus
status) (\s :: DataShareAssociation
s@DataShareAssociation' {} Maybe DataShareStatus
a -> DataShareAssociation
s {$sel:status:DataShareAssociation' :: Maybe DataShareStatus
status = Maybe DataShareStatus
a} :: DataShareAssociation)

-- | The name of the consumer accounts that have an association with a
-- producer datashare.
dataShareAssociation_consumerIdentifier :: Lens.Lens' DataShareAssociation (Prelude.Maybe Prelude.Text)
dataShareAssociation_consumerIdentifier :: (Maybe Text -> f (Maybe Text))
-> DataShareAssociation -> f DataShareAssociation
dataShareAssociation_consumerIdentifier = (DataShareAssociation -> Maybe Text)
-> (DataShareAssociation -> Maybe Text -> DataShareAssociation)
-> Lens
     DataShareAssociation DataShareAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShareAssociation' {Maybe Text
consumerIdentifier :: Maybe Text
$sel:consumerIdentifier:DataShareAssociation' :: DataShareAssociation -> Maybe Text
consumerIdentifier} -> Maybe Text
consumerIdentifier) (\s :: DataShareAssociation
s@DataShareAssociation' {} Maybe Text
a -> DataShareAssociation
s {$sel:consumerIdentifier:DataShareAssociation' :: Maybe Text
consumerIdentifier = Maybe Text
a} :: DataShareAssociation)

-- | The creation date of the datashare that is associated.
dataShareAssociation_createdDate :: Lens.Lens' DataShareAssociation (Prelude.Maybe Prelude.UTCTime)
dataShareAssociation_createdDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DataShareAssociation -> f DataShareAssociation
dataShareAssociation_createdDate = (DataShareAssociation -> Maybe ISO8601)
-> (DataShareAssociation -> Maybe ISO8601 -> DataShareAssociation)
-> Lens
     DataShareAssociation
     DataShareAssociation
     (Maybe ISO8601)
     (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShareAssociation' {Maybe ISO8601
createdDate :: Maybe ISO8601
$sel:createdDate:DataShareAssociation' :: DataShareAssociation -> Maybe ISO8601
createdDate} -> Maybe ISO8601
createdDate) (\s :: DataShareAssociation
s@DataShareAssociation' {} Maybe ISO8601
a -> DataShareAssociation
s {$sel:createdDate:DataShareAssociation' :: Maybe ISO8601
createdDate = Maybe ISO8601
a} :: DataShareAssociation) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> DataShareAssociation -> f DataShareAssociation)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DataShareAssociation
-> f DataShareAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The status change data of the datashare that is associated.
dataShareAssociation_statusChangeDate :: Lens.Lens' DataShareAssociation (Prelude.Maybe Prelude.UTCTime)
dataShareAssociation_statusChangeDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DataShareAssociation -> f DataShareAssociation
dataShareAssociation_statusChangeDate = (DataShareAssociation -> Maybe ISO8601)
-> (DataShareAssociation -> Maybe ISO8601 -> DataShareAssociation)
-> Lens
     DataShareAssociation
     DataShareAssociation
     (Maybe ISO8601)
     (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataShareAssociation' {Maybe ISO8601
statusChangeDate :: Maybe ISO8601
$sel:statusChangeDate:DataShareAssociation' :: DataShareAssociation -> Maybe ISO8601
statusChangeDate} -> Maybe ISO8601
statusChangeDate) (\s :: DataShareAssociation
s@DataShareAssociation' {} Maybe ISO8601
a -> DataShareAssociation
s {$sel:statusChangeDate:DataShareAssociation' :: Maybe ISO8601
statusChangeDate = Maybe ISO8601
a} :: DataShareAssociation) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> DataShareAssociation -> f DataShareAssociation)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DataShareAssociation
-> f DataShareAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML DataShareAssociation where
  parseXML :: [Node] -> Either String DataShareAssociation
parseXML [Node]
x =
    Maybe DataShareStatus
-> Maybe Text
-> Maybe ISO8601
-> Maybe ISO8601
-> DataShareAssociation
DataShareAssociation'
      (Maybe DataShareStatus
 -> Maybe Text
 -> Maybe ISO8601
 -> Maybe ISO8601
 -> DataShareAssociation)
-> Either String (Maybe DataShareStatus)
-> Either
     String
     (Maybe Text
      -> Maybe ISO8601 -> Maybe ISO8601 -> DataShareAssociation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe DataShareStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either
  String
  (Maybe Text
   -> Maybe ISO8601 -> Maybe ISO8601 -> DataShareAssociation)
-> Either String (Maybe Text)
-> Either
     String (Maybe ISO8601 -> Maybe ISO8601 -> DataShareAssociation)
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
"ConsumerIdentifier")
      Either
  String (Maybe ISO8601 -> Maybe ISO8601 -> DataShareAssociation)
-> Either String (Maybe ISO8601)
-> Either String (Maybe ISO8601 -> DataShareAssociation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CreatedDate")
      Either String (Maybe ISO8601 -> DataShareAssociation)
-> Either String (Maybe ISO8601)
-> Either String DataShareAssociation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StatusChangeDate")

instance Prelude.Hashable DataShareAssociation

instance Prelude.NFData DataShareAssociation