{-# 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.SSMSAP.Types.ApplicationCredential
-- 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.SSMSAP.Types.ApplicationCredential 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.SSMSAP.Types.CredentialType

-- |
--
-- /See:/ 'newApplicationCredential' smart constructor.
data ApplicationCredential = ApplicationCredential'
  { ApplicationCredential -> Text
databaseName :: Prelude.Text,
    ApplicationCredential -> CredentialType
credentialType :: CredentialType,
    ApplicationCredential -> Sensitive Text
secretId :: Data.Sensitive Prelude.Text
  }
  deriving (ApplicationCredential -> ApplicationCredential -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationCredential -> ApplicationCredential -> Bool
$c/= :: ApplicationCredential -> ApplicationCredential -> Bool
== :: ApplicationCredential -> ApplicationCredential -> Bool
$c== :: ApplicationCredential -> ApplicationCredential -> Bool
Prelude.Eq, Int -> ApplicationCredential -> ShowS
[ApplicationCredential] -> ShowS
ApplicationCredential -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationCredential] -> ShowS
$cshowList :: [ApplicationCredential] -> ShowS
show :: ApplicationCredential -> String
$cshow :: ApplicationCredential -> String
showsPrec :: Int -> ApplicationCredential -> ShowS
$cshowsPrec :: Int -> ApplicationCredential -> ShowS
Prelude.Show, forall x. Rep ApplicationCredential x -> ApplicationCredential
forall x. ApplicationCredential -> Rep ApplicationCredential x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApplicationCredential x -> ApplicationCredential
$cfrom :: forall x. ApplicationCredential -> Rep ApplicationCredential x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationCredential' 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:
--
-- 'databaseName', 'applicationCredential_databaseName' -
--
-- 'credentialType', 'applicationCredential_credentialType' -
--
-- 'secretId', 'applicationCredential_secretId' -
newApplicationCredential ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'credentialType'
  CredentialType ->
  -- | 'secretId'
  Prelude.Text ->
  ApplicationCredential
newApplicationCredential :: Text -> CredentialType -> Text -> ApplicationCredential
newApplicationCredential
  Text
pDatabaseName_
  CredentialType
pCredentialType_
  Text
pSecretId_ =
    ApplicationCredential'
      { $sel:databaseName:ApplicationCredential' :: Text
databaseName =
          Text
pDatabaseName_,
        $sel:credentialType:ApplicationCredential' :: CredentialType
credentialType = CredentialType
pCredentialType_,
        $sel:secretId:ApplicationCredential' :: Sensitive Text
secretId = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pSecretId_
      }

applicationCredential_databaseName :: Lens.Lens' ApplicationCredential Prelude.Text
applicationCredential_databaseName :: Lens' ApplicationCredential Text
applicationCredential_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationCredential' {Text
databaseName :: Text
$sel:databaseName:ApplicationCredential' :: ApplicationCredential -> Text
databaseName} -> Text
databaseName) (\s :: ApplicationCredential
s@ApplicationCredential' {} Text
a -> ApplicationCredential
s {$sel:databaseName:ApplicationCredential' :: Text
databaseName = Text
a} :: ApplicationCredential)

applicationCredential_credentialType :: Lens.Lens' ApplicationCredential CredentialType
applicationCredential_credentialType :: Lens' ApplicationCredential CredentialType
applicationCredential_credentialType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationCredential' {CredentialType
credentialType :: CredentialType
$sel:credentialType:ApplicationCredential' :: ApplicationCredential -> CredentialType
credentialType} -> CredentialType
credentialType) (\s :: ApplicationCredential
s@ApplicationCredential' {} CredentialType
a -> ApplicationCredential
s {$sel:credentialType:ApplicationCredential' :: CredentialType
credentialType = CredentialType
a} :: ApplicationCredential)

applicationCredential_secretId :: Lens.Lens' ApplicationCredential Prelude.Text
applicationCredential_secretId :: Lens' ApplicationCredential Text
applicationCredential_secretId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationCredential' {Sensitive Text
secretId :: Sensitive Text
$sel:secretId:ApplicationCredential' :: ApplicationCredential -> Sensitive Text
secretId} -> Sensitive Text
secretId) (\s :: ApplicationCredential
s@ApplicationCredential' {} Sensitive Text
a -> ApplicationCredential
s {$sel:secretId:ApplicationCredential' :: Sensitive Text
secretId = Sensitive Text
a} :: ApplicationCredential) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON ApplicationCredential where
  parseJSON :: Value -> Parser ApplicationCredential
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ApplicationCredential"
      ( \Object
x ->
          Text -> CredentialType -> Sensitive Text -> ApplicationCredential
ApplicationCredential'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DatabaseName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CredentialType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SecretId")
      )

instance Prelude.Hashable ApplicationCredential where
  hashWithSalt :: Int -> ApplicationCredential -> Int
hashWithSalt Int
_salt ApplicationCredential' {Text
Sensitive Text
CredentialType
secretId :: Sensitive Text
credentialType :: CredentialType
databaseName :: Text
$sel:secretId:ApplicationCredential' :: ApplicationCredential -> Sensitive Text
$sel:credentialType:ApplicationCredential' :: ApplicationCredential -> CredentialType
$sel:databaseName:ApplicationCredential' :: ApplicationCredential -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CredentialType
credentialType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
secretId

instance Prelude.NFData ApplicationCredential where
  rnf :: ApplicationCredential -> ()
rnf ApplicationCredential' {Text
Sensitive Text
CredentialType
secretId :: Sensitive Text
credentialType :: CredentialType
databaseName :: Text
$sel:secretId:ApplicationCredential' :: ApplicationCredential -> Sensitive Text
$sel:credentialType:ApplicationCredential' :: ApplicationCredential -> CredentialType
$sel:databaseName:ApplicationCredential' :: ApplicationCredential -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CredentialType
credentialType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
secretId

instance Data.ToJSON ApplicationCredential where
  toJSON :: ApplicationCredential -> Value
toJSON ApplicationCredential' {Text
Sensitive Text
CredentialType
secretId :: Sensitive Text
credentialType :: CredentialType
databaseName :: Text
$sel:secretId:ApplicationCredential' :: ApplicationCredential -> Sensitive Text
$sel:credentialType:ApplicationCredential' :: ApplicationCredential -> CredentialType
$sel:databaseName:ApplicationCredential' :: ApplicationCredential -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
databaseName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"CredentialType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CredentialType
credentialType),
            forall a. a -> Maybe a
Prelude.Just (Key
"SecretId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
secretId)
          ]
      )