"""Simple ProtoRPC request/response with a datetime.""" datetime_value = message_types.DateTimeField(1) class TestIntegers(messages.Message): """Simple ProtoRPC request/response with a few integer types.""" var_int32 = messages.IntegerField(1, variant=messages.Variant.INT32) var_int64 = messages.IntegerField(2, variant=messages.Variant.INT64) var_repeated_int64 = messages.IntegerField(3, variant=messages.Variant.INT64, repeated=True) var_sint64 = messages.IntegerField(4, variant=messages.Variant.SINT64) var_uint64 = messages.IntegerField(5, variant=messages.Variant.UINT64) my_api = endpoints.api(name='test_service', version='v1') @my_api.api_class() class TestService(remote.Service): """ProtoRPC test class for Cloud Endpoints.""" @endpoints.method(message_types.VoidMessage, TestResponse, http_method='GET', name='test', path='test', scopes=[]) def test(self, unused_request): return TestResponse(text='Test response') @endpoints.method(message_types.VoidMessage,
import pledges import messages from google.appengine.ext import endpoints from protorpc import remote api_class = endpoints.api(name='pledgecounter', version='v0.1').api_class @api_class(resource_name='pledges') class PledgeService(remote.Service): @endpoints.method(messages.CreatePledgeRequest, messages.CreatePledgeResponse, path='pledges', http_method='POST') def create(self, request): try: pledge = pledges.Pledge.create(request.pledge.email, request.pledge.first_name, request.pledge.last_name) except pledges.PledgeExistsError as e: raise endpoints.BadRequestException(str(e)) message = messages.CreatePledgeResponse() message.pledge = pledge.to_message() message.pledge_count = pledges.Pledge.count() + 1 return message @endpoints.method(messages.CountPledgesRequest, messages.CountPledgesResponse, path='pledges/count', http_method='GET')
"""Simple ProtoRPC request, for testing.""" name = messages.StringField(1) number = messages.IntegerField(2) class TestResponse(messages.Message): """Simple ProtoRPC response with a text field.""" text = messages.StringField(1) class TestDateTime(messages.Message): """Simple ProtoRPC request/response with a datetime.""" datetime_value = message_types.DateTimeField(1) my_api = endpoints.api(name='test_service', version='v1') @my_api.collection() class TestService(remote.Service): """ProtoRPC test class for Cloud Endpoints.""" @endpoints.method(message_types.VoidMessage, TestResponse, http_method='GET', name='test', path='test', scopes=[]) def test(self, unused_request): return TestResponse(text='Test response') @endpoints.method(TestRequest, TestResponse, http_method='POST', name='t2name', path='t2path', scopes=[])
import pledges import messages from google.appengine.ext import endpoints from protorpc import remote api_class = endpoints.api(name='pledgecounter', version='v0.1').api_class @api_class(resource_name='pledges') class PledgeService(remote.Service): @endpoints.method( messages.CreatePledgeRequest, messages.CreatePledgeResponse, path='pledges', http_method='POST') def create(self, request): try: pledge = pledges.Pledge.create( request.pledge.email, request.pledge.first_name, request.pledge.last_name) except pledges.PledgeExistsError as e: raise endpoints.BadRequestException(str(e)) message = messages.CreatePledgeResponse() message.pledge = pledge.to_message() message.pledge_count = pledges.Pledge.count() + 1 return message @endpoints.method( messages.CountPledgesRequest, messages.CountPledgesResponse, path='pledges/count', http_method='GET')