You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/06/25 22:28:37 UTC
[39/51] [partial] incubator-usergrid git commit: Moving website from
SVN to Git.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/query-language.md
----------------------------------------------------------------------
diff --git a/website/content/docs/query-language.md b/website/content/docs/query-language.md
new file mode 100644
index 0000000..99827f9
--- /dev/null
+++ b/website/content/docs/query-language.md
@@ -0,0 +1,465 @@
+---
+title: Query Language
+category: docs
+layout: docs
+---
+
+> Query examples in this content are shown unencoded to make
+> them easier to read. Keep in mind that you might need to encode query
+> strings if you're sending them as part of URLs, such as when you're
+> executing them with the cURL tool.
+
+The following example retrieves a list of restaurants (from a
+restaurants collection) whose name property contains the value "diner",
+sorting the list in ascending order by name:
+
+ /restaurants?ql=select * where name contains 'diner' order by name asc
+
+
+## Basic syntax
+
+Queries of Apigee data for Apache Usergrid are made up of two kinds of
+statements: the path to the collection you want to query, followed by
+the query language statement containing your query. These two statements
+are separated by "?ql=" to indicate where the query language statement
+starts.
+
+To retrieve items from a collection, you would use a syntax such as the
+following:
+
+ /<collection>?ql=<query_statement>
+
+In the following example, the query is retrieving all users whose name
+is Gladys Kravitz.
+
+ /users?ql=select * where name = 'Gladys Kravitz'
+
+The following example selects all items except those that have an a
+property value of 5:
+
+ /items?ql=select * where NOT a = 5
+
+Note that there is a shortcut available when your query selects all
+items matching certain criteria -- in other words, where you use a
+statement that starts "select \* where". In this case, you can omit the
+first part of the statement and abbreviate it this way:
+
+ /items?ql=NOT a = 5
+
+You query your Apache Usergrid data by using a query syntax that's like
+Structured Query Language (SQL), the query language for relational
+databases. Unlike a relational database, where you specify tables and
+columns containing the data you want to query, in your Apache Usergrid
+queries you specify collections and entities.
+
+The syntax of Apache Usergrid queries only *resembles* SQL to
+make queries familiar and easier to write. However, the language isn't
+SQL. Only the syntax items documented here are supported.
+
+## Supported operators
+
+Comparisons
+
+* Less than `<` or `lt`
+* Less than or equal `<=` or `lte`
+* Equal `=` or `eq`
+* Greater than or equal `>=` or `gte`
+* Greater than `>` or `gt`
+* Not equal `NOT`
+
+Logical operations
+
+* Intersection of results `and`
+* Union of results `or`
+* Subtraction of results `not`
+
+
+## Query Response Format
+
+the query’s response is formatted in
+JavaScript Object Notation (JSON). This is a common format used for
+parameter and return values in REST web services.
+
+So for the following query:
+
+ /users?ql=select * where name = ‘Gladys Kravitz’
+
+...you would get a response such as the the one below. The JSON format
+arranges the data in name/value pairs. Many of the values correspond to
+specifics of the request, including the request’s HTTP action (GET), the
+application’s UUID, the request’s parameters (the query string you
+sent), and so on.
+
+Here, the query is asking for whole entities in the users collection.
+Data corresponding to the response is captured in the response’s
+`entities` array. The array has one member here, corresponding to the
+one user found by the query (another kind of query might have found more
+users). That one member gives the UUID of the entity (user), the entity
+type, and values for properties such as name, username, email, and so
+on.
+
+```json
+{
+ "action" : "get",
+ "application" : "8272c9b0-d86a-11e2-92e2-cdf1ce04c1c0",
+ "params" : {
+ "ql" : [ "select * where name = 'Gladys Kravitz'" ]
+ },
+ "path" : "/users",
+ "uri" : "http://api.usergrid.com/myorg/myapp/users",
+ "entities" : [ {
+ "uuid" : "d0d7d0ba-e97b-11e2-8cef-411c466c4f2c",
+ "type" : "user",
+ "name" : "Gladys Kravitz",
+ "created" : 1373472876859,
+ "modified" : 1373472876859,
+ "username" : "gladys",
+ "email" : "gladys@example.com",
+ "activated" : true,
+ "picture" : "http://www.gravatar.com/avatar/20c57d4f41cf51f2db44165eb058b3b2",
+ "metadata" : {
+ "path" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c",
+ "sets" : {
+ "rolenames" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/rolenames",
+ "permissions" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/permissions"
+ },
+ "connections" : {
+ "firstname" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/firstname",
+ "lastname" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/lastname"
+ },
+ "collections" : {
+ "activities" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/activities",
+ "devices" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/devices",
+ "feed" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/feed",
+ "groups" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/groups",
+ "roles" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/roles",
+ "following" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/following",
+ "followers" : "/users/d0d7d0ba-e97b-11e2-8cef-411c466c4f2c/followers"
+ }
+ }
+ } ],
+ "timestamp" : 1374694196061,
+ "duration" : 48,
+ "organization" : "myorg",
+ "applicationName" : "myapp",
+ "count" : 1
+}
+```
+
+Compare the preceding example with the following for another kind of
+query. Imagine the following request string, where the query string is
+asking for only the values of two of the entity’s properties (username
+and name):
+
+ /users?ql=select username,name where name=’Gladys Kravitz’
+
+In the response JSON from this query, the return value is specified as
+the property of the `list` item -- here, an array containing only the
+values of the properties the query asked for, in the order they were
+requested (username first, then name).
+
+ {
+ "action" : "get",
+ "application" : "8272c9b0-d86a-11e2-92e2-cdf1ce04c1c0",
+ "params" : {
+ "ql" : [ "select username,name where name='Gladys Kravitz'" ]
+ },
+ "path" : "/users",
+ "uri" : "http://api.usergrid.com/myorg/myapp/users",
+ "list" : [ [ "gladys", "Gladys Kravitz" ] ],
+ "timestamp" : 1374697463190,
+ "duration" : 25,
+ "organization" : "myorg",
+ "applicationName" : "myapp",
+ "count" : 1
+ }
+
+
+## Data types supported in queries
+
+As you develop queries for your Apache Usergrid data, remember that entity
+properties each conform to a particular data type (whether the entity is
+included by default or an entity you defined). Your queries must
+acknowledge this, testing with values that conform to each property's
+data type. (You can view the list of property data types for the default
+entities at [Default Data Entities](/default-data-entities).)
+
+For example, in the default entity `User`, the `name` property is stored
+as a `string`, the created date as a `long`, and metadata is stored as a
+JSON object. Your queries must be data type-aware so that you can be
+sure that query results are as you expect them to be.
+
+So imagine you define an entity with a `price` property whose value
+might be `100.00`. Querying for `100` will return no results even if
+there are occurrences of `100.00` as `price` values in your data set.
+That's because the database expected a decimal-delimited `float` value
+in your query.
+
++-------------------------+-------------------------+-------------------------+
+| Data Type | Examples | Notes |
++=========================+=========================+=========================+
+| `string` | `'value'`, | |
+| | `unicode '\uFFFF'`, | |
+| | `octal '\0707'` | |
++-------------------------+-------------------------+-------------------------+
+| `long` | 1357412326021 | Timestamps are |
+| | | typically stored as |
+| | | `long` values. |
++-------------------------+-------------------------+-------------------------+
+| `float` | 10.1, -10.1, 10e10, | Your query must be |
+| | 10e-10, 10E10, 10E-10 | specific about the |
+| | | value you're looking |
+| | | for, down to the value |
+| | | (if any) after the |
+| | | decimal point. |
++-------------------------+-------------------------+-------------------------+
+| `boolean` | true | false | |
++-------------------------+-------------------------+-------------------------+
+| `UUID` | ee912c4b-5769-11e2- | UUID types are |
+| | 924d-02e81ac5a17b | typically used for the |
+| | | unique IDs of entities. |
+| | | The value must conform |
+| | | to the following format |
+| | | (do not enclose with |
+| | | quotation marks): |
+| | | xxxxxxxx-xxxx-xxxx- |
+| | | xxxx-xxxxxxxxxxxx |
+| | | |
+| | | . |
++-------------------------+-------------------------+-------------------------+
+| `object` | For a JSON object like | Objects are often used |
+| | this one: | to contain entity |
+| | | metadata, such as the |
+| | { | activities associated |
+| | "items": [ | with a user, the users |
+| | { | associated with a role, |
+| | "name": "rocks" | and so on. |
+| | }, | |
+| | { | |
+| | "name": "boats" | |
+| | } | |
+| | ] | |
+| | } | |
+| | | |
+| | ... you can use dot | |
+| | notation to reach | |
+| | property values in the | |
+| | object: | |
+| | | |
+| | /mycollection/thing | |
+| | ?ql="select * where ite | |
+| | ms.name = 'rocks'" | |
++-------------------------+-------------------------+-------------------------+
+
+
+## Retrieving values for multiple properties
+
+Your query can return multiple kinds of values -- such as the values of
+multiple properties -- by specifying the property names in your select
+statement as a comma-separated list.
+
+For example, the following request returns the address and phone number
+of users whose name is Gladys Kravitz:
+
+ /users?ql=select address,phone_number where name = 'Gladys Kravitz'
+
+
+## Querying for the contents of text
+
+Your query can search the text of entity values of the string data type.
+For example, you can search a postal code field for values that start
+with a specific three numbers.
+
+For example, the following query selects all restaurants with the word
+`diner` in the name:
+
+ /restaurants?ql=select * where name contains 'diner'
+
+**Note:** Not all string properties of the default entities are
+indexed for searching. This includes the `User` entity's `username`
+property.
+
+This will return all users whose name property contains the word 'Kravitz'
+
+ /users?ql=select * where name contains 'Kravitz'
+
+This will return all users whose name property contains a word beginning with 'Krav'
+
+ /users?ql=select * where name contains 'Krav*'
+
+This will return all users whose name is exactly 'Gladys Kravitz'
+
+ /users?ql=select * where name = 'Gladys Kravitz'
+
+
+## Sorting results
+
+You can return query results that are sorted in the order you specify.
+Use the `order by` clause to specify the property to sort by, along with
+the order in which results should be sorted. The syntax for the clause
+is as follows `order by <property_name> asc | desc`
+
+The following table includes a few examples:
+
+ /users?ql=select * where lastname = 'Smith' order by firstname asc
+
+
+ /users?ql=select * where lastname = 'Smith' order by firstname desc
+
+
+ /users?ql=select * where lastname contains 'Sm*' order by lastname asc, firstname asc
+
+
+## Geoqueries
+
+Many of today's apps are enhanced by the use of *geolocation*, wireless
+detection of the physical location of a remote device. These apps are
+said to be *geolocation-aware* in that they query the device to
+determine the user's position and then use this data to further enhance
+the user's experience. For example, apps can capture the exact location
+where a picture was taken or a message was created.
+
+App services support geolocation on any entity, both built in (e.g.,
+users, groups) and user defined.
+
+To add a location to any entity, include the following member to the
+JSON in a POST or PUT call:
+
+ "location": {
+ "latitude": 37.779632,
+ "longitude": -122.395131
+ }
+
+For example, to store a listing of restaurants and their locations,
+start by creating a collection called restaurants:
+
+ POST https://api.usergrid.com/org_name/app_name/restaurants
+
+Next, add a new entity to the collection:
+
+ POST https://api.usergrid.com/org_name/app_name/restaurants
+ {
+ "name": "Rockadero",
+ "address": "21 Slate Street, Bedrock, CA",
+ "location": {
+ "latitude": 37.779632,
+ "longitude": -122.395131
+ }
+ }
+
+This creates a new restaurant entity called "Rockadero" with the
+longitude and latitude included as part of the object.
+
+When a location is added to an entity, it is easy to make queries
+against that data. For example, to see all restaurants within a 10 mile
+radius of the user's location, make a GET call against that entity, and
+include a search query in the following format:
+
+ location within <distance in meters> of <latitude>, <longitude>
+
+If we use the location of our user Fred, we first need to convert miles
+to meters. 1 mile is equivalent to 1609.344 meters, so 10 miles is about
+16093 meters. Thus, the API call looks like this:
+
+ GET https://api.usergrid.com/org_name/app_name/restaurants?ql=location within 16093 of 37.776753, -122.407846
+
+
+## Managing large sets of results
+
+When your query might return more results than you want to display to
+the user at once, you can use the limit parameter with cursors or API
+methods to manage the display of results. By default, query results are
+limited to 10 at a time. You can adjust this by setting the limit
+parameter to a value you prefer.
+
+For example, you might execute a query that could potentially return
+hundreds of results, but you want to display 20 of those at a time to
+users. To do this, your code sets the limit parameter to 20 when
+querying for data, then provides a way for the user to request more of
+the results when they're ready.
+
+You would use the following parameters in your query:
+
++-------------------------+-------------------------+-------------------------+
+| Parameter | Type | Description |
++=========================+=========================+=========================+
+| `limit` | integer | Number of results to |
+| | | return. The maximum |
+| | | number of results is |
+| | | 1,000. Specifying a |
+| | | limit greater than |
+| | | 1,000 will result in a |
+| | | limit of 1,000. |
+| | | |
+| | | Limit is applied to the |
+| | | collection, not the |
+| | | query string. For |
+| | | example, the following |
+| | | query will find the |
+| | | first 100 entities in |
+| | | the books collection, |
+| | | then from that set |
+| | | return the ones with |
+| | | author='Hemingway': |
+| | | |
+| | | /books?ql=author = |
+| | | 'Hemingway'&limit=100 |
+| | | |
+| | | You can also use the |
+| | | limit parameter on a |
+| | | request without a query |
+| | | string. The following |
+| | | example is shorthand |
+| | | for selecting all books |
+| | | and limiting by 100 at |
+| | | a time: |
+| | | |
+| | | /books?limit=100 |
+| | | |
+| | | Using a limit on a |
+| | | DELETE can help you |
+| | | manage the amount of |
+| | | time it takes to delete |
+| | | data. For example you |
+| | | can delete all of the |
+| | | books, 1000 at a time, |
+| | | with the following: |
+| | | |
+| | | DELETE /books?limit |
+| | | =1000 |
+| | | |
+| | | Keep in mind that |
+| | | DELETE operations can |
+| | | take longer to execute. |
+| | | Yet even though the |
+| | | DELETE query call might |
+| | | time out (such as with |
+| | | a very large limit), |
+| | | the operation will |
+| | | continue on the server |
+| | | even if the client |
+| | | stops waiting for the |
+| | | result. |
++-------------------------+-------------------------+-------------------------+
+| `cursor` | string | An encoded |
+| | | representation of the |
+| | | query position pointing |
+| | | to a set of results. To |
+| | | retrieve the next set |
+| | | of results, pass the |
+| | | cursor with your next |
+| | | call for most results. |
++-------------------------+-------------------------+-------------------------+
+
+For example:
+
+Select all users whose name starts with fred, and returns the first 50
+results:
+
+ /users?ql=select * where name = 'fred*'&limit=50
+
+Retrieve the next batch of users whose name is "fred", passing the
+cursor received from the last request to specify where the next set of
+results should begin:
+
+ /users?ql=select * where name = 'fred*'&limit=50&cursor=LTIxNDg0NDUxNDpnR2tBQVFFQWdITUFDWFJ2YlM1emJXbDBhQUNBZFFBUUQyMVZneExfRWVLRlV3TG9Hc1doZXdDQWRRQVFIYVdjb0JwREVlS1VCd0xvR3NWT0JRQQ
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/querying-data-admin-portal.md
----------------------------------------------------------------------
diff --git a/website/content/docs/querying-data-admin-portal.md b/website/content/docs/querying-data-admin-portal.md
new file mode 100644
index 0000000..72238a4
--- /dev/null
+++ b/website/content/docs/querying-data-admin-portal.md
@@ -0,0 +1,40 @@
+---
+title: Querying data from the admin portal
+category: docs
+layout: docs
+---
+
+Querying data from the admin portal
+===================================
+
+The easiest way to try out Apache Usergrid queries you're considering is to
+use the admin portal, which you can reach at
+[https://apigee.com/usergrid/](https://apigee.com/usergrid/).
+
+To try out queries in the portal, use the following steps:
+
+1. Go to the **Data Explorer** using the left navigation pane.
+2. Under **Method**, select the HTTP method you want to use, as
+ follows:
+ - GET to retrieve data.
+ - POST to create data.
+ - PUT to update data.
+ - DELETE to delete data.
+
+3. In the **Path** box, enter the path to the collection you're
+ querying.
+4. In the **Query String** box, enter your query string.
+
+ Note that you put the path and query string in separate fields,
+ rather than appending the query string to the path in the **Path**
+ box.
+
+The admin portal transforms queries into standard URL-encoded parameters
+before issuing HTTP requests. For example, given the following query
+resulting from what you've entered in the portal:
+
+ /users?ql=select * where name = 'gladys*'
+
+The string received by Apigee would be the following:
+
+ /users?ql=select%20*%20where%20name%20%3d%20'gladys*'
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/querying-your-app-services-data.md
----------------------------------------------------------------------
diff --git a/website/content/docs/querying-your-app-services-data.md b/website/content/docs/querying-your-app-services-data.md
new file mode 100644
index 0000000..25158ba
--- /dev/null
+++ b/website/content/docs/querying-your-app-services-data.md
@@ -0,0 +1,81 @@
+---
+title: Querying your Apache Usergrid data
+category: docs
+layout: docs
+---
+
+Querying your Apache Usergrid data
+===============================
+
+You can write code to query for data you've stored in your Apache Usergrid
+application. You'll most likely use queries as filters to retrieve
+specific entities. For example, you might want to get data about users
+who are "following" a specific other user, businesses in specific
+geographical locations, and so on.
+
+The following example retrieves a list of restaurants (from a
+restaurants collection) whose name property contains the value "diner",
+sorting the list in ascending order by name:
+
+ /restaurants?ql=select * where name contains 'diner' order by name asc
+
+Having retrieved the list of restaurants, your code could display the
+list to your users. You could also use a query to retrieve a list of
+diners that are located within a particular geographical area (such as
+near your user's current location).
+
+> **Important:** By default, results from queries of your Apache Usergrid
+> data are limited to 10 items at a time. You can control this with the
+> `limit` parameter, as discussed [Working with
+> queries](/working-queries#cursor).
+
+You query your Apache Usergrid data by using a query syntax that's like
+Structured Query Language (SQL), the query language for relational
+databases. Unlike a relational database, where you specify tables and
+columns containing the data you want to query, in your Apache Usergrid
+queries you specify collections and entities.
+
+The examples in this section illustrate queries using simple strings to
+make the queries easier to read. You can also use one of the Apigee
+SDKs, which provide functions through which you can pass query strings,
+and in some cases shortcuts for bypassing queries altogether.
+
+**Note:** Queries replace filters, which are deprecated.
+
+Querying data from the admin portal
+-----------------------------------
+
+The easiest way to try out queries you're considering is to use the
+admin portal, which you can reach at
+[https://apigee.com/usergrid/](https://apigee.com/usergrid/).
+
+To try out queries in the portal, use the following steps:
+
+1. Go to the **Data Explorer** using the left navigation pane.
+
+ ![](/docs/sites/docs/files/styles/large/public/as_push_console_delete.png?itok=BFAfMReE)
+
+2. Under **Method**, select the HTTP method you want to use, as
+ follows:\
+ - GET to retrieve data.
+ - POST to create data.
+ - PUT to update data.
+ - DELETE to delete data.
+
+3. In the **Path** box, enter the path to the collection you're
+ querying.
+4. In the **Query String** box, enter your query string.
+
+ Note that you put the path and query string in separate fields,
+ rather than appending the query string to the path in the **Path**
+ box.
+
+The admin portal transforms queries into standard URL-encoded parameters
+before issuing HTTP requests. For example, given the following query
+resulting from what you've entered in the portal:
+
+ /users?ql=select * where name = 'gladys*'
+
+The string received by Apigee would be the following:
+
+ /users?ql=select%20*%20where%20name%20%3d%20'gladys*'
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/relationships.md
----------------------------------------------------------------------
diff --git a/website/content/docs/relationships.md b/website/content/docs/relationships.md
new file mode 100644
index 0000000..9d57d3c
--- /dev/null
+++ b/website/content/docs/relationships.md
@@ -0,0 +1,104 @@
+---
+title: Relationships
+category: docs
+layout: docs
+---
+
+Creating connections between entities
+-------------------------------------
+
+One of the most useful features of App services is the ability to create
+connections between entities. A simple example of this is the
+Twitter-like use of *following*, where one user forms a connection with
+another by subscribing to any tweets they post. [Messagee
+Example](/messagee-example) walks you through an example of following
+other users in our sample app, *Messagee*. Here is the basic format:
+
+ POST https://api.usergrid.com/my-org/my-app/users/fred/following/users/barney
+
+This API call results in two users, Fred and Barney, linked with a
+connection where Fred is following Barney.
+
+If you create a *following* connection between two users, Apache Usergrid
+automatically creates a virtual connection called *followers* that
+mirrors the *following* connection. In other words, if you create a
+connection where Fred is following Barney, Apache Usergrid automatically
+creates a virtual connection where Fred is a follower of Barney.
+
+Note that there is no mirror connection established. Apache Usergrid only
+creates a mirror connection when you create a *following* connection. It
+does not create a mirror connection for other verbs such as likes.
+
+You can see all the users that Fred is following, in this case only
+Barney, by making the following API call:
+
+ GET https://api.usergrid.com/my-org/my-app/users/fred/following
+
+You can see all of barney’s followers, in this case only Fred, by making
+the following API call:
+
+ GET https://api.usergrid.com/my-org/my-app/users/barney/followers
+
+The *followers* connection is a virtual connection because you can’t use
+it to link two entities. In other words, you can’t make fred a follower
+of barney by using a *followers* connection. **This is wrong:**
+
+ POST https://api.usergrid.com/my-org/my-app/users/barney/followers/users/fred
+
+To create a *following* connection with the users switched, so that
+Barney is following Fred, do this:
+
+ POST https://api.usergrid.com/my-org/my-app/users/barney/following/users/fred
+
+You can now see Fred’s followers (only Barney) by making the following
+call:
+
+ GET https://api.usergrid.com/my-org/my-app/users/fred/followers
+
+Creating other connections
+--------------------------
+
+You can extend this connection structure to create connections using any
+"verb" that can link two entities. For example, you could use likes to
+denote a connection between a user and his dog. First, create a dogs
+collection:
+
+ POST https://api.usergrid.com/my-org/my-app/dogs
+
+Then populate this collection with a new dog named Dino:
+
+ POST https://api.usergrid.com/my-org/my-app/dogs {"name" : "dino"}
+
+Then create a likes connection between Fred and his dog Dino:
+
+ POST https://api.usergrid.com/my-org/my-app/users/fred/likes/dogs/dino
+
+Getting connections
+-------------------
+
+### Get all connections for an entity
+
+To get a list that only contains the connections, do a GET on the
+connections sub-property of the entity:
+
+ GET https://api.usergrid.com/my-org/my-app/users/fred/connections
+
+### Get information on a specific connection type
+
+To get a list of users who like Fred:
+
+ GET https://api.usergrid.com/my-org/my-app/users/fred/connecting/likes
+
+To get a list of all dogs that Fred likes:
+
+ GET https://api.usergrid.com/my-org/my-app/users/fred/likes/dog
+
+Deleting a connection
+---------------------
+
+You can delete a connection in a way similar to creating one. Just
+replace the POST method with the DELETE method. For example, you can
+delete the connection between fred and barney with the following API
+call:
+
+ DELETE https://api.usergrid.com/my-org/my-app/users/fred/following/barney
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/rest-api.md
----------------------------------------------------------------------
diff --git a/website/content/docs/rest-api.md b/website/content/docs/rest-api.md
new file mode 100644
index 0000000..91d263b
--- /dev/null
+++ b/website/content/docs/rest-api.md
@@ -0,0 +1,17 @@
+---
+title: REST API
+category: docs
+layout: docs
+---
+
+Organizations
+-------------
+
+```bash
+# Create an Organization
+curl -X POST "https://api.usergrid.com/management/organizations" \
+ -d '{ "password":"test12345", "email":"tester123@hotmail.com", "name":"test", "username":"test123", "organization":"testorg" }'
+
+# Read an Organization
+curl -X GET "https://api.usergrid.com/management/organizations/testorg"
+```
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/rest-endpoints.md
----------------------------------------------------------------------
diff --git a/website/content/docs/rest-endpoints.md b/website/content/docs/rest-endpoints.md
new file mode 100644
index 0000000..b99c094
--- /dev/null
+++ b/website/content/docs/rest-endpoints.md
@@ -0,0 +1,918 @@
+---
+title: REST Endpoints
+category: docs
+layout: docs
+---
+
+REST Endpoints
+==============
+
+### Base URL: https://api.usergrid.com/management
+
+
+
+### Access Token
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/token
+'{"grant\_type":"client\_credentials","client\_id":"{client\_id}","client\_secret":"client\_secret"}'
+
+POST
+
+application/json
+
+Obtain an access token (access type = organization)
+
+[Detail](/access-token)
+
+/token
+'{"grant\_type":"password","username":"{username}":"password"="{password}"}'
+
+POST
+
+application/json
+
+Obtain an access token (access type = admin user)
+
+[Detail](/access-token)
+
+/{org\_id}/{app\_id}/token
+'{"grant\_type":"client\_credentials","client\_id":"{client\_id}","client\_secret":"{client\_secret}"}'
+
+POST
+
+application/json
+
+Obtain an access token (access type = application)
+
+[Detail](/access-token)
+
+{org\_id}/{app\_id}/token
+'{"grant\_type":"password","username":"{username}","password":"{password}"}'
+
+POST
+
+application/json
+
+Obtain an access token (access type = application user)
+
+[Detail](/access-token)
+
+### Admin users
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/users
+
+POST
+
+application/json
+
+Create an admin user
+
+[Detail](/docs/usergrid/content/admin-user#creating-an-admin-user)
+
+/users/{user|username|email|uuid}
+
+PUT
+
+application/json
+
+Update an admin user
+
+[Detail](/docs/usergrid/content/admin-user#updating-an-admin-user)
+
+/users/{user|username|email|uuid}
+
+GET
+
+application/json
+
+Get an admin user
+
+[Detail](/docs/usergrid/content/admin-user#getting-an-admin-user)
+
+/users/{user|username|email|uuid}/\
+ password
+
+PUT
+
+application/json
+
+Set an admin user's password
+
+[Detail](/docs/usergrid/content/admin-user#setting-an-admin-user-s-password)
+
+users/resetpw
+
+GET
+
+application/json
+
+Initiate the reset of an admin user's password
+
+[Detail](/docs/usergrid/content/admin-user#setting-an-admin-user-s-password)
+
+/users/resetpw
+
+POST
+
+application/json
+
+Complete the reset of an admin user's password
+
+[Detail](/docs/usergrid/content/admin-user#setting-an-admin-user-s-password)
+
+/users/{user|username|email|uuid}/activate?\
+ token={token}&confirm={confirm\_email}
+
+GET
+
+application/json
+
+Activate an admin user
+
+[Detail](/docs/usergrid/content/admin-user#activating-an-admin-user)
+
+/users/{user|username|email|uuid}/reactivate
+
+GET
+
+application/json
+
+Reactivate an admin user
+
+[Detail](/docs/usergrid/content/admin-user#reactivating-an-admin-user)
+
+/users/{user|username|email|uuid}/feed
+
+GET
+
+application/json
+
+Get an admin user's feed
+
+[Detail](/docs/usergrid/content/admin-user#getting-an-admin-user-s-activity-feed)
+
+### Applications
+
+ -------------------
+ See Organizations
+ -------------------
+
+### Client authorization
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/authorize?response\_type={response\_type}&\
+ client\_id={client\_id}
+
+GET
+
+application/json
+
+Authorize a client
+
+[Detail](/docs/usergrid/content/client-authorization)
+
+### Organizations
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/organizations|orgs
+
+POST
+
+application/json
+
+Create an organization
+
+[Detail](/docs/usergrid/content/organization#creating-an-organization)
+
+/organizations|orgs/{org\_name}|{uuid}
+
+GET
+
+application/json
+
+Retrieve an organization
+
+[Detail](/docs/usergrid/content/organization#getting-an-organization)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ activate?token={token}&confirm={confirm\_email}
+
+GET
+
+application/json
+
+Activate an organization
+
+[Detail](/docs/usergrid/content/organization#activating-an-organization)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ reactivate
+
+GET
+
+application/json
+
+Reactivate an organization
+
+[Detail](/docs/usergrid/content/organization#reactivating-an-organization)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ credentials
+
+POST
+
+application/json
+
+Generate organization client credentials
+
+[Detail](/docs/usergrid/content/organization#generating-organization-client-credentials)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ credentials
+
+GET
+
+application/json
+
+Retrieve organization client credentials
+
+[Detail](/docs/usergrid/content/organization#retrieving-organization-client-credentials)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ feed
+
+GET
+
+application/json
+
+Retrieve an organization's activity feed
+
+[Detail](/docs/usergrid/content/organization#getting-an-organization-s-activity-feed)
+
+/organizations|orgs/{org\_name}|{org\_uuid}/\
+ apps
+
+POST
+
+application/json
+
+Create an organization application
+
+[Detail](/docs/usergrid/content/organization#creating-an-organization-application)
+
+/organizations|orgs/{org\_name}|{org\_uuid}/\
+ apps/{app\_name}|{app\_uuid}
+
+DELETE
+
+application/json
+
+Delete an organization application
+
+[Detail](/docs/usergrid/content/organization#deleting-an-organization-application)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ applications|apps/{app\_name}|{uuid}/\
+ credentials
+
+POST
+
+application/json
+
+Generate credentials for an organization application
+
+[Detail](/docs/usergrid/content/organization#generating-an-application-credentials)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ applications|apps/\
+ {app\_name}|{uuid}/credentials
+
+GET
+
+application/json
+
+Get credentials for an organization application
+
+[Detail](/docs/usergrid/content/organization#getting-application-credentials)
+
+/organizations|orgs/{org\_name}|{uuid}/\
+ applications|apps
+
+GET
+
+application/json
+
+Get the applications in an organization
+
+[Detail](/docs/usergrid/content/organization#getting-the-applications-in-an-organization)
+
+/organizations|orgs/{org\_name}|{org\_uuid}/\
+ users/{username|email|uuid}
+
+PUT
+
+application/json
+
+Adding an admin user to an organization
+
+[Detail](/docs/usergrid/content/organization#adding-an-admin-user-to-an-organization)
+
+/organizations|orgs/{org\_name}|{org\_uuid}/ users
+
+GET
+
+application/json
+
+Getting the admin users in an organization
+
+[Detail](/docs/usergrid/content/organization#getting-the-admin-users-in-an-organization)
+
+/organizations|orgs/{org\_name}|{org\_uuid}/\
+ users/{username|email|uuid}
+
+DELETE
+
+application/json
+
+Removing an admin user from an organization
+
+[Detail](/docs/usergrid/content/organization#removing-an-admin-user-from-an-organization)
+
+### Base URL: https://api.usergrid.com
+
+### Activities
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/{org\_id}/{app\_id}/users/\
+ {uuid|username}/activities
+
+POST
+
+application/json
+
+Create an activity
+
+[Detail](/docs/usergrid/content/activity#creating-an-activity)
+
+/{org\_id}/{app\_id}/groups/\
+ {uuid|groupname}/activities
+
+POST
+
+application/json
+
+Post an activity to a group
+
+[Detail](/docs/usergrid/content/activity#posting-an-activity-to-a-group)
+
+### Assets
+
+ -------------------------------------------------------
+ See Collections (other than users, groups, and roles)
+ -------------------------------------------------------
+
+### Collections (other than users, groups, and roles)
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/{org\_id}/{app\_id}/
+
+GET
+
+application/json
+
+Retrieve all collections
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#create_entity)
+
+/{org\_id}/{app\_id}/{collection}
+
+POST
+
+application/json
+
+Create a new entity or collection
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#create_entity)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {uuid|name}
+
+GET
+
+application/json
+
+Retrieve an entity
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#get_entity_uuid)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {uuid|name}
+
+PUT
+
+application/json
+
+Update an entity
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#update_entity)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {uuid|name}
+
+DELETE
+
+application/json
+
+Delete an entity
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#delete_uuid)
+
+/{org\_id}/{app\_id}/{collection}?{query}
+
+GET
+
+application/json
+
+Query a collection
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#query_entity_collection)
+
+/{org\_id}/{app\_id}/{collection}?{query}
+
+PUT
+
+application/json
+
+Update a collection by query
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#update_collection)
+
+/{org\_id}/{app\_id}/{collection}/{entity\_id}/\
+ {relationship}?{query}
+
+GET
+
+application/json
+
+Query an entity's collections or connections
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#query_entity_collection)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_id}\
+ or\
+ /{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_type}/{second\_entity\_id}
+
+POST
+
+application/json
+
+Add an entity to a collection or create a connection
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#put_entity)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_id}\
+ or\
+ /{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_type}/{second\_entity\_id}
+
+DELETE
+
+application/json
+
+Remove an entity from a collection or delete a connection
+
+[Detail](/docs/usergrid/content/general-purpose-endpoints#remove_entity)
+
+### Devices
+
+ -------------------------------------------------------
+ See Collections (other than users, groups, and roles)
+ -------------------------------------------------------
+
+### Events
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/{org\_id}/{app\_id}/events
+
+POST
+
+application/json
+
+Create an event
+
+[Detail](/docs/usergrid/content/events-and-counters#new_event)
+
+### Folders
+
+ -------------------------------------------------------
+ See Collections (other than users, groups, and roles)
+ -------------------------------------------------------
+
+### Groups
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/{org\_id}/{app\_id}/groups
+
+POST
+
+application/json
+
+Create a new group
+
+[Detail](/docs/usergrid/content/group#create_group)
+
+/{org\_id}/{app\_id}/groups/\
+ {uuid|groupname}/users/{uuid|username}
+
+POST
+
+application/json
+
+Add a user to a group
+
+[Detail](/docs/usergrid/content/group#add_user_group)
+
+/{org\_id}/{app\_id}/groups/\
+ {uuid|groupname}
+
+GET
+
+application/json
+
+Get a group
+
+[Detail](/docs/usergrid/content/group#get_group)
+
+/{org\_id}{app\_id}/groups/\
+ {uuid|groupname}
+
+PUT
+
+application/json
+
+Update a group
+
+[Detail](/docs/usergrid/content/group#update_group)
+
+/{org\_id}/{app\_id}/groups/\
+ {uuid|groupname}/users/{uuid|username}
+
+DELETE
+
+application/json
+
+Delete user from a group
+
+[Detail](/docs/usergrid/content/group#delete_user_group)
+
+/{org\_id}/{app\_id}/groups/\
+ {uuid|groupname}/feed
+
+GET
+
+application/json
+
+Get a group's feed
+
+[Detail](/docs/usergrid/content/group#getting-a-group-s-feed)
+
+### Roles
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/{org\_id}/{app\_id}/roles
+
+POST
+
+application/json
+
+Create a new role
+
+[Detail](/docs/usergrid/content/role#create_role)
+
+/{org\_id}/{app\_id}/roles
+
+GET
+
+application/json
+
+Get the roles in an application
+
+[Detail](/docs/usergrid/content/role#get_roles)
+
+/{org\_id}/{app\_id}/roles/{rolename}
+
+DELETE
+
+application/json
+
+Delete a role
+
+[Detail](/docs/usergrid/content/role#delete_role)
+
+/{org\_id}/{app\_id}/roles/\
+ {rolename|role\_id}/permissions
+
+GET
+
+application/json
+
+Get permissions for a role
+
+[Detail](/docs/usergrid/content/role#get_permission)
+
+/{org\_id}/{app\_id}/roles/\
+ {rolename|role\_id}/permissions
+
+POST
+
+application/json
+
+Add permissions to a role
+
+[Detail](/docs/usergrid/content/role#add_permission)
+
+{org\_id}/{app\_id}/roles/\
+ {rolename|role\_id}/permissions?\
+ permission={grant\_url\_pattern}
+
+DELETE
+
+application/json
+
+Delete permissions from a role
+
+[Detail](/docs/usergrid/content/role#delete_permission)
+
+/{org\_id}/{app\_id}/roles/{role\_id}/\
+ users/{uuid|username}\
+ or\
+ /{org\_id}/{app\_id}/users/\
+ {uuid|username}/roles/{role\_id}
+
+POST
+
+application/json
+
+Add a user to a role
+
+[Detail](/docs/usergrid/content/role#adding-a-user-to-a-role)
+
+/{org\_id}/{app\_id}/roles/{role\_id}/\
+ users
+
+GET
+
+application/json
+
+Get the users in a role
+
+[Detail](/docs/usergrid/content/role#getting-the-users-in-a-role)
+
+/{org\_id}/{app\_id}/roles/{role\_id}/\
+ users/{uuid|username}
+
+DELETE
+
+application/json
+
+Delete a user from a role
+
+[Detail](/docs/usergrid/content/role#deleting-a-user-from-a-role)
+
+### Users
+
+URI
+
+Verb
+
+Content Types
+
+Action
+
+
+
+/{org\_id}/{app\_id}/users
+
+POST
+
+application/json
+
+Create a user in the users collection
+
+[Detail](/docs/usergrid/content/user#create_user)
+
+/{org\_id}/{app\_id}/users/{user}/\
+ password
+
+POST
+
+application/json
+
+Set a user's password or reset the user's existing password
+
+[Detail](/docs/usergrid/content/user#set_password)
+
+/{org\_id}/{app\_id}/users/\
+ {uuid|username|email\_address}
+
+GET
+
+application/json
+
+Retrieve a user
+
+[Detail](/docs/usergrid/content/user#uuid)
+
+/{org\_id}/{app\_id}/users/\
+ {uuid|username}
+
+PUT
+
+application/json
+
+Update a user
+
+[Detail](/docs/usergrid/content/user#update_user)
+
+/{org\_id}/{app\_id}/users/{uuid|username}
+
+DELETE
+
+application/json
+
+Delete a user
+
+[Detail](/docs/usergrid/content/user#delete_user)
+
+/{org\_id}/{app\_id}/users?{query}
+
+GET
+
+application/json
+
+Query to get users
+
+[Detail](/docs/usergrid/content/user#query_get)
+
+/{org\_id}/{app\_id}/groups/\
+ {uuid|groupname}/users/{uuid|username}
+
+POST
+
+application/json
+
+Add a user to a group
+
+[Detail](/docs/usergrid/content/user#add_user_group)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_id}\
+ or\
+ /{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_type}/{second\_entity\_id}
+
+POST
+
+application/json
+
+Add a user to a collection or create a connection
+
+[Detail](/docs/usergrid/content/user#add_collection)
+
+/{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_id}\
+ or\
+ /{org\_id}/{app\_id}/{collection}/\
+ {first\_entity\_id}/{relationship}/\
+ {second\_entity\_type}/{second\_entity\_id}
+
+DELETE
+
+application/json
+
+Remove a user from a collection or delete a connection
+
+[Detail](/docs/usergrid/content/user#delete_collection)
+
+/{org\_id}/{app\_id}/users/{uuid|username}/\
+ {relationship}?{query}
+
+GET
+
+application/json
+
+Query a user's collections or connections
+
+[Detail](/docs/usergrid/content/user#query_collection)
+
+/{org\_id}/{app\_id}/users/\
+ {uuid|username}/feed
+
+GET
+
+application/json
+
+Get a user's feed
+
+[Detail](/docs/usergrid/content/user#getting-a-user-s-feed)
+
+### Notifications, Notifiers, and Receipts
+
+ -------------------------------------------------------------------
+ See [Create & Manage Notifications](/create-manage-notifications)
+ -------------------------------------------------------------------
+
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c8b7d6c5/website/content/docs/retrieving-collections.md
----------------------------------------------------------------------
diff --git a/website/content/docs/retrieving-collections.md b/website/content/docs/retrieving-collections.md
new file mode 100644
index 0000000..9a510f6
--- /dev/null
+++ b/website/content/docs/retrieving-collections.md
@@ -0,0 +1,484 @@
+---
+title: Retrieving Collections
+category: docs
+layout: docs
+---
+
+Retrieving Collections
+======================
+
+This article describes how to retrieve all of the entities in a
+collection.
+
+By default, the Apache Usergrid API returns 10 entities per request. For
+collections with more than 10 entities, use the returned 'cursor'
+property to retrieve the next 10 entities in the result set. You may
+also use the `LIMIT` parameter in a query string to increase the number
+of results returned. For more information on using cursors, see
+[Managing large sets of results](/working-queries#cursor).
+
+**Note:** Although not shown in the API examples below, you need to
+provide a valid access token with each API call. See [Authenticating
+users and application
+clients](/authenticating-users-and-application-clients) for details.
+
+Retrieving sets of entities from a collection
+---------------------------------------------
+
+- [cURL](#curl_get_collection)
+- [iOS](#ios_get_collection)
+- [Android](#android_get_collection)
+- [JavaScript (HTML5)](#javascript_get_collection)
+- [Ruby](#ruby_get_collection)
+- [Node.js](#nodejs_get_collection)
+
+### Example Request/Response
+
+#### Request:
+
+ curl -X GET "https://api.usergrid.com/your-org/your-app/items"
+
+#### Response:
+
+ {
+ "action" : "get",
+ "application" : "f34f4222-a166-11e2-a7f7-02e81adcf3d0",
+ "params" : { },
+ "path" : "/items",
+ "uri" : "http://api.usergrid.com/your-org/your-app/items",
+ "entities" : [ {
+ "uuid" : "5bb76bca-1657-11e3-903f-9ff6c621a7a4",
+ "type" : "item",
+ "name" : "milk",
+ "created" : 1378405020796,
+ "modified" : 1378405020796,
+ "metadata" : {
+ "path" : "/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"
+ },
+ "name" : "milk",
+ "price" : "3.25"
+ }, {
+ "uuid" : "1a9356ba-1682-11e3-a72a-81581bbaf055",
+ "type" : "item",
+ "name" : "bread",
+ "created" : 1378423379867,
+ "modified" : 1378423379867,
+ "metadata" : {
+ "path" : "/items/1a9356ba-1682-11e3-a72a-81581bbaf055"
+ },
+ "name" : "bread",
+ "price" : "2.50"
+ } ],
+ "timestamp" : 1378426821261,
+ "duration" : 35,
+ "organization" : "your-org",
+ "applicationName" : "your-app",
+ "count" : 2
+ }
+
+### Request Syntax
+
+ curl -X GET https://api.usergrid.com/<org>/<app>/<collection>
+
+### Parameters
+
+ Parameter Description
+ ------------ ----------------------------------------
+ org Organization UUID or organization name
+ app Application UUID or application name
+ collection Collection UUID or collection name
+
+This example uses the [Apache Usergrid iOS SDK](/app-services-sdks#ios).
+
+### Example Request/Response
+
+#### Request:
+
+ -(NSString*)getCollection {
+
+ //specify the entity type that corresponds to the collection to be retrieved
+ NSString *type = @"item";
+
+ //we recommend you call ApigeeClient from your AppDelegate.
+ //for more information see the iOS SDK install guide: http://apigee.com/docs/app-services/content/installing-apigee-sdk-ios
+
+ //create an instance of AppDelegate
+ AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+ ApigeeCollection *collection = [[ApigeeCollection alloc] init:apigeeClient.dataClient type:type];
+
+ @try {
+ //success
+ }
+ @catch (NSException * e) {
+ //fail
+ }
+
+ }
+
+
+
+#### Response:
+
+ {
+ "action" : "get",
+ "application" : "f34f4222-a166-11e2-a7f7-02e81adcf3d0",
+ "params" : { },
+ "path" : "/items",
+ "uri" : "http://api.usergrid.com/your-org/your-app/items",
+ "entities" : [ {
+ "uuid" : "5bb76bca-1657-11e3-903f-9ff6c621a7a4",
+ "type" : "item",
+ "name" : "milk",
+ "created" : 1378405020796,
+ "modified" : 1378405020796,
+ "metadata" : {
+ "path" : "/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"
+ },
+ "name" : "milk",
+ "price" : "3.25"
+ }, {
+ "uuid" : "1a9356ba-1682-11e3-a72a-81581bbaf055",
+ "type" : "item",
+ "name" : "bread",
+ "created" : 1378423379867,
+ "modified" : 1378423379867,
+ "metadata" : {
+ "path" : "/items/1a9356ba-1682-11e3-a72a-81581bbaf055"
+ },
+ "name" : "bread",
+ "price" : "2.50"
+ } ],
+ "timestamp" : 1378426821261,
+ "duration" : 35,
+ "organization" : "your-org",
+ "applicationName" : "your-app",
+ "count" : 2
+ }
+
+### SDK Method
+
+ (ApigeeCollection*)getCollection:(NSString*)type
+
+### Properties
+
+ Parameter Description
+ ----------- ----------------------------------------------------------------
+ type The entity type associated with the collection to be retrieved
+
+This example uses the [Apache Usergrid Android
+SDK](/app-services-sdks#android).
+
+### Example Request/Response
+
+#### Request:
+
+ //Create client entity
+ String ORGNAME = "your-org";
+ String APPNAME = "your-app";
+ ApigeeClient apigeeClient = new ApigeeClient(ORGNAME,APPNAME);
+ DataClient dataClient = apigeeClient.getDataClient();
+
+ String type = "item"; //entity type to be retrieved
+ Map<String,Object> queryString = null; //we don't need any additional query parameters, in this case
+
+ //call getCollectionAsync to initiate the asynchronous API call
+ dataClient.getCollectionAsync(type, queryString, new ApiResponseCallback() {
+
+ //If getEntitiesAsync fails, catch the error
+ @Override
+ public void onException(Exception e) {
+ // Error
+ }
+
+ //If getCollectionAsync is successful, handle the response object
+ @Override
+ public void onResponse(ApiResponse response) {
+ try {
+ if (response != null) {
+ // Success
+ }
+ } catch (Exception e) { //The API request returned an error
+ // Fail
+ }
+ }
+ });
+
+
+#### Response:
+
+ {"action":"get","application":"f34f4222-a166-11e2-a7f7-02e81adcf3d0","entities":[{"dataClient":{"accessToken":null,"apiUrl":"https://api.usergrid.com","applicationId":"your-app","clientId":null,"clientSecret":null,"currentOrganization":null,"loggedInUser":null,"organizationId":"your-org"},"type":"item","uuid":"5bb76bca-1657-11e3-903f-9ff6c621a7a4","price":"4.00","created":1378405020796,"name":"milk","modified":1378505935248,"availability":"in-stock","metadata":{"path":"/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"}},{"dataClient":{"accessToken":null,"apiUrl":"https://api.usergrid.com","applicationId":"your-app","clientId":null,"clientSecret":null,"currentOrganization":null,"loggedInUser":null,"organizationId":"your-org"},"type":"item","uuid":"1a9356ba-1682-11e3-a72a-81581bbaf055","price":"2.50","created":1378423379867,"name":"bread","modified":1378423379867,"metadata":{"path":"/items/1a9356ba-1682-11e3-a72a-81581bbaf055"}}],"params":{},"path":"/items","rawResponse":"{
+ "action" : "get",
+ "application" : "f34f4222-a166-11e2-a7f7-02e81adcf3d0",
+ "params" : { },
+ "path" : "/items",
+ "uri" : "http://api.usergrid.com/your-org/your-app/items",
+ "entities" : [ {
+ "uuid" : "5bb76bca-1657-11e3-903f-9ff6c621a7a4",
+ "type" : "item",
+ "name" : "milk",
+ "created" : 1378405020796,
+ "modified" : 1378505935248,
+ "availability" : "in-stock",
+ "metadata" : {
+ "path" : "/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"
+ },
+ "name" : "milk",
+ "price" : "4.00"
+ }, {
+ "uuid" : "1a9356ba-1682-11e3-a72a-81581bbaf055",
+ "type" : "item",
+ "name" : "bread",
+ "created" : 1378423379867,
+ "modified" : 1378423379867,
+ "metadata" : {
+ "path" : "/items/1a9356ba-1682-11e3-a72a-81581bbaf055"
+ },
+ "name" : "bread",
+ "price" : "2.50"
+ } ],
+ "timestamp" : 1378512710357,
+ "duration" : 39,
+ "organization" : "your-org",
+ "applicationName" : "your-app"
+ }
+ ","uri":"http://api.usergrid.com/your-org/your-app/items","timestamp":1378512710357,"entityCount":2,"firstEntity":{"dataClient":{"accessToken":null,"apiUrl":"https://api.usergrid.com","applicationId":"your-app","clientId":null,"clientSecret":null,"currentOrganization":null,"loggedInUser":null,"organizationId":"your-org"},"type":"item","uuid":"5bb76bca-1657-11e3-903f-9ff6c621a7a4","price":"4.00","created":1378405020796,"name":"milk","modified":1378505935248,"availability":"in-stock","metadata":{"path":"/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"}},"lastEntity":{"dataClient":{"accessToken":null,"apiUrl":"https://api.usergrid.com","applicationId":"your-app","clientId":null,"clientSecret":null,"currentOrganization":null,"loggedInUser":null,"organizationId":"your-org"},"type":"item","uuid":"1a9356ba-1682-11e3-a72a-81581bbaf055","price":"2.50","created":1378423379867,"name":"bread","modified":1378423379867,"metadata":{"path":"/items/1a9356ba-1682-11e3-a72a-81581bbaf055"}},"organi
zation":"your-org","duration":39,"applicationName":"your-app"}
+
+
+### SDK Method
+
+Asynchronous:
+
+ getCollectionAsync(String type, Map<String,Object> queryString, ApiResponseCallback callback)
+
+Synchronous:
+
+ ApiResponse getCollection(String type, Map<String,Object> queryString)
+
+### Properties
+
+ Parameter Description
+ ------------- ----------------------------------------------------------------------------------
+ type The entity type being retrieved
+ queryString Map object of entity properties to be matched for the collection to be retrieved
+ callback Callback function (Asynchronous calls only)
+
+This example uses the [Apache Usergrid JavaScript (HTML5)
+SDK](/app-services-sdks#javascript).
+
+### Example Request/Response
+
+#### Request:
+
+ var dataClient = new Usergrid.Client({
+ orgName:'your-org',
+ appName:'your-app'
+ });
+
+ var options = {
+ type:"item", //Required - the type of collection to be retrieved
+ client:dataClient //Required
+ };
+
+ //Create a collection object to hold the response
+ var collection = new Usergrid.Collection(options);
+
+ //Call request to initiate the API call
+ collection.fetch(
+ function() {
+ //success callback
+ },
+ function() {
+ //error callback
+ }
+ );
+
+
+#### Response:
+
+ Object {action: "get", application: "f34f4222-a166-11e2-a7f7-02e81adcf3d0", params: Object, path: "/items", uri: "http://api.usergrid.com/your-org/your-app/items"…}
+ action: "get"
+ application: "f34f4222-a166-11e2-a7f7-02e81adcf3d0"
+ applicationName: "your-app"
+ count: 2
+ duration: 33
+ entities: Array[2]
+ 0: Object
+ created: 1378423379867
+ metadata: Object
+ modified: 1378423379867
+ name: "bread"
+ price: "2.50"
+ type: "item"
+ uuid: "1a9356ba-1682-11e3-a72a-81581bbaf055"
+ __proto__: Object
+ 1: Object
+ created: 1378405020796
+ metadata: Object
+ modified: 1378405020796
+ name: "milk"
+ price: "3.25"
+ type: "item"
+ uuid: "5bb76bca-1657-11e3-903f-9ff6c621a7a4"
+ __proto__: Object
+ length: 2
+ __proto__: Array[0]
+ organization: "your-org"
+ params: Object
+ path: "/items"
+ timestamp: 1378427598013
+ uri: "http://api.usergrid.com/your-org/your-app/items"
+ __proto__: Object
+
+
+### SDK Method
+
+ Collection.fetch(callback);
+
+### Parameters
+
+ Parameter Description
+ ----------- ----------------------------------------------
+ callback Callback function to handle the API response
+
+This example uses the [Apache Usergrid RubyGem](/app-services-sdks#ruby).
+
+### Example Request/Response
+
+#### Request:
+
+ #Create a client object
+ usergrid_api = 'https://api.usergrid.com'
+ organization = 'your-org'
+ application = 'your-app'
+
+ dataClient = Usergrid::Application.new "#{usergrid_api}/#{organization}/#{application}"
+
+ begin
+ # Retrieve the collection by referencing the [type]
+ # and save the response
+ response = dataClient['items'].entity
+
+ rescue
+ #fail
+ end
+
+
+
+#### Response:
+
+ {
+ "action" : "get",
+ "application" : "f34f4222-a166-11e2-a7f7-02e81adcf3d0",
+ "params" : { },
+ "path" : "/items",
+ "uri" : "http://api.usergrid.com/your-org/your-app/items",
+ "entities" : [ {
+ "uuid" : "5bb76bca-1657-11e3-903f-9ff6c621a7a4",
+ "type" : "item",
+ "name" : "milk",
+ "created" : 1378405020796,
+ "modified" : 1378405020796,
+ "metadata" : {
+ "path" : "/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"
+ },
+ "name" : "milk",
+ "price" : "3.25"
+ }, {
+ "uuid" : "1a9356ba-1682-11e3-a72a-81581bbaf055",
+ "type" : "item",
+ "name" : "bread",
+ "created" : 1378423379867,
+ "modified" : 1378423379867,
+ "metadata" : {
+ "path" : "/items/1a9356ba-1682-11e3-a72a-81581bbaf055"
+ },
+ "name" : "bread",
+ "price" : "2.50"
+ } ],
+ "timestamp" : 1378426821261,
+ "duration" : 35,
+ "organization" : "your-org",
+ "applicationName" : "your-app",
+ "count" : 2
+ }
+
+### SDK Method
+
+ Application.[<entity_type>].entity
+
+### Parameters
+
+ Parameter Description
+ -------------- ----------------------------------------------------------------
+ entity\_type The entity type associated with the collection to be retrieved
+
+This example uses the [Apache Usergrid Node.js
+module](/app-services-sdks#nodejs).
+
+### Example Request/Response
+
+#### Request:
+
+ var dataClient = new Usergrid.client({
+ orgName:'your-org',
+ appName:'your-app'
+ });
+
+ var options = {
+ type:"item", //Required - the type of collection to be retrieved
+ client:dataClient //Required
+ };
+
+ //Create a collection object to hold the response
+ var collection = new Usergrid.collection(options);
+
+ //Call request to initiate the API call
+ collection.fetch(function (error, response) {
+ if (error) {
+ //error
+ } else {
+ //success
+ }
+ });
+
+
+#### Response:
+
+ { action: 'get',
+ application: 'f34f4222-a166-11e2-a7f7-02e81adcf3d0',
+ params: {},
+ path: '/items',
+ uri: 'http://api.usergrid.com/your-org/your-app/items',
+ entities:
+ [ { uuid: '5bb76bca-1657-11e3-903f-9ff6c621a7a4',
+ type: 'item',
+ name: 'milk',
+ created: 1378405020796,
+ modified: 1378405020796,
+ metadata: [Object],
+ price: '3.25' },
+ { uuid: '1a9356ba-1682-11e3-a72a-81581bbaf055',
+ type: 'item',
+ name: 'bread',
+ created: 1378423379867,
+ modified: 1378423379867,
+ metadata: [Object],
+ price: '2.50' } ],
+ timestamp: 1378428161834,
+ duration: 33,
+ organization: 'your-org',
+ applicationName: 'your-app' }
+
+
+### SDK Method
+
+ Collection.fetch(callback)
+
+### Parameters
+
+ Parameter Description
+ ----------- ----------------------------------------------
+ callback Callback function to handle the API response
+
+