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}"
[[["이해하기 쉬움","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(UTC)"],[[["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"]]