add vehicle api (#221)

* add vehicle api

* Commit from GitHub Actions (Publish APIs & Clients)

Co-authored-by: asim <asim@users.noreply.github.com>
This commit is contained in:
Asim Aslam
2021-10-04 12:14:31 +01:00
committed by GitHub
parent ec9fc27f24
commit 9b6010372e
22 changed files with 884 additions and 1 deletions

373
vehicle/proto/vehicle.pb.go Normal file
View File

@@ -0,0 +1,373 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.15.6
// source: proto/vehicle.proto
package vehicle
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// Lookup a UK vehicle by it's registration number
type LookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// the vehicle registration number
Registration string `protobuf:"bytes,1,opt,name=registration,proto3" json:"registration,omitempty"`
}
func (x *LookupRequest) Reset() {
*x = LookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_vehicle_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LookupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LookupRequest) ProtoMessage() {}
func (x *LookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_vehicle_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LookupRequest.ProtoReflect.Descriptor instead.
func (*LookupRequest) Descriptor() ([]byte, []int) {
return file_proto_vehicle_proto_rawDescGZIP(), []int{0}
}
func (x *LookupRequest) GetRegistration() string {
if x != nil {
return x.Registration
}
return ""
}
type LookupResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// registration number
Registration string `protobuf:"bytes,1,opt,name=registration,proto3" json:"registration,omitempty"`
// make of vehicle
Make string `protobuf:"bytes,2,opt,name=make,proto3" json:"make,omitempty"`
// colour of vehicle
Colour string `protobuf:"bytes,3,opt,name=colour,proto3" json:"colour,omitempty"`
// year of manufacture
YearOfManufacture int32 `protobuf:"varint,4,opt,name=year_of_manufacture,json=yearOfManufacture,proto3" json:"year_of_manufacture,omitempty"`
// co2 emmissions
Co2Emissions float64 `protobuf:"fixed64,5,opt,name=co2_emissions,json=co2Emissions,proto3" json:"co2_emissions,omitempty"`
// engine capacity
EngineCapacity int32 `protobuf:"varint,6,opt,name=engine_capacity,json=engineCapacity,proto3" json:"engine_capacity,omitempty"`
// fuel type e.g petrol, diesel
FuelType string `protobuf:"bytes,7,opt,name=fuel_type,json=fuelType,proto3" json:"fuel_type,omitempty"`
// month of first registration
MonthOfFirstRegistration string `protobuf:"bytes,8,opt,name=month_of_first_registration,json=monthOfFirstRegistration,proto3" json:"month_of_first_registration,omitempty"`
// mot status
MotStatus string `protobuf:"bytes,9,opt,name=mot_status,json=motStatus,proto3" json:"mot_status,omitempty"`
// mot expiry
MotExpiry string `protobuf:"bytes,10,opt,name=mot_expiry,json=motExpiry,proto3" json:"mot_expiry,omitempty"`
// tax due data
TaxDueDate string `protobuf:"bytes,11,opt,name=tax_due_date,json=taxDueDate,proto3" json:"tax_due_date,omitempty"`
// tax status
TaxStatus string `protobuf:"bytes,12,opt,name=tax_status,json=taxStatus,proto3" json:"tax_status,omitempty"`
// type approvale
TypeApproval string `protobuf:"bytes,13,opt,name=type_approval,json=typeApproval,proto3" json:"type_approval,omitempty"`
// wheel plan
Wheelplan string `protobuf:"bytes,14,opt,name=wheelplan,proto3" json:"wheelplan,omitempty"`
// date of last v5 issue
LastV5Issued string `protobuf:"bytes,15,opt,name=last_v5_issued,json=lastV5Issued,proto3" json:"last_v5_issued,omitempty"`
}
func (x *LookupResponse) Reset() {
*x = LookupResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_vehicle_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LookupResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LookupResponse) ProtoMessage() {}
func (x *LookupResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_vehicle_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LookupResponse.ProtoReflect.Descriptor instead.
func (*LookupResponse) Descriptor() ([]byte, []int) {
return file_proto_vehicle_proto_rawDescGZIP(), []int{1}
}
func (x *LookupResponse) GetRegistration() string {
if x != nil {
return x.Registration
}
return ""
}
func (x *LookupResponse) GetMake() string {
if x != nil {
return x.Make
}
return ""
}
func (x *LookupResponse) GetColour() string {
if x != nil {
return x.Colour
}
return ""
}
func (x *LookupResponse) GetYearOfManufacture() int32 {
if x != nil {
return x.YearOfManufacture
}
return 0
}
func (x *LookupResponse) GetCo2Emissions() float64 {
if x != nil {
return x.Co2Emissions
}
return 0
}
func (x *LookupResponse) GetEngineCapacity() int32 {
if x != nil {
return x.EngineCapacity
}
return 0
}
func (x *LookupResponse) GetFuelType() string {
if x != nil {
return x.FuelType
}
return ""
}
func (x *LookupResponse) GetMonthOfFirstRegistration() string {
if x != nil {
return x.MonthOfFirstRegistration
}
return ""
}
func (x *LookupResponse) GetMotStatus() string {
if x != nil {
return x.MotStatus
}
return ""
}
func (x *LookupResponse) GetMotExpiry() string {
if x != nil {
return x.MotExpiry
}
return ""
}
func (x *LookupResponse) GetTaxDueDate() string {
if x != nil {
return x.TaxDueDate
}
return ""
}
func (x *LookupResponse) GetTaxStatus() string {
if x != nil {
return x.TaxStatus
}
return ""
}
func (x *LookupResponse) GetTypeApproval() string {
if x != nil {
return x.TypeApproval
}
return ""
}
func (x *LookupResponse) GetWheelplan() string {
if x != nil {
return x.Wheelplan
}
return ""
}
func (x *LookupResponse) GetLastV5Issued() string {
if x != nil {
return x.LastV5Issued
}
return ""
}
var File_proto_vehicle_proto protoreflect.FileDescriptor
var file_proto_vehicle_proto_rawDesc = []byte{
0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x65, 0x68, 0x69, 0x63, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x65, 0x68, 0x69, 0x63, 0x6c, 0x65, 0x22, 0x33,
0x0a, 0x0d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x22, 0x0a, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x22, 0xa2, 0x04, 0x0a, 0x0e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74,
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65,
0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61,
0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x61, 0x6b, 0x65, 0x12, 0x16,
0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x12, 0x2e, 0x0a, 0x13, 0x79, 0x65, 0x61, 0x72, 0x5f, 0x6f,
0x66, 0x5f, 0x6d, 0x61, 0x6e, 0x75, 0x66, 0x61, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x04, 0x20,
0x01, 0x28, 0x05, 0x52, 0x11, 0x79, 0x65, 0x61, 0x72, 0x4f, 0x66, 0x4d, 0x61, 0x6e, 0x75, 0x66,
0x61, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x32, 0x5f, 0x65, 0x6d,
0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x63,
0x6f, 0x32, 0x45, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x65,
0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x43, 0x61, 0x70, 0x61,
0x63, 0x69, 0x74, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x75, 0x65, 0x6c, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x75, 0x65, 0x6c, 0x54, 0x79, 0x70,
0x65, 0x12, 0x3d, 0x0a, 0x1b, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x5f, 0x6f, 0x66, 0x5f, 0x66, 0x69,
0x72, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x4f, 0x66, 0x46,
0x69, 0x72, 0x73, 0x74, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x6f, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x09,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x6f, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x1d, 0x0a, 0x0a, 0x6d, 0x6f, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x0a, 0x20,
0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x6f, 0x74, 0x45, 0x78, 0x70, 0x69, 0x72, 0x79, 0x12, 0x20,
0x0a, 0x0c, 0x74, 0x61, 0x78, 0x5f, 0x64, 0x75, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x0b,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x78, 0x44, 0x75, 0x65, 0x44, 0x61, 0x74, 0x65,
0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x78, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0c,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x23, 0x0a, 0x0d, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c,
0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x79, 0x70, 0x65, 0x41, 0x70, 0x70, 0x72,
0x6f, 0x76, 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x70, 0x6c, 0x61,
0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x70, 0x6c,
0x61, 0x6e, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x76, 0x35, 0x5f, 0x69, 0x73,
0x73, 0x75, 0x65, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74,
0x56, 0x35, 0x49, 0x73, 0x73, 0x75, 0x65, 0x64, 0x32, 0x46, 0x0a, 0x07, 0x56, 0x65, 0x68, 0x69,
0x63, 0x6c, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x12, 0x16, 0x2e,
0x76, 0x65, 0x68, 0x69, 0x63, 0x6c, 0x65, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x76, 0x65, 0x68, 0x69, 0x63, 0x6c, 0x65, 0x2e,
0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x76, 0x65, 0x68, 0x69,
0x63, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_vehicle_proto_rawDescOnce sync.Once
file_proto_vehicle_proto_rawDescData = file_proto_vehicle_proto_rawDesc
)
func file_proto_vehicle_proto_rawDescGZIP() []byte {
file_proto_vehicle_proto_rawDescOnce.Do(func() {
file_proto_vehicle_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_vehicle_proto_rawDescData)
})
return file_proto_vehicle_proto_rawDescData
}
var file_proto_vehicle_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_proto_vehicle_proto_goTypes = []interface{}{
(*LookupRequest)(nil), // 0: vehicle.LookupRequest
(*LookupResponse)(nil), // 1: vehicle.LookupResponse
}
var file_proto_vehicle_proto_depIdxs = []int32{
0, // 0: vehicle.Vehicle.Lookup:input_type -> vehicle.LookupRequest
1, // 1: vehicle.Vehicle.Lookup:output_type -> vehicle.LookupResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_proto_vehicle_proto_init() }
func file_proto_vehicle_proto_init() {
if File_proto_vehicle_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_vehicle_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_vehicle_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LookupResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_vehicle_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_vehicle_proto_goTypes,
DependencyIndexes: file_proto_vehicle_proto_depIdxs,
MessageInfos: file_proto_vehicle_proto_msgTypes,
}.Build()
File_proto_vehicle_proto = out.File
file_proto_vehicle_proto_rawDesc = nil
file_proto_vehicle_proto_goTypes = nil
file_proto_vehicle_proto_depIdxs = nil
}

View File

@@ -0,0 +1,93 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/vehicle.proto
package vehicle
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/micro/v3/service/api"
client "github.com/micro/micro/v3/service/client"
server "github.com/micro/micro/v3/service/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for Vehicle service
func NewVehicleEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Vehicle service
type VehicleService interface {
Lookup(ctx context.Context, in *LookupRequest, opts ...client.CallOption) (*LookupResponse, error)
}
type vehicleService struct {
c client.Client
name string
}
func NewVehicleService(name string, c client.Client) VehicleService {
return &vehicleService{
c: c,
name: name,
}
}
func (c *vehicleService) Lookup(ctx context.Context, in *LookupRequest, opts ...client.CallOption) (*LookupResponse, error) {
req := c.c.NewRequest(c.name, "Vehicle.Lookup", in)
out := new(LookupResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Vehicle service
type VehicleHandler interface {
Lookup(context.Context, *LookupRequest, *LookupResponse) error
}
func RegisterVehicleHandler(s server.Server, hdlr VehicleHandler, opts ...server.HandlerOption) error {
type vehicle interface {
Lookup(ctx context.Context, in *LookupRequest, out *LookupResponse) error
}
type Vehicle struct {
vehicle
}
h := &vehicleHandler{hdlr}
return s.Handle(s.NewHandler(&Vehicle{h}, opts...))
}
type vehicleHandler struct {
VehicleHandler
}
func (h *vehicleHandler) Lookup(ctx context.Context, in *LookupRequest, out *LookupResponse) error {
return h.VehicleHandler.Lookup(ctx, in, out)
}

View File

@@ -0,0 +1,48 @@
syntax = "proto3";
package vehicle;
option go_package = "./proto;vehicle";
service Vehicle {
rpc Lookup(LookupRequest) returns (LookupResponse) {}
}
// Lookup a UK vehicle by it's registration number
message LookupRequest {
// the vehicle registration number
string registration = 1;
}
message LookupResponse {
// registration number
string registration = 1;
// make of vehicle
string make = 2;
// colour of vehicle
string colour = 3;
// year of manufacture
int32 year_of_manufacture = 4;
// co2 emmissions
double co2_emissions = 5;
// engine capacity
int32 engine_capacity = 6;
// fuel type e.g petrol, diesel
string fuel_type = 7;
// month of first registration
string month_of_first_registration = 8;
// mot status
string mot_status = 9;
// mot expiry
string mot_expiry = 10;
// tax due data
string tax_due_date = 11;
// tax status
string tax_status = 12;
// type approvale
string type_approval = 13;
// wheel plan
string wheelplan = 14;
// date of last v5 issue
string last_v5_issued = 15;
}