{-# 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.SecurityHub.Types.AwsIamPolicyVersion
-- 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.SecurityHub.Types.AwsIamPolicyVersion where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A version of an IAM policy.
--
-- /See:/ 'newAwsIamPolicyVersion' smart constructor.
data AwsIamPolicyVersion = AwsIamPolicyVersion'
  { -- | The identifier of the policy version.
    AwsIamPolicyVersion -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
    -- | Indicates when the version was created.
    --
    -- Uses the @date-time@ format specified in
    -- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
    -- The value cannot contain spaces. For example,
    -- @2020-03-22T13:22:13.933Z@.
    AwsIamPolicyVersion -> Maybe Text
createDate :: Prelude.Maybe Prelude.Text,
    -- | Whether the version is the default version.
    AwsIamPolicyVersion -> Maybe Bool
isDefaultVersion :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool
(AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool)
-> (AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool)
-> Eq AwsIamPolicyVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool
$c/= :: AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool
== :: AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool
$c== :: AwsIamPolicyVersion -> AwsIamPolicyVersion -> Bool
Prelude.Eq, ReadPrec [AwsIamPolicyVersion]
ReadPrec AwsIamPolicyVersion
Int -> ReadS AwsIamPolicyVersion
ReadS [AwsIamPolicyVersion]
(Int -> ReadS AwsIamPolicyVersion)
-> ReadS [AwsIamPolicyVersion]
-> ReadPrec AwsIamPolicyVersion
-> ReadPrec [AwsIamPolicyVersion]
-> Read AwsIamPolicyVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsIamPolicyVersion]
$creadListPrec :: ReadPrec [AwsIamPolicyVersion]
readPrec :: ReadPrec AwsIamPolicyVersion
$creadPrec :: ReadPrec AwsIamPolicyVersion
readList :: ReadS [AwsIamPolicyVersion]
$creadList :: ReadS [AwsIamPolicyVersion]
readsPrec :: Int -> ReadS AwsIamPolicyVersion
$creadsPrec :: Int -> ReadS AwsIamPolicyVersion
Prelude.Read, Int -> AwsIamPolicyVersion -> ShowS
[AwsIamPolicyVersion] -> ShowS
AwsIamPolicyVersion -> String
(Int -> AwsIamPolicyVersion -> ShowS)
-> (AwsIamPolicyVersion -> String)
-> ([AwsIamPolicyVersion] -> ShowS)
-> Show AwsIamPolicyVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsIamPolicyVersion] -> ShowS
$cshowList :: [AwsIamPolicyVersion] -> ShowS
show :: AwsIamPolicyVersion -> String
$cshow :: AwsIamPolicyVersion -> String
showsPrec :: Int -> AwsIamPolicyVersion -> ShowS
$cshowsPrec :: Int -> AwsIamPolicyVersion -> ShowS
Prelude.Show, (forall x. AwsIamPolicyVersion -> Rep AwsIamPolicyVersion x)
-> (forall x. Rep AwsIamPolicyVersion x -> AwsIamPolicyVersion)
-> Generic AwsIamPolicyVersion
forall x. Rep AwsIamPolicyVersion x -> AwsIamPolicyVersion
forall x. AwsIamPolicyVersion -> Rep AwsIamPolicyVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsIamPolicyVersion x -> AwsIamPolicyVersion
$cfrom :: forall x. AwsIamPolicyVersion -> Rep AwsIamPolicyVersion x
Prelude.Generic)

-- |
-- Create a value of 'AwsIamPolicyVersion' 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:
--
-- 'versionId', 'awsIamPolicyVersion_versionId' - The identifier of the policy version.
--
-- 'createDate', 'awsIamPolicyVersion_createDate' - Indicates when the version was created.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
--
-- 'isDefaultVersion', 'awsIamPolicyVersion_isDefaultVersion' - Whether the version is the default version.
newAwsIamPolicyVersion ::
  AwsIamPolicyVersion
newAwsIamPolicyVersion :: AwsIamPolicyVersion
newAwsIamPolicyVersion =
  AwsIamPolicyVersion' :: Maybe Text -> Maybe Text -> Maybe Bool -> AwsIamPolicyVersion
AwsIamPolicyVersion'
    { $sel:versionId:AwsIamPolicyVersion' :: Maybe Text
versionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createDate:AwsIamPolicyVersion' :: Maybe Text
createDate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isDefaultVersion:AwsIamPolicyVersion' :: Maybe Bool
isDefaultVersion = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the policy version.
awsIamPolicyVersion_versionId :: Lens.Lens' AwsIamPolicyVersion (Prelude.Maybe Prelude.Text)
awsIamPolicyVersion_versionId :: (Maybe Text -> f (Maybe Text))
-> AwsIamPolicyVersion -> f AwsIamPolicyVersion
awsIamPolicyVersion_versionId = (AwsIamPolicyVersion -> Maybe Text)
-> (AwsIamPolicyVersion -> Maybe Text -> AwsIamPolicyVersion)
-> Lens
     AwsIamPolicyVersion AwsIamPolicyVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamPolicyVersion' {Maybe Text
versionId :: Maybe Text
$sel:versionId:AwsIamPolicyVersion' :: AwsIamPolicyVersion -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: AwsIamPolicyVersion
s@AwsIamPolicyVersion' {} Maybe Text
a -> AwsIamPolicyVersion
s {$sel:versionId:AwsIamPolicyVersion' :: Maybe Text
versionId = Maybe Text
a} :: AwsIamPolicyVersion)

-- | Indicates when the version was created.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
awsIamPolicyVersion_createDate :: Lens.Lens' AwsIamPolicyVersion (Prelude.Maybe Prelude.Text)
awsIamPolicyVersion_createDate :: (Maybe Text -> f (Maybe Text))
-> AwsIamPolicyVersion -> f AwsIamPolicyVersion
awsIamPolicyVersion_createDate = (AwsIamPolicyVersion -> Maybe Text)
-> (AwsIamPolicyVersion -> Maybe Text -> AwsIamPolicyVersion)
-> Lens
     AwsIamPolicyVersion AwsIamPolicyVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamPolicyVersion' {Maybe Text
createDate :: Maybe Text
$sel:createDate:AwsIamPolicyVersion' :: AwsIamPolicyVersion -> Maybe Text
createDate} -> Maybe Text
createDate) (\s :: AwsIamPolicyVersion
s@AwsIamPolicyVersion' {} Maybe Text
a -> AwsIamPolicyVersion
s {$sel:createDate:AwsIamPolicyVersion' :: Maybe Text
createDate = Maybe Text
a} :: AwsIamPolicyVersion)

-- | Whether the version is the default version.
awsIamPolicyVersion_isDefaultVersion :: Lens.Lens' AwsIamPolicyVersion (Prelude.Maybe Prelude.Bool)
awsIamPolicyVersion_isDefaultVersion :: (Maybe Bool -> f (Maybe Bool))
-> AwsIamPolicyVersion -> f AwsIamPolicyVersion
awsIamPolicyVersion_isDefaultVersion = (AwsIamPolicyVersion -> Maybe Bool)
-> (AwsIamPolicyVersion -> Maybe Bool -> AwsIamPolicyVersion)
-> Lens
     AwsIamPolicyVersion AwsIamPolicyVersion (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsIamPolicyVersion' {Maybe Bool
isDefaultVersion :: Maybe Bool
$sel:isDefaultVersion:AwsIamPolicyVersion' :: AwsIamPolicyVersion -> Maybe Bool
isDefaultVersion} -> Maybe Bool
isDefaultVersion) (\s :: AwsIamPolicyVersion
s@AwsIamPolicyVersion' {} Maybe Bool
a -> AwsIamPolicyVersion
s {$sel:isDefaultVersion:AwsIamPolicyVersion' :: Maybe Bool
isDefaultVersion = Maybe Bool
a} :: AwsIamPolicyVersion)

instance Core.FromJSON AwsIamPolicyVersion where
  parseJSON :: Value -> Parser AwsIamPolicyVersion
parseJSON =
    String
-> (Object -> Parser AwsIamPolicyVersion)
-> Value
-> Parser AwsIamPolicyVersion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsIamPolicyVersion"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Bool -> AwsIamPolicyVersion
AwsIamPolicyVersion'
            (Maybe Text -> Maybe Text -> Maybe Bool -> AwsIamPolicyVersion)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Bool -> AwsIamPolicyVersion)
forall (f :: * -> *) a b. Functor 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
"VersionId")
            Parser (Maybe Text -> Maybe Bool -> AwsIamPolicyVersion)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> AwsIamPolicyVersion)
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
"CreateDate")
            Parser (Maybe Bool -> AwsIamPolicyVersion)
-> Parser (Maybe Bool) -> Parser AwsIamPolicyVersion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IsDefaultVersion")
      )

instance Prelude.Hashable AwsIamPolicyVersion

instance Prelude.NFData AwsIamPolicyVersion

instance Core.ToJSON AwsIamPolicyVersion where
  toJSON :: AwsIamPolicyVersion -> Value
toJSON AwsIamPolicyVersion' {Maybe Bool
Maybe Text
isDefaultVersion :: Maybe Bool
createDate :: Maybe Text
versionId :: Maybe Text
$sel:isDefaultVersion:AwsIamPolicyVersion' :: AwsIamPolicyVersion -> Maybe Bool
$sel:createDate:AwsIamPolicyVersion' :: AwsIamPolicyVersion -> Maybe Text
$sel:versionId:AwsIamPolicyVersion' :: AwsIamPolicyVersion -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VersionId" 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
versionId,
            (Text
"CreateDate" 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
createDate,
            (Text
"IsDefaultVersion" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isDefaultVersion
          ]
      )