{-# 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.Glue.Types.GluePolicy
-- 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.Glue.Types.GluePolicy 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

-- | A structure for returning a resource policy.
--
-- /See:/ 'newGluePolicy' smart constructor.
data GluePolicy = GluePolicy'
  { -- | The date and time at which the policy was created.
    GluePolicy -> Maybe POSIX
createTime :: Prelude.Maybe Data.POSIX,
    -- | Contains the hash value associated with this policy.
    GluePolicy -> Maybe Text
policyHash :: Prelude.Maybe Prelude.Text,
    -- | Contains the requested policy document, in JSON format.
    GluePolicy -> Maybe Text
policyInJson :: Prelude.Maybe Prelude.Text,
    -- | The date and time at which the policy was last updated.
    GluePolicy -> Maybe POSIX
updateTime :: Prelude.Maybe Data.POSIX
  }
  deriving (GluePolicy -> GluePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GluePolicy -> GluePolicy -> Bool
$c/= :: GluePolicy -> GluePolicy -> Bool
== :: GluePolicy -> GluePolicy -> Bool
$c== :: GluePolicy -> GluePolicy -> Bool
Prelude.Eq, ReadPrec [GluePolicy]
ReadPrec GluePolicy
Int -> ReadS GluePolicy
ReadS [GluePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GluePolicy]
$creadListPrec :: ReadPrec [GluePolicy]
readPrec :: ReadPrec GluePolicy
$creadPrec :: ReadPrec GluePolicy
readList :: ReadS [GluePolicy]
$creadList :: ReadS [GluePolicy]
readsPrec :: Int -> ReadS GluePolicy
$creadsPrec :: Int -> ReadS GluePolicy
Prelude.Read, Int -> GluePolicy -> ShowS
[GluePolicy] -> ShowS
GluePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GluePolicy] -> ShowS
$cshowList :: [GluePolicy] -> ShowS
show :: GluePolicy -> String
$cshow :: GluePolicy -> String
showsPrec :: Int -> GluePolicy -> ShowS
$cshowsPrec :: Int -> GluePolicy -> ShowS
Prelude.Show, forall x. Rep GluePolicy x -> GluePolicy
forall x. GluePolicy -> Rep GluePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GluePolicy x -> GluePolicy
$cfrom :: forall x. GluePolicy -> Rep GluePolicy x
Prelude.Generic)

-- |
-- Create a value of 'GluePolicy' 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:
--
-- 'createTime', 'gluePolicy_createTime' - The date and time at which the policy was created.
--
-- 'policyHash', 'gluePolicy_policyHash' - Contains the hash value associated with this policy.
--
-- 'policyInJson', 'gluePolicy_policyInJson' - Contains the requested policy document, in JSON format.
--
-- 'updateTime', 'gluePolicy_updateTime' - The date and time at which the policy was last updated.
newGluePolicy ::
  GluePolicy
newGluePolicy :: GluePolicy
newGluePolicy =
  GluePolicy'
    { $sel:createTime:GluePolicy' :: Maybe POSIX
createTime = forall a. Maybe a
Prelude.Nothing,
      $sel:policyHash:GluePolicy' :: Maybe Text
policyHash = forall a. Maybe a
Prelude.Nothing,
      $sel:policyInJson:GluePolicy' :: Maybe Text
policyInJson = forall a. Maybe a
Prelude.Nothing,
      $sel:updateTime:GluePolicy' :: Maybe POSIX
updateTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time at which the policy was created.
gluePolicy_createTime :: Lens.Lens' GluePolicy (Prelude.Maybe Prelude.UTCTime)
gluePolicy_createTime :: Lens' GluePolicy (Maybe UTCTime)
gluePolicy_createTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GluePolicy' {Maybe POSIX
createTime :: Maybe POSIX
$sel:createTime:GluePolicy' :: GluePolicy -> Maybe POSIX
createTime} -> Maybe POSIX
createTime) (\s :: GluePolicy
s@GluePolicy' {} Maybe POSIX
a -> GluePolicy
s {$sel:createTime:GluePolicy' :: Maybe POSIX
createTime = Maybe POSIX
a} :: GluePolicy) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Contains the hash value associated with this policy.
gluePolicy_policyHash :: Lens.Lens' GluePolicy (Prelude.Maybe Prelude.Text)
gluePolicy_policyHash :: Lens' GluePolicy (Maybe Text)
gluePolicy_policyHash = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GluePolicy' {Maybe Text
policyHash :: Maybe Text
$sel:policyHash:GluePolicy' :: GluePolicy -> Maybe Text
policyHash} -> Maybe Text
policyHash) (\s :: GluePolicy
s@GluePolicy' {} Maybe Text
a -> GluePolicy
s {$sel:policyHash:GluePolicy' :: Maybe Text
policyHash = Maybe Text
a} :: GluePolicy)

-- | Contains the requested policy document, in JSON format.
gluePolicy_policyInJson :: Lens.Lens' GluePolicy (Prelude.Maybe Prelude.Text)
gluePolicy_policyInJson :: Lens' GluePolicy (Maybe Text)
gluePolicy_policyInJson = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GluePolicy' {Maybe Text
policyInJson :: Maybe Text
$sel:policyInJson:GluePolicy' :: GluePolicy -> Maybe Text
policyInJson} -> Maybe Text
policyInJson) (\s :: GluePolicy
s@GluePolicy' {} Maybe Text
a -> GluePolicy
s {$sel:policyInJson:GluePolicy' :: Maybe Text
policyInJson = Maybe Text
a} :: GluePolicy)

-- | The date and time at which the policy was last updated.
gluePolicy_updateTime :: Lens.Lens' GluePolicy (Prelude.Maybe Prelude.UTCTime)
gluePolicy_updateTime :: Lens' GluePolicy (Maybe UTCTime)
gluePolicy_updateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GluePolicy' {Maybe POSIX
updateTime :: Maybe POSIX
$sel:updateTime:GluePolicy' :: GluePolicy -> Maybe POSIX
updateTime} -> Maybe POSIX
updateTime) (\s :: GluePolicy
s@GluePolicy' {} Maybe POSIX
a -> GluePolicy
s {$sel:updateTime:GluePolicy' :: Maybe POSIX
updateTime = Maybe POSIX
a} :: GluePolicy) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON GluePolicy where
  parseJSON :: Value -> Parser GluePolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GluePolicy"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe Text -> Maybe POSIX -> GluePolicy
GluePolicy'
            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
"CreateTime")
            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
"PolicyHash")
            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
"PolicyInJson")
            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
"UpdateTime")
      )

instance Prelude.Hashable GluePolicy where
  hashWithSalt :: Int -> GluePolicy -> Int
hashWithSalt Int
_salt GluePolicy' {Maybe Text
Maybe POSIX
updateTime :: Maybe POSIX
policyInJson :: Maybe Text
policyHash :: Maybe Text
createTime :: Maybe POSIX
$sel:updateTime:GluePolicy' :: GluePolicy -> Maybe POSIX
$sel:policyInJson:GluePolicy' :: GluePolicy -> Maybe Text
$sel:policyHash:GluePolicy' :: GluePolicy -> Maybe Text
$sel:createTime:GluePolicy' :: GluePolicy -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyHash
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyInJson
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
updateTime

instance Prelude.NFData GluePolicy where
  rnf :: GluePolicy -> ()
rnf GluePolicy' {Maybe Text
Maybe POSIX
updateTime :: Maybe POSIX
policyInJson :: Maybe Text
policyHash :: Maybe Text
createTime :: Maybe POSIX
$sel:updateTime:GluePolicy' :: GluePolicy -> Maybe POSIX
$sel:policyInJson:GluePolicy' :: GluePolicy -> Maybe Text
$sel:policyHash:GluePolicy' :: GluePolicy -> Maybe Text
$sel:createTime:GluePolicy' :: GluePolicy -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyHash
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyInJson
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
updateTime