{-# 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.IoT.Types.PolicyVersionIdentifier
-- 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.IoT.Types.PolicyVersionIdentifier 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

-- | Information about the version of the policy associated with the
-- resource.
--
-- /See:/ 'newPolicyVersionIdentifier' smart constructor.
data PolicyVersionIdentifier = PolicyVersionIdentifier'
  { -- | The name of the policy.
    PolicyVersionIdentifier -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The ID of the version of the policy associated with the resource.
    PolicyVersionIdentifier -> Maybe Text
policyVersionId :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyVersionIdentifier -> PolicyVersionIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyVersionIdentifier -> PolicyVersionIdentifier -> Bool
$c/= :: PolicyVersionIdentifier -> PolicyVersionIdentifier -> Bool
== :: PolicyVersionIdentifier -> PolicyVersionIdentifier -> Bool
$c== :: PolicyVersionIdentifier -> PolicyVersionIdentifier -> Bool
Prelude.Eq, ReadPrec [PolicyVersionIdentifier]
ReadPrec PolicyVersionIdentifier
Int -> ReadS PolicyVersionIdentifier
ReadS [PolicyVersionIdentifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyVersionIdentifier]
$creadListPrec :: ReadPrec [PolicyVersionIdentifier]
readPrec :: ReadPrec PolicyVersionIdentifier
$creadPrec :: ReadPrec PolicyVersionIdentifier
readList :: ReadS [PolicyVersionIdentifier]
$creadList :: ReadS [PolicyVersionIdentifier]
readsPrec :: Int -> ReadS PolicyVersionIdentifier
$creadsPrec :: Int -> ReadS PolicyVersionIdentifier
Prelude.Read, Int -> PolicyVersionIdentifier -> ShowS
[PolicyVersionIdentifier] -> ShowS
PolicyVersionIdentifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyVersionIdentifier] -> ShowS
$cshowList :: [PolicyVersionIdentifier] -> ShowS
show :: PolicyVersionIdentifier -> String
$cshow :: PolicyVersionIdentifier -> String
showsPrec :: Int -> PolicyVersionIdentifier -> ShowS
$cshowsPrec :: Int -> PolicyVersionIdentifier -> ShowS
Prelude.Show, forall x. Rep PolicyVersionIdentifier x -> PolicyVersionIdentifier
forall x. PolicyVersionIdentifier -> Rep PolicyVersionIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyVersionIdentifier x -> PolicyVersionIdentifier
$cfrom :: forall x. PolicyVersionIdentifier -> Rep PolicyVersionIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'PolicyVersionIdentifier' 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:
--
-- 'policyName', 'policyVersionIdentifier_policyName' - The name of the policy.
--
-- 'policyVersionId', 'policyVersionIdentifier_policyVersionId' - The ID of the version of the policy associated with the resource.
newPolicyVersionIdentifier ::
  PolicyVersionIdentifier
newPolicyVersionIdentifier :: PolicyVersionIdentifier
newPolicyVersionIdentifier =
  PolicyVersionIdentifier'
    { $sel:policyName:PolicyVersionIdentifier' :: Maybe Text
policyName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:policyVersionId:PolicyVersionIdentifier' :: Maybe Text
policyVersionId = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the policy.
policyVersionIdentifier_policyName :: Lens.Lens' PolicyVersionIdentifier (Prelude.Maybe Prelude.Text)
policyVersionIdentifier_policyName :: Lens' PolicyVersionIdentifier (Maybe Text)
policyVersionIdentifier_policyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyVersionIdentifier' {Maybe Text
policyName :: Maybe Text
$sel:policyName:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
policyName} -> Maybe Text
policyName) (\s :: PolicyVersionIdentifier
s@PolicyVersionIdentifier' {} Maybe Text
a -> PolicyVersionIdentifier
s {$sel:policyName:PolicyVersionIdentifier' :: Maybe Text
policyName = Maybe Text
a} :: PolicyVersionIdentifier)

-- | The ID of the version of the policy associated with the resource.
policyVersionIdentifier_policyVersionId :: Lens.Lens' PolicyVersionIdentifier (Prelude.Maybe Prelude.Text)
policyVersionIdentifier_policyVersionId :: Lens' PolicyVersionIdentifier (Maybe Text)
policyVersionIdentifier_policyVersionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyVersionIdentifier' {Maybe Text
policyVersionId :: Maybe Text
$sel:policyVersionId:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
policyVersionId} -> Maybe Text
policyVersionId) (\s :: PolicyVersionIdentifier
s@PolicyVersionIdentifier' {} Maybe Text
a -> PolicyVersionIdentifier
s {$sel:policyVersionId:PolicyVersionIdentifier' :: Maybe Text
policyVersionId = Maybe Text
a} :: PolicyVersionIdentifier)

instance Data.FromJSON PolicyVersionIdentifier where
  parseJSON :: Value -> Parser PolicyVersionIdentifier
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PolicyVersionIdentifier"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> PolicyVersionIdentifier
PolicyVersionIdentifier'
            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
"policyName")
            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
"policyVersionId")
      )

instance Prelude.Hashable PolicyVersionIdentifier where
  hashWithSalt :: Int -> PolicyVersionIdentifier -> Int
hashWithSalt Int
_salt PolicyVersionIdentifier' {Maybe Text
policyVersionId :: Maybe Text
policyName :: Maybe Text
$sel:policyVersionId:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
$sel:policyName:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyVersionId

instance Prelude.NFData PolicyVersionIdentifier where
  rnf :: PolicyVersionIdentifier -> ()
rnf PolicyVersionIdentifier' {Maybe Text
policyVersionId :: Maybe Text
policyName :: Maybe Text
$sel:policyVersionId:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
$sel:policyName:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyVersionId

instance Data.ToJSON PolicyVersionIdentifier where
  toJSON :: PolicyVersionIdentifier -> Value
toJSON PolicyVersionIdentifier' {Maybe Text
policyVersionId :: Maybe Text
policyName :: Maybe Text
$sel:policyVersionId:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
$sel:policyName:PolicyVersionIdentifier' :: PolicyVersionIdentifier -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"policyName" 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
policyName,
            (Key
"policyVersionId" 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
policyVersionId
          ]
      )