Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions appengine/endpoints/multiapi/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
runtime: python27
threadsafe: true
api_version: 1

handlers:
# The endpoints handler must be mapped to /_ah/spi.
# Apps send requests to /_ah/api, but the endpoints service handles mapping
# those requests to /_ah/spi.
- url: /_ah/spi/.*
script: main.api

libraries:
- name: pycrypto
version: 2.6
- name: endpoints
version: 1.0
52 changes: 52 additions & 0 deletions appengine/endpoints/multiapi/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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.

"""This is a sample multi-class API implemented using Cloud Ednpoints"""

import endpoints
from protorpc import messages
from protorpc import remote


class Request(messages.Message):
message = messages.StringField(1)


class Response(messages.Message):
message = messages.StringField(1)


# [START multiclass]
api_collection = endpoints.api(name='library', version='v1.0')


@api_collection.api_class(resource_name='shelves')
class Shelves(remote.Service):

@endpoints.method(Request, Response, path='list')
def list(self, request):
return Response()


@api_collection.api_class(resource_name='books', path='books')
class Books(remote.Service):

@endpoints.method(Request, Response, path='bookmark')
def bookmark(self, request):
return Response()
# [END multiclass]

# [START api_server]
api = endpoints.api_server([api_collection])
# [END api_server]
27 changes: 27 additions & 0 deletions appengine/endpoints/multiapi/main_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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.

import main


def test_shelves(testbed):
api = main.Shelves()
response = api.list(main.Request())
assert response


def test_books(testbed):
api = main.Books()
response = api.bookmark(main.Request())
assert response