module Stratosphere.IAM.Policy ( Policy(..), mkPolicy ) where import qualified Data.Aeson as JSON import qualified Stratosphere.Prelude as Prelude import Stratosphere.Property import Stratosphere.ResourceProperties import Stratosphere.Value data Policy = -- | See: Policy {haddock_workaround_ :: (), -- | See: groups :: (Prelude.Maybe (ValueList Prelude.Text)), -- | See: policyDocument :: JSON.Object, -- | See: policyName :: (Value Prelude.Text), -- | See: roles :: (Prelude.Maybe (ValueList Prelude.Text)), -- | See: users :: (Prelude.Maybe (ValueList Prelude.Text))} deriving stock (Prelude.Eq, Prelude.Show) mkPolicy :: JSON.Object -> Value Prelude.Text -> Policy mkPolicy policyDocument policyName = Policy {haddock_workaround_ = (), policyDocument = policyDocument, policyName = policyName, groups = Prelude.Nothing, roles = Prelude.Nothing, users = Prelude.Nothing} instance ToResourceProperties Policy where toResourceProperties Policy {..} = ResourceProperties {awsType = "AWS::IAM::Policy", supportsTags = Prelude.False, properties = Prelude.fromList ((Prelude.<>) ["PolicyDocument" JSON..= policyDocument, "PolicyName" JSON..= policyName] (Prelude.catMaybes [(JSON..=) "Groups" Prelude.<$> groups, (JSON..=) "Roles" Prelude.<$> roles, (JSON..=) "Users" Prelude.<$> users]))} instance JSON.ToJSON Policy where toJSON Policy {..} = JSON.object (Prelude.fromList ((Prelude.<>) ["PolicyDocument" JSON..= policyDocument, "PolicyName" JSON..= policyName] (Prelude.catMaybes [(JSON..=) "Groups" Prelude.<$> groups, (JSON..=) "Roles" Prelude.<$> roles, (JSON..=) "Users" Prelude.<$> users]))) instance Property "Groups" Policy where type PropertyType "Groups" Policy = ValueList Prelude.Text set newValue Policy {..} = Policy {groups = Prelude.pure newValue, ..} instance Property "PolicyDocument" Policy where type PropertyType "PolicyDocument" Policy = JSON.Object set newValue Policy {..} = Policy {policyDocument = newValue, ..} instance Property "PolicyName" Policy where type PropertyType "PolicyName" Policy = Value Prelude.Text set newValue Policy {..} = Policy {policyName = newValue, ..} instance Property "Roles" Policy where type PropertyType "Roles" Policy = ValueList Prelude.Text set newValue Policy {..} = Policy {roles = Prelude.pure newValue, ..} instance Property "Users" Policy where type PropertyType "Users" Policy = ValueList Prelude.Text set newValue Policy {..} = Policy {users = Prelude.pure newValue, ..}