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

-- | 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 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,
    -- | 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]
  }
  deriving (DBSnapshotAttribute -> DBSnapshotAttribute -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
newDBSnapshotAttribute ::
  DBSnapshotAttribute
newDBSnapshotAttribute :: DBSnapshotAttribute
newDBSnapshotAttribute =
  DBSnapshotAttribute'
    { $sel:attributeName:DBSnapshotAttribute' :: Maybe Text
attributeName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:attributeValues:DBSnapshotAttribute' :: Maybe [Text]
attributeValues = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' DBSnapshotAttribute (Maybe Text)
dbSnapshotAttribute_attributeName = 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)

-- | 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 :: Lens' DBSnapshotAttribute (Maybe [Text])
dbSnapshotAttribute_attributeValues = 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) 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

instance Data.FromXML DBSnapshotAttribute where
  parseXML :: [Node] -> Either String DBSnapshotAttribute
parseXML [Node]
x =
    Maybe Text -> Maybe [Text] -> DBSnapshotAttribute
DBSnapshotAttribute'
      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
"AttributeName")
      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
"AttributeValues"
                      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
"AttributeValue")
                  )

instance Prelude.Hashable DBSnapshotAttribute where
  hashWithSalt :: Int -> DBSnapshotAttribute -> Int
hashWithSalt Int
_salt DBSnapshotAttribute' {Maybe [Text]
Maybe Text
attributeValues :: Maybe [Text]
attributeName :: Maybe Text
$sel:attributeValues:DBSnapshotAttribute' :: DBSnapshotAttribute -> Maybe [Text]
$sel:attributeName:DBSnapshotAttribute' :: DBSnapshotAttribute -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attributeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
attributeValues

instance Prelude.NFData DBSnapshotAttribute where
  rnf :: DBSnapshotAttribute -> ()
rnf DBSnapshotAttribute' {Maybe [Text]
Maybe Text
attributeValues :: Maybe [Text]
attributeName :: Maybe Text
$sel:attributeValues:DBSnapshotAttribute' :: DBSnapshotAttribute -> Maybe [Text]
$sel:attributeName:DBSnapshotAttribute' :: DBSnapshotAttribute -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attributeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
attributeValues