コード例 #1
0
 def update_pyp(self, request):
     pyp = Pyp.get_by_id(request.id)
     if not pyp:
         raise endpoints.NotFoundException(
             "The policy or program ID: " + str(request.id) + " doesn't exist")
     updated_pyp = Pyp.update(pyp, request)
     if not updated_pyp:
         raise endpoints.InternalServerErrorException('Something went wrong')
     return PypListResponse(
         pyps=[PypApiHelper().to_message(pyp)])
コード例 #2
0
 def delete_pyp(self, request):
     pyp = Pyp.get_by_id(request.id)
     if not pyp:
         raise endpoints.NotFoundException(
             "The policy or program ID: " + str(request.id) + " doesn't exist")
     pyp.key.delete()
     return message_types.VoidMessage()
コード例 #3
0
 def get_pyp(self, request):
     pyp = Pyp.get_by_id(request.id)
     if not pyp:
         raise endpoints.NotFoundException(
             "The policy or program ID: " + str(request.id) + " doesn't exist")
     return PypListResponse(
         pyps=[PypApiHelper().to_message(pyp)])
コード例 #4
0
 def create_pyp(self, request):
     if not (request.title and request.country):
         raise endpoints.BadRequestException('Title and country are required')
     pyp = Pyp.create(request)
     if not pyp:
         raise endpoints.InternalServerErrorException('Something went wrong')
     return PypListResponse(
         pyps=[PypApiHelper().to_message(pyp)])
コード例 #5
0
 def get_pyps(self, request):
     pyps = Pyp.get_all()
     return PypListResponse(
         pyps=[PypApiHelper().to_message(pyp) for pyp in pyps if pyps])