Can I get root URL to my Google Cloud Function? - google-cloud-platform

For example, I have https://REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/myfunctionname
But I want to have a root link to my function. Something like that:
https://myfunctionname.REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/
How can I get this?

You can't change the URL provided by Cloud Functions, but you can use Firebase Hosting as a proxy to Cloud Functions so you can use a custom domain to access functions deployed to the same project.
https://firebase.google.com/docs/hosting/functions

Currently there is no way to get a different URL from a Cloud Function other than the one automatically generated which will always have the format "https://REGION-PROJECT_ID.cloudfunctions.net/hello_get".
If there was a way to do this, it would need to be defined during ht deployment of the function, and according to the documentation for 'gcloud function deploy', there is no way to specify a way to change the URL generated.

Related

Structuring Google Cloud Functions project

I have a REST API that I'd like to port to run as a collection of cloud functions. I'm wondering how to split up the different endpoints in the best way, and how much to rename endpoints to fit the GCF model.
For example, I have the following types of request.
GET /images
GET /images/<image_id>
POST /images
If this was implemented with GCF, these would all fall under the same function images, and then I would need to implement some routing based on HTTP method, plus a pattern match for <image_id>, etc..
I could however choose to implement something like...
GET /images
GET /image/<image_id>
POST /createImage
...so that each endpoint has a distinct function that is invoked. This seems more appropriate from a cloud functions point of view, but not at all appropriate from a RESTful design point of view.
What are the trade-offs for implementing cloud functions in one or the other of these ways?

How to customize URL pattern in WSO2AM

I am designing an API using WSO2AM 2.0
My service is like : http://190.100.10.10:9000/abc/xyz/doPost<br>
I want to replace /abc/xyz/doPost by /<MY_CUSTOM_PATH>/doPost
How can I make a custom URL pattern to hide my original URL path from the service?
Like: http://<WSO2AM_GENERATED_HOST>/WSO2AM_CONTEXT/WSO2AM_VERSION/<MY_CUSTOM_PATH>/doPost
I have searched the docs, but I am not able to find any related tutorial.
If I put /abc/xyz/doPost it will get appended to the WSO2AM generated hostname.
What is "EDIT SOURCE" in the image below? Can it be used to do what I want? If YES, How??
There aren't anything like WSO2AM_CONTEXT or WSO2AM_VERSION. You can provide any value for the context and version. Version can be String, numbers, etc.
In your case, you can use abc as context and xyz as the version.
That is exactly the kind of URL you would get in WSO2 API Cloud: http://your.custom.url/api-name/version/context. See this tutorial for details: https://docs.wso2.com/display/APICloud/Customize+the+API+Store+and+Gateway+URLs
It might not be complicated...
In publisher interface, when you add/edit an API, in "Implementation" screen, just configure WSO2 APIM to point to "http://190.100.10.10:9000/abc/xyz" - this way, "/abc/xyz" will not be visible to your clients.
So in this case,
http://<WSO2AM_GENERATED_HOST>/WSO2AM_CONTEXT/WSO2AM_VERSION/doPost
will point to:
http://190.100.10.10:9000/abc/xyz/doPost
If you wanted to add additional custi=om paths, in the "Design" screen you attached, you can also add your "(MY_CUSTOM_PATH)/doPost" path there.
This way
http://<WSO2AM_GENERATED_HOST>/WSO2AM_CONTEXT/WSO2AM_VERSION/<MY_CUSTOM_PATH>/doPost
will point to:
http://190.100.10.10:9000/abc/xyz//<MY_CUSTOM_PATH>/doPost
(However, your backend services should also have "//doPost" implemented)

Possible to change a Google Cloud Platform Project ID?

I understand project names can be changed however I don't see any method to change the project ID.
Is this possible using the gcloud shell perhaps if not in the UI?
You cannot change project ID.
You have an option to use a custom domain, e.g. www.myCompany.com, in which case projectID is something that only your internal code needs to know.

How to refer more than one url using regex in Java

I'm basically trying to make a REST call to the artifactory to get json response about the repositories.
My URL is something like this "http://127.0.0.1:8081/artifactory/api/storage/deploy/" where deploy is my repository.
Now i want to get the information about all the repositories whose name starts with - deploy .
How to modify the url in-order to get the info about the repositories with name starts with deploy??
Is it possible to do this, without getting all repositories name and then filtering?
Thanks.
I suppose this is not a java question, rather a question of your rest service supporting such behaviour. I.e your rest api must provide a method to get a list of all the repositories by regexp.
I don't think this can be solved by means of java in any way other than bruteforcing links.

How to call a webservice programmatically in asp.net

How to call webservice programmatically in asp.net without using add web reference?
My webservice url keeps on changing. Hence i need to capture the url at runtime and display the results.
Please advice.
You can change the URL of a web-reference at runtime (provided that the new address is hosting a service with the same schema that you originally used to create the reference):
MyWebService ms = new MyWebService();
ms.Url = "http://example.com/webservice.asmx";
ms.MyWebMethod();
Web References are definitely the way to go - whilst the classes that are created by the web reference are usually pretty heavy, all that strong typing makes it well worth your while.
you need to do the following steps.
PreReq :
First of all, you know the URL of web service.
Solution:
use wsdl.exe to create a proxy class and than compile it.
wsdl /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL
(there are other switches available
for wsdl. For Example to generate VB
class, you need to add switch
/language:VB)
Once your proxy class is generated you can easily consume in code.
MyProxyClass objService = new MyProxyClass();
DateTime time = objService.GetServerTime(); //Suppose service has method getServerTime
You can specify the end-point URL as part of the constructor of your client-side proxy class.
If you don't need to specify it during runtime then it can also be set in your web.config file.
Where are you trying to call the service and where the service file is located?
If the service is located on the same site. Why not just instantiate the class name from the service. Or just create a separate class and use interface