{-# 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.Greengrass.Types.SecretsManagerSecretResourceData
-- 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.Greengrass.Types.SecretsManagerSecretResourceData 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

-- | Attributes that define a secret resource, which references a secret from
-- AWS Secrets Manager. AWS IoT Greengrass stores a local, encrypted copy
-- of the secret on the Greengrass core, where it can be securely accessed
-- by connectors and Lambda functions.
--
-- /See:/ 'newSecretsManagerSecretResourceData' smart constructor.
data SecretsManagerSecretResourceData = SecretsManagerSecretResourceData'
  { -- | The ARN of the Secrets Manager secret to make available on the core. The
    -- value of the secret\'s latest version (represented by the
    -- \'\'AWSCURRENT\'\' staging label) is included by default.
    SecretsManagerSecretResourceData -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Optional. The staging labels whose values you want to make available on
    -- the core, in addition to \'\'AWSCURRENT\'\'.
    SecretsManagerSecretResourceData -> Maybe [Text]
additionalStagingLabelsToDownload :: Prelude.Maybe [Prelude.Text]
  }
  deriving (SecretsManagerSecretResourceData
-> SecretsManagerSecretResourceData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecretsManagerSecretResourceData
-> SecretsManagerSecretResourceData -> Bool
$c/= :: SecretsManagerSecretResourceData
-> SecretsManagerSecretResourceData -> Bool
== :: SecretsManagerSecretResourceData
-> SecretsManagerSecretResourceData -> Bool
$c== :: SecretsManagerSecretResourceData
-> SecretsManagerSecretResourceData -> Bool
Prelude.Eq, ReadPrec [SecretsManagerSecretResourceData]
ReadPrec SecretsManagerSecretResourceData
Int -> ReadS SecretsManagerSecretResourceData
ReadS [SecretsManagerSecretResourceData]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecretsManagerSecretResourceData]
$creadListPrec :: ReadPrec [SecretsManagerSecretResourceData]
readPrec :: ReadPrec SecretsManagerSecretResourceData
$creadPrec :: ReadPrec SecretsManagerSecretResourceData
readList :: ReadS [SecretsManagerSecretResourceData]
$creadList :: ReadS [SecretsManagerSecretResourceData]
readsPrec :: Int -> ReadS SecretsManagerSecretResourceData
$creadsPrec :: Int -> ReadS SecretsManagerSecretResourceData
Prelude.Read, Int -> SecretsManagerSecretResourceData -> ShowS
[SecretsManagerSecretResourceData] -> ShowS
SecretsManagerSecretResourceData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecretsManagerSecretResourceData] -> ShowS
$cshowList :: [SecretsManagerSecretResourceData] -> ShowS
show :: SecretsManagerSecretResourceData -> String
$cshow :: SecretsManagerSecretResourceData -> String
showsPrec :: Int -> SecretsManagerSecretResourceData -> ShowS
$cshowsPrec :: Int -> SecretsManagerSecretResourceData -> ShowS
Prelude.Show, forall x.
Rep SecretsManagerSecretResourceData x
-> SecretsManagerSecretResourceData
forall x.
SecretsManagerSecretResourceData
-> Rep SecretsManagerSecretResourceData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SecretsManagerSecretResourceData x
-> SecretsManagerSecretResourceData
$cfrom :: forall x.
SecretsManagerSecretResourceData
-> Rep SecretsManagerSecretResourceData x
Prelude.Generic)

-- |
-- Create a value of 'SecretsManagerSecretResourceData' 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:
--
-- 'arn', 'secretsManagerSecretResourceData_arn' - The ARN of the Secrets Manager secret to make available on the core. The
-- value of the secret\'s latest version (represented by the
-- \'\'AWSCURRENT\'\' staging label) is included by default.
--
-- 'additionalStagingLabelsToDownload', 'secretsManagerSecretResourceData_additionalStagingLabelsToDownload' - Optional. The staging labels whose values you want to make available on
-- the core, in addition to \'\'AWSCURRENT\'\'.
newSecretsManagerSecretResourceData ::
  SecretsManagerSecretResourceData
newSecretsManagerSecretResourceData :: SecretsManagerSecretResourceData
newSecretsManagerSecretResourceData =
  SecretsManagerSecretResourceData'
    { $sel:arn:SecretsManagerSecretResourceData' :: Maybe Text
arn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:additionalStagingLabelsToDownload:SecretsManagerSecretResourceData' :: Maybe [Text]
additionalStagingLabelsToDownload =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the Secrets Manager secret to make available on the core. The
-- value of the secret\'s latest version (represented by the
-- \'\'AWSCURRENT\'\' staging label) is included by default.
secretsManagerSecretResourceData_arn :: Lens.Lens' SecretsManagerSecretResourceData (Prelude.Maybe Prelude.Text)
secretsManagerSecretResourceData_arn :: Lens' SecretsManagerSecretResourceData (Maybe Text)
secretsManagerSecretResourceData_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerSecretResourceData' {Maybe Text
arn :: Maybe Text
$sel:arn:SecretsManagerSecretResourceData' :: SecretsManagerSecretResourceData -> Maybe Text
arn} -> Maybe Text
arn) (\s :: SecretsManagerSecretResourceData
s@SecretsManagerSecretResourceData' {} Maybe Text
a -> SecretsManagerSecretResourceData
s {$sel:arn:SecretsManagerSecretResourceData' :: Maybe Text
arn = Maybe Text
a} :: SecretsManagerSecretResourceData)

-- | Optional. The staging labels whose values you want to make available on
-- the core, in addition to \'\'AWSCURRENT\'\'.
secretsManagerSecretResourceData_additionalStagingLabelsToDownload :: Lens.Lens' SecretsManagerSecretResourceData (Prelude.Maybe [Prelude.Text])
secretsManagerSecretResourceData_additionalStagingLabelsToDownload :: Lens' SecretsManagerSecretResourceData (Maybe [Text])
secretsManagerSecretResourceData_additionalStagingLabelsToDownload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerSecretResourceData' {Maybe [Text]
additionalStagingLabelsToDownload :: Maybe [Text]
$sel:additionalStagingLabelsToDownload:SecretsManagerSecretResourceData' :: SecretsManagerSecretResourceData -> Maybe [Text]
additionalStagingLabelsToDownload} -> Maybe [Text]
additionalStagingLabelsToDownload) (\s :: SecretsManagerSecretResourceData
s@SecretsManagerSecretResourceData' {} Maybe [Text]
a -> SecretsManagerSecretResourceData
s {$sel:additionalStagingLabelsToDownload:SecretsManagerSecretResourceData' :: Maybe [Text]
additionalStagingLabelsToDownload = Maybe [Text]
a} :: SecretsManagerSecretResourceData) 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.FromJSON
    SecretsManagerSecretResourceData
  where
  parseJSON :: Value -> Parser SecretsManagerSecretResourceData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SecretsManagerSecretResourceData"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> SecretsManagerSecretResourceData
SecretsManagerSecretResourceData'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AdditionalStagingLabelsToDownload"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

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

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

instance Data.ToJSON SecretsManagerSecretResourceData where
  toJSON :: SecretsManagerSecretResourceData -> Value
toJSON SecretsManagerSecretResourceData' {Maybe [Text]
Maybe Text
additionalStagingLabelsToDownload :: Maybe [Text]
arn :: Maybe Text
$sel:additionalStagingLabelsToDownload:SecretsManagerSecretResourceData' :: SecretsManagerSecretResourceData -> Maybe [Text]
$sel:arn:SecretsManagerSecretResourceData' :: SecretsManagerSecretResourceData -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
arn,
            (Key
"AdditionalStagingLabelsToDownload" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
additionalStagingLabelsToDownload
          ]
      )