diff --git a/examples/directory/applications/grant_application_perms.py b/examples/directory/applications/grant_application_perms.py index 77e65956a..45e5823cb 100644 --- a/examples/directory/applications/grant_application_perms.py +++ b/examples/directory/applications/grant_application_perms.py @@ -18,20 +18,20 @@ from tests import ( test_client_id, test_client_secret, - test_tenant, + test_tenant, test_admin_principal_name, ) -# client = GraphClient.with_token_interactive( -# test_tenant, test_client_id, test_admin_principal_name -# ) -client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret) +client = GraphClient.with_token_interactive( + test_tenant, test_client_id, test_admin_principal_name +) +#client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret) # Step 1: Get the resource service principal resource = client.service_principals.get_by_name("Microsoft Graph") # Step 2: Grant an app role to a client app app = client.applications.get_by_app_id(test_client_id) -resource.grant_application_permissions(app, "Bookings.Read.All").execute_query() +resource.grant_application_permissions(app, "ThreatAssessment.Read.All").execute_query() # Step 3 (optional). Print app role assignments diff --git a/examples/directory/applications/has_application_perms.py b/examples/directory/applications/has_application_perms.py index be0b6e504..3fdc523f7 100644 --- a/examples/directory/applications/has_application_perms.py +++ b/examples/directory/applications/has_application_perms.py @@ -18,7 +18,7 @@ resource = client.service_principals.get_by_name("Microsoft Graph") -app_role = "Bookings.Read.All" +app_role = "ThreatAssessment.Read.All" # "Bookings.Read.All" result = resource.get_application_permissions(test_client_id).execute_query() if ( len([cur_app_role for cur_app_role in result.value if cur_app_role == app_role]) diff --git a/generator/metadata/Graph.xml b/generator/metadata/Graph.xml index 2083bbf47..342dfb59c 100644 --- a/generator/metadata/Graph.xml +++ b/generator/metadata/Graph.xml @@ -17290,6 +17290,11 @@ within the time frame of their original request."/> + + + + + @@ -18407,6 +18412,13 @@ within the time frame of their original request."/> + + + + + + + @@ -22245,6 +22257,13 @@ within the time frame of their original request."/> + + + + + + + @@ -22310,6 +22329,9 @@ within the time frame of their original request."/> + + + @@ -24062,6 +24084,10 @@ within the time frame of their original request."/> + + + + @@ -24286,6 +24312,7 @@ within the time frame of their original request."/> + @@ -26544,6 +26571,7 @@ within the time frame of their original request."/> + @@ -28428,6 +28456,7 @@ within the time frame of their original request."/> + @@ -28435,11 +28464,17 @@ within the time frame of their original request."/> + + + + + + @@ -28663,6 +28698,9 @@ within the time frame of their original request."/> + + + @@ -28809,6 +28847,11 @@ within the time frame of their original request."/> + + + + + @@ -34641,6 +34684,7 @@ within the time frame of their original request."/> + @@ -34709,6 +34753,7 @@ within the time frame of their original request."/> + @@ -34722,6 +34767,7 @@ within the time frame of their original request."/> + @@ -34741,6 +34787,7 @@ within the time frame of their original request."/> + @@ -35687,6 +35734,10 @@ within the time frame of their original request."/> + + + + @@ -39126,12 +39177,21 @@ within the time frame of their original request."/> + + + + + + + + + @@ -39197,6 +39257,9 @@ within the time frame of their original request."/> + + + @@ -40799,6 +40862,9 @@ within the time frame of their original request."/> + + + diff --git a/office365/directory/protection/threatassessment/email_file_request.py b/office365/directory/protection/threatassessment/email_file_request.py new file mode 100644 index 000000000..89166c393 --- /dev/null +++ b/office365/directory/protection/threatassessment/email_file_request.py @@ -0,0 +1,18 @@ +from typing import Optional + +from office365.directory.protection.threatassessment.request import ThreatAssessmentRequest + + +class EmailFileAssessmentRequest(ThreatAssessmentRequest): + """ + Represents a resource that creates and retrieves an email file threat assessment. + The email file can be an .eml file type. + """ + + @property + def content_data(self): + # type: () -> Optional[str] + """ + Base64 encoded .eml email file content. The file content can't fetch back because it isn't stored. + """ + return self.properties.get("contentData", None) diff --git a/office365/directory/protection/threatassessment/request.py b/office365/directory/protection/threatassessment/request.py index ad0199c36..7b6c11b6f 100644 --- a/office365/directory/protection/threatassessment/request.py +++ b/office365/directory/protection/threatassessment/request.py @@ -3,3 +3,4 @@ class ThreatAssessmentRequest(Entity): """An abstract resource type used to represent a threat assessment request item.""" + diff --git a/office365/base_item.py b/office365/onedrive/base_item.py similarity index 100% rename from office365/base_item.py rename to office365/onedrive/base_item.py diff --git a/office365/onedrive/columns/definition.py b/office365/onedrive/columns/definition.py index 52a5f6f15..098af1f7c 100644 --- a/office365/onedrive/columns/definition.py +++ b/office365/onedrive/columns/definition.py @@ -1,6 +1,6 @@ from typing import Optional -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.onedrive.columns.boolean import BooleanColumn from office365.onedrive.columns.calculated import CalculatedColumn from office365.onedrive.columns.choice import ChoiceColumn diff --git a/office365/onedrive/contenttypes/content_type.py b/office365/onedrive/contenttypes/content_type.py index f46c5f36c..ca5d93846 100644 --- a/office365/onedrive/contenttypes/content_type.py +++ b/office365/onedrive/contenttypes/content_type.py @@ -1,6 +1,6 @@ from typing import Optional -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.entity_collection import EntityCollection from office365.onedrive.columns.column_link import ColumnLink from office365.onedrive.columns.definition import ColumnDefinition diff --git a/office365/onedrive/driveitems/driveItem.py b/office365/onedrive/driveitems/driveItem.py index bc15dab95..a799019e4 100644 --- a/office365/onedrive/driveitems/driveItem.py +++ b/office365/onedrive/driveitems/driveItem.py @@ -9,7 +9,7 @@ import requests from typing_extensions import Self -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.delta_path import DeltaPath from office365.entity_collection import EntityCollection from office365.onedrive.analytics.item_activity_stat import ItemActivityStat diff --git a/office365/onedrive/drives/drive.py b/office365/onedrive/drives/drive.py index 587586a9b..cf00d122b 100644 --- a/office365/onedrive/drives/drive.py +++ b/office365/onedrive/drives/drive.py @@ -1,6 +1,6 @@ from typing import Optional -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.directory.permissions.identity_set import IdentitySet from office365.entity_collection import EntityCollection from office365.onedrive.driveitems.conflict_behavior import ConflictBehavior diff --git a/office365/onedrive/listitems/field_value_set.py b/office365/onedrive/listitems/field_value_set.py index 22ac4e24b..513f91a64 100644 --- a/office365/onedrive/listitems/field_value_set.py +++ b/office365/onedrive/listitems/field_value_set.py @@ -1,4 +1,4 @@ -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem class FieldValueSet(BaseItem): diff --git a/office365/onedrive/listitems/list_item.py b/office365/onedrive/listitems/list_item.py index 15df796b8..961c73bf5 100644 --- a/office365/onedrive/listitems/list_item.py +++ b/office365/onedrive/listitems/list_item.py @@ -1,4 +1,4 @@ -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.entity_collection import EntityCollection from office365.onedrive.analytics.item_analytics import ItemAnalytics from office365.onedrive.contenttypes.info import ContentTypeInfo diff --git a/office365/onedrive/lists/list.py b/office365/onedrive/lists/list.py index 67ad0c1f9..933e3a659 100644 --- a/office365/onedrive/lists/list.py +++ b/office365/onedrive/lists/list.py @@ -1,6 +1,6 @@ from typing import Optional -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.entity_collection import EntityCollection from office365.onedrive.columns.definition_collection import ColumnDefinitionCollection from office365.onedrive.contenttypes.collection import ContentTypeCollection diff --git a/office365/onedrive/recyclebin/__init__.py b/office365/onedrive/recyclebin/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/office365/onedrive/recyclebin/item.py b/office365/onedrive/recyclebin/item.py new file mode 100644 index 000000000..423e81549 --- /dev/null +++ b/office365/onedrive/recyclebin/item.py @@ -0,0 +1,10 @@ +from office365.onedrive.base_item import BaseItem + + +class RecycleBinItem(BaseItem): + """Represents information about a deleted item in a recycleBin of a SharePoint site or a SharePoint + Embedded fileStorageContainer.""" + + + + diff --git a/office365/onedrive/recyclebin/recyclebin.py b/office365/onedrive/recyclebin/recyclebin.py new file mode 100644 index 000000000..d733f418a --- /dev/null +++ b/office365/onedrive/recyclebin/recyclebin.py @@ -0,0 +1,26 @@ +from office365.entity_collection import EntityCollection +from office365.onedrive.base_item import BaseItem +from office365.onedrive.recyclebin.item import RecycleBinItem +from office365.onedrive.recyclebin.settings import RecycleBinSettings +from office365.runtime.paths.resource_path import ResourcePath + + +class RecycleBin(BaseItem): + """Represents a container for a collection of recycleBinItem resources in a SharePoint site or a + SharePoint Embedded fileStorageContainer.""" + + @property + def items(self): + # type: () -> EntityCollection[RecycleBinItem] + """List of the recycleBinItems deleted by a user.""" + return self.properties.setdefault( + "items", + EntityCollection( + self.context, RecycleBinItem, ResourcePath("items", self.resource_path), self + ), + ) + + @property + def settings(self): + """Settings for the recycleBin""" + return self.properties.get("settings", RecycleBinSettings()) diff --git a/office365/onedrive/recyclebin/settings.py b/office365/onedrive/recyclebin/settings.py new file mode 100644 index 000000000..9cc99d184 --- /dev/null +++ b/office365/onedrive/recyclebin/settings.py @@ -0,0 +1,13 @@ +from office365.runtime.client_value import ClientValue + + +class RecycleBinSettings(ClientValue): + """Represents settings for the recycleBin resource type.""" + + def __init__(self, retention_period_override_days=None): + """ + :param int retention_period_override_days: Recycle bin retention period override in days for deleted content. + The default value is 93; the value range is 7 to 180. The setting applies to newly deleted content only. + Setting this property to null reverts to its default value. + """ + self.retentionPeriodOverrideDays = retention_period_override_days diff --git a/office365/onedrive/shares/drive_item.py b/office365/onedrive/shares/drive_item.py index 2c321bd69..3feec7b02 100644 --- a/office365/onedrive/shares/drive_item.py +++ b/office365/onedrive/shares/drive_item.py @@ -1,4 +1,4 @@ -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.directory.permissions.identity_set import IdentitySet from office365.entity_collection import EntityCollection from office365.onedrive.driveitems.driveItem import DriveItem diff --git a/office365/onedrive/sitepages/base.py b/office365/onedrive/sitepages/base.py index 79c17face..b50294473 100644 --- a/office365/onedrive/sitepages/base.py +++ b/office365/onedrive/sitepages/base.py @@ -1,6 +1,6 @@ from typing import Optional -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.onedrive.driveitems.publication_facet import PublicationFacet diff --git a/office365/onedrive/sites/site.py b/office365/onedrive/sites/site.py index fddbe6e72..24c682f9e 100644 --- a/office365/onedrive/sites/site.py +++ b/office365/onedrive/sites/site.py @@ -1,7 +1,7 @@ from datetime import datetime from typing import Optional -from office365.base_item import BaseItem +from office365.onedrive.base_item import BaseItem from office365.entity_collection import EntityCollection from office365.onedrive.analytics.item_activity_stat import ItemActivityStat from office365.onedrive.analytics.item_analytics import ItemAnalytics diff --git a/office365/onedrive/workbooks/charts/axes.py b/office365/onedrive/workbooks/charts/axes.py index 3d827a415..1c241fbdd 100644 --- a/office365/onedrive/workbooks/charts/axes.py +++ b/office365/onedrive/workbooks/charts/axes.py @@ -1,7 +1,47 @@ from office365.entity import Entity +from office365.onedrive.workbooks.charts.axis import WorkbookChartAxis +from office365.runtime.paths.resource_path import ResourcePath class WorkbookChartAxes(Entity): """Represents the chart axes.""" - pass + @property + def category_axis(self): + """Represents the category axis in a chart.""" + return self.properties.get( + "categoryAxis", + WorkbookChartAxis( + self.context, ResourcePath("categoryAxis", self.resource_path) + ), + ) + + @property + def series_axis(self): + """Represents the series axis of a 3-dimensional chart.""" + return self.properties.get( + "seriesAxis", + WorkbookChartAxis( + self.context, ResourcePath("seriesAxis", self.resource_path) + ), + ) + + @property + def value_axis(self): + """Represents the value axis in an axis.""" + return self.properties.get( + "valueAxis", + WorkbookChartAxis( + self.context, ResourcePath("valueAxis", self.resource_path) + ), + ) + + def get_property(self, name, default_value=None): + if default_value is None: + property_mapping = { + "categoryAxis": self.category_axis, + "seriesAxis": self.series_axis, + "valueAxis": self.value_axis, + } + default_value = property_mapping.get(name, None) + return super(WorkbookChartAxes, self).get_property(name, default_value) diff --git a/office365/onedrive/workbooks/charts/axis.py b/office365/onedrive/workbooks/charts/axis.py new file mode 100644 index 000000000..8f1e68114 --- /dev/null +++ b/office365/onedrive/workbooks/charts/axis.py @@ -0,0 +1,5 @@ +from office365.entity import Entity + + +class WorkbookChartAxis(Entity): + """ Represents a single axis in a chart. """ diff --git a/tests/directory/test_security.py b/tests/directory/test_security.py index 7258e3e73..a4ad504bc 100644 --- a/tests/directory/test_security.py +++ b/tests/directory/test_security.py @@ -15,9 +15,9 @@ def test1_list_incidents(self): col = self.client.security.incidents.top(10).get().execute_query() self.assertIsNotNone(col.resource_path) - # def test2_list_threat_assessment_requests(self): - # col = self.client.information_protection.threat_assessment_requests.top(10).get().execute_query() - # self.assertIsNotNone(col.resource_path) + def test2_list_threat_assessment_requests(self): + col = self.client.information_protection.threat_assessment_requests.get().execute_query() + self.assertIsNotNone(col.resource_path) # def test3_list_landing_pages(self): # col = (