Skip to content

Commit

Permalink
add grpc-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
birdayz committed Dec 3, 2018
1 parent 213982a commit 89b774b
Show file tree
Hide file tree
Showing 7 changed files with 835 additions and 19 deletions.
44 changes: 29 additions & 15 deletions pkg/apiserver/apipb/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 40 additions & 4 deletions pkg/apiserver/apipb/api.proto
Expand Up @@ -5,10 +5,46 @@ package infinimesh.api;
option go_package = "apipb";

import "pkg/registry/registrypb/device_registry.proto";
import "protoc-gen-swagger/options/annotations.proto";
import "google/api/annotations.proto";

option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
host: "api.infinimesh.io";
info: {
title: "Infinimesh IoT Platform";
description: "Cloud Native IoT Platform";
version: "0.0.1";
contact: {
name: "Infinimesh";
url: "http://infinimesh.io";
email: "joe@infinimesh.io";
};
};
schemes: HTTPS;
consumes: "application/json";
produces: "application/json";
};

service Devices {
rpc Create(infinimesh.deviceregistry.CreateRequest) returns (infinimesh.deviceregistry.CreateResponse);
rpc GetByName(infinimesh.deviceregistry.GetByNameRequest) returns (infinimesh.deviceregistry.GetByNameResponse);
rpc List(infinimesh.deviceregistry.ListDevicesRequest) returns (infinimesh.deviceregistry.ListResponse);
rpc Delete(infinimesh.deviceregistry.DeleteRequest) returns (infinimesh.deviceregistry.DeleteResponse);
rpc Create(infinimesh.deviceregistry.CreateRequest) returns (infinimesh.deviceregistry.CreateResponse) {
option (google.api.http) = {
post: "/devices"
body: "device"
};
};
rpc GetByName(infinimesh.deviceregistry.GetByNameRequest) returns (infinimesh.deviceregistry.GetByNameResponse) {
option (google.api.http) = {
get: "/devices/{name}"
};
};
rpc List(infinimesh.deviceregistry.ListDevicesRequest) returns (infinimesh.deviceregistry.ListResponse) {
option (google.api.http) = {
get: "/devices"
};
}
rpc Delete(infinimesh.deviceregistry.DeleteRequest) returns (infinimesh.deviceregistry.DeleteResponse) {
option (google.api.http) = {
delete: "/devices/{name}"
};
};
}
5 changes: 5 additions & 0 deletions prototool.yaml
Expand Up @@ -3,6 +3,8 @@ excludes:

protoc:
version: 3.6.1
includes:
- tools/proto/

lint:
rules:
Expand All @@ -15,6 +17,9 @@ lint:
generate:
go_options:
import_path: "github.com/infinimesh/infinimesh"
extra_modifiers:
google/api/annotations.proto: google.golang.org/genproto/googleapis/api/annotations
google/api/http.proto: google.golang.org/genproto/googleapis/api/annotations
plugins:
- name: go
type: go
Expand Down
31 changes: 31 additions & 0 deletions tools/proto/google/api/annotations.proto
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.api;

import "google/api/http.proto";
import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}

0 comments on commit 89b774b

Please sign in to comment.