-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from GoogleCloudPlatform/remote-api
Adding remote api sample
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 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.') | ||
raise | ||
|
||
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] |