{-# 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.DBSnapshotAttributesResult
-- 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.DBSnapshotAttributesResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.DBSnapshotAttribute

-- | Contains the results of a successful call to the
-- @DescribeDBSnapshotAttributes@ API action.
--
-- Manual DB snapshot attributes are used to authorize other Amazon Web
-- Services accounts to copy or restore a manual DB snapshot. For more
-- information, see the @ModifyDBSnapshotAttribute@ API action.
--
-- /See:/ 'newDBSnapshotAttributesResult' smart constructor.
data DBSnapshotAttributesResult = DBSnapshotAttributesResult'
  { -- | The identifier of the manual DB snapshot that the attributes apply to.
    DBSnapshotAttributesResult -> Maybe Text
dbSnapshotIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The list of attributes and values for the manual DB snapshot.
    DBSnapshotAttributesResult -> Maybe [DBSnapshotAttribute]
dbSnapshotAttributes :: Prelude.Maybe [DBSnapshotAttribute]
  }
  deriving (DBSnapshotAttributesResult -> DBSnapshotAttributesResult -> Bool
(DBSnapshotAttributesResult -> DBSnapshotAttributesResult -> Bool)
-> (DBSnapshotAttributesResult
    -> DBSnapshotAttributesResult -> Bool)
-> Eq DBSnapshotAttributesResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBSnapshotAttributesResult -> DBSnapshotAttributesResult -> Bool
$c/= :: DBSnapshotAttributesResult -> DBSnapshotAttributesResult -> Bool
== :: DBSnapshotAttributesResult -> DBSnapshotAttributesResult -> Bool
$c== :: DBSnapshotAttributesResult -> DBSnapshotAttributesResult -> Bool
Prelude.Eq, ReadPrec [DBSnapshotAttributesResult]
ReadPrec DBSnapshotAttributesResult
Int -> ReadS DBSnapshotAttributesResult
ReadS [DBSnapshotAttributesResult]
(Int -> ReadS DBSnapshotAttributesResult)
-> ReadS [DBSnapshotAttributesResult]
-> ReadPrec DBSnapshotAttributesResult
-> ReadPrec [DBSnapshotAttributesResult]
-> Read DBSnapshotAttributesResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBSnapshotAttributesResult]
$creadListPrec :: ReadPrec [DBSnapshotAttributesResult]
readPrec :: ReadPrec DBSnapshotAttributesResult
$creadPrec :: ReadPrec DBSnapshotAttributesResult
readList :: ReadS [DBSnapshotAttributesResult]
$creadList :: ReadS [DBSnapshotAttributesResult]
readsPrec :: Int -> ReadS DBSnapshotAttributesResult
$creadsPrec :: Int -> ReadS DBSnapshotAttributesResult
Prelude.Read, Int -> DBSnapshotAttributesResult -> ShowS
[DBSnapshotAttributesResult] -> ShowS
DBSnapshotAttributesResult -> String
(Int -> DBSnapshotAttributesResult -> ShowS)
-> (DBSnapshotAttributesResult -> String)
-> ([DBSnapshotAttributesResult] -> ShowS)
-> Show DBSnapshotAttributesResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBSnapshotAttributesResult] -> ShowS
$cshowList :: [DBSnapshotAttributesResult] -> ShowS
show :: DBSnapshotAttributesResult -> String
$cshow :: DBSnapshotAttributesResult -> String
showsPrec :: Int -> DBSnapshotAttributesResult -> ShowS
$cshowsPrec :: Int -> DBSnapshotAttributesResult -> ShowS
Prelude.Show, (forall x.
 DBSnapshotAttributesResult -> Rep DBSnapshotAttributesResult x)
-> (forall x.
    Rep DBSnapshotAttributesResult x -> DBSnapshotAttributesResult)
-> Generic DBSnapshotAttributesResult
forall x.
Rep DBSnapshotAttributesResult x -> DBSnapshotAttributesResult
forall x.
DBSnapshotAttributesResult -> Rep DBSnapshotAttributesResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DBSnapshotAttributesResult x -> DBSnapshotAttributesResult
$cfrom :: forall x.
DBSnapshotAttributesResult -> Rep DBSnapshotAttributesResult x
Prelude.Generic)

-- |
-- Create a value of 'DBSnapshotAttributesResult' 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:
--
-- 'dbSnapshotIdentifier', 'dbSnapshotAttributesResult_dbSnapshotIdentifier' - The identifier of the manual DB snapshot that the attributes apply to.
--
-- 'dbSnapshotAttributes', 'dbSnapshotAttributesResult_dbSnapshotAttributes' - The list of attributes and values for the manual DB snapshot.
newDBSnapshotAttributesResult ::
  DBSnapshotAttributesResult
newDBSnapshotAttributesResult :: DBSnapshotAttributesResult
newDBSnapshotAttributesResult =
  DBSnapshotAttributesResult' :: Maybe Text
-> Maybe [DBSnapshotAttribute] -> DBSnapshotAttributesResult
DBSnapshotAttributesResult'
    { $sel:dbSnapshotIdentifier:DBSnapshotAttributesResult' :: Maybe Text
dbSnapshotIdentifier =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dbSnapshotAttributes:DBSnapshotAttributesResult' :: Maybe [DBSnapshotAttribute]
dbSnapshotAttributes = Maybe [DBSnapshotAttribute]
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the manual DB snapshot that the attributes apply to.
dbSnapshotAttributesResult_dbSnapshotIdentifier :: Lens.Lens' DBSnapshotAttributesResult (Prelude.Maybe Prelude.Text)
dbSnapshotAttributesResult_dbSnapshotIdentifier :: (Maybe Text -> f (Maybe Text))
-> DBSnapshotAttributesResult -> f DBSnapshotAttributesResult
dbSnapshotAttributesResult_dbSnapshotIdentifier = (DBSnapshotAttributesResult -> Maybe Text)
-> (DBSnapshotAttributesResult
    -> Maybe Text -> DBSnapshotAttributesResult)
-> Lens
     DBSnapshotAttributesResult
     DBSnapshotAttributesResult
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSnapshotAttributesResult' {Maybe Text
dbSnapshotIdentifier :: Maybe Text
$sel:dbSnapshotIdentifier:DBSnapshotAttributesResult' :: DBSnapshotAttributesResult -> Maybe Text
dbSnapshotIdentifier} -> Maybe Text
dbSnapshotIdentifier) (\s :: DBSnapshotAttributesResult
s@DBSnapshotAttributesResult' {} Maybe Text
a -> DBSnapshotAttributesResult
s {$sel:dbSnapshotIdentifier:DBSnapshotAttributesResult' :: Maybe Text
dbSnapshotIdentifier = Maybe Text
a} :: DBSnapshotAttributesResult)

-- | The list of attributes and values for the manual DB snapshot.
dbSnapshotAttributesResult_dbSnapshotAttributes :: Lens.Lens' DBSnapshotAttributesResult (Prelude.Maybe [DBSnapshotAttribute])
dbSnapshotAttributesResult_dbSnapshotAttributes :: (Maybe [DBSnapshotAttribute] -> f (Maybe [DBSnapshotAttribute]))
-> DBSnapshotAttributesResult -> f DBSnapshotAttributesResult
dbSnapshotAttributesResult_dbSnapshotAttributes = (DBSnapshotAttributesResult -> Maybe [DBSnapshotAttribute])
-> (DBSnapshotAttributesResult
    -> Maybe [DBSnapshotAttribute] -> DBSnapshotAttributesResult)
-> Lens
     DBSnapshotAttributesResult
     DBSnapshotAttributesResult
     (Maybe [DBSnapshotAttribute])
     (Maybe [DBSnapshotAttribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSnapshotAttributesResult' {Maybe [DBSnapshotAttribute]
dbSnapshotAttributes :: Maybe [DBSnapshotAttribute]
$sel:dbSnapshotAttributes:DBSnapshotAttributesResult' :: DBSnapshotAttributesResult -> Maybe [DBSnapshotAttribute]
dbSnapshotAttributes} -> Maybe [DBSnapshotAttribute]
dbSnapshotAttributes) (\s :: DBSnapshotAttributesResult
s@DBSnapshotAttributesResult' {} Maybe [DBSnapshotAttribute]
a -> DBSnapshotAttributesResult
s {$sel:dbSnapshotAttributes:DBSnapshotAttributesResult' :: Maybe [DBSnapshotAttribute]
dbSnapshotAttributes = Maybe [DBSnapshotAttribute]
a} :: DBSnapshotAttributesResult) ((Maybe [DBSnapshotAttribute] -> f (Maybe [DBSnapshotAttribute]))
 -> DBSnapshotAttributesResult -> f DBSnapshotAttributesResult)
-> ((Maybe [DBSnapshotAttribute]
     -> f (Maybe [DBSnapshotAttribute]))
    -> Maybe [DBSnapshotAttribute] -> f (Maybe [DBSnapshotAttribute]))
-> (Maybe [DBSnapshotAttribute] -> f (Maybe [DBSnapshotAttribute]))
-> DBSnapshotAttributesResult
-> f DBSnapshotAttributesResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DBSnapshotAttribute]
  [DBSnapshotAttribute]
  [DBSnapshotAttribute]
  [DBSnapshotAttribute]
-> Iso
     (Maybe [DBSnapshotAttribute])
     (Maybe [DBSnapshotAttribute])
     (Maybe [DBSnapshotAttribute])
     (Maybe [DBSnapshotAttribute])
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
  [DBSnapshotAttribute]
  [DBSnapshotAttribute]
  [DBSnapshotAttribute]
  [DBSnapshotAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable DBSnapshotAttributesResult

instance Prelude.NFData DBSnapshotAttributesResult