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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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],
    -- | 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
  }
  deriving (SecretsManagerSecretResourceData
-> SecretsManagerSecretResourceData -> Bool
(SecretsManagerSecretResourceData
 -> SecretsManagerSecretResourceData -> Bool)
-> (SecretsManagerSecretResourceData
    -> SecretsManagerSecretResourceData -> Bool)
-> Eq SecretsManagerSecretResourceData
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]
(Int -> ReadS SecretsManagerSecretResourceData)
-> ReadS [SecretsManagerSecretResourceData]
-> ReadPrec SecretsManagerSecretResourceData
-> ReadPrec [SecretsManagerSecretResourceData]
-> Read 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
(Int -> SecretsManagerSecretResourceData -> ShowS)
-> (SecretsManagerSecretResourceData -> String)
-> ([SecretsManagerSecretResourceData] -> ShowS)
-> Show SecretsManagerSecretResourceData
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.
 SecretsManagerSecretResourceData
 -> Rep SecretsManagerSecretResourceData x)
-> (forall x.
    Rep SecretsManagerSecretResourceData x
    -> SecretsManagerSecretResourceData)
-> Generic SecretsManagerSecretResourceData
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:
--
-- 'additionalStagingLabelsToDownload', 'secretsManagerSecretResourceData_additionalStagingLabelsToDownload' - Optional. The staging labels whose values you want to make available on
-- the core, in addition to \'\'AWSCURRENT\'\'.
--
-- '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.
newSecretsManagerSecretResourceData ::
  SecretsManagerSecretResourceData
newSecretsManagerSecretResourceData :: SecretsManagerSecretResourceData
newSecretsManagerSecretResourceData =
  SecretsManagerSecretResourceData' :: Maybe [Text] -> Maybe Text -> SecretsManagerSecretResourceData
SecretsManagerSecretResourceData'
    { $sel:additionalStagingLabelsToDownload:SecretsManagerSecretResourceData' :: Maybe [Text]
additionalStagingLabelsToDownload =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:SecretsManagerSecretResourceData' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text]))
-> SecretsManagerSecretResourceData
-> f SecretsManagerSecretResourceData
secretsManagerSecretResourceData_additionalStagingLabelsToDownload = (SecretsManagerSecretResourceData -> Maybe [Text])
-> (SecretsManagerSecretResourceData
    -> Maybe [Text] -> SecretsManagerSecretResourceData)
-> Lens
     SecretsManagerSecretResourceData
     SecretsManagerSecretResourceData
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> SecretsManagerSecretResourceData
 -> f SecretsManagerSecretResourceData)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SecretsManagerSecretResourceData
-> f SecretsManagerSecretResourceData
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 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 :: (Maybe Text -> f (Maybe Text))
-> SecretsManagerSecretResourceData
-> f SecretsManagerSecretResourceData
secretsManagerSecretResourceData_arn = (SecretsManagerSecretResourceData -> Maybe Text)
-> (SecretsManagerSecretResourceData
    -> Maybe Text -> SecretsManagerSecretResourceData)
-> Lens
     SecretsManagerSecretResourceData
     SecretsManagerSecretResourceData
     (Maybe Text)
     (Maybe Text)
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)

instance
  Core.FromJSON
    SecretsManagerSecretResourceData
  where
  parseJSON :: Value -> Parser SecretsManagerSecretResourceData
parseJSON =
    String
-> (Object -> Parser SecretsManagerSecretResourceData)
-> Value
-> Parser SecretsManagerSecretResourceData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecretsManagerSecretResourceData"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> SecretsManagerSecretResourceData
SecretsManagerSecretResourceData'
            (Maybe [Text] -> Maybe Text -> SecretsManagerSecretResourceData)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> SecretsManagerSecretResourceData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AdditionalStagingLabelsToDownload"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> SecretsManagerSecretResourceData)
-> Parser (Maybe Text) -> Parser SecretsManagerSecretResourceData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ARN")
      )

instance
  Prelude.Hashable
    SecretsManagerSecretResourceData

instance
  Prelude.NFData
    SecretsManagerSecretResourceData

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