با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این راهنما اجزای اصلی یک پاسخ را در Google Drive Activity API توضیح میدهد، نمونههایی و نحوه تفسیر آنها را نشان میدهد.
اشیاء
DriveActivity : این منبع اصلی است که توسط پرس و جوها به Drive Activity API بازگردانده می شود. این یک یا چند بازیگر را توصیف می کند که یک یا چند عمل را انجام می دهند که بر یک یا چند هدف تأثیر می گذارد.
Timestamp و TimeRange : اینها به ترتیب، یا یک نقطه زمانی را که فعالیت رخ داده است، یا شروع و پایان زمانی که فعالیت در یک بازه زمانی رخ داده است، توصیف میکنند.
Actor : به طور معمول، یک Actor یک کاربر نهایی است. با این حال، گاهی اوقات، یک رویداد سیستم می تواند یک Action هنگامی که یک مدیر به عنوان یک کاربر یا خودش عمل می کند، یا زمانی که توسط یک فرد غیرقابل شناسایی انجام می شود، راه اندازی کند. پیام Actor هر یک از این موارد را در بر می گیرد.
Target : Target هدف یک فعالیت است، مانند یک فایل، یک پوشه، یک درایو مشترک یا یک نظر فایل. توجه داشته باشید که بسیاری از انواع عملیات از بیش از یک نوع هدف پشتیبانی می کنند. به عنوان مثال، اگرچه Edit به طور کلی برای فایلهای Drive اعمال میشود، اقدامات دیگری مانند Rename و Create نیز میتوانند در پوشههای Drive و درایوهای مشترک اعمال شوند. اهدافی که آیتمهای Drive نیستند همچنان میتوانند به یکی از آنها ارجاع دهند، مانند پوشه اصلی یک درایو یا سند والد حاوی یک نظر فایل.
Action : هر منبع DriveActivity یک یا چند کنش مرتبط دارد. یک Action مانند یک رویداد مستقل است، زیرا نه تنها شامل نوع دقیق و اطلاعات مربوط به کنش است، بلکه شامل یک Actor ، یک Target ، و یک Timestamp یا TimeRange است. برای جلوگیری از افزونگی، یک Action فیلدهای Target ، Actor یا زمان خودش را پر نمیکند، زمانی که این فیلدها با DriveActivity کلی یکسان هستند.
ActionDetail : این نوع خاص و اطلاعات دقیق در مورد یک Action است. به عنوان مثال، جزئیات اقدام Move دارای منبع و مکان مقصد است، و PermissionChange مشخص می کند که اکنون چه کسی می تواند به یک سند و با چه امتیازاتی دسترسی داشته باشد.
نمونه پاسخ ها
برای مشاهده نمونه پاسخ ها موارد زیر را مرور کنید.
کاربری فایلی را در Drive ویرایش کرد
یک منبع DriveActivity ممکن است فقط شامل یک عمل باشد، مانند ویرایش یک فایل توسط کاربر.
ACCOUNT_ID : شناسه کاربر. برای دریافت اطلاعات بیشتر می توان از آن با People API استفاده کرد.
ITEM_ID : شناسه مورد Drive.
TITLE : عنوان مورد Drive.
توجه داشته باشید که شی Action در این پاسخ شامل Actor ، Target یا timestamp نمیشود، زیرا آنها با DriveActivity کلی یکسان هستند.
دو کاربر یک فایل را در زمان های مشابه ویرایش کردند
هنگامی که از یک ConsolidationStrategy استفاده می شود، اقدامات مرتبط در یک DriveActivity ترکیبی گروه بندی می شوند. در این مثال، دو اقدام مشابه گروه بندی شده اند: یک نوع اقدام Edit از دو کاربر مختلف.
ACCOUNT_ID_1 : شناسه اولین کاربر. برای دریافت اطلاعات بیشتر می توان از آن با People API استفاده کرد.
ACCOUNT_ID_2 : شناسه کاربر دوم.
ITEM_ID : شناسه مورد Drive.
TITLE : عنوان مورد Drive.
توجه داشته باشید که شی Action در این پاسخ، Target شامل نمیشود، زیرا با DriveActivity کلی یکسان است.
این مثال همچنین نشان میدهد که چگونه برنامهها ممکن است تنها از اطلاعات خلاصه در DriveActivity استفاده کنند، بدون اینکه به اقدامات فردی نگاه کنند. پاسخ نشان می دهد که دو کاربر یک فایل معین را در یک بازه زمانی ویرایش کرده اند.
یک کاربر دو فایل را به یک فهرست جدید منتقل کرد
در این مثال، ConsolidationStrategy دو اقدام Move مرتبط را گروه بندی می کند زیرا فایل ها همزمان از یک منبع به یک مقصد منتقل شده اند.
تاریخ آخرین بهروزرسانی 2025-03-26 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-03-26 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Drive Activity API data model\n\nThis guide explains the main components of a response in the Google Drive Activity API,\nshowing examples and how to interpret them.\n\nObjects\n-------\n\n- [`DriveActivity`](/drive/activity/v2/reference/rest/v2/activity/driveactivity): This is the primary\n resource returned by queries to the Drive Activity API. It describes one\n or more actors performing one or more actions affecting one or more targets.\n\n- [`Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp)\n and [`TimeRange`](/drive/activity/v2/reference/rest/v2/activity/timerange): These describe,\n respectively, either a single point in time when the activity occurred, or\n the start and end of when the activity occurred over a span of time.\n\n- [`Actor`](/drive/activity/v2/reference/rest/v2/activity/actor): Typically, an `Actor` is an end user.\n However, sometimes, a system event can trigger an [`Action`](/drive/activity/v2/reference/rest/v2/activity/action) when an administrator is acting as a user or as\n themselves, or when performed by an unidentifiable person. The `Actor`\n message encapsulates each of these cases.\n\n- [`Target`](/drive/activity/v2/reference/rest/v2/activity/target): A `Target` is the object of an\n activity, like a file, a folder, a shared drive, or a file comment. Note\n that many action types support more than one kind of target. For example,\n though `Edit` generally applies to Drive files, other actions\n like `Rename` and `Create` can also apply to Drive folders\n and shared drives. Targets that aren't Drive items can still\n refer to one, such as the root folder of a drive or the parent document\n containing a file comment.\n\n- [`Action`](/drive/activity/v2/reference/rest/v2/activity/action): Each `DriveActivity` resource has one\n or more related actions. An `Action` is self-contained, like an\n *event* , in that it comprises not only the detailed type and information\n about the action, but also an `Actor`, a `Target`, and either a `Timestamp`\n or `TimeRange`. To avoid redundancy, an `Action` doesn't populate its own\n `Target`, `Actor`, or time fields when those are the same as the overall\n `DriveActivity`.\n\n- [`ActionDetail`](/drive/activity/v2/reference/rest/v2/activity/actiondetail): This is the specific type\n and detailed information about an `Action`. For example, a `Move` action\n detail has a source and destination location, and a `PermissionChange`\n specifies who can now access a document and with what privileges.\n\nExample responses\n-----------------\n\nReview the following to see sample responses.\n\n### A user edited a file in Drive\n\nA `DriveActivity` resource might include only one action, such as a user\nediting one file. \n\n \"activities\":[{\n \"primaryActionDetail\":{ \"edit\":{} },\n \"actors\":[ { \"user\":{ \"knownUser\":{ \"personName\":\"people/\u003cvar translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e\" } } } ],\n \"targets\":[ { \"driveItem\":{ \"name\":\"items/\u003cvar translate=\"no\"\u003eITEM_ID\u003c/var\u003e\", \"title\":\"\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e\", \"file\":{} } } ],\n \"timestamp\":{ \"seconds\":\"1536794657\", \"nanos\":791000000 },\n \"actions\":[ { \"detail\":{ \"edit\":{} } } ]\n }]\n\nThis output includes the following values:\n\n- \u003cvar translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e: the ID of the user. It can be used with the [People API](/people) to get more information.\n- \u003cvar translate=\"no\"\u003eITEM_ID\u003c/var\u003e: the ID of the Drive item.\n- \u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e: the title of the Drive item.\n\nNote that the `Action` object in this response doesn't include the `Actor`,\n`Target`, or `timestamp` because they're the same as the overall\n`DriveActivity`.\n\n### Two users edited the same file at similar times\n\nWhen a [`ConsolidationStrategy`](/drive/activity/v2/reference/rest/v2/activity/query#consolidationstrategy)\nis used, related actions are grouped into one combined `DriveActivity`. In this\nexample, two similar actions are grouped: one `Edit` action type from two\ndifferent users. \n\n \"activities\":[{\n \"primaryActionDetail\":{ \"edit\":{} },\n \"actors\":[\n { \"user\":{ \"knownUser\":{ \"personName\":\"people/\u003cvar translate=\"no\"\u003eACCOUNT_ID_1\u003c/var\u003e\" } } },\n { \"user\":{ \"knownUser\":{ \"personName\":\"people/\u003cvar translate=\"no\"\u003eACCOUNT_ID_2\u003c/var\u003e\" } } }\n ],\n \"targets\":[\n { \"driveItem\":{ \"name\":\"items/\u003cvar translate=\"no\"\u003eITEM_ID\u003c/var\u003e\", \"title\":\"\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e\", \"file\":{} } }\n ],\n \"timeRange\":{\n \"startTime\":{ \"seconds\":\"1541089823\", \"nanos\":712000000 },\n \"endTime\":{ \"seconds\":\"1541089830\", \"nanos\":830000000 }\n },\n \"actions\":[\n {\n \"detail\":{ \"edit\":{} },\n \"actor\":{ \"user\":{ \"knownUser\":{ \"personName\":\"people/\u003cvar translate=\"no\"\u003eACCOUNT_ID_1\u003c/var\u003e\" } } },\n \"timestamp\":{ \"seconds\":\"1541089830\", \"nanos\":830000000 }\n },\n {\n \"detail\":{ \"edit\":{} },\n \"actor\":{ \"user\":{ \"knownUser\":{ \"personName\":\"people/\u003cvar translate=\"no\"\u003eACCOUNT_ID_2\u003c/var\u003e\" } } },\n \"timestamp\":{ \"seconds\":\"1541089823\", \"nanos\":712000000 }\n }\n ]\n }]\n\nThis output includes the following values:\n\n- \u003cvar translate=\"no\"\u003eACCOUNT_ID_1\u003c/var\u003e: the ID of the first user. It can be used with the [People API](/people) to get more information.\n- \u003cvar translate=\"no\"\u003eACCOUNT_ID_2\u003c/var\u003e: the ID of the second user.\n- \u003cvar translate=\"no\"\u003eITEM_ID\u003c/var\u003e: the ID of the Drive item.\n- \u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e: the title of the Drive item.\n\nNote that the `Action` object in this response doesn't include the `Target`\nbecause it's the same as the overall `DriveActivity`.\n\nThe example also illustrates how apps might use only the summary information in\n`DriveActivity`, without looking at the individual actions. The response\nindicates that two users edited a given file over a span of time.\n\n### A user moved two files into a new directory\n\nIn this example, the `ConsolidationStrategy` grouped two related `Move` actions\nbecause the files were moved from the same source to the same destination at the\nsame time. \n\n \"activities\":[{\n \"primaryActionDetail\":{\n \"move\":{\n \"addedParents\":[ { ... } ]\n \"removedParents\":[ { ... } ]\n }\n },\n \"actors\":[ { \"user\":{ \"knownUser\":{ \"personName\":\"people/\u003cvar translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e\" } } } ],\n \"targets\":[\n { \"driveItem\":{ \"name\":\"items/\u003cvar translate=\"no\"\u003eITEM_ID_1\u003c/var\u003e\", \"title\":\"\u003cvar translate=\"no\"\u003eTITLE_1\u003c/var\u003e\", \"file\":{} } },\n { \"driveItem\":{ \"name\":\"items/\u003cvar translate=\"no\"\u003eITEM_ID_2\u003c/var\u003e\", \"title\":\"* \u003cvar translate=\"no\"\u003eTITLE_2\u003c/var\u003e\", \"file\":{} } }\n ],\n \"timestamp\":{ \"seconds\":\"1541090960\", \"nanos\":985000000 },\n \"actions\":[\n {\n \"detail\":{ \"move\":{ \"addedParents\":[ { ... } ] \"removedParents\":[ { ... } ] } },\n \"target\":{ \"driveItem\":{ \"name\":\"items/\u003cvar translate=\"no\"\u003eITEM_ID_1\u003c/var\u003e\", \"title\":\"\u003cvar translate=\"no\"\u003eTITLE_1\u003c/var\u003e\", \"file\":{} } }\n },\n {\n \"detail\":{ \"move\":{ \"addedParents\":[ { ... } ] \"removedParents\":[ { ... } ] } },\n \"target\":{ \"driveItem\":{ \"name\":\"items/\u003cvar translate=\"no\"\u003eITEM_ID_2\u003c/var\u003e\", \"title\":\"* \u003cvar translate=\"no\"\u003eTITLE_2\u003c/var\u003e\", \"file\":{} } }\n }\n ]\n }]\n\nThis output includes the following values:\n\n- \u003cvar translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e: the ID of the user. It can be used with the [People API](/people) to get more information.\n- \u003cvar translate=\"no\"\u003eITEM_ID_1\u003c/var\u003e: the ID of the first Drive item.\n- \u003cvar translate=\"no\"\u003eITEM_ID_2\u003c/var\u003e: the ID of the second Drive item.\n- \u003cvar translate=\"no\"\u003eTITLE_1\u003c/var\u003e: the title of the first Drive item.\n- \u003cvar translate=\"no\"\u003eTITLE_2\u003c/var\u003e: the title of the second Drive item.\n\nNote that the `Action` object in this response doesn't include the `Actor` or\n`timestamp` because they're the same as the overall `DriveActivity`."]]