class PermissionGrantPolicy
A class representing a permission grant policy that specifies conditions under which consent can be granted, using include and exclude condition sets.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/policies/permission_grant.py
9 - 46
moderate
Purpose
PermissionGrantPolicy manages permission grant policies in a directory system (likely Microsoft Graph API). It provides access to condition sets that determine when consent can be granted. The policy uses an include/exclude model where an event must match at least one include condition set and no exclude condition sets to be granted permission. This class extends PolicyBase and provides lazy-loaded collections of PermissionGrantConditionSet objects.
Source Code
class PermissionGrantPolicy(PolicyBase):
"""
A permission grant policy is used to specify the conditions under which consent can be granted.
A permission grant policy consists of a list of includes condition sets, and a list of excludes condition sets.
For an event to match a permission grant policy, it must match at least one of the includes conditions sets,
and none of the excludes condition sets.
"""
@property
def excludes(self):
"""
Condition sets which are excluded in this permission grant policy.
This navigation is automatically expanded on GET.
"""
return self.properties.get(
"excludes",
EntityCollection(
self.context,
PermissionGrantConditionSet,
ResourcePath("excludes", self.resource_path),
),
)
@property
def includes(self):
"""
Condition sets which are included in this permission grant policy.
This navigation is automatically expanded on GET.
"""
return self.properties.get(
"includes",
EntityCollection(
self.context,
PermissionGrantConditionSet,
ResourcePath("includes", self.resource_path),
),
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
PolicyBase | - |
Parameter Details
context: The context object required by the parent PolicyBase class, typically containing authentication and connection information for API calls
resource_path: The resource path identifying this policy in the API hierarchy, inherited from PolicyBase
Return Value
Instantiation returns a PermissionGrantPolicy object. The excludes property returns an EntityCollection of PermissionGrantConditionSet objects representing excluded conditions. The includes property returns an EntityCollection of PermissionGrantConditionSet objects representing included conditions. Both properties are lazily loaded and automatically expanded on GET operations.
Class Interface
Methods
@property excludes(self) -> EntityCollection
property
Purpose: Returns the collection of condition sets that are excluded in this permission grant policy
Returns: EntityCollection of PermissionGrantConditionSet objects representing excluded conditions. Returns cached value from properties if available, otherwise creates new EntityCollection with resource path 'excludes'
@property includes(self) -> EntityCollection
property
Purpose: Returns the collection of condition sets that are included in this permission grant policy
Returns: EntityCollection of PermissionGrantConditionSet objects representing included conditions. Returns cached value from properties if available, otherwise creates new EntityCollection with resource path 'includes'
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | The context object containing authentication and connection information, inherited from PolicyBase | instance |
resource_path |
ResourcePath | The resource path identifying this policy in the API hierarchy, inherited from PolicyBase | instance |
properties |
dict | Internal dictionary storing cached property values including excludes and includes collections, inherited from PolicyBase | instance |
Dependencies
office365.directory.permissions.grants.condition_setoffice365.directory.policies.baseoffice365.entity_collectionoffice365.runtime.paths.resource_path
Required Imports
from office365.directory.permissions.grants.condition_set import PermissionGrantConditionSet
from office365.directory.policies.base import PolicyBase
from office365.entity_collection import EntityCollection
from office365.runtime.paths.resource_path import ResourcePath
Usage Example
# Assuming you have a configured context object
from office365.directory.permissions.grants.policy import PermissionGrantPolicy
# Instantiate through parent context (typical usage)
# policy = context.permission_grant_policies.get_by_id('policy_id')
# Access included condition sets
includes = policy.includes
for condition_set in includes:
print(f"Include condition: {condition_set.id}")
# Access excluded condition sets
excludes = policy.excludes
for condition_set in excludes:
print(f"Exclude condition: {condition_set.id}")
# Check if policy matches (conceptual - actual matching logic in backend)
# An event matches if it matches any include AND no excludes
Best Practices
- Do not instantiate PermissionGrantPolicy directly; obtain instances through the parent context or API client
- The excludes and includes properties are lazily loaded - they create EntityCollection objects on first access
- Properties are cached in the internal properties dictionary after first access
- The policy follows an include/exclude pattern: events must match at least one include condition and zero exclude conditions
- Both condition set collections are automatically expanded on GET operations, reducing the need for additional API calls
- Treat this as a read-mostly object - modifications should go through proper API update methods
- The class inherits from PolicyBase, so all PolicyBase methods and attributes are available
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class PermissionGrantConditionSet 78.4% similar
-
class ConditionalAccessPolicy 58.9% similar
-
class OAuth2PermissionGrant 58.5% similar
-
class ResourceSpecificPermissionGrant 58.1% similar
-
class AuthorizationPolicy 57.0% similar