Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud datastore access to appengine python with out Managed vm or Compute engine. #405

Closed
sasivarunan opened this issue Dec 3, 2014 · 6 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@sasivarunan
Copy link

All the demos and guides shows how to access cloud datastore from python on GCE or from local machine, but is it possible to access cloud datastore from python hosted on a GAE ?

from gcloud import datastore
import os
import webapp2

# dataset = datastore.get_dataset(
#     'appid',
#     'xxx@developer.gserviceaccount.com',
#     os.path.abspath("appid.p12"))
#
# entity = dataset.entity('People')
# entity['name'] = 'helloworld'
# entity['age'] = 25
# entity.save()
# print 'Hello, world!'
class MainPage(webapp2.RequestHandler):
    def get(self):
        dataset = datastore.get_dataset(
            'appid',
            'xxxx@developer.gserviceaccount.com',
            os.path.abspath("appid.p12"))

        entity = dataset.entity('People')
        entity['name'] = 'helloworld'
        entity['age'] = 25
        entity.save()
        self.response.out.write('Hello')


application = webapp2.WSGIApplication([
    ('/', MainPage)
], debug=True)

I don't seem to get this working. like https://cloud.google.com/appengine/docs/python/gettingstartedpython27/helloworld

If anyone has this working on appengine please share. Thanks

@dhermes
Copy link
Contributor

dhermes commented Dec 3, 2014

@sasivarunan It is on our todo list, but you can use the datastore directly using ndb.

Is there a reason you can't or don't want to do this?

The most difficult part for you will be auth, but IIRC you can get an access token for the service account associated with you app. (It's possible in Go, for example, which means the underlying RPC is available in Python.)

I've gotta run but will look into this more. You should check out how to create a Credentials object from the oauth2client library with only an access token.

@sasivarunan
Copy link
Author

I guess with ndb i can only access only native datastore associated with my app id not a cloud datastore

@dhermes
Copy link
Contributor

dhermes commented Dec 3, 2014

I see. It's not a typical use case. Do you actually need to access more than one datastore instance or do you instead need non-App Engine clients to access the same one?

@sasivarunan
Copy link
Author

need to access more than one datastore instance
thanks

@dhermes
Copy link
Contributor

dhermes commented Dec 3, 2014

Update, you can get an access token for the application via the app_identity API. Luckily the oauth2client.appengine.AppAssertionCredentials class supports this.

You can use these credentials with this library via the following:

from gcloud.datastore import SCOPE
from gcloud.datastore.connection import Connection

from oauth2client.appengine import AppAssertionCredentials

app_credentials = AppAssertionCredentials(SCOPE)
connection = Connection(credentials=app_credentials)

I have not tested this yet, so am not 100% sure (will try to later).

Also, I am not closing this bug since we'd like to support this.

@dhermes
Copy link
Contributor

dhermes commented Dec 4, 2014

I'm closing out. @sasivarunan feel free to follow along in #335 where I'll be addressing this and much more shortly.

@dhermes dhermes closed this as completed Dec 4, 2014
@jgeewax jgeewax added the api: datastore Issues related to the Datastore API. label Jan 30, 2015
@jgeewax jgeewax modified the milestone: Datastore Stable Jan 30, 2015
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 7, 2020
parthea pushed a commit that referenced this issue Jun 4, 2023
* chore(main): release 2.1.0

* Update constraints-3.7.txt

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Holt Skinner <holtskinner@google.com>
parthea added a commit that referenced this issue Jun 4, 2023
…d project) (#405)

* docs(samples): update samples to include new parent levels (folder and project)

* change parent_name to parent_id

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* updated acc to review comments

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this issue Jul 6, 2023
…ve] (#405)

Source-Link: https://togithub.com/googleapis/synthtool/commit/6ed3a831cb9ff69ef8a504c353e098ec0192ad93
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3abfa0f1886adaf0b83f07cb117b24a639ea1cb9cffe56d43280b977033563eb
parthea pushed a commit that referenced this issue Aug 15, 2023
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 459095142

Source-Link: googleapis/googleapis@4f1be99

Source-Link: googleapis/googleapis-gen@ae686d9
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9

docs: improve comments for protos
PiperOrigin-RevId: 458250124

Source-Link: googleapis/googleapis@913b9bd

Source-Link: googleapis/googleapis-gen@5601594
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTYwMTU5NGYxY2RmNDVkOWRmMjZmMjQ1NjA0YzMzM2UzZmYzODM4ZCJ9

docs: clarify descriptions of the AdvancedSettings and WebhookRequest data types
PiperOrigin-RevId: 458000126

Source-Link: googleapis/googleapis@c425ac6

Source-Link: googleapis/googleapis-gen@1b0446d
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMWIwNDQ2ZGJhYmEwODZmMWJmNjRkOTc2YjE4MGQ2YWI2ZjMzOGViNiJ9

feat: add audience parameter
PiperOrigin-RevId: 456827138

Source-Link: googleapis/googleapis@23f1a15

Source-Link: googleapis/googleapis-gen@4075a85
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9

feat(v3): added webhook_config
The webhook_config field was added to the Environment resource to support environment-level webhook overrides as a preview feature.

Support for the Google Cloud Locations API has also been added.

PiperOrigin-RevId: 454733966

Source-Link: googleapis/googleapis@d5d0f8d

Source-Link: googleapis/googleapis-gen@e5a3716
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTVhMzcxNmNkYzFjODU4YWYyY2VjYjljODNiOTNhY2NkOGVhNWY4MiJ9

feat(v3beta1): added webhook_config
The webhook_config field was added to the Environment resource to support environment-level webhook overrides as a preview feature.

Support for the Google Cloud Locations API has also been added.

PiperOrigin-RevId: 454731805

Source-Link: googleapis/googleapis@585fa8c

Source-Link: googleapis/googleapis-gen@e8aee07
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZThhZWUwN2ZkMzk0NTQzMWQ1YWM0ZGQyYmQ0YjRlOGRmYTZlMmMyZCJ9
parthea pushed a commit that referenced this issue Sep 22, 2023
…r compliance with a provided Binary Authorization platform policy via Binary Authorization Continuous Validation (#405)

* feat: Add preview support for monitoring a cluster's pods for compliance with a provided Binary Authorization platform policy via Binary Authorization Continuous Validation

PiperOrigin-RevId: 555745169

Source-Link: googleapis/googleapis@2edfcad

Source-Link: googleapis/googleapis-gen@cf19791
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2YxOTc5MWQ4MmViZjU2OTE3YmY2YjcwNGYyNzRhNGNjNWQ4OTU0NiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
* Update python-api-walkthrough.md

Dataproc python walkthrough update.

* Update submit_job_to_cluster.py

Dataproc python walkthrough update

* Update submit_job_to_cluster.py

docs: fix lint errors.
parthea pushed a commit that referenced this issue Sep 22, 2023
…p/templates/python_library/.kokoro (#405)

Source-Link: https://togithub.com/googleapis/synthtool/commit/bb171351c3946d3c3c32e60f5f18cee8c464ec51
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f62c53736eccb0c4934a3ea9316e0d57696bb49c1a7c86c726e9bb8a2f87dadf
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@eb78c98
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163
parthea pushed a commit that referenced this issue Oct 21, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea added a commit that referenced this issue Oct 21, 2023
* chore(python): drop python 3.6

Source-Link: googleapis/synthtool@4f89b13
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e7bb19d47c13839fe8c147e50e02e8b6cf5da8edd1af8b82208cd6f66cc2829c

* add api_description to .repo-metadata.json

* require python 3.7+ in setup.py

* remove python 3.6 sample configs

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix(deps): update extra for pandas >= 1.0.5

* exclude templated README

* update README

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: https://togithub.com/googleapis/synthtool/commit/30bd01b4ab78bf1b2a425816e15b3e7e090993dd
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9bc5fa3b62b091f60614c08a7fb4fd1d3e1678e326f34dd66ce1eefb5dc3267b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants