{-# 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.SSMIncidents.Types.ResourcePolicy
-- 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.SSMIncidents.Types.ResourcePolicy 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

-- | The resource policy that allows Incident Manager to perform actions on
-- resources on your behalf.
--
-- /See:/ 'newResourcePolicy' smart constructor.
data ResourcePolicy = ResourcePolicy'
  { -- | The JSON blob that describes the policy.
    ResourcePolicy -> Text
policyDocument :: Prelude.Text,
    -- | The ID of the resource policy.
    ResourcePolicy -> Text
policyId :: Prelude.Text,
    -- | The Amazon Web Services Region that policy allows resources to be used
    -- in.
    ResourcePolicy -> Text
ramResourceShareRegion :: Prelude.Text
  }
  deriving (ResourcePolicy -> ResourcePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourcePolicy -> ResourcePolicy -> Bool
$c/= :: ResourcePolicy -> ResourcePolicy -> Bool
== :: ResourcePolicy -> ResourcePolicy -> Bool
$c== :: ResourcePolicy -> ResourcePolicy -> Bool
Prelude.Eq, ReadPrec [ResourcePolicy]
ReadPrec ResourcePolicy
Int -> ReadS ResourcePolicy
ReadS [ResourcePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourcePolicy]
$creadListPrec :: ReadPrec [ResourcePolicy]
readPrec :: ReadPrec ResourcePolicy
$creadPrec :: ReadPrec ResourcePolicy
readList :: ReadS [ResourcePolicy]
$creadList :: ReadS [ResourcePolicy]
readsPrec :: Int -> ReadS ResourcePolicy
$creadsPrec :: Int -> ReadS ResourcePolicy
Prelude.Read, Int -> ResourcePolicy -> ShowS
[ResourcePolicy] -> ShowS
ResourcePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourcePolicy] -> ShowS
$cshowList :: [ResourcePolicy] -> ShowS
show :: ResourcePolicy -> String
$cshow :: ResourcePolicy -> String
showsPrec :: Int -> ResourcePolicy -> ShowS
$cshowsPrec :: Int -> ResourcePolicy -> ShowS
Prelude.Show, forall x. Rep ResourcePolicy x -> ResourcePolicy
forall x. ResourcePolicy -> Rep ResourcePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourcePolicy x -> ResourcePolicy
$cfrom :: forall x. ResourcePolicy -> Rep ResourcePolicy x
Prelude.Generic)

-- |
-- Create a value of 'ResourcePolicy' 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:
--
-- 'policyDocument', 'resourcePolicy_policyDocument' - The JSON blob that describes the policy.
--
-- 'policyId', 'resourcePolicy_policyId' - The ID of the resource policy.
--
-- 'ramResourceShareRegion', 'resourcePolicy_ramResourceShareRegion' - The Amazon Web Services Region that policy allows resources to be used
-- in.
newResourcePolicy ::
  -- | 'policyDocument'
  Prelude.Text ->
  -- | 'policyId'
  Prelude.Text ->
  -- | 'ramResourceShareRegion'
  Prelude.Text ->
  ResourcePolicy
newResourcePolicy :: Text -> Text -> Text -> ResourcePolicy
newResourcePolicy
  Text
pPolicyDocument_
  Text
pPolicyId_
  Text
pRamResourceShareRegion_ =
    ResourcePolicy'
      { $sel:policyDocument:ResourcePolicy' :: Text
policyDocument = Text
pPolicyDocument_,
        $sel:policyId:ResourcePolicy' :: Text
policyId = Text
pPolicyId_,
        $sel:ramResourceShareRegion:ResourcePolicy' :: Text
ramResourceShareRegion = Text
pRamResourceShareRegion_
      }

-- | The JSON blob that describes the policy.
resourcePolicy_policyDocument :: Lens.Lens' ResourcePolicy Prelude.Text
resourcePolicy_policyDocument :: Lens' ResourcePolicy Text
resourcePolicy_policyDocument = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourcePolicy' {Text
policyDocument :: Text
$sel:policyDocument:ResourcePolicy' :: ResourcePolicy -> Text
policyDocument} -> Text
policyDocument) (\s :: ResourcePolicy
s@ResourcePolicy' {} Text
a -> ResourcePolicy
s {$sel:policyDocument:ResourcePolicy' :: Text
policyDocument = Text
a} :: ResourcePolicy)

-- | The ID of the resource policy.
resourcePolicy_policyId :: Lens.Lens' ResourcePolicy Prelude.Text
resourcePolicy_policyId :: Lens' ResourcePolicy Text
resourcePolicy_policyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourcePolicy' {Text
policyId :: Text
$sel:policyId:ResourcePolicy' :: ResourcePolicy -> Text
policyId} -> Text
policyId) (\s :: ResourcePolicy
s@ResourcePolicy' {} Text
a -> ResourcePolicy
s {$sel:policyId:ResourcePolicy' :: Text
policyId = Text
a} :: ResourcePolicy)

-- | The Amazon Web Services Region that policy allows resources to be used
-- in.
resourcePolicy_ramResourceShareRegion :: Lens.Lens' ResourcePolicy Prelude.Text
resourcePolicy_ramResourceShareRegion :: Lens' ResourcePolicy Text
resourcePolicy_ramResourceShareRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourcePolicy' {Text
ramResourceShareRegion :: Text
$sel:ramResourceShareRegion:ResourcePolicy' :: ResourcePolicy -> Text
ramResourceShareRegion} -> Text
ramResourceShareRegion) (\s :: ResourcePolicy
s@ResourcePolicy' {} Text
a -> ResourcePolicy
s {$sel:ramResourceShareRegion:ResourcePolicy' :: Text
ramResourceShareRegion = Text
a} :: ResourcePolicy)

instance Data.FromJSON ResourcePolicy where
  parseJSON :: Value -> Parser ResourcePolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourcePolicy"
      ( \Object
x ->
          Text -> Text -> Text -> ResourcePolicy
ResourcePolicy'
            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
"policyDocument")
            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
"policyId")
            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
"ramResourceShareRegion")
      )

instance Prelude.Hashable ResourcePolicy where
  hashWithSalt :: Int -> ResourcePolicy -> Int
hashWithSalt Int
_salt ResourcePolicy' {Text
ramResourceShareRegion :: Text
policyId :: Text
policyDocument :: Text
$sel:ramResourceShareRegion:ResourcePolicy' :: ResourcePolicy -> Text
$sel:policyId:ResourcePolicy' :: ResourcePolicy -> Text
$sel:policyDocument:ResourcePolicy' :: ResourcePolicy -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyDocument
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ramResourceShareRegion

instance Prelude.NFData ResourcePolicy where
  rnf :: ResourcePolicy -> ()
rnf ResourcePolicy' {Text
ramResourceShareRegion :: Text
policyId :: Text
policyDocument :: Text
$sel:ramResourceShareRegion:ResourcePolicy' :: ResourcePolicy -> Text
$sel:policyId:ResourcePolicy' :: ResourcePolicy -> Text
$sel:policyDocument:ResourcePolicy' :: ResourcePolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
policyDocument
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ramResourceShareRegion