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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Region that policy allows resources to be used in.
    ResourcePolicy -> Text
ramResourceShareRegion :: Prelude.Text
  }
  deriving (ResourcePolicy -> ResourcePolicy -> Bool
(ResourcePolicy -> ResourcePolicy -> Bool)
-> (ResourcePolicy -> ResourcePolicy -> Bool) -> Eq ResourcePolicy
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]
(Int -> ReadS ResourcePolicy)
-> ReadS [ResourcePolicy]
-> ReadPrec ResourcePolicy
-> ReadPrec [ResourcePolicy]
-> Read 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
(Int -> ResourcePolicy -> ShowS)
-> (ResourcePolicy -> String)
-> ([ResourcePolicy] -> ShowS)
-> Show ResourcePolicy
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. ResourcePolicy -> Rep ResourcePolicy x)
-> (forall x. Rep ResourcePolicy x -> ResourcePolicy)
-> Generic ResourcePolicy
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 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' :: Text -> Text -> Text -> ResourcePolicy
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 :: (Text -> f Text) -> ResourcePolicy -> f ResourcePolicy
resourcePolicy_policyDocument = (ResourcePolicy -> Text)
-> (ResourcePolicy -> Text -> ResourcePolicy)
-> Lens ResourcePolicy ResourcePolicy Text Text
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 :: (Text -> f Text) -> ResourcePolicy -> f ResourcePolicy
resourcePolicy_policyId = (ResourcePolicy -> Text)
-> (ResourcePolicy -> Text -> ResourcePolicy)
-> Lens ResourcePolicy ResourcePolicy Text Text
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 Region that policy allows resources to be used in.
resourcePolicy_ramResourceShareRegion :: Lens.Lens' ResourcePolicy Prelude.Text
resourcePolicy_ramResourceShareRegion :: (Text -> f Text) -> ResourcePolicy -> f ResourcePolicy
resourcePolicy_ramResourceShareRegion = (ResourcePolicy -> Text)
-> (ResourcePolicy -> Text -> ResourcePolicy)
-> Lens ResourcePolicy ResourcePolicy Text Text
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 Core.FromJSON ResourcePolicy where
  parseJSON :: Value -> Parser ResourcePolicy
parseJSON =
    String
-> (Object -> Parser ResourcePolicy)
-> Value
-> Parser ResourcePolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourcePolicy"
      ( \Object
x ->
          Text -> Text -> Text -> ResourcePolicy
ResourcePolicy'
            (Text -> Text -> Text -> ResourcePolicy)
-> Parser Text -> Parser (Text -> Text -> ResourcePolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"policyDocument")
            Parser (Text -> Text -> ResourcePolicy)
-> Parser Text -> Parser (Text -> ResourcePolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"policyId")
            Parser (Text -> ResourcePolicy)
-> Parser Text -> Parser ResourcePolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ramResourceShareRegion")
      )

instance Prelude.Hashable ResourcePolicy

instance Prelude.NFData ResourcePolicy