My goal is to build an app powered by Google App Engine + NDB Datastore which facilitates a RESTful API so that I can use VueJS in the frontend.
I am at a lost with this task. From my research, I have been pointed towards endpoints-proto-datastore and Google Cloud Endpoints. The front page of endpoints-proto-datastore states the following:
This library is intended to be used with the Python version of Google
Cloud Endpoints.
This sentence suggests that even this library requires, depends or relates to Google Cloud Endpoints. I have tried to get started with Google Cloud Endpoints and end up dabbling with swagger.io and the Open API. I've been through the rabbit hole for months. At this point, I'm seeking some clarification.
I have the following questions:
What is the best approach to achieving my goal?
What is the relationship between these two pieces of the puzzle (Cloud Endpoints and endpoints-proto-datastore)?
What is the simplest way to get started with my goal?
Thank you.
endpoints-proto-datastore is a library designed to be used with the Cloud Endpoints Framework for Python. However, endpoints-proto-datastore is not itself part of the Cloud Endpoints Framework, and is not supported by Google.
While Cloud Datastore is accessible from any environment, ndb Datastore can be used only in App Engine's Standard environment, so you would need to use the Cloud Endpoints Framework for Python, rather than the regular Cloud Endpoints functionality.
Related
I am trying to get Firestore working and I am wondering which Python package I should use. It appears that there is some overlap between the functionality of the firebase_admin.firestore and google.cloud.firestore, as well as between firebase_admin.credentials and google.auth.credentials. But it also seems like there is some incompatibility between them, or at least they can't be used together.
What is the difference between these Python packages, and which is it recommended that a beginner should use?
Thanks!
Here’s a simple answer for beginners, as requested:
Google provides Firebase and Google Cloud Platform as two different suites of products. Some Google products are shared across these, Cloud Firestore being one of them.
So, if one is using Cloud Firestore from within a Firebase project, it is recommended to use firebase_admin.firestore and firebase_admin.credentials packages and other Firebase APIs as required.
If on the other hand, one is using the Google Cloud Platform project, it is recommended to use google.cloud.firestore, and google.auth.credentials packages and other GCP Cloud APIs as required.
HTH, reach out for any additional questions/queries.
If you plan to use other Firebase functionality (e.g. eventually have mobile users that authenticate with Firebase, and connect to their Firestore instance from their phones or web pages), then firebase_admin is the best choice.
Otherwise, if you plan on using Firestore without Firebase, then google.cloud.firestore would be more straight-forward.
The same applies to the credentials libraries.
And the main differences are between the Cloud services:
Cloud Firestore supports SDKs for Android, IOS, and Web. Combined with Cloud Firestore security rules and Firebase Auth, the mobile and web SDKs support serverless app architectures where clients connect directly to your Cloud Firestore database. With a serverless architecture, you do not need to maintain an intermediary server between your clients and your Cloud Firestore database.
The Firebase Admin SDKs bundle the Google Cloud client libraries for Cloud Firestore alongside client libraries and SDKs for several other Firebase features. And it is for accessing your Firebase products on a backend server you control, which could be Cloud Functions, or even your desktop. It will typically have full access to everything, as determined by the service account you used to initialize it.
I am a newbie who wants to deploy his flask app using google cloud functions. When I am searching it online, people are telling me to deploy it as a Flask app. I want to ask if there is any difference between those two.
A cloud instance or deploying flask app on google cloud VS cloud serverless function
As described by John and Kolban, Cloud Functions is a single purpose endpoint. You want to perform 1 thing, deploy 1 function.
However, if you want to have a many consistent things, like a microservice, you will have to deploy several endpoints that allow you to perform a CRUD on the same data object. You should prefer to deploy several endpoints (CRUD) and to have the capability to easily reuse class and object definitions and business logic. For this, a Flask webserver is that I recommend (and I prefer, I wrote an article on this).
A packaging in Cloud Run is the best for having a serverless platform and pay-per-use pricing model (and automatic scaling and...).
There is an additional great thing: Cloud Functions request object is based on Flask request object. By the way, and it's that I also present in my article, it's easy to switch from one platform to another one. You only have to choose according with your requirements, your skills,... I also wrote another article on this
If you deploy your Flask app as an application in a Compute Engine VM instance, you are basically configuring a computer and application to run your code. The notion of Cloud Functions relieves you from the chore and toil of having to create and manage the environment in which your program runs. A marketing mantra is "You bring the code, we bring the environment". When using Cloud Functions all you need do is code your application logic. The maintenance of the server, scaling up as load increases, making sure the server is available and much more is taken care of for you. When you run your code in your own VM instance, it is your responsibility to manage the whole environment.
References:
HTTP Functions
Deploying a Python serverless function in minutes with GCP
We are using GCP's Firebase with Firestore for a new mobile app we are developing. As part of this effort we need to deploy a number of cloud functions which will act as Firestore triggers for doing some back end processing.
Our intention is to keep the deploys encapsulated inside of Firebase by using the firebase cli tools. However when we attempt to initiate the Firebase project for functions using the "firebase init functions" call the only two language options are "Javascript" and "Typescript", and the only deployable stack seems to be Node.js.
On previous GCP projects we had deployed Python based cloud functions (using the gcloud cli) and ideally we'd like to continue using Python for our Firebase cloud functions. So my questions are:
is it possible to deploy Python-based Firebase cloud functions? If not:
can we simply go back to deploying Python-based GCP cloud functions using the gcloud cli and still have them work as Firestore triggers?
Thanks
The Firebase CLI does not support deploying functions written in python.
You can certainly write Cloud Firestore triggers in python and deploy them with gcloud.
One thing you might not be aware of: the underlying Cloud Functions product is the same no matter how you deploy your functions. Firebase just adds tools and APIs on top of the existing Google Cloud Functions infrastructure. There is really no such thing as a "Firebase Cloud Function". There is just Cloud Functions, and you have options about how you can write and deploy them, either using gcloud, or the Firebase CLI.
I'm looking for ways to expose business logic that I've implemented in a Google App Engine application as an RPC service for mobile clients to call; there seem to be two ways of doing this:
Google Protocol RPC Library for App Engine. The examples there had me create a WSGI service using protorpc.wsgi.service.service_mapping exposing service classes whose methods are decorated with protorpc.remote.method.
Cloud Endpoints Framework for App Engine. The examples there had me create a Cloud Endpoint using endpoints.api_server exposing service classes whose methods are decorated with endpoints.method.
I started with Google Protocol RPC library because that was the main thing that was linked from the App Engine documentation, and got the RPC working, which I can verify with a simple curl command. But I could not find how to generate Android / iOS client libraries.
After searching longer, I found Cloud Endpoints Framework for App Engine, which seems to be offering the option to generate Android / iOS libraries, but I'm confused by the similarities between the two options (e.g. it seems that Cloud Endpoints Framework relies at least partly on protorpc as well, but the decorators and handlers are different) and am unsure which one I should be choosing.
(NB: I understand that Cloud Endpoints are available for more environments, such as Compute Engine, but I want to stay in App Engine standard as much as possible.)
My questions:
Can someone articulate the differences between these two seemingly very similar solutions? What are some situations in which I might prefer using the Google Protocol RPC library over the Cloud Endpoints Framework for App Engine? What are some of the other situations in which Cloud Endpoints Framework is preferable?
Is there a way to generate client libraries from API definitions written for the Google Protocol RPC library? Now that I've gotten the simple Google Protocol RPC library version working, I'm not sure I should do the work to migrate over to Cloud Endpoints Framework for App Engine just for the benefit of client code generation.
I'm trying to setup a flask app on google app engine that will be something of a frontend management console for google container engine. Google has put out working APIs to spin up a container cluster, but it does not look like they have put out (python) APIs to administer kubernetes. That is, everything needed implement services, pods, RCs etc. seems to be setup to run through bash scripting. This is not compatible with the restrictions of google's app engine.
Is there a commonly accepted solution/package for this? Would it make more sense to abandon appengine in favor for a managed VM (not ideal)?
Thanks
As I mentioned in Submit jobs using API Client Library for Python?, the Kubernetes API uses a standard swagger specification, so it should be possible to generate a python client library. There is also pykube if you want to experiment with a existing client library.