تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يمكنك الحصول على مركبة من بيئة خادم باستخدام gRPC أو REST. تقدّم هذه
الوثيقة أمثلة على كليهما.
استخدام gRPC للحصول على مركبة تسليم
Java
يوضّح المثال التالي كيفية استخدام مكتبة Java gRPC للبحث عن
مركبة.
staticfinalStringPROJECT_ID="my-delivery-co-gcp-project";staticfinalStringVEHICLE_ID="vehicle-8241890";DeliveryServiceBlockingStubdeliveryService=DeliveryServiceGrpc.newBlockingStub(channel);// Vehicle requestStringname="providers/"+PROJECT_ID+"/deliveryVehicles/"+VEHICLE_ID;GetDeliveryVehicleRequestgetVehicleRequest=GetDeliveryVehicleRequest.newBuilder()// No need for the header.setName(name).build();try{DeliveryVehiclevehicle=deliveryService.getDeliveryVehicle(getVehicleRequest);}catch(StatusRuntimeExceptione){Statuss=e.getStatus();switch(s.getCode()){caseNOT_FOUND:break;casePERMISSION_DENIED:break;}return;}
REST
للحصول على مركبة من بيئة خادم باستخدام REST، يمكنك إجراء مكالمة إلى
GetVehicle على النحو التالي:
GEThttps://fleetengine.googleapis.com/v1/providers/<project_id>/deliveryVehicles/<vehicleId>
# Set JWT, PROJECT_ID, and VEHICLE_ID in the local environmentcurl-H"Authorization: Bearer ${JWT}"\"https://fleetengine.googleapis.com/v1/providers/${PROJECT_ID}/deliveryVehicles/${VEHICLE_ID}"
إذا كانت عملية البحث ناجحة، يحتوي نص الاستجابة على عنصر مركبة.
تاريخ التعديل الأخير: 2025-02-25 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-02-25 (حسب التوقيت العالمي المتفَّق عليه)"],[[["You can retrieve vehicle data using either gRPC or REST methods."],["This document provides code samples demonstrating how to get a vehicle using both Java gRPC and REST."],["Before making vehicle requests, review the requirements in the vehicle requests section of the introduction."],["If the vehicle lookup is successful, the response will contain a vehicle entity."]]],["Before requesting a vehicle, review the requirements. Vehicles can be retrieved via gRPC or REST from a server environment. Using gRPC in Java involves creating a `GetDeliveryVehicleRequest` with the project and vehicle IDs, then using `deliveryService.getDeliveryVehicle()` to fetch it. With REST, a `GET` request to the `GetVehicle` endpoint with the project and vehicle ID is required, the response is a vehicle entity.\n"]]