REST Resource: operations
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
משאב: פעולה
המשאב הזה מייצג פעולה ממושכת שהיא תוצאה של קריאה ל-API ברשת.
ייצוג JSON |
{
"name": string,
"metadata": {
"@type": string,
field1: ...,
...
},
"done": boolean,
// Union field result can be only one of the following:
"error": {
object (Status )
},
"response": {
"@type": string,
field1: ...,
...
}
// End of list of possible types for union field result .
} |
שדות |
name |
string
השם שמוקצה על ידי השרת, שהוא ייחודי באותו שירות שהחזיר אותו במקור. אם משתמשים במיפוי ה-HTTP שמוגדר כברירת מחדל, name צריך להיות שם משאב שמסתיים ב-operations/{unique_id} .
|
metadata |
object
השדה הזה יכיל אובייקט DevicesLongRunningOperationMetadata אם הפעולה נוצרה על ידי claimAsync , unclaimAsync או updateMetadataAsync . אובייקט שמכיל שדות מסוג שרירותי. שדה נוסף "@type" מכיל URI המזהה את הסוג. לדוגמה: { "id": 1234, "@type": "types.example.com/standard/id" } .
|
done |
boolean
אם הערך הוא false , המשמעות היא שהפעולה עדיין מתבצעת. אם הערך הוא true , הפעולה הושלמה ואפשר להזין error או response .
|
שדה איחוד result . תוצאת הפעולה, שיכולה להיות error או response חוקית. אם done == false , לא מוגדר error וגם response . אם done == true , אפשר להגדיר בדיוק אחד מהערכים error או response . יכול להיות ששירותים מסוימים לא יספקו את התוצאה. result יכול להיות רק אחת מהאפשרויות הבאות: |
error |
object (Status )
השדה הזה תמיד לא יוגדר אם הפעולה נוצרת על ידי claimAsync , unclaimAsync או updateMetadataAsync . במקרה הזה, פרטי השגיאות לכל מכשיר מוגדרים ב-response.perDeviceStatus.result.status .
|
response |
object
השדה הזה יכיל אובייקט DevicesLongRunningOperationResponse אם הפעולה נוצרה על ידי claimAsync , unclaimAsync או updateMetadataAsync . אובייקט שמכיל שדות מסוג שרירותי. שדה נוסף "@type" מכיל URI המזהה את הסוג. לדוגמה: { "id": 1234, "@type": "types.example.com/standard/id" } .
|
סטטוס
הסוג Status
מגדיר מודל שגיאות לוגי שמתאים לסביבות תכנות שונות, כולל ממשקי API ל-REST וממשקי API ל-RPC. הוא נמצא בשימוש של gRPC. כל הודעת Status
מכילה שלושה נתונים: קוד שגיאה, הודעת שגיאה ופרטי שגיאה.
במדריך לעיצוב API אפשר לקרוא מידע נוסף על מודל השגיאות הזה ולהבין איך לעבוד איתו.
ייצוג JSON |
{
"code": integer,
"message": string,
"details": [
{
"@type": string,
field1: ...,
...
}
]
} |
שדות |
code |
integer
קוד הסטטוס, שצריך להיות ערך enum של google.rpc.Code .
|
message |
string
הודעת שגיאה שמיועדת למפתחים וצריכה להיות באנגלית. כל הודעת שגיאה שמוצגת למשתמשים צריכה להיות מותאמת לשוק המקומי ולשלוח אותה בשדה google.rpc.Status.details או להתאים אותה לשוק המקומי.
|
details[] |
object
רשימה של הודעות שמכילות את פרטי השגיאה. יש כמה סוגים של הודעות שאפשר להשתמש בהם בממשקי API. אובייקט שמכיל שדות מסוג שרירותי. שדה נוסף "@type" מכיל URI המזהה את הסוג. לדוגמה: { "id": 1234, "@type": "types.example.com/standard/id" } .
|
שיטות |
|
כך אפשר ליהנות מהמצב העדכני ביותר של פעולה ממושכת. |
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-25 (שעון UTC)."],[[["\u003cp\u003eThis content defines the \u003ccode\u003eOperation\u003c/code\u003e resource, representing a long-running operation resulting from a network API call.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eOperation\u003c/code\u003e resource includes fields like \u003ccode\u003ename\u003c/code\u003e, \u003ccode\u003emetadata\u003c/code\u003e, and \u003ccode\u003edone\u003c/code\u003e, along with a union field \u003ccode\u003eresult\u003c/code\u003e that can be either an \u003ccode\u003eerror\u003c/code\u003e or a \u003ccode\u003eresponse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e resource defines a logical error model for APIs, including error \u003ccode\u003ecode\u003c/code\u003e, \u003ccode\u003emessage\u003c/code\u003e, and \u003ccode\u003edetails\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe provided methods for working with operations are limited to \u003ccode\u003eget\u003c/code\u003e, which allows retrieval of the latest state of a long running operation.\u003c/p\u003e\n"]]],["The content details two key components: `Operation` and `Status`. `Operation` represents a long-running API task, identified by a unique `name`. It tracks progress with a `done` boolean and provides either an `error` or `response` upon completion. `Status` defines the error model, containing an error `code`, `message`, and detailed `details`. The method described allows for getting the latest state of a long-running `operation`.\n"],null,[]]