{-# 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.RDS.Types.DBClusterSnapshotAttribute
-- 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.RDS.Types.DBClusterSnapshotAttribute where

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

-- | Contains the name and values of a manual DB cluster snapshot attribute.
--
-- Manual DB cluster snapshot attributes are used to authorize other Amazon
-- Web Services accounts to restore a manual DB cluster snapshot. For more
-- information, see the @ModifyDBClusterSnapshotAttribute@ API action.
--
-- /See:/ 'newDBClusterSnapshotAttribute' smart constructor.
data DBClusterSnapshotAttribute = DBClusterSnapshotAttribute'
  { -- | The value(s) for the manual DB cluster snapshot attribute.
    --
    -- If the @AttributeName@ field is set to @restore@, then this element
    -- returns a list of IDs of the Amazon Web Services accounts that are
    -- authorized to copy or restore the manual DB cluster snapshot. If a value
    -- of @all@ is in the list, then the manual DB cluster snapshot is public
    -- and available for any Amazon Web Services account to copy or restore.
    DBClusterSnapshotAttribute -> Maybe [Text]
attributeValues :: Prelude.Maybe [Prelude.Text],
    -- | The name of the manual DB cluster snapshot attribute.
    --
    -- The attribute named @restore@ refers to the list of Amazon Web Services
    -- accounts that have permission to copy or restore the manual DB cluster
    -- snapshot. For more information, see the
    -- @ModifyDBClusterSnapshotAttribute@ API action.
    DBClusterSnapshotAttribute -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text
  }
  deriving (DBClusterSnapshotAttribute -> DBClusterSnapshotAttribute -> Bool
(DBClusterSnapshotAttribute -> DBClusterSnapshotAttribute -> Bool)
-> (DBClusterSnapshotAttribute
    -> DBClusterSnapshotAttribute -> Bool)
-> Eq DBClusterSnapshotAttribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBClusterSnapshotAttribute -> DBClusterSnapshotAttribute -> Bool
$c/= :: DBClusterSnapshotAttribute -> DBClusterSnapshotAttribute -> Bool
== :: DBClusterSnapshotAttribute -> DBClusterSnapshotAttribute -> Bool
$c== :: DBClusterSnapshotAttribute -> DBClusterSnapshotAttribute -> Bool
Prelude.Eq, ReadPrec [DBClusterSnapshotAttribute]
ReadPrec DBClusterSnapshotAttribute
Int -> ReadS DBClusterSnapshotAttribute
ReadS [DBClusterSnapshotAttribute]
(Int -> ReadS DBClusterSnapshotAttribute)
-> ReadS [DBClusterSnapshotAttribute]
-> ReadPrec DBClusterSnapshotAttribute
-> ReadPrec [DBClusterSnapshotAttribute]
-> Read DBClusterSnapshotAttribute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBClusterSnapshotAttribute]
$creadListPrec :: ReadPrec [DBClusterSnapshotAttribute]
readPrec :: ReadPrec DBClusterSnapshotAttribute
$creadPrec :: ReadPrec DBClusterSnapshotAttribute
readList :: ReadS [DBClusterSnapshotAttribute]
$creadList :: ReadS [DBClusterSnapshotAttribute]
readsPrec :: Int -> ReadS DBClusterSnapshotAttribute
$creadsPrec :: Int -> ReadS DBClusterSnapshotAttribute
Prelude.Read, Int -> DBClusterSnapshotAttribute -> ShowS
[DBClusterSnapshotAttribute] -> ShowS
DBClusterSnapshotAttribute -> String
(Int -> DBClusterSnapshotAttribute -> ShowS)
-> (DBClusterSnapshotAttribute -> String)
-> ([DBClusterSnapshotAttribute] -> ShowS)
-> Show DBClusterSnapshotAttribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBClusterSnapshotAttribute] -> ShowS
$cshowList :: [DBClusterSnapshotAttribute] -> ShowS
show :: DBClusterSnapshotAttribute -> String
$cshow :: DBClusterSnapshotAttribute -> String
showsPrec :: Int -> DBClusterSnapshotAttribute -> ShowS
$cshowsPrec :: Int -> DBClusterSnapshotAttribute -> ShowS
Prelude.Show, (forall x.
 DBClusterSnapshotAttribute -> Rep DBClusterSnapshotAttribute x)
-> (forall x.
    Rep DBClusterSnapshotAttribute x -> DBClusterSnapshotAttribute)
-> Generic DBClusterSnapshotAttribute
forall x.
Rep DBClusterSnapshotAttribute x -> DBClusterSnapshotAttribute
forall x.
DBClusterSnapshotAttribute -> Rep DBClusterSnapshotAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DBClusterSnapshotAttribute x -> DBClusterSnapshotAttribute
$cfrom :: forall x.
DBClusterSnapshotAttribute -> Rep DBClusterSnapshotAttribute x
Prelude.Generic)

-- |
-- Create a value of 'DBClusterSnapshotAttribute' 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:
--
-- 'attributeValues', 'dbClusterSnapshotAttribute_attributeValues' - The value(s) for the manual DB cluster snapshot attribute.
--
-- If the @AttributeName@ field is set to @restore@, then this element
-- returns a list of IDs of the Amazon Web Services accounts that are
-- authorized to copy or restore the manual DB cluster snapshot. If a value
-- of @all@ is in the list, then the manual DB cluster snapshot is public
-- and available for any Amazon Web Services account to copy or restore.
--
-- 'attributeName', 'dbClusterSnapshotAttribute_attributeName' - The name of the manual DB cluster snapshot attribute.
--
-- The attribute named @restore@ refers to the list of Amazon Web Services
-- accounts that have permission to copy or restore the manual DB cluster
-- snapshot. For more information, see the
-- @ModifyDBClusterSnapshotAttribute@ API action.
newDBClusterSnapshotAttribute ::
  DBClusterSnapshotAttribute
newDBClusterSnapshotAttribute :: DBClusterSnapshotAttribute
newDBClusterSnapshotAttribute =
  DBClusterSnapshotAttribute' :: Maybe [Text] -> Maybe Text -> DBClusterSnapshotAttribute
DBClusterSnapshotAttribute'
    { $sel:attributeValues:DBClusterSnapshotAttribute' :: Maybe [Text]
attributeValues =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:DBClusterSnapshotAttribute' :: Maybe Text
attributeName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value(s) for the manual DB cluster snapshot attribute.
--
-- If the @AttributeName@ field is set to @restore@, then this element
-- returns a list of IDs of the Amazon Web Services accounts that are
-- authorized to copy or restore the manual DB cluster snapshot. If a value
-- of @all@ is in the list, then the manual DB cluster snapshot is public
-- and available for any Amazon Web Services account to copy or restore.
dbClusterSnapshotAttribute_attributeValues :: Lens.Lens' DBClusterSnapshotAttribute (Prelude.Maybe [Prelude.Text])
dbClusterSnapshotAttribute_attributeValues :: (Maybe [Text] -> f (Maybe [Text]))
-> DBClusterSnapshotAttribute -> f DBClusterSnapshotAttribute
dbClusterSnapshotAttribute_attributeValues = (DBClusterSnapshotAttribute -> Maybe [Text])
-> (DBClusterSnapshotAttribute
    -> Maybe [Text] -> DBClusterSnapshotAttribute)
-> Lens
     DBClusterSnapshotAttribute
     DBClusterSnapshotAttribute
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterSnapshotAttribute' {Maybe [Text]
attributeValues :: Maybe [Text]
$sel:attributeValues:DBClusterSnapshotAttribute' :: DBClusterSnapshotAttribute -> Maybe [Text]
attributeValues} -> Maybe [Text]
attributeValues) (\s :: DBClusterSnapshotAttribute
s@DBClusterSnapshotAttribute' {} Maybe [Text]
a -> DBClusterSnapshotAttribute
s {$sel:attributeValues:DBClusterSnapshotAttribute' :: Maybe [Text]
attributeValues = Maybe [Text]
a} :: DBClusterSnapshotAttribute) ((Maybe [Text] -> f (Maybe [Text]))
 -> DBClusterSnapshotAttribute -> f DBClusterSnapshotAttribute)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DBClusterSnapshotAttribute
-> f DBClusterSnapshotAttribute
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

-- | The name of the manual DB cluster snapshot attribute.
--
-- The attribute named @restore@ refers to the list of Amazon Web Services
-- accounts that have permission to copy or restore the manual DB cluster
-- snapshot. For more information, see the
-- @ModifyDBClusterSnapshotAttribute@ API action.
dbClusterSnapshotAttribute_attributeName :: Lens.Lens' DBClusterSnapshotAttribute (Prelude.Maybe Prelude.Text)
dbClusterSnapshotAttribute_attributeName :: (Maybe Text -> f (Maybe Text))
-> DBClusterSnapshotAttribute -> f DBClusterSnapshotAttribute
dbClusterSnapshotAttribute_attributeName = (DBClusterSnapshotAttribute -> Maybe Text)
-> (DBClusterSnapshotAttribute
    -> Maybe Text -> DBClusterSnapshotAttribute)
-> Lens
     DBClusterSnapshotAttribute
     DBClusterSnapshotAttribute
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterSnapshotAttribute' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:DBClusterSnapshotAttribute' :: DBClusterSnapshotAttribute -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: DBClusterSnapshotAttribute
s@DBClusterSnapshotAttribute' {} Maybe Text
a -> DBClusterSnapshotAttribute
s {$sel:attributeName:DBClusterSnapshotAttribute' :: Maybe Text
attributeName = Maybe Text
a} :: DBClusterSnapshotAttribute)

instance Core.FromXML DBClusterSnapshotAttribute where
  parseXML :: [Node] -> Either String DBClusterSnapshotAttribute
parseXML [Node]
x =
    Maybe [Text] -> Maybe Text -> DBClusterSnapshotAttribute
DBClusterSnapshotAttribute'
      (Maybe [Text] -> Maybe Text -> DBClusterSnapshotAttribute)
-> Either String (Maybe [Text])
-> Either String (Maybe Text -> DBClusterSnapshotAttribute)
forall (f :: * -> *) a b. Functor 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
"AttributeValues" 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 [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"AttributeValue")
                  )
      Either String (Maybe Text -> DBClusterSnapshotAttribute)
-> Either String (Maybe Text)
-> Either String DBClusterSnapshotAttribute
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
"AttributeName")

instance Prelude.Hashable DBClusterSnapshotAttribute

instance Prelude.NFData DBClusterSnapshotAttribute