{-# 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.SnapshotCopyGrant
-- 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.Redshift.Types.SnapshotCopyGrant 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
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.Tag

-- | The snapshot copy grant that grants Amazon Redshift permission to
-- encrypt copied snapshots with the specified encrypted symmetric key from
-- Amazon Web Services KMS in the destination region.
--
-- For more information about managing snapshot copy grants, go to
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-db-encryption.html Amazon Redshift Database Encryption>
-- in the /Amazon Redshift Cluster Management Guide/.
--
-- /See:/ 'newSnapshotCopyGrant' smart constructor.
data SnapshotCopyGrant = SnapshotCopyGrant'
  { -- | The unique identifier of the encrypted symmetric key in Amazon Web
    -- Services KMS to which Amazon Redshift is granted permission.
    SnapshotCopyGrant -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The name of the snapshot copy grant.
    SnapshotCopyGrant -> Maybe Text
snapshotCopyGrantName :: Prelude.Maybe Prelude.Text,
    -- | A list of tag instances.
    SnapshotCopyGrant -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (SnapshotCopyGrant -> SnapshotCopyGrant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapshotCopyGrant -> SnapshotCopyGrant -> Bool
$c/= :: SnapshotCopyGrant -> SnapshotCopyGrant -> Bool
== :: SnapshotCopyGrant -> SnapshotCopyGrant -> Bool
$c== :: SnapshotCopyGrant -> SnapshotCopyGrant -> Bool
Prelude.Eq, ReadPrec [SnapshotCopyGrant]
ReadPrec SnapshotCopyGrant
Int -> ReadS SnapshotCopyGrant
ReadS [SnapshotCopyGrant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapshotCopyGrant]
$creadListPrec :: ReadPrec [SnapshotCopyGrant]
readPrec :: ReadPrec SnapshotCopyGrant
$creadPrec :: ReadPrec SnapshotCopyGrant
readList :: ReadS [SnapshotCopyGrant]
$creadList :: ReadS [SnapshotCopyGrant]
readsPrec :: Int -> ReadS SnapshotCopyGrant
$creadsPrec :: Int -> ReadS SnapshotCopyGrant
Prelude.Read, Int -> SnapshotCopyGrant -> ShowS
[SnapshotCopyGrant] -> ShowS
SnapshotCopyGrant -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapshotCopyGrant] -> ShowS
$cshowList :: [SnapshotCopyGrant] -> ShowS
show :: SnapshotCopyGrant -> String
$cshow :: SnapshotCopyGrant -> String
showsPrec :: Int -> SnapshotCopyGrant -> ShowS
$cshowsPrec :: Int -> SnapshotCopyGrant -> ShowS
Prelude.Show, forall x. Rep SnapshotCopyGrant x -> SnapshotCopyGrant
forall x. SnapshotCopyGrant -> Rep SnapshotCopyGrant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapshotCopyGrant x -> SnapshotCopyGrant
$cfrom :: forall x. SnapshotCopyGrant -> Rep SnapshotCopyGrant x
Prelude.Generic)

-- |
-- Create a value of 'SnapshotCopyGrant' 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:
--
-- 'kmsKeyId', 'snapshotCopyGrant_kmsKeyId' - The unique identifier of the encrypted symmetric key in Amazon Web
-- Services KMS to which Amazon Redshift is granted permission.
--
-- 'snapshotCopyGrantName', 'snapshotCopyGrant_snapshotCopyGrantName' - The name of the snapshot copy grant.
--
-- 'tags', 'snapshotCopyGrant_tags' - A list of tag instances.
newSnapshotCopyGrant ::
  SnapshotCopyGrant
newSnapshotCopyGrant :: SnapshotCopyGrant
newSnapshotCopyGrant =
  SnapshotCopyGrant'
    { $sel:kmsKeyId:SnapshotCopyGrant' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotCopyGrantName:SnapshotCopyGrant' :: Maybe Text
snapshotCopyGrantName = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:SnapshotCopyGrant' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier of the encrypted symmetric key in Amazon Web
-- Services KMS to which Amazon Redshift is granted permission.
snapshotCopyGrant_kmsKeyId :: Lens.Lens' SnapshotCopyGrant (Prelude.Maybe Prelude.Text)
snapshotCopyGrant_kmsKeyId :: Lens' SnapshotCopyGrant (Maybe Text)
snapshotCopyGrant_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotCopyGrant' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: SnapshotCopyGrant
s@SnapshotCopyGrant' {} Maybe Text
a -> SnapshotCopyGrant
s {$sel:kmsKeyId:SnapshotCopyGrant' :: Maybe Text
kmsKeyId = Maybe Text
a} :: SnapshotCopyGrant)

-- | The name of the snapshot copy grant.
snapshotCopyGrant_snapshotCopyGrantName :: Lens.Lens' SnapshotCopyGrant (Prelude.Maybe Prelude.Text)
snapshotCopyGrant_snapshotCopyGrantName :: Lens' SnapshotCopyGrant (Maybe Text)
snapshotCopyGrant_snapshotCopyGrantName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotCopyGrant' {Maybe Text
snapshotCopyGrantName :: Maybe Text
$sel:snapshotCopyGrantName:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe Text
snapshotCopyGrantName} -> Maybe Text
snapshotCopyGrantName) (\s :: SnapshotCopyGrant
s@SnapshotCopyGrant' {} Maybe Text
a -> SnapshotCopyGrant
s {$sel:snapshotCopyGrantName:SnapshotCopyGrant' :: Maybe Text
snapshotCopyGrantName = Maybe Text
a} :: SnapshotCopyGrant)

-- | A list of tag instances.
snapshotCopyGrant_tags :: Lens.Lens' SnapshotCopyGrant (Prelude.Maybe [Tag])
snapshotCopyGrant_tags :: Lens' SnapshotCopyGrant (Maybe [Tag])
snapshotCopyGrant_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotCopyGrant' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: SnapshotCopyGrant
s@SnapshotCopyGrant' {} Maybe [Tag]
a -> SnapshotCopyGrant
s {$sel:tags:SnapshotCopyGrant' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: SnapshotCopyGrant) 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 SnapshotCopyGrant where
  parseXML :: [Node] -> Either String SnapshotCopyGrant
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe [Tag] -> SnapshotCopyGrant
SnapshotCopyGrant'
      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
"KmsKeyId")
      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
"SnapshotCopyGrantName")
      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
"Tags"
                      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
"Tag")
                  )

instance Prelude.Hashable SnapshotCopyGrant where
  hashWithSalt :: Int -> SnapshotCopyGrant -> Int
hashWithSalt Int
_salt SnapshotCopyGrant' {Maybe [Tag]
Maybe Text
tags :: Maybe [Tag]
snapshotCopyGrantName :: Maybe Text
kmsKeyId :: Maybe Text
$sel:tags:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe [Tag]
$sel:snapshotCopyGrantName:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe Text
$sel:kmsKeyId:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snapshotCopyGrantName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags

instance Prelude.NFData SnapshotCopyGrant where
  rnf :: SnapshotCopyGrant -> ()
rnf SnapshotCopyGrant' {Maybe [Tag]
Maybe Text
tags :: Maybe [Tag]
snapshotCopyGrantName :: Maybe Text
kmsKeyId :: Maybe Text
$sel:tags:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe [Tag]
$sel:snapshotCopyGrantName:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe Text
$sel:kmsKeyId:SnapshotCopyGrant' :: SnapshotCopyGrant -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snapshotCopyGrantName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags