সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
আপনি gRPC বা REST ব্যবহার করে সার্ভার পরিবেশ থেকে একটি গাড়ি পেতে পারেন। এই নথি উভয়ের জন্য উদাহরণ প্রদান করে।
একটি ডেলিভারি গাড়ি পেতে gRPC ব্যবহার করুন
জাভা
নিম্নলিখিত উদাহরণটি দেখায় যে কীভাবে একটি গাড়ির সন্ধান করতে 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 ব্যবহার করে সার্ভার পরিবেশ থেকে একটি গাড়ি পেতে, 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}"
লুকআপ সফল হলে, প্রতিক্রিয়া বডিতে একটি যানবাহন সত্তা থাকে।
[null,null,["2025-08-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eYou can retrieve vehicle data using either gRPC or REST methods.\u003c/p\u003e\n"],["\u003cp\u003eThis document provides code samples demonstrating how to get a vehicle using both Java gRPC and REST.\u003c/p\u003e\n"],["\u003cp\u003eBefore making vehicle requests, review the requirements in the vehicle requests section of the introduction.\u003c/p\u003e\n"],["\u003cp\u003eIf the vehicle lookup is successful, the response will contain a vehicle entity.\u003c/p\u003e\n"]]],["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"],null,["# Get a vehicle\n\n| **Note:** **Before constructing a vehicle request** , read the requirements under [Vehicle requests](/maps/documentation/mobility/fleet-engine/essentials/vehicles#vehicle_requests) in the Introduction.\n\nYou can get a vehicle either from a server environment using gRPC or REST. This\ndocument provides examples for both.\n\nUse gRPC to get a delivery vehicle\n----------------------------------\n\n### Java\n\n\nThe following example shows how to use the [Java gRPC library](/maps/documentation/mobility/fleet-engine/essentials/client-libraries-trips#java) to look up a\nvehicle. \n\n static final String PROJECT_ID = \"my-delivery-co-gcp-project\";\n static final String VEHICLE_ID = \"vehicle-8241890\";\n\n DeliveryServiceBlockingStub deliveryService =\n DeliveryServiceGrpc.newBlockingStub(channel);\n\n // Vehicle request\n String name = \"providers/\" + PROJECT_ID + \"/deliveryVehicles/\" + VEHICLE_ID;\n GetDeliveryVehicleRequest getVehicleRequest = GetDeliveryVehicleRequest.newBuilder() // No need for the header\n .setName(name)\n .build();\n\n try {\n DeliveryVehicle vehicle = deliveryService.getDeliveryVehicle(getVehicleRequest);\n } catch (StatusRuntimeException e) {\n Status s = e.getStatus();\n switch (s.getCode()) {\n case NOT_FOUND:\n break;\n case PERMISSION_DENIED:\n break;\n }\n return;\n }\n\n### REST\n\n\nTo get a vehicle from a server environment using REST, make a call to\n`GetVehicle` as follows: \n\n GET https://fleetengine.googleapis.com/v1/providers/\u003cproject_id\u003e/deliveryVehicles/\u003cvehicleId\u003e\n\n # Set JWT, PROJECT_ID, and VEHICLE_ID in the local environment\n curl -H \"Authorization: Bearer ${JWT}\" \\\n \"https://fleetengine.googleapis.com/v1/providers/${PROJECT_ID}/deliveryVehicles/${VEHICLE_ID}\"\n\nIf the lookup is successful, the response body contains a vehicle entity.\n\nWhat's next\n-----------\n\n- [List delivery vehicles](/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-list-vehicle)"]]