Database Reference
In-Depth Information
REST Collections
To make an API RESTful, you can take the main objects— users , for
example—and expose operations on them as operations on collections of
those objects. The endpoint that responds to those operations is a simple
URL, usually with the name of the collection as part of the URL. For
instance, the method to create a user wouldn't be called “create.” It would
be an insert operation into the users collection (called Users.insert() )
that you'd send to the users URL.
REST collections respond to a standardized set of operations, or HTTP
verbs. The verb is the first portion of the HTTP protocol. When you open
a web page in your browser, it sends a GET request to the server you're
accessing. If you are updating data—submitting a form, for instance—it uses
the POST verb instead. The HTTP 1.1 specification describes a few more
verbs that can come in handy when accessing REST collections, as shown in
Table 5.1 .
Table 5.1 REST Verbs
Method name Verb
Description
Adds a resource to the collection
insert()
POST
Gets a single resource in the collection
get()
GET
Lists resources
list()
GET
Updates an entire resource
update()
PUT
PATCH Updates a portion of a resource
patch()
DELETE Deletes a resource
delete()
To list objects in a collection, you send a GET request to the base URL
of the collection. For instance, in BigQuery, there is a Projects collection,
representing the projects that are visible to the logged-in user. To list your
projects,
you
can
send
an
HTTP
request
to
GET
https://www.googleapis.com/bigquery/v2/projects .
To read a particular object in a REST collection, send a GET request to
the URL of the object. In BigQuery, the Datasets collection is nested under
the projects collection; you can read the metadata for the dataset
bigquery-e2e:application_logs object by sending a GET request to
 
 
Search WWH ::




Custom Search