{-# 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.DBSnapshotAttribute
-- 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.DBSnapshotAttribute 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 snapshot attribute
--
-- Manual DB snapshot attributes are used to authorize other Amazon Web
-- Services accounts to restore a manual DB snapshot. For more information,
-- see the @ModifyDBSnapshotAttribute@ API.
--
-- /See:/ 'newDBSnapshotAttribute' smart constructor.
data DBSnapshotAttribute = DBSnapshotAttribute'
  { -- | The value or values for the manual DB 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 snapshot. If a value of
    -- @all@ is in the list, then the manual DB snapshot is public and
    -- available for any Amazon Web Services account to copy or restore.
    DBSnapshotAttribute -> Maybe [Text]
attributeValues :: Prelude.Maybe [Prelude.Text],
    -- | The name of the manual DB 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 @ModifyDBSnapshotAttribute@ API
    -- action.
    DBSnapshotAttribute -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text
  }
  deriving (DBSnapshotAttribute -> DBSnapshotAttribute -> Bool
(DBSnapshotAttribute -> DBSnapshotAttribute -> Bool)
-> (DBSnapshotAttribute -> DBSnapshotAttribute -> Bool)
-> Eq DBSnapshotAttribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBSnapshotAttribute -> DBSnapshotAttribute -> Bool
$c/= :: DBSnapshotAttribute -> DBSnapshotAttribute -> Bool
== :: DBSnapshotAttribute -> DBSnapshotAttribute -> Bool
$c== :: DBSnapshotAttribute -> DBSnapshotAttribute -> Bool
Prelude.Eq, ReadPrec [DBSnapshotAttribute]
ReadPrec DBSnapshotAttribute
Int -> ReadS DBSnapshotAttribute
ReadS [DBSnapshotAttribute]
(Int -> ReadS DBSnapshotAttribute)
-> ReadS [DBSnapshotAttribute]
-> ReadPrec DBSnapshotAttribute
-> ReadPrec [DBSnapshotAttribute]
-> Read DBSnapshotAttribute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBSnapshotAttribute]
$creadListPrec :: ReadPrec [DBSnapshotAttribute]
readPrec :: ReadPrec DBSnapshotAttribute
$creadPrec :: ReadPrec DBSnapshotAttribute
readList :: ReadS [DBSnapshotAttribute]
$creadList :: ReadS [DBSnapshotAttribute]
readsPrec :: Int -> ReadS DBSnapshotAttribute
$creadsPrec :: Int -> ReadS DBSnapshotAttribute
Prelude.Read, Int -> DBSnapshotAttribute -> ShowS
[DBSnapshotAttribute] -> ShowS
DBSnapshotAttribute -> String
(Int -> DBSnapshotAttribute -> ShowS)
-> (DBSnapshotAttribute -> String)
-> ([DBSnapshotAttribute] -> ShowS)
-> Show DBSnapshotAttribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBSnapshotAttribute] -> ShowS
$cshowList :: [DBSnapshotAttribute] -> ShowS
show :: DBSnapshotAttribute -> String
$cshow :: DBSnapshotAttribute -> String
showsPrec :: Int -> DBSnapshotAttribute -> ShowS
$cshowsPrec :: Int -> DBSnapshotAttribute -> ShowS
Prelude.Show, (forall x. DBSnapshotAttribute -> Rep DBSnapshotAttribute x)
-> (forall x. Rep DBSnapshotAttribute x -> DBSnapshotAttribute)
-> Generic DBSnapshotAttribute
forall x. Rep DBSnapshotAttribute x -> DBSnapshotAttribute
forall x. DBSnapshotAttribute -> Rep DBSnapshotAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DBSnapshotAttribute x -> DBSnapshotAttribute
$cfrom :: forall x. DBSnapshotAttribute -> Rep DBSnapshotAttribute x
Prelude.Generic)

-- |
-- Create a value of 'DBSnapshotAttribute' 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', 'dbSnapshotAttribute_attributeValues' - The value or values for the manual DB 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 snapshot. If a value of
-- @all@ is in the list, then the manual DB snapshot is public and
-- available for any Amazon Web Services account to copy or restore.
--
-- 'attributeName', 'dbSnapshotAttribute_attributeName' - The name of the manual DB 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 @ModifyDBSnapshotAttribute@ API
-- action.
newDBSnapshotAttribute ::
  DBSnapshotAttribute
newDBSnapshotAttribute :: DBSnapshotAttribute
newDBSnapshotAttribute =
  DBSnapshotAttribute' :: Maybe [Text] -> Maybe Text -> DBSnapshotAttribute
DBSnapshotAttribute'
    { $sel:attributeValues:DBSnapshotAttribute' :: Maybe [Text]
attributeValues =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:DBSnapshotAttribute' :: Maybe Text
attributeName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value or values for the manual DB 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 snapshot. If a value of
-- @all@ is in the list, then the manual DB snapshot is public and
-- available for any Amazon Web Services account to copy or restore.
dbSnapshotAttribute_attributeValues :: Lens.Lens' DBSnapshotAttribute (Prelude.Maybe [Prelude.Text])
dbSnapshotAttribute_attributeValues :: (Maybe [Text] -> f (Maybe [Text]))
-> DBSnapshotAttribute -> f DBSnapshotAttribute
dbSnapshotAttribute_attributeValues = (DBSnapshotAttribute -> Maybe [Text])
-> (DBSnapshotAttribute -> Maybe [Text] -> DBSnapshotAttribute)
-> Lens
     DBSnapshotAttribute
     DBSnapshotAttribute
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSnapshotAttribute' {Maybe [Text]
attributeValues :: Maybe [Text]
$sel:attributeValues:DBSnapshotAttribute' :: DBSnapshotAttribute -> Maybe [Text]
attributeValues} -> Maybe [Text]
attributeValues) (\s :: DBSnapshotAttribute
s@DBSnapshotAttribute' {} Maybe [Text]
a -> DBSnapshotAttribute
s {$sel:attributeValues:DBSnapshotAttribute' :: Maybe [Text]
attributeValues = Maybe [Text]
a} :: DBSnapshotAttribute) ((Maybe [Text] -> f (Maybe [Text]))
 -> DBSnapshotAttribute -> f DBSnapshotAttribute)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DBSnapshotAttribute
-> f DBSnapshotAttribute
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 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 @ModifyDBSnapshotAttribute@ API
-- action.
dbSnapshotAttribute_attributeName :: Lens.Lens' DBSnapshotAttribute (Prelude.Maybe Prelude.Text)
dbSnapshotAttribute_attributeName :: (Maybe Text -> f (Maybe Text))
-> DBSnapshotAttribute -> f DBSnapshotAttribute
dbSnapshotAttribute_attributeName = (DBSnapshotAttribute -> Maybe Text)
-> (DBSnapshotAttribute -> Maybe Text -> DBSnapshotAttribute)
-> Lens
     DBSnapshotAttribute DBSnapshotAttribute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSnapshotAttribute' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:DBSnapshotAttribute' :: DBSnapshotAttribute -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: DBSnapshotAttribute
s@DBSnapshotAttribute' {} Maybe Text
a -> DBSnapshotAttribute
s {$sel:attributeName:DBSnapshotAttribute' :: Maybe Text
attributeName = Maybe Text
a} :: DBSnapshotAttribute)

instance Core.FromXML DBSnapshotAttribute where
  parseXML :: [Node] -> Either String DBSnapshotAttribute
parseXML [Node]
x =
    Maybe [Text] -> Maybe Text -> DBSnapshotAttribute
DBSnapshotAttribute'
      (Maybe [Text] -> Maybe Text -> DBSnapshotAttribute)
-> Either String (Maybe [Text])
-> Either String (Maybe Text -> DBSnapshotAttribute)
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 -> DBSnapshotAttribute)
-> Either String (Maybe Text) -> Either String DBSnapshotAttribute
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 DBSnapshotAttribute

instance Prelude.NFData DBSnapshotAttribute