Method: files.modifyLabels
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تعديل مجموعة التصنيفات المطبَّقة على ملف تعرض هذه الطريقة قائمة بالتصنيفات التي تمت إضافتها أو تعديلها.
طلب HTTP
POST https://www.googleapis.com/drive/v2/files/{fileId}/modifyLabels
يستخدِم عنوان URL بنية تحويل الترميز gRPC.
مَعلمات المسار
المعلمات |
fileId |
string
رقم تعريف الملف الذي تنتمي إليه التصنيفات
|
نص الطلب
يحتوي نص الطلب على مثال ModifyLabelsRequest
.
نص الاستجابة
ردّ على طلب files.modifyLabels يحتوي هذا الحقل على التصنيفات التي تمت إضافتها أو تعديلها من خلال الطلب فقط.
إذا كانت الاستجابة ناجحة، سيحتوي نص الاستجابة على بيانات بالبنية التالية:
تمثيل JSON |
{
"modifiedLabels": [
{
object (Label )
}
],
"kind": string
} |
الحقول |
modifiedLabels[] |
object (Label )
قائمة التصنيفات التي تمت إضافتها أو تعديلها من خلال الطلب.
|
kind |
string
هذا هو دائمًا drive#modifyLabelsResponse
|
نطاقات الأذونات
يجب توفير أحد نطاقات OAuth التالية:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
بعض النطاقات محظورة وتتطلّب إجراء تقييم أمان لتتمكّن من استخدامها في تطبيقك. لمزيد من المعلومات، يمكنك الاطّلاع على دليل التفويض.
ModifyLabelsRequest
طلب لتعديل مجموعة التصنيفات في ملف قد يحتوي هذا الطلب على العديد من التعديلات التي ستنجح كلها أو ستتعذّر كلها بشكل ذري.
تمثيل JSON |
{
"labelModifications": [
{
object (LabelModification )
}
],
"kind": string
} |
الحقول |
labelModifications[] |
object (LabelModification )
قائمة التعديلات التي سيتم تطبيقها على التصنيفات في الملف
|
kind |
string
يكون هذا الخيار drive#modifyLabelsRequest دائمًا.
|
LabelModification
تعديل على تصنيف في ملف يمكن استخدام LabelModification لتطبيق تصنيف على ملف أو تعديل تصنيف حالي على ملف أو إزالة تصنيف من ملف.
تمثيل JSON |
{
"fieldModifications": [
{
object (FieldModification )
}
],
"labelId": string,
"removeLabel": boolean,
"kind": string
} |
الحقول |
fieldModifications[] |
object (FieldModification )
قائمة التعديلات على حقول هذا التصنيف
|
labelId |
string
رقم تعريف التصنيف المطلوب تعديله.
|
removeLabel |
boolean
إذا كانت القيمة هي true، ستتم إزالة التصنيف من الملف.
|
kind |
string
يكون هذا الخيار drive#labelModification دائمًا.
|
FieldModification
تمثيل JSON |
{
"setDateValues": [
string
],
"setTextValues": [
string
],
"setSelectionValues": [
string
],
"setIntegerValues": [
string
],
"setUserValues": [
string
],
"fieldId": string,
"kind": string,
"unsetValues": boolean
} |
الحقول |
setDateValues[] |
string
يستبدل قيمة الحقل date بهذه القيم الجديدة. يجب أن تكون السلسلة بالتنسيق الكامل للتاريخ RFC 3339: YYYY-MM-DD.
|
setTextValues[] |
string
تضبط هذه السمة قيمة حقل text .
|
setSelectionValues[] |
string
يستبدل حقل selection بهذه القيم الجديدة.
|
setIntegerValues[] |
string (int64 format)
يستبدل قيمة الحقل integer بهذه القيم الجديدة.
|
setUserValues[] |
string
يستبدل حقل user بهذه القيم الجديدة. يجب أن تكون القيم عناوين بريد إلكتروني صالحة.
|
fieldId |
string
رقم تعريف الحقل المطلوب تعديله
|
kind |
string
يكون هذا الخيار drive#labelFieldModification دائمًا.
|
unsetValues |
boolean
تؤدي إلى إلغاء ضبط قيم هذا الحقل.
|
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Method: files.modifyLabels\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ModifyLabelsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [ModifyLabelsRequest](#ModifyLabelsRequest)\n - [JSON representation](#ModifyLabelsRequest.SCHEMA_REPRESENTATION)\n- [LabelModification](#LabelModification)\n - [JSON representation](#LabelModification.SCHEMA_REPRESENTATION)\n- [FieldModification](#FieldModification)\n - [JSON representation](#FieldModification.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nModifies the set of labels applied to a file. Returns a list of the labels that were added or modified.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v2/files/{fileId}/modifyLabels`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|---------------------------------------------------------|\n| `fileId` | `string` The ID of the file to which the labels belong. |\n\n### Request body\n\nThe request body contains an instance of [ModifyLabelsRequest](/workspace/drive/api/reference/rest/v2/files/modifyLabels#ModifyLabelsRequest).\n\n### Response body\n\nResponse to a files.modifyLabels request. This contains only those labels which were added or updated by the request.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------|\n| ``` { \"modifiedLabels\": [ { object (/workspace/drive/api/reference/rest/v2/Label) } ], \"kind\": string } ``` |\n\n| Fields ||\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `modifiedLabels[]` | `object (`[Label](/workspace/drive/api/reference/rest/v2/Label)`)` The list of labels which were added or updated by the request. |\n| `kind` | `string` This is always `drive#modifyLabelsResponse` |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/drive`\n- `\n https://www.googleapis.com/auth/drive.file`\n- `\n https://www.googleapis.com/auth/drive.metadata`\n\nSome scopes are restricted and require a security assessment for your app to use them. For more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent).\n\nModifyLabelsRequest\n-------------------\n\nA request to modify the set of labels on a file. This request may contain many modifications that will either all succeed or all fail atomically.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"labelModifications\": [ { object (/workspace/drive/api/reference/rest/v2/files/modifyLabels#LabelModification) } ], \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `labelModifications[]` | `object (`[LabelModification](/workspace/drive/api/reference/rest/v2/files/modifyLabels#LabelModification)`)` The list of modifications to apply to the labels on the file. |\n| `kind` | `string` This is always `drive#modifyLabelsRequest`. |\n\nLabelModification\n-----------------\n\nA modification to a label on a file. A LabelModification can be used to apply a label to a file, update an existing label on a file, or remove a label from a file.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"fieldModifications\": [ { object (/workspace/drive/api/reference/rest/v2/files/modifyLabels#FieldModification) } ], \"labelId\": string, \"removeLabel\": boolean, \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fieldModifications[]` | `object (`[FieldModification](/workspace/drive/api/reference/rest/v2/files/modifyLabels#FieldModification)`)` The list of modifications to this label's fields. |\n| `labelId` | `string` The ID of the label to modify. |\n| `removeLabel` | `boolean` If true, the label will be removed from the file. |\n| `kind` | `string` This is always `drive#labelModification`. |\n\nFieldModification\n-----------------\n\nA modification to a label's field.\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"setDateValues\": [ string ], \"setTextValues\": [ string ], \"setSelectionValues\": [ string ], \"setIntegerValues\": [ string ], \"setUserValues\": [ string ], \"fieldId\": string, \"kind\": string, \"unsetValues\": boolean } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `setDateValues[]` | `string` Replaces the value of a `date` field with these new values. The string must be in the RFC 3339 full-date format: YYYY-MM-DD. |\n| `setTextValues[]` | `string` Sets the value of a `text` field. |\n| `setSelectionValues[]` | `string` Replaces a `selection` field with these new values. |\n| `setIntegerValues[]` | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` Replaces the value of an `integer` field with these new values. |\n| `setUserValues[]` | `string` Replaces a `user` field with these new values. The values must be valid email addresses. |\n| `fieldId` | `string` The ID of the field to be modified. |\n| `kind` | `string` This is always `drive#labelFieldModification`. |\n| `unsetValues` | `boolean` Unsets the values for this field. |"]]