- Henry
> --
> You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
> To post to this group, send email to opensocial-an...@googlegroups.com.
> To unsubscribe from this group, send email to opensocial-and-gadg...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/SsFmpP1c8-gJ.
--
You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/NHnc1sDJfnUJ.
--
You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/rQFJfqP99S0J.
you can create an osapi.BatchRequest with osapi.newBatch() and then
add multiple osapi requests (including osapi.http requests) to this
batch with
batchRequest.add(key, request);
Authorization is set for each HTTP request separately in each request object.
with
batchRequest.execute(callbackFunction)
you then send a single request to the rpc api which executes each
request and returns an associative json with the given request key and
the response object for each request.
It's specified here:
http://opensocial-resources.googlecode.com/svn/spec/2.0.1/Core-Gadget.xml#osapi.BatchRequest
Cheers
Bastian
Then separate the rpc protocols and rest protocols into separate distinct pieces. Define a core Rest protocol, then separately define and describe the rpc binding specifically as it relates to the Javascript API.
--
You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/gkgXdf8vHG4J.
Unless we have support for "universal object" which support different
data type in OpenSocial specs to allow REST style APIs to get data
with different types of data, we need to support the RPC protocol to
for the data API batch requests.
- Henry
Given the way things are currently defined in the API's, I have little
doubt that batching helps performance, but that's not really the point
I'm trying to make...
Consider this: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven#comment-743.
The salient points: "People perceive a need for batch operations
because they don’t understand the scope of resources... [t]he same
resource state can be overlayed by multiple resources, just as an XML
document can be represented as a sequence of bytes or a tree of
individually addressable nodes. Likewise, a single resource can be the
equivalent of a database stored procedure, with the power to abstract
state changes over any number of storage items... If you find yourself
in need of a batch operation, then most likely you just haven’t
defined enough resources."
Let's look at the case you brought up in your earlier message. You
said: "So you get a collection of users, batch up the ones you want to
know more about and away you go."
My question to this is: why do we need a "batch" request?
Consider.. this is what a current RPC batch request currently looks
like in the RPC model..
POST /rpc HTTP/1.1
Host: api.example.org
Authorization: hh5s93j4hdidpola
Content-Type: application/json
[
{
"method" : "people.get",
"id" : "myself",
"params" : {
"userId" : "@me",
"groupId" : "@self"
}
},
{
"method" : "people.get",
"id" : "myfriends",
"params" : {
"userId" : "@me",
"groupId" : "@friends"
}
}
]
The thing that strikes me as very odd about this is.. why isn't it just...
POST /rpc HTTP/1.1
Host: api.example.org
Authorization: hh5s93j4hdidpola
Content-Type: application/json
{
"method" : "people.get",
"id" : "myself",
"params" : {
"userId" : "@me",
"groups": ["@self","@friends"]
}
]
}
Or even better...
GET /people/@me/@self,@friends HTTP/1.1
Host: api.example.org
Authorization: hh5s93j4hdidpola
From everything that I can see, the *ONLY* reason batching is required
here is because of how the people.get operation is currently defined.
With either of the two alternatives I suggest, the requirement for a
batch request completely disappears. The GET option would be WAY more
efficient than the POST /rpc with a batch request option could ever
be. Period.
In your note you also said that another case "is to retrieve more
information about the "stuff" a user has, e.g. blogs, documents,
discussions, etc. " ... to which the natural question is: Well, why
isn't there a single operation that would allow you to retrieve this
information? I'd argue, as Roy suggests in the quote above, the only
reason you'd need to batch requests to get the data you need is
because we have created enough resources. We can take the time now to
define those missing resources, and we can take the time to define
something like the Persistent Query Service and better search and
filter capabilities to completely eliminate the need for batching
requests altogether.
We simply need to define new resources that provide all the information we need.
If you still think batching is an absolute requirement, let's put it
to a test... show me a use case that absolutely requires batch request
capability and if I'm not able to demonstrate that the same case can
be implemented more efficiently without batching, I'll concede on the
point.
- James
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/-pUQfbGJcTMJ.
POST /rpc HTTP/1.1
Host: api.example.org
Authorization: hh5s93j4hdidpola
Content-Type: application/json
[
{
"method" : "people.get",
"id" : "myself",
"params" : {
"userId" : "@me",
"groupId" : "@self"
}
},
{
"method" : "activitystreams.get",
"id" : "mystreams",
"params" : {
"userId" : "@me",
"groupId" : "@self"
}
}
]
One way to use REST is to have a universal object data type so we
could have something like:
GET /universalobject/@me/@self?objecttypes=people:activitystreams&people_userId=@me&people_groupId=@self&activitystreams_userId=@me&activitystreams_groupId=@self
Overloading REST to do this kind of request probably not a good and clean way.
Another way, like Matthew Marum has said, we could piggyback
activitystreams request to the field response of the person. But this
way force developers to be "creative" to find out how to send batch
requests for different data types.
Not sure if either way is the best way to achieve multi data types requests.
- Henry
GET /api/@me/@self,@stream HTTP/1.1
Host: api.example.org
Authorization: hh5s93j4hdidpola
Which can return something as simple as...
{
"@self": {
// the profile
},
"@stream": {
// the stream
}
}
- James
I assume /api is the root context for the REST APIs or the same level
as /person and /activitystream?
It just feel like sounds like we are trying forcing existing use cases to REST.
I believe REST and JSON-RPC endpoints serve different purpose.
The REST endpoints are primarily used for server to server
communication and JSON-RPC usually used by JavaScript/ OS gadgets
clients.
Currently, the OS REST specs are not super clean and also they arent
100% follow the basic guidelines of RESTful web services (or APIs).
For example, the response format does not have any links that let
client on how to get different resources that could be reached by
another resource.
I propose we clean up the REST protocol for OS for one spec release
and once the implementation catch up with the specs upgrade and we
still believe there is no need for JSON-RPC protocol we could revisit
this removing/ deprecating it.
- Henry
No, I'm trying to say that we can do a heck of a lot better supporting
those use cases than what we currently have by intelligently
refactoring the api.
>
> I believe REST and JSON-RPC endpoints serve different purpose.
> The REST endpoints are primarily used for server to server
> communication and JSON-RPC usually used by JavaScript/ OS gadgets
> clients.
Why can't the javascript/os gadget clients use the REST api?
>
> Currently, the OS REST specs are not super clean and also they arent
> 100% follow the basic guidelines of RESTful web services (or APIs).
> For example, the response format does not have any links that let
> client on how to get different resources that could be reached by
> another resource.
>
> I propose we clean up the REST protocol for OS for one spec release
> and once the implementation catch up with the specs upgrade and we
> still believe there is no need for JSON-RPC protocol we could revisit
> this removing/ deprecating it.
>
If we do a 2.5 spec, I agree, leave it as is technically but clean up
the spec. My proposal for removing the RPC protocol is for 3.0 and
beyond.
So if I'm reading this correctly, it's basically just a call to
retrieve the profile and the activity stream for @me, right?
GET /api/@me/@self,@stream HTTP/1.1
Host: api.example.org
Authorization: hh5s93j4hdidpola
Which can return something as simple as...
{
"@self": {
// the profile
},
"@stream": {
// the stream
}
}
- James
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/0CAxFqqfILAJ.