From 8d50d51d80f55590e4b2901b91fd611f43421d13 Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Fri, 18 Nov 2016 16:23:08 -0800 Subject: [PATCH 1/2] Add gRPC api config files. --- endpoints/bookstore-grpc/bookstore.yaml | 36 ++++++ endpoints/bookstore-grpc/bookstore_http.yaml | 114 +++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 endpoints/bookstore-grpc/bookstore.yaml create mode 100644 endpoints/bookstore-grpc/bookstore_http.yaml diff --git a/endpoints/bookstore-grpc/bookstore.yaml b/endpoints/bookstore-grpc/bookstore.yaml new file mode 100644 index 00000000000..a7d4c576b8c --- /dev/null +++ b/endpoints/bookstore-grpc/bookstore.yaml @@ -0,0 +1,36 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# 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. + +# +# A Bookstore example API configuration. +# +# Below, replace MY_PROJECT_ID with your Google Cloud Project ID. +# + +# The configuration schema is defined by service.proto file +# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto +type: google.api.Service +config_version: 3 + +# +# Name of the service configuration. +# +name: bookstore..appspot.com + +# +# API title to appear in the user interface (Google Cloud Console). +# +title: Bookstore gRPC API +apis: +- name: endpoints.examples.bookstore.Bookstore diff --git a/endpoints/bookstore-grpc/bookstore_http.yaml b/endpoints/bookstore-grpc/bookstore_http.yaml new file mode 100644 index 00000000000..81b2f1e5679 --- /dev/null +++ b/endpoints/bookstore-grpc/bookstore_http.yaml @@ -0,0 +1,114 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# 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. + +# +# Example HTTP rules for Bookstore +# + +# The configuration schema is defined by service.proto file +# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto +type: google.api.Service +config_version: 3 + +# +# HTTP rules define translation from HTTP/REST/JSON to gRPC. With these rules +# HTTP/REST/JSON clients will be able to call the Bookstore service. +# +http: + rules: + # + # HTTP/REST/JSON clients can call the 'ListShelves' method of the Bookstore + # service using the GET HTTP verb and the '/shelves' URL path. The response + # will the JSON representation of the 'ListShelvesResponse' message. + # + # Client example (Assuming your service is hosted at the given 'DOMAIN_NAME'): + # curl http://DOMAIN_NAME/v1/shelves + # + - selector: endpoints.examples.bookstore.Bookstore.ListShelves + get: /v1/shelves + # + # 'CreateShelf' can be called using the POST HTTP verb and the '/shelves' URL + # path. The posted HTTP body is the JSON respresentation of the 'shelf' field + # of 'CreateShelfRequest' protobuf message. + # + # Client example: + # curl -d '{"theme":"Music"}' http://DOMAIN_NAME/v1/shelves + # + - selector: endpoints.examples.bookstore.Bookstore.CreateShelf + post: /v1/shelves + body: shelf + # + # 'GetShelf' is available via the GET HTTP verb and '/shelves/{shelf}' URL + # path, where {shelf} is the value of the 'shelf' field of 'GetShelfRequest' + # protobuf message. + # + # Client example - returns the first shelf: + # curl http://DOMAIN_NAME/v1/shelves/1 + # + - selector: endpoints.examples.bookstore.Bookstore.GetShelf + get: /v1/shelves/{shelf} + # + # 'DeleteShelf' can be called using the DELETE HTTP verb and + # '/shelves/{shelf}' URL path, where {shelf} is the value of the 'shelf' field + # of 'DeleteShelfRequest' protobuf message. + # + # Client example - deletes the second shelf: + # curl -X DELETE http://DOMAIN_NAME/v1/shelves/2 + # + - selector: endpoints.examples.bookstore.Bookstore.DeleteShelf + delete: /v1/shelves/{shelf} + # + # 'ListBooks' can be called using the GET HTTP verb and + # '/shelves/{shelf}/books' URL path, where {shelf} is the value of the 'shelf' + # field of 'ListBooksRequest' protobuf message. + # + # Client example - list the books from the first shelf: + # curl http://DOMAIN_NAME/v1/shelves/1/books + # + - selector: endpoints.examples.bookstore.Bookstore.ListBooks + get: /v1/shelves/{shelf}/books + # + # 'CreateBook' can be called using the POST HTTP verb and + # '/shelves/{shelf}/books' URL path, where {shelf} is the value of the 'shelf' + # field of 'CreateBookRequest' protobuf message and the posted HTTP body is + # the JSON representation of the 'book' field of 'CreateBookRequest' message. + # + # Client example - create a new book in the first shelf: + # curl -d '{"author":"foo","title":"bar"}' http://DOMAIN_NAME/v1/shelves/1/books + # + - selector: endpoints.examples.bookstore.Bookstore.CreateBook + post: /v1/shelves/{shelf}/books + body: book + # + # 'GetBook' can be called using the GET HTTP verb and + # '/shelves/{shelf}/books/{book}' URL path, where {shelf} is the value of the + # 'shelf' field of 'GetShelfRequest' protobuf message and {book} is the value + # of the 'book' field of the 'GetShelfRequest' message. + # + # Client example - get the first book from the second shelf: + # curl http://DOMAIN_NAME/v1/shelves/2/books/1 + # + - selector: endpoints.examples.bookstore.Bookstore.GetBook + get: /v1/shelves/{shelf}/books/{book} + # + # 'DeleteBook' can be called using DELETE HTTP verb and + # '/shelves/{shelf}/books/{book}' URL path, where {shelf} is the value of the + # 'shelf' field of 'DeleteShelfRequest' protobuf message and {book} is the + # value of the 'book' field of the 'DeleteShelfRequest' message. + # + # Client example - delete the first book from the first shelf: + # curl -X DELETE http://DOMAIN_NAME/v1/shelves/1/books/1 + # + - selector: endpoints.examples.bookstore.Bookstore.DeleteBook + delete: /v1/shelves/{shelf}/books/{book} From 409fd932ef943e9e82dd0696890c04bedc454320 Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Mon, 21 Nov 2016 12:00:27 -0800 Subject: [PATCH 2/2] Renamed bookstore.yaml to api_config.yaml --- endpoints/bookstore-grpc/{bookstore.yaml => api_config.yaml} | 0 .../bookstore-grpc/{bookstore_http.yaml => http_api_config.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename endpoints/bookstore-grpc/{bookstore.yaml => api_config.yaml} (100%) rename endpoints/bookstore-grpc/{bookstore_http.yaml => http_api_config.yaml} (100%) diff --git a/endpoints/bookstore-grpc/bookstore.yaml b/endpoints/bookstore-grpc/api_config.yaml similarity index 100% rename from endpoints/bookstore-grpc/bookstore.yaml rename to endpoints/bookstore-grpc/api_config.yaml diff --git a/endpoints/bookstore-grpc/bookstore_http.yaml b/endpoints/bookstore-grpc/http_api_config.yaml similarity index 100% rename from endpoints/bookstore-grpc/bookstore_http.yaml rename to endpoints/bookstore-grpc/http_api_config.yaml