I am trying to deploy an already built image to Cloud Run using .NET Cloud Client Libraries.
I need exactly the same behavior as gcloud run deploy hello --image=us-docker.pkg.dev/cloudrun/container/hello but with .NET Cloud Client Libraries.
Unfortunately, I cannot find an API that does that in https://cloud.google.com/dotnet/docs/reference.
I also tried downloading Cloud SDK from https://cloud.google.com/sdk/docs/install and inspecting the code with PyCharm.
The API is called Cloud Run Admin API.
Cloud Run Admin API
There is an SDK for .NET.
Cloud Run Admin API Client Library for .NET
Namespace Google.Apis.CloudRun.v1
Creating a Cloud Run service is fairly complicated. I recommend that you study the REST API first so that you understand the request body. The .NET library models the REST API.
Method: namespaces.services.create
The key item is the service resource:
Resource: Service
There is a quick way to learn the API request body. Create a simple Cloud Run example and then add the command line option --log-http. Save the output to a file and then study the HTTP request parameters and request body to decipher the very large data structures that are required to create a service.
gcloud run deploy --log-http
I wrote two articles on the Cloud Run Admin API:
Google Cloud Run Deep Dive – Understanding the APIs – Part 1
Google Cloud Run Deep Dive – Understanding the APIs – Part 2
Note: I wrote those articles two years ago. Cloud Run has advanced a lot since then. However, these articles will help you understand the low-level details of the service that were not published elsewhere at the time.
Related
I have deployed an AI model on Google Cloud Platform in the 'SavedModel' format. The model is able to make predictions when I enter sample input data through the 'Test & Use' facility on AI Platform.
Now, I would like to expose API endpoints so that other front end applications (eg. Android) can make use of this deployed model. What is the procedure to do so? I could not find much help in the documentations provided by Google.
I'm not 100% clear on your requirements, but you can make REST API calls with cURL.
ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
curl -X POST -d '{json-input}' https://ml.googleapis.com/v1/projects/{project-name}/models/{model-resource-name}:predict\?access_token\=${ACCESS_TOKEN}
Other resources:
https://cloud.google.com/ml-engine/docs/online-predict#requesting_predictions
https://cloud.google.com/ml-engine/docs/v1/predict-request#http-url-format
There are a lot of path's in order to serve your custom model but to make a concise answer to that question but you can deploy your custom model through an API endpoint following this workaround:
Upload your model into a bucket.
Create a model resource
Create a version.
Deploy
Once it's deployed, you can call the endpoint in your front-end applications.
(Bear in mind that batch predictions are not implemented on Python 3.x yet)
Endpoint URL request syntax:
POST https://ml.googleapis.com/v1/projects/{my-project}/models/{my-model}/versions/{my-version}:predict
Not specifying a version would redirect the request to your default version.
Here's some further information about prediction using the Java library an overview about ML Engine predictions.
Or do you have to build the web application using a certain language to use composer? I've been looking this up but I'm confused how a web app would use the blockchain.
Yes, this is the purpose of the composer-rest-server which has a Swagger (OpenAPI) documented RESTful interface that allows one to interact with a Composer business network.
This is documented in the "Generate REST API" section of the Developer Guide.
After you create and composer deploy your .bna (business network archive) you would use the composer-rest-server command-line tool to generate and start a rest server that can interact with your business network.
Using this REST API, you can access the swagger definition source via http://localhost:3000/explorer/swagger.json. From that, you can generate a Java client using a tool such as Swagger Codegen.
Yes, you can do that exposing the business network as a REST API & invoking that from any web application.
See this: https://hyperledger.github.io/composer/integrating/getting-started-rest-api.html
Can any one help me how to access google cloud ml service using Rest API in python. I have tried it using postman but it gives 404 in response everytime.I have some project on google cloud I just want to use all the apis available on https://cloud.google.com/ml-engine/reference/rest/
You can find examples from Datalab:
Training service:
https://github.com/googledatalab/pydatalab/blob/master/google/datalab/ml/_job.py#L61
Prediction service:
https://github.com/googledatalab/pydatalab/blob/master/google/datalab/ml/_cloud_models.py#L225
Alternatively, instead of calling CloudML service endpoints directly, you can try Datalab's ml toolbox itself which supports structured data and image classification. You can view the notebooks first without setting up datalab:
https://github.com/googledatalab/notebooks/tree/master/samples/ML%20Toolbox
To set up Datalab and actually run these notebooks, see https://cloud.google.com/datalab/docs/quickstarts.
I am new with google cloud platform and trying to get started. I am interested in using Google Cloud storage.
Following this link:
datastore reference I can see available client libraries (c++ is not one of them)
Now there is google api c++ client:
google api c++ client
and it has "Google Cloud Datastore API" as one of the service api's available.
And then there is this link:
https://developers.google.com/api-client-library/cpp/
which just says:
"The Google APIs C++ Client Library is no longer available. Thank you for your interest."
That got me a bit confused. As I would like to use cloud DataStore via native c++ api.
If you're willing to do quite a bit of work you can interact with the REST API directly using whatever technology you like. You'll need to do understand how to generate an OAUTH2 credential and how the OAUTH2 scopes etc. work. You can then create an OAUTH2 cookie for the Authorization header. Once you're on top of the that the Google APIs helps you navigate the APIs and work out the expected requests and responses:
https://cloud.google.com/datastore/docs/reference/data/rest/
The REST guide lets you try out calls yourself too.
I need to integrate the Cloudfoundry with third party authentication tool, say, Keystone. I need to write a plug-in where it can be attached / installed to the cloud foundry with out any code changes in Cloudfoundry. If I want to use the authentication from keystone I will install the plug-in for Cloudfoundry. The code changes should only go to the plug-in and not to the Cloudfoundry code.
Please let me know how can I achieve this.
Thanks in advance,
Sateesh B.
The following link https://github.com/cloudfoundry/vcap-java-client is a java client library that does restful calls to vcap (aka cloud foundry). Now in my opinion, if you want to use a custom authentication method (be whatever you choose) in high level terms, you would have to make it into a adapter design pattern.
Once your users pass your authentication, your application can then communicate with Cloud Foundry via rest calls or libraries such as https://github.com/cloudfoundry/vcap-java-client and have their account created or etc. You just have to add that layer of your own authentication which then you can use the data from the authenticated user in creating or fetching cloud foundry info/apps.
This way you haven't touched cloud foundry and you can easily implement more than one way of authentication.