Skip to content

Commit

Permalink
Adding remote api sample
Browse files Browse the repository at this point in the history
Change-Id: I73effffef6fafa576fd8187edefb0dd1ce1fb9d5
  • Loading branch information
Jon Wayne Parrott committed Apr 20, 2016
1 parent 176ec8c commit 94351e5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
6 changes: 6 additions & 0 deletions appengine/remote_api/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
runtime: python27
api_version: 1
threadsafe: true

builtins:
- remote_api: on
53 changes: 53 additions & 0 deletions appengine/remote_api/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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.

"""Sample app that uses the Google App Engine Remote API to make calls to the
live App Engine APIs."""

# [START all]

import argparse

try:
import dev_appserver
dev_appserver.fix_sys_path()
except ImportError:
print('Please make sure the App Engine SDK is in your PYTHONPATH.')

from google.appengine.ext import ndb
from google.appengine.ext.remote_api import remote_api_stub


def main(project_id):
remote_api_stub.ConfigureRemoteApiForOAuth(
'{}.appspot.com'.format(project_id),
'/_ah/remote_api')

# List the first 10 keys in the datastore.
keys = ndb.Query().fetch(10, keys_only=True)

for key in keys:
print(key)


if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('project_id', help='Your Project ID.')

args = parser.parse_args()

main(args.project_id)
# [END all]

0 comments on commit 94351e5

Please sign in to comment.