The only docs I can find say say "click 'generate endpoint class' and then something magic happens".
I'm looking for a bit more detail.
Specifically what I am trying to achieve is to generate Endpoint classes that use Objectify in place of JDO for persistence.
For clarity, I am not interested in generating client classes since I will be accessing the endpoints from Erlang.
All the features that you describe are things you need to do in your own server-side logic. Those are not generated for you. After that, you need to annotate your APIs (entry points).
Then you can use the endpoint tools to generate the endpoint classes on the client side.
https://developers.google.com/appengine/docs/java/endpoints/annotations
Related
In a cakephp 4 project in need to read data from a third party api.
I found this doc for cakephp 2, but no equivalent for cakephp 4.
https://book.cakephp.org/2/en/models/datasources.html
Where is it ?
Thanks
Read data from a third part api direct in your controller using HttpClient or other libs.
https://book.cakephp.org/4/en/core-libraries/httpclient.html
In CakePHP 4 the ORM is structured quite differently, data is retrieved via a Datasource, so you essentially need an HTTP-backed Datasource.
While CakePHP doesn't naively supply an HTTP source, there are a few of plugins that do, such as:
https://github.com/imsamurai/cakephp-httpsource-datasource
https://github.com/CakePHP-Copula/Copula
It looks like these may have some drawbacks and limitations - and in general be fairly advanced setups requiring some creative problem solving. So in the end, as the other poster mentioned, it may in the end be easier to just make HTTP requests directly if you don't require any of the ORM features (validation, Entity classes, virtual fields, Event hooks, etc.)
If the API communicate using POST/GET requests and responds using JSON format (which is usually the case), you can use the Request & Response Objects to ask and get data from the API
I am looking at building a class implementing the IdentityServer IResourceStore interface. My goal is to serve IdentityResource and ApiResource collections as defined in a custom repository.
Ideally, I will receive requests for these resources and respond with the subset relevant to the query. In short: You only get what you ask for.
The GetAllResources()method makes me leery: Is IdentityServer actually requiring that I pull the entire set of my Identity and API resources from my repository and make this available? At this point I have no idea how large those collections will grow, or the cost of pulling them from the repository.
What are the consequences of simply responding with a null or empty lists of resources?
-S
It's used in the GetAllEnabledResourcesAsync method in the IResourceStoreExtensions class, which in turn is used by the DiscoveryEndpoint. So, if you don't implement this method the Discovery endpoint will not be able to display any scopes or claims.
By don't implement I mean return some empty lists or something, not throw a NotImplementedException or return null... That would break everything.
I am a bit new to the whole APEX service plugins but I was wondering if Salesforce has native support for Swagger, or any similar REST description language, for the REST api's that I create in the APEX service platform?
For example:
#RestResource(urlMapping='/v1/users/*')
global with sharing class UserRestService {
...
#HttpGet
global static List<Member__c> doGet(....)
{
...
}
}
I would like the ability to return the swagger json, a WADL document, or something for this REST service (and all other REST services I have in there). Does anyone know of a way I can do this?
Thanks in advance!
There is no built in support at this time. I was interested in seeing what could be done via currently available public APIs. The first thing I ran into is the grammar does not seem to like parameters to HttpGet methods. That right there will make it challenging since the only way to get input parameters appears to be via the Request entity which means you would have to parse the actual code. In other words, there does not appear to be declarative input binding.
Further, in looking at the tooling API which let's me get some amount of "reflective" information about the class, there is not always sufficient information to render a response payload (in your case, it just shows LIST but not what's in the list)
Again, it looks like one would have to rely on a parser (there is at least one Antl grammar floating around).
(this is getting some internal attention but I can't say any more at this time)
I am learning endpoints and saw that other Google APIs have this "fields" query attribute.
Also it appears in the api explorer.
I would like to get a partial response for my api also, but when using the fields selector from the api explorer it is simply ignored by the server.
Do I need to implement something in the server side?
Haven't found anything in the docs.
Any help is welcome.
From what I gather, Google has enabled partial response for their APIs, but has not yet explained how to enable it for custom APIs.
I'm assuming if they do let us know, it might entail annotations, and possibly overriding a method or two.
I've been looking also, to no avail.
I've been looking into this just due to a related question, where I'd like to know how to force the JSON object in the response from my google Endpoint API, to include even the members of the class that are null valued.
I was trying to see if anything would be returned if I used a partial response with a field indicated that was null.. would the response have the property at least, or would it still not even exist as a property.
Anyway, this lead me into the same research, and I do not believe we can enable partial responses in our own APIs yet.
You can return a partial response by defining the parameter in #MyModel.method
#MyModel.method(path='mymodel',
http_method='POST',
name='mymodel.insert',
response_fields=('model_id', 'date_time'))
def mymodel_insert(self, mymodel):
mymodel.put()
return mymodel
Check out this tutorial Endpoints tutorial
I try to get an application running which should interact with a server via RPC (JDO in Google DataStore). So I defined a persistent POJO on the server-side to get it put in the datastore via the PersistenceManager (as shown in the gwt rpc tuts). Everything works fine. But I am not able to receive the callback POJO on the client side because the POJO is only defined on server-side. How can I realize it, that the client knows that kind of object??
(sry for my bad english)
Lars
Put your POJOs in a separate package/directory (e.g. com.example.common) and then add source declaration to your GWT module descriptor (xyz.gwt.xml):
<source path="common"/> //relative to your xyz.gwt.xml location
GWT compiler will then also compile POJOs and they will be seen by your other GWT code.
Edited:
#Lars - now I understand your problem. As I see it you have several options:
If possible use Objectify instead of JDO. Objectify uses pure POJOs and they play nicely with GWT. I use this in my projects. One nice thing that Objectify gives you is #PostLoad & # PrePersist on methods to run some code before/after POJOs are loaded/saved to datastore. I use this to handle serialization of GeoPoint for instance.
Use JDO and make copies of your domain classes. This is a pain but it would work. Use 'transient' java keyword in your server JDO classes to exclude fields you do not want to RPC.
Edit #2: There is a third option that you might prefer:
Create "fake" JDO annotation classes using super-sourcing. This is a common technique to replace classes with a GWT version. Described here: http://fredsa.allen-sauer.com/2009/04/1st-look-at-app-engine-using-jdo.html
You can use DTO(stackoverflow, moar) for transferring data to client.
Basic sample here (method getTenLatestEntries() in your case).
Or you can use some third-party libraries like objectify and stop worry about making DTO`s.