module Stratosphere.IoT.Policy (
        Policy(..), mkPolicy
    ) where
import qualified Data.Aeson as JSON
import qualified Stratosphere.Prelude as Prelude
import Stratosphere.Property
import Stratosphere.ResourceProperties
import Stratosphere.Tag
import Stratosphere.Value
data Policy
  = -- | See: <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-policy.html>
    Policy {Policy -> ()
haddock_workaround_ :: (),
            -- | See: <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-policy.html#cfn-iot-policy-policydocument>
            Policy -> Object
policyDocument :: JSON.Object,
            -- | See: <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-policy.html#cfn-iot-policy-policyname>
            Policy -> Maybe (Value Text)
policyName :: (Prelude.Maybe (Value Prelude.Text)),
            -- | See: <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-policy.html#cfn-iot-policy-tags>
            Policy -> Maybe [Tag]
tags :: (Prelude.Maybe [Tag])}
  deriving stock (Policy -> Policy -> Bool
(Policy -> Policy -> Bool)
-> (Policy -> Policy -> Bool) -> Eq Policy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Policy -> Policy -> Bool
== :: Policy -> Policy -> Bool
$c/= :: Policy -> Policy -> Bool
/= :: Policy -> Policy -> Bool
Prelude.Eq, Int -> Policy -> ShowS
[Policy] -> ShowS
Policy -> String
(Int -> Policy -> ShowS)
-> (Policy -> String) -> ([Policy] -> ShowS) -> Show Policy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Policy -> ShowS
showsPrec :: Int -> Policy -> ShowS
$cshow :: Policy -> String
show :: Policy -> String
$cshowList :: [Policy] -> ShowS
showList :: [Policy] -> ShowS
Prelude.Show)
mkPolicy :: JSON.Object -> Policy
mkPolicy :: Object -> Policy
mkPolicy Object
policyDocument
  = Policy
      {haddock_workaround_ :: ()
haddock_workaround_ = (), policyDocument :: Object
policyDocument = Object
policyDocument,
       policyName :: Maybe (Value Text)
policyName = Maybe (Value Text)
forall a. Maybe a
Prelude.Nothing, tags :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing}
instance ToResourceProperties Policy where
  toResourceProperties :: Policy -> ResourceProperties
toResourceProperties Policy {Maybe [Tag]
Maybe (Value Text)
()
Object
haddock_workaround_ :: Policy -> ()
policyDocument :: Policy -> Object
policyName :: Policy -> Maybe (Value Text)
tags :: Policy -> Maybe [Tag]
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
..}
    = ResourceProperties
        {awsType :: Text
awsType = Text
"AWS::IoT::Policy", supportsTags :: Bool
supportsTags = Bool
Prelude.True,
         properties :: Object
properties = [Item Object] -> Object
forall l. IsList l => [Item l] -> l
Prelude.fromList
                        ([(Key, Value)] -> [(Key, Value)] -> [(Key, Value)]
forall a. Semigroup a => a -> a -> a
(Prelude.<>)
                           [Key
"PolicyDocument" Key -> Object -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
JSON..= Object
policyDocument]
                           ([Maybe (Key, Value)] -> [(Key, Value)]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
                              [Key -> Value Text -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
(JSON..=) Key
"PolicyName" (Value Text -> (Key, Value))
-> Maybe (Value Text) -> Maybe (Key, Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Value Text)
policyName,
                               Key -> [Tag] -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
(JSON..=) Key
"Tags" ([Tag] -> (Key, Value)) -> Maybe [Tag] -> Maybe (Key, Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags]))}
instance JSON.ToJSON Policy where
  toJSON :: Policy -> Value
toJSON Policy {Maybe [Tag]
Maybe (Value Text)
()
Object
haddock_workaround_ :: Policy -> ()
policyDocument :: Policy -> Object
policyName :: Policy -> Maybe (Value Text)
tags :: Policy -> Maybe [Tag]
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
..}
    = [(Key, Value)] -> Value
JSON.object
        ([Item [(Key, Value)]] -> [(Key, Value)]
forall l. IsList l => [Item l] -> l
Prelude.fromList
           ([(Key, Value)] -> [(Key, Value)] -> [(Key, Value)]
forall a. Semigroup a => a -> a -> a
(Prelude.<>)
              [Key
"PolicyDocument" Key -> Object -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
JSON..= Object
policyDocument]
              ([Maybe (Key, Value)] -> [(Key, Value)]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
                 [Key -> Value Text -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
(JSON..=) Key
"PolicyName" (Value Text -> (Key, Value))
-> Maybe (Value Text) -> Maybe (Key, Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Value Text)
policyName,
                  Key -> [Tag] -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
(JSON..=) Key
"Tags" ([Tag] -> (Key, Value)) -> Maybe [Tag] -> Maybe (Key, Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags])))
instance Property "PolicyDocument" Policy where
  type PropertyType "PolicyDocument" Policy = JSON.Object
  set :: PropertyType "PolicyDocument" Policy -> Policy -> Policy
set PropertyType "PolicyDocument" Policy
newValue Policy {Maybe [Tag]
Maybe (Value Text)
()
Object
haddock_workaround_ :: Policy -> ()
policyDocument :: Policy -> Object
policyName :: Policy -> Maybe (Value Text)
tags :: Policy -> Maybe [Tag]
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
..} = Policy {policyDocument :: Object
policyDocument = Object
PropertyType "PolicyDocument" Policy
newValue, Maybe [Tag]
Maybe (Value Text)
()
haddock_workaround_ :: ()
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
haddock_workaround_ :: ()
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
..}
instance Property "PolicyName" Policy where
  type PropertyType "PolicyName" Policy = Value Prelude.Text
  set :: PropertyType "PolicyName" Policy -> Policy -> Policy
set PropertyType "PolicyName" Policy
newValue Policy {Maybe [Tag]
Maybe (Value Text)
()
Object
haddock_workaround_ :: Policy -> ()
policyDocument :: Policy -> Object
policyName :: Policy -> Maybe (Value Text)
tags :: Policy -> Maybe [Tag]
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
..}
    = Policy {policyName :: Maybe (Value Text)
policyName = Value Text -> Maybe (Value Text)
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure PropertyType "PolicyName" Policy
Value Text
newValue, Maybe [Tag]
()
Object
haddock_workaround_ :: ()
policyDocument :: Object
tags :: Maybe [Tag]
haddock_workaround_ :: ()
policyDocument :: Object
tags :: Maybe [Tag]
..}
instance Property "Tags" Policy where
  type PropertyType "Tags" Policy = [Tag]
  set :: PropertyType "Tags" Policy -> Policy -> Policy
set PropertyType "Tags" Policy
newValue Policy {Maybe [Tag]
Maybe (Value Text)
()
Object
haddock_workaround_ :: Policy -> ()
policyDocument :: Policy -> Object
policyName :: Policy -> Maybe (Value Text)
tags :: Policy -> Maybe [Tag]
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
tags :: Maybe [Tag]
..}
    = Policy {tags :: Maybe [Tag]
tags = [Tag] -> Maybe [Tag]
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure [Tag]
PropertyType "Tags" Policy
newValue, Maybe (Value Text)
()
Object
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
haddock_workaround_ :: ()
policyDocument :: Object
policyName :: Maybe (Value Text)
..}