Skip to content

Commit

Permalink
new types for Intune & directory namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Aug 6, 2023
1 parent 6be54d6 commit dcc741d
Show file tree
Hide file tree
Showing 32 changed files with 385 additions and 41 deletions.
3 changes: 2 additions & 1 deletion office365/directory/groups/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def add_favorite(self):
return self

def check_granted_permissions_for_app(self):
""""""
return_type = EntityCollection(self.context, ResourceSpecificPermissionGrant)
qry = ServiceOperationQuery(self, "checkGrantedPermissionsForApp", None, None, None, return_type)
qry = ServiceOperationQuery(self, "checkGrantedPermissionsForApp", return_type=return_type)
self.context.add_query(qry)
return return_type

Expand Down
16 changes: 14 additions & 2 deletions office365/directory/licenses/assigned_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ class AssignedPlan(ClientValue):
The assignedPlans property of both the user entity and the organization entity is a collection of assignedPlan.
"""

def __init__(self, assigned_datetime=None):
def __init__(self, assigned_datetime=None, capability_status=None, service=None, service_plan_id=None):
"""
:param datetime assigned_datetime: The date and time at which the plan was assigned.
:param datetime.datetime assigned_datetime: The date and time at which the plan was assigned.
:param str capability_status: Condition of the capability assignment.
The possible values are Enabled, Warning, Suspended, Deleted, LockedOut.
See a detailed description of each value.
:param str service: The name of the service; for example, exchange.
:param str service_plan_id: A GUID that identifies the service plan. For a complete list of GUIDs and their
equivalent friendly service names, see Product names and service plan identifiers for licensing.
"""
self.assignedDateTime = assigned_datetime
self.capabilityStatus = capability_status
self.service = service
self.servicePlanId = service_plan_id

def __repr__(self):
return self.service

5 changes: 5 additions & 0 deletions office365/directory/permissions/email_identity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.directory.permissions.identity import Identity


class EmailIdentity(Identity):
"""Represents the email identity of a user."""
26 changes: 26 additions & 0 deletions office365/directory/permissions/grants/condition_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ def client_application_ids(self):
"""
return self.properties.get("clientApplicationIds", StringCollection())

@property
def client_application_publisher_ids(self):
"""
A list of Microsoft Partner Network (MPN) IDs for verified publishers of the client application, or a list
with the single value all to match with client apps from any publisher. Default is the single value all.
"""
return self.properties.get("clientApplicationPublisherIds", StringCollection())

@property
def client_applications_from_verified_publisher_only(self):
"""
Set to true to only match on client applications with a verified publisher. Set to false to match on any client
app, even if it does not have a verified publisher. Default is false.
:rtype: bool
"""
return self.properties.get("clientApplicationsFromVerifiedPublisherOnly", None)

@property
def permissions(self):
"""
Expand All @@ -30,3 +47,12 @@ def permissions(self):
Default is the single value all.
"""
return self.properties.get("permissions", StringCollection())

@property
def resource_application(self):
"""
The appId of the resource application (e.g. the API) for which a permission is being granted, or any to match
with any resource application or API. Default is any.
:rtype: str
"""
return self.properties.get("resourceApplication", None)
21 changes: 21 additions & 0 deletions office365/directory/permissions/grants/resource_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,24 @@ def client_app_id(self):
"""ID of the service principal of the Azure AD app that has been granted access."""
return self.properties.get("clientAppId", None)

@property
def permission(self):
"""The name of the resource-specific permission.
:rtype: str
"""
return self.properties.get("permission", None)

@property
def permission_type(self):
"""The type of permission. Possible values are: Application, Delegated. Read-only.
:rtype: str
"""
return self.properties.get("permissionType", None)

@property
def resource_app_id(self):
"""ID of the Azure AD app that is hosting the resource. Read-only.
:rtype: str
"""
return self.properties.get("resourceAppId", None)

18 changes: 18 additions & 0 deletions office365/directory/rolemanagement/unified_role_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ class UnifiedRoleAssignment(Entity):
(for example, a user or a role-assignable group) at a particular scope.
"""

@property
def app_scope_id(self):
"""
Identifier of the app-specific scope when the assignment scope is app-specific. Either this property or
directoryScopeId is required. App scopes are scopes that are defined and understood by this application only.
Use / for tenant-wide app scopes. Use directoryScopeId to limit the scope to particular directory objects,
for example, administrative units. Supports $filter (eq, in).
:rtype: str
"""
return self.properties.get("appScopeId", None)

@property
def condition(self):
"""
:rtype: str
"""
return self.properties.get("condition", None)

@property
def role_definition(self):
"""
Expand Down
6 changes: 6 additions & 0 deletions office365/directory/security/alerts/alert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from office365.directory.security.alerts.evidence import AlertEvidence
from office365.directory.security.alerts.history_state import AlertHistoryState
from office365.entity import Entity
from office365.runtime.client_value_collection import ClientValueCollection

Expand All @@ -12,3 +13,8 @@ class Alert(Entity):
def evidence(self):
"""Collection of evidence related to the alert."""
return self.properties.get("evidence", ClientValueCollection(AlertEvidence))

@property
def history_states(self):
"""Collection of changes for the alert."""
return self.properties.get("historyStates", ClientValueCollection(AlertHistoryState))
5 changes: 5 additions & 0 deletions office365/directory/security/alerts/history_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class AlertHistoryState(ClientValue):
"""Stores changes made to alerts."""
16 changes: 16 additions & 0 deletions office365/directory/security/attacksimulations/automation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
from office365.directory.permissions.email_identity import EmailIdentity
from office365.directory.security.attacksimulations.automation_run import SimulationAutomationRun
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.runtime.paths.resource_path import ResourcePath


class SimulationAutomation(Entity):
"""Represents simulation automation created to run on a tenant."""

@property
def created_by(self):
"""Identity of the user who created the attack simulation automation."""
return self.properties.get('createdBy', EmailIdentity())

@property
def runs(self):
"""A collection of simulation automation runs."""
return self.properties.get('runs',
EntityCollection(self.context, SimulationAutomationRun,
ResourcePath("runs", self.resource_path)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.entity import Entity


class SimulationAutomationRun(Entity):
"""Represents a run of an attack simulation automation on a tenant."""
1 change: 0 additions & 1 deletion office365/directory/security/attacksimulations/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ def get_property(self, name, default_value=None):
}
default_value = property_mapping.get(name, None)
return super(AttackSimulationRoot, self).get_property(name, default_value)

2 changes: 1 addition & 1 deletion office365/graph_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from office365.entity_collection import EntityCollection
from office365.search.external.external import External
from office365.intune.devices.app_management import DeviceAppManagement
from office365.intune.devices.management import DeviceManagement
from office365.intune.devices.management.management import DeviceManagement
from office365.intune.organizations.contact import OrgContact
from office365.intune.organizations.organization import Organization
from office365.onedrive.admin import Admin
Expand Down
5 changes: 5 additions & 0 deletions office365/intune/audit/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class AuditActor(ClientValue):
"""A class containing the properties for Audit Actor."""
46 changes: 21 additions & 25 deletions office365/intune/audit/event.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.function import FunctionQuery
from office365.runtime.types.collections import StringCollection
from office365.intune.audit.actor import AuditActor
from office365.intune.audit.resource import AuditResource
from office365.runtime.client_value_collection import ClientValueCollection


class AuditEvent(Entity):
"""A class containing the properties for Audit Event."""


class AuditEventCollection(EntityCollection):

def __init__(self, context, resource_path=None):
super(AuditEventCollection, self).__init__(context, AuditEvent, resource_path)

def get_audit_categories(self):
"""Not yet documented"""
return_type = ClientResult(self.context, StringCollection())
qry = FunctionQuery(self, "getAuditCategories", None, return_type)
self.context.add_query(qry)
return return_type

def get_audit_activity_types(self, category):
"""Not yet documented"""
return_type = ClientResult(self.context, StringCollection())
params = {"category": category}
qry = FunctionQuery(self, "getAuditActivityTypes", params, return_type)
self.context.add_query(qry)
return return_type

@property
def activity(self):
"""Friendly name of the activity.
:rtype: str
"""
return self.properties.get("activity", None)

@property
def actor(self):
"""
AAD user and application that are associated with the audit event.
"""
return self.properties.get("actor", AuditActor())

@property
def resources(self):
"""Resources being modified"""
return self.properties.get("resources", ClientValueCollection(AuditResource))
26 changes: 26 additions & 0 deletions office365/intune/audit/event_collection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from office365.entity_collection import EntityCollection
from office365.intune.audit.event import AuditEvent
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.function import FunctionQuery
from office365.runtime.types.collections import StringCollection


class AuditEventCollection(EntityCollection):

def __init__(self, context, resource_path=None):
super(AuditEventCollection, self).__init__(context, AuditEvent, resource_path)

def get_audit_categories(self):
"""Not yet documented"""
return_type = ClientResult(self.context, StringCollection())
qry = FunctionQuery(self, "getAuditCategories", None, return_type)
self.context.add_query(qry)
return return_type

def get_audit_activity_types(self, category):
"""Not yet documented"""
return_type = ClientResult(self.context, StringCollection())
params = {"category": category}
qry = FunctionQuery(self, "getAuditActivityTypes", params, return_type)
self.context.add_query(qry)
return return_type
5 changes: 5 additions & 0 deletions office365/intune/audit/property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class AuditProperty(ClientValue):
"""A class containing the properties for Audit Property."""
11 changes: 11 additions & 0 deletions office365/intune/audit/resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from office365.runtime.client_value import ClientValue


class AuditResource(ClientValue):
"""A class containing the properties for Audit Resource."""

def __init__(self, audit_resource_type=None):
"""
:param str audit_resource_type: Audit resource's type.
"""
self.auditResourceType = audit_resource_type
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.intune.audit.event import AuditEventCollection
from office365.intune.audit.event_collection import AuditEventCollection
from office365.intune.devices.category import DeviceCategory
from office365.intune.devices.enrollment.configuration import DeviceEnrollmentConfiguration
from office365.intune.devices.managed import ManagedDevice
from office365.runtime.paths.resource_path import ResourcePath

Expand All @@ -16,7 +18,23 @@ class DeviceManagement(Entity):
def audit_events(self):
""""""
return self.properties.get("auditEvents", AuditEventCollection(self.context,
ResourcePath("auditEvents", self.resource_path)))
ResourcePath("auditEvents",
self.resource_path)))

@property
def device_categories(self):
""""""
return self.properties.get("deviceCategories",
EntityCollection(self.context, DeviceCategory, ResourcePath("deviceCategories",
self.resource_path)))

@property
def device_enrollment_configurations(self):
""""""
return self.properties.get('deviceEnrollmentConfigurations',
EntityCollection(self.context, DeviceEnrollmentConfiguration,
ResourcePath("deviceEnrollmentConfigurations",
self.resource_path)))

@property
def managed_devices(self):
Expand All @@ -29,6 +47,8 @@ def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"auditEvents": self.audit_events,
"deviceCategories": self.device_categories,
"deviceEnrollmentConfigurations": self.device_enrollment_configurations,
"managedDevices": self.managed_devices
}
default_value = property_mapping.get(name, None)
Expand Down
5 changes: 5 additions & 0 deletions office365/intune/devices/management/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class DeviceManagementSettings(ClientValue):
""""""
15 changes: 15 additions & 0 deletions office365/intune/organizations/branding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from office365.intune.organizations.branding_properties import OrganizationalBrandingProperties


class OrganizationalBranding(OrganizationalBrandingProperties):
"""
Contains details about the organization's default branding. Inherits from organizationalBrandingProperties.
Organizations can customize their Azure Active Directory (Azure AD) sign-in pages which appear when users sign
in to their organization's tenant-specific apps, or when Azure AD identifies the user's tenant from their username.
A developer can also read the company's branding information and customize their app experience to tailor
it specifically for the signed-in user using their company's branding.
You can't change your original configuration's language. However, companies can add different branding based on
locale. For language-specific branding, see the organizationalBrandingLocalization object.
"""
14 changes: 14 additions & 0 deletions office365/intune/organizations/organization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from office365.directory.certificates.auth_configuration import CertificateBasedAuthConfiguration
from office365.directory.domains.verified import VerifiedDomain
from office365.directory.licenses.assigned_plan import AssignedPlan
from office365.directory.object import DirectoryObject
from office365.directory.extensions.extension import Extension
from office365.entity_collection import EntityCollection
from office365.intune.organizations.branding import OrganizationalBranding
from office365.intune.provisioned_plan import ProvisionedPlan
from office365.runtime.client_value_collection import ClientValueCollection
from office365.runtime.paths.resource_path import ResourcePath
Expand All @@ -15,6 +17,17 @@ class Organization(DirectoryObject):
which operate and are provisioned at the tenant-level.
"""

@property
def assigned_plans(self):
"""The plans that are assigned to the organization."""
return self.properties.get('assignedPlans', ClientValueCollection(AssignedPlan))

@property
def branding(self):
return self.properties.get('branding',
OrganizationalBranding(self.context,
ResourcePath("branding", self.resource_path)))

@property
def business_phones(self):
"""
Expand Down Expand Up @@ -51,6 +64,7 @@ def verified_domains(self):
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"assignedPlans": self.assigned_plans,
"certificateBasedAuthConfiguration": self.certificate_based_auth_configuration,
"businessPhones": self.business_phones,
"provisionedPlans": self.provisioned_plans,
Expand Down
Loading

0 comments on commit dcc741d

Please sign in to comment.