| |
| |
| <!DOCTYPE html> |
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>Entities — Apache Usergrid 1.0 documentation</title> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| |
| |
| |
| |
| |
| <link rel="top" title="Apache Usergrid 1.0 documentation" href="../index.html"/> |
| <link rel="next" title="Querying your data" href="../data-queries/querying-your-data.html"/> |
| <link rel="prev" title="Collections" href="collections.html"/> |
| |
| |
| <script src="../_static/js/modernizr.min.js"></script> |
| |
| </head> |
| |
| <body class="wy-body-for-nav" role="document"> |
| |
| <div class="wy-grid-for-nav"> |
| |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-nav-search"> |
| |
| |
| |
| <a href="../index.html" class="icon icon-home"> Apache Usergrid |
| |
| |
| |
| </a> |
| |
| |
| |
| |
| <div class="version"> |
| 1.0 |
| </div> |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| <p class="caption"><span class="caption-text">Getting Started</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/overview.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/usergrid-features.html">Usergrid Features</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/data-model.html">Usergrid Data model</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/async-vs-sync.html">Async vs. sync calls</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Using Usergrid</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/creating-account.html">Creating a Usergrid Account</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/creating-a-new-application.html">Creating a new application</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/using-a-sandbox-app.html">Using a Sandbox Application</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/using-the-api.html">Using the API</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Data Storage</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="data-store-dbms.html">The Usergrid Data Store</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="optimizing-access.html">Data Store Best Practices</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="collections.html">Collections</a></li> |
| <li class="toctree-l1 current"><a class="current reference internal" href="">Entities</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="#creating-custom-data-entities">Creating Custom Data Entities</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#creating-a-custom-entity">Creating a custom entity</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#request-syntax">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#example-request-response">Example Request/Response</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#creating-multiple-custom-entities">Creating multiple custom entities</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#id1">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id2">Example Request/Response</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#creating-an-entity-with-sub-properties">Creating an entity with sub-properties</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#updating-sub-properties">Updating sub-properties</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#retrieving-data-entities">Retrieving Data Entities</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#retrieving-an-entity">Retrieving an entity</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id3">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id4">Example Request/Response</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#retrieving-multiple-entities">Retrieving multiple entities</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id5">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id6">Example Request/Response</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#updating-data-entities">Updating Data Entities</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#updating-an-entity">Updating an entity</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id7">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id8">Example Request/Response</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#updating-a-sub-property">Updating a sub-property</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id9">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id10">Example Request/Response</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#deleting-data-entities">Deleting Data Entities</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#deleting-an-entity">Deleting an entity</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id11">Request Syntax</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#id12">Example Request/Response</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <p class="caption"><span class="caption-text">Data Queries</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/querying-your-data.html">Querying your data</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/query-parameters.html">Query parameters & clauses</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/operators-and-types.html">Query operators & data types</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/advanced-query-usage.html">Advanced query usage</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Entity Connections</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/connecting-entities.html">Connecting entities</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/retrieving-entities.html">Retrieving connections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/disconnecting-entities.html">Disconnecting entities</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Push Notifications</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/overview.html">Push notifications overview</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/adding-push-support.html">Adding push notifications support</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/getting-started.html">Getting started with push notifications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/tutorial.html">Tutorial: Push notifications sample app</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/registering.html">Registering with a notification service</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/creating-notifiers.html">Creating notifiers</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/managing-users-and-devices.html">Managing users and devices</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/creating-and-managing-notifications.html">Creating and managing notifications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/troubleshooting.html">Troubleshooting</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Security & Authentication</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/app-security.html">Security & token authentication</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/using-permissions.html">Using permissions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/using-roles.html">Using roles</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating users & app clients</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/user-authentication-types.html">Authentication levels</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/changing-token-time-live-ttl.html">Changing token expiration (time-to-live)</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/authenticating-api-requests.html">Authenticating API requests</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/revoking-tokens-logout.html">Revoking tokens (logout)</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/facebook-sign.html">Facebook sign in</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/securing-your-app.html">Security best practices</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">User Management & Social Graph</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/user-management.html">User management & social graph</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/working-user-data.html">Working with User Data</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/group.html">Working with group data</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/activity.html">Activity</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/user-connections.html">Social Graph Connections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/user-connections.html#creating-other-connections">Creating other connections</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../user-management/messagee-example.html">App Example - Messagee</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Geo-location</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../geolocation/geolocation.html">Geolocating your Entities</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Assets & Files</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/uploading-assets.html">Uploading assets</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/retrieving-assets.html">Retrieving assets</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/folders.html">Folders</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Counters & Events</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/events-and-counters.html">Counters & events</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html">Creating & incrementing counters</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html#decrementing-resetting-counters">Decrementing/resetting counters</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html#using-counters-hierarchically">Using counters hierarchically</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/retrieving-counters.html">Retrieving counters</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Organizations & Applications</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/managing.html">Organization & application management</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/organization.html">Organization</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/application.html">Application</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/admin-user.html">Admin user</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">API Reference</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html">Methods</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html#models">Models</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html#sub-types">Sub-Types</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Client SDKs</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../sdks/tbd.html">COMING SOON...</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Installing Usergrid</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../installation/deployment-guide.html">Usergrid 2.1.0 Deployment Guide</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">More about Usergrid</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/presos-and-videos.html">Presentations & Videos</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/contribute-code.html">How to Contribute Code & Docs</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">Apache Usergrid</a> |
| </nav> |
| |
| |
| |
| <div class="wy-nav-content"> |
| <div class="rst-content"> |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| <ul class="wy-breadcrumbs"> |
| <li><a href="../index.html">Docs</a> »</li> |
| |
| <li>Entities</li> |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../_sources/data-storage/entities.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| </ul> |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="entities"> |
| <h1>Entities<a class="headerlink" href="#entities" title="Permalink to this headline">¶</a></h1> |
| <div class="section" id="creating-custom-data-entities"> |
| <h2>Creating Custom Data Entities<a class="headerlink" href="#creating-custom-data-entities" title="Permalink to this headline">¶</a></h2> |
| <p>This article describes how to create custom data entities and entity |
| properties. Entity types correspond to the name of collection to which |
| they are posted. For example, if you create a new custom “dog” entity, a |
| “dogs” collection will be created if one did not already exist. If a |
| “dogs” collection already exists, the new “dog” entity will be saved in |
| it. All user-defined properties are indexed, and strings that contain |
| multiple words are keyword-indexed.</p> |
| <p>The methods cited in this article should be used to create custom data |
| entities. If you are using one of the Usergrid SDKs, use one of the |
| entity type-specific SDK methods to create default data entities.</p> |
| <p><strong>Note</strong>: Although not shown in the API examples below, you need to |
| provide a valid access token with each API call. See <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating |
| users and application |
| clients</a> |
| for details.</p> |
| <div class="section" id="creating-a-custom-entity"> |
| <h3>Creating a custom entity<a class="headerlink" href="#creating-a-custom-entity" title="Permalink to this headline">¶</a></h3> |
| <p>When a new entity is created, Usergrid will automatically create a |
| corresponding collection if one does not already exist. The collection |
| will automatically be named with the plural form of the entity type. For |
| example, creating a custom entity of type ‘item’ will automatically |
| create a collection named ‘items’ in which all future ‘item’ entities |
| will be saved.</p> |
| </div> |
| <div class="section" id="request-syntax"> |
| <h3>Request Syntax<a class="headerlink" href="#request-syntax" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X POST https://api.usergrid.com/<org>/<app>/<entity_type> -d 'json_object' |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="27%" /> |
| <col width="73%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org</td> |
| <td>Organization UUID or organization name</td> |
| </tr> |
| <tr class="row-odd"><td>app</td> |
| <td>Application UUID or application name</td> |
| </tr> |
| <tr class="row-even"><td>entity_type</td> |
| <td>Entity type to create.</td> |
| </tr> |
| <tr class="row-odd"><td>json_object</td> |
| <td>JSON representation of entity properties</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>(For a full list of default properties, see Default Data Entity Types)</p> |
| <p>Usergrid will create a corresponding collection if one does not already |
| exist. To add an entity to an existing collections, use the pluralized |
| collection name for entity_type.</p> |
| </div> |
| <div class="section" id="example-request-response"> |
| <h3>Example Request/Response<a class="headerlink" href="#example-request-response" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X POST "https://api.usergrid.com/your-org/your-app/item" -d '{"name":"milk", "price":"3.25"}' |
| </pre></div> |
| </div> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"post"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"4a1edb70-d7a8-11e2-9ce3-f315e5aa568a"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/my-org/my-app/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"83e9b7ea-e8f5-11e2-84df-e94123890c7a"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1373415195230</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1373415195230</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/83e9b7ea-e8f5-11e2-84df-e94123890c7a"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"3.25"</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1373415195225</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">635</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"my-org"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"my-app"</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| <div class="section" id="creating-multiple-custom-entities"> |
| <h2>Creating multiple custom entities<a class="headerlink" href="#creating-multiple-custom-entities" title="Permalink to this headline">¶</a></h2> |
| <div class="section" id="id1"> |
| <h3>Request Syntax<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X POST https://api.usergrid.com/<org>/<app>/<entity_type>/ -d 'json_array' |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="28%" /> |
| <col width="72%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org</td> |
| <td>Organization UUID or name</td> |
| </tr> |
| <tr class="row-odd"><td>app</td> |
| <td>Application UUID or name</td> |
| </tr> |
| <tr class="row-even"><td>entity_type</td> |
| <td>Custom entity type to create.</td> |
| </tr> |
| <tr class="row-odd"><td>json_array</td> |
| <td>JSON array of entities to be created.</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>Usergrid will create a corresponding collection if one does not already |
| exist. To add an entity to an existing collections, use the collection |
| name or collection UUID in place of the entity type.</p> |
| </div> |
| <div class="section" id="id2"> |
| <h3>Example Request/Response<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X POST "https://api.usergrid.com/your-org/your-app/item" -d '[{"name":"milk", "price":"3.25"}, {"name":"bread", "price":"2.50"}]' |
| </pre></div> |
| </div> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"post"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"f34f4222-a166-11e2-a7f7-02e9sjwsf3d0"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/your-org/your-app/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"f3a8061a-ef0b-11e2-9e92-5f4a65c16193"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"3.25"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1374084538609</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1374084538609</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/multis/f3a8061a-ef0b-11e2-9e92-5f4a65c16193"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span> |
| <span class="p">},</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"f3be262a-ef0b-11e2-a51b-6715d5ef47a6"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"bread"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"2.50"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1374084538754</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1374084538754</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/f3be262a-ef0b-11e2-a51b-6715d5ef47a6"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"bread"</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1374084538584</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">388</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"your-org"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"your-app"</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="creating-an-entity-with-sub-properties"> |
| <h3>Creating an entity with sub-properties<a class="headerlink" href="#creating-an-entity-with-sub-properties" title="Permalink to this headline">¶</a></h3> |
| <p>Any valid JSON object can be stored in an entity, regardless of the |
| level of complexity, including sub-properties. For example, suppose you |
| have an ‘items’ collection that contains an entity named ‘milk’. You |
| might store the different varieties of milk as sub-properties of a |
| ‘varieties’ property:</p> |
| <div class="highlight-python"><div class="highlight"><pre>{ |
| "type" : "item" |
| "name" : "milk" |
| "varieties" : [ { |
| "name" : "1%", |
| "price" : "3.25", |
| "sku" : "0393847575533445" |
| }, { |
| "name" : "whole", |
| "price" : "3.85", |
| "sku" : "0393394956788445" |
| }, { |
| "name" : "skim", |
| "price" : "4.00", |
| "sku" : "0390299933488445" |
| } ] |
| } |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="updating-sub-properties"> |
| <h3>Updating sub-properties<a class="headerlink" href="#updating-sub-properties" title="Permalink to this headline">¶</a></h3> |
| <p>An array of sub-properties is treated as a single object. This means |
| that sub-properties cannot be updated atomically. All sub-properties of |
| a given property must be updated as a set. For more on updating an |
| existing sub-property, see <a class="reference external" href="../data-storage/entities.html#updating-data-entities">Updating Data |
| Entities</a>.</p> |
| <p>Example Request/Response</p> |
| <div class="highlight-python"><div class="highlight"><pre>Request: |
| //Note the use of square brackets for specifying multiple nested objects |
| curl -X POST "https://api.usergrid.com/your-org/your-app/items" -d '{"varieties":[{"name":"1%","price" : "3.25", "sku" : "0393847575533445"},{"name" : "whole", "price" : "3.85", "sku" : "0393394956788445"}, {"name" : "skim", "price" : "4.00", "sku" : "0390299933488445"}]}' |
| Response: |
| { |
| "action" : "post", |
| "application" : "f34f4222-a166-11e2-a7f7-02e81adcf3d0", |
| "params" : { }, |
| "path" : "/items", |
| "uri" : "http://api.usergrid.com/your-org/your-app/items", |
| "entities" : [ { |
| "uuid" : "0d7cf92a-effb-11e2-917d-c5e707256e71", |
| "type" : "item", |
| "name" : "milk", |
| "created" : 1374187231666, |
| "modified" : 1374187231666, |
| "metadata" : { |
| "path" : "/items/0d7cf92a-effb-11e2-917d-c5e707256e71" |
| }, |
| "name" : "milk", |
| "varieties" : [ { |
| "name" : "1%", |
| "price" : "3.25", |
| "SKU" : "0393847575533445" |
| }, { |
| "name" : "whole", |
| "price" : "3.85", |
| "SKU" : "0393394956788445" |
| }, { |
| "name" : "skim", |
| "price" : "4.00", |
| "SKU" : "0390299933488445" |
| } ] |
| } ], |
| "timestamp" : 1374187450826, |
| "duration" : 50, |
| "organization" : "your-org", |
| "applicationName" : "your-app" |
| } |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| <hr class="docutils" /> |
| <div class="section" id="retrieving-data-entities"> |
| <h2>Retrieving Data Entities<a class="headerlink" href="#retrieving-data-entities" title="Permalink to this headline">¶</a></h2> |
| <p>This article describes how to retrieve entities from your account.</p> |
| <p><strong>Note</strong>: Although not shown in the API examples below, you need to |
| provide a valid access token with each API call. See <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating |
| users and application |
| clients</a> |
| for details.</p> |
| <p>With the exception of the user entity, all data entities can be |
| retrieved by using their UUID or a ‘name’ property. The user entity can |
| be retrieved by UUID or the ‘username’ property. The value for the |
| ‘name’ or ‘username’ property must be unique.</p> |
| <div class="section" id="retrieving-an-entity"> |
| <h3>Retrieving an entity<a class="headerlink" href="#retrieving-an-entity" title="Permalink to this headline">¶</a></h3> |
| </div> |
| <div class="section" id="id3"> |
| <h3>Request Syntax<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X GET https://api.usergrid.com/<org>/<app>/<collection>/<entity> |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="25%" /> |
| <col width="75%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org</td> |
| <td>Organization UUID or organization name</td> |
| </tr> |
| <tr class="row-odd"><td>app</td> |
| <td>Application UUID or application name</td> |
| </tr> |
| <tr class="row-even"><td>collection</td> |
| <td>Collection UUID or collection name</td> |
| </tr> |
| <tr class="row-odd"><td>entity</td> |
| <td>Entity UUID or entity name</td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="section" id="id4"> |
| <h3>Example Request/Response<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <p>Retrieve by UUID:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X GET "https://api.usergrid.com/your-org/your-app/items/da4a50dc-38dc-11e2-b2e4-02e81adcf3d0" |
| </pre></div> |
| </div> |
| <p>Retrieve by ‘name’ property:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X GET "https://api.usergrid.com/your-org/your-app/items/milk" |
| </pre></div> |
| </div> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"get"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"f34f4222-a166-11e2-a7f7-02e81adcf3d0"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/amuramoto/sandbox/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1378405020796</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1378405020796</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"3.25"</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1378405025763</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">31</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"amuramoto"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"sandbox"</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="retrieving-multiple-entities"> |
| <h3>Retrieving multiple entities<a class="headerlink" href="#retrieving-multiple-entities" title="Permalink to this headline">¶</a></h3> |
| <p>This example describes how to retrieve multiple entities by UUID. You |
| can also retrieve a set of entities by using a query string. For more |
| information on querying your data, see Querying your data.</p> |
| </div> |
| <div class="section" id="id5"> |
| <h3>Request Syntax<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X GET https://api.usergrid.com/<org_id>/<app_id>/<collection>?ql= uuid = <entity_uuid> OR uuid = <entity_uuid>; ... |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="18%" /> |
| <col width="83%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org_id</td> |
| <td>Organization UUID or organization name</td> |
| </tr> |
| <tr class="row-odd"><td>app_id</td> |
| <td>Application UUID or application name</td> |
| </tr> |
| <tr class="row-even"><td>collection</td> |
| <td>Collection UUID or collection name</td> |
| </tr> |
| <tr class="row-odd"><td>query</td> |
| <td>A url-encoded query string of entity properties to be matched.</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>The query must be in Usergrid Query Language, for example:</p> |
| <div class="highlight-python"><div class="highlight"><pre>?ql=uuid="<entity_uuid>"" OR name="<entity_name>" OR... |
| </pre></div> |
| </div> |
| <p>You may also specify the following for certain entity types:</p> |
| <p>User entities: username =</p> |
| <p>All other entities except groups: name =</p> |
| </div> |
| <div class="section" id="id6"> |
| <h3>Example Request/Response<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <div class="highlight-python"><div class="highlight"><pre>//note the url-encoded query string |
| curl -X GET "https://api.usergrid.com/your-org/your-app/items?ql=name%3D'milk'%20OR%20UUID%3D1a9356ba-1682-11e3-a72a-81581bbaf055&limit=" |
| </pre></div> |
| </div> |
| <p>Note: The query parameter of the request must be url encoded for curl |
| requests</p> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"get"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"f34f4222-a166-11e2-a7f7-02e81adcf3d0"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"ql"</span> <span class="p">:</span> <span class="p">[</span> <span class="s">"name='milk' OR UUID=1a9356ba-1682-11e3-a72a-81581bbaf055"</span> <span class="p">]</span> |
| <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/your-org/your-app/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1378405020796</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1378405020796</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"3.25"</span> |
| <span class="p">},</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"1a9356ba-1682-11e3-a72a-81581bbaf055"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"bread"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1378423379867</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1378423379867</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/1a9356ba-1682-11e3-a72a-81581bbaf055"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"bread"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"2.50"</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1378423793729</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">63</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"your-org"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"your-app"</span><span class="p">,</span> |
| <span class="s">"count"</span> <span class="p">:</span> <span class="mi">2</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| <hr class="docutils" /> |
| <div class="section" id="updating-data-entities"> |
| <h2>Updating Data Entities<a class="headerlink" href="#updating-data-entities" title="Permalink to this headline">¶</a></h2> |
| <p>This article describes how to update entities in your account.</p> |
| <p><strong>Note</strong>: Although not shown in the API examples below, you need to |
| provide a valid access token with each API call. See <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating |
| users and application |
| clients</a> |
| for details.</p> |
| <div class="section" id="updating-an-entity"> |
| <h3>Updating an entity<a class="headerlink" href="#updating-an-entity" title="Permalink to this headline">¶</a></h3> |
| <p>One or more properties can be updated with a single PUT request. For |
| information on updating sub-properties, see Updating sub-properties |
| below.</p> |
| </div> |
| <div class="section" id="id7"> |
| <h3>Request Syntax<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X PUT https://api.usergrid.com/<org>/<app>/<collection>/<entity> -d {<property>} |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="21%" /> |
| <col width="79%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org_id</td> |
| <td>Organization UUID or organization name</td> |
| </tr> |
| <tr class="row-odd"><td>app_id</td> |
| <td>Application UUID or application name</td> |
| </tr> |
| <tr class="row-even"><td>collection</td> |
| <td>Name of the collection containing the entity to be updated</td> |
| </tr> |
| <tr class="row-odd"><td>uuid|name</td> |
| <td>UUID or name of the data entity to be updated</td> |
| </tr> |
| <tr class="row-even"><td>json_object</td> |
| <td>JSON object with a field for each property to be updated</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>An entity property to be updated, formatted as a key-value pair. For |
| example:</p> |
| <div class="highlight-python"><div class="highlight"><pre>{"property_1":"value_1", "property_2":"value_2",...} |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="id8"> |
| <h3>Example Request/Response<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X PUT https://api.usergrid.com/your-org/your-app/items/milk -d '{"price":"4.00", "availability":"in-stock"}' |
| </pre></div> |
| </div> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"put"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"f34f4222-a166-11e2-a7f7-02e81adcf3d0"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/your-org/your-app/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1378405020796</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1378505705077</span><span class="p">,</span> |
| <span class="s">"availability"</span> <span class="p">:</span> <span class="s">"in-stock"</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"4.00"</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1378505705050</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">87</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"your-org"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"your-app"</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="updating-a-sub-property"> |
| <h3>Updating a sub-property<a class="headerlink" href="#updating-a-sub-property" title="Permalink to this headline">¶</a></h3> |
| <p>Data entities may contain sets of sub-properties as nested JSON objects. |
| Unlike normal entity properties, however, sub-properties cannot be |
| updated individually. Updating a nested object will cause all |
| sub-properties within it to be overwritten.</p> |
| <p>For example, if you have a data entity with the following nested object:</p> |
| </div> |
| <div class="section" id="id9"> |
| <h3>Request Syntax<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X PUT https://api.usergrid.com/<org_id>/<app_id>/<collection>/<uuid|name> -d '{<property> : [{<sub_property>}, {<sub_property>}...]}' |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="21%" /> |
| <col width="79%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org_id</td> |
| <td>Organization UUID or organization name</td> |
| </tr> |
| <tr class="row-odd"><td>app_id</td> |
| <td>Application UUID or application name</td> |
| </tr> |
| <tr class="row-even"><td>collection</td> |
| <td>Name of the collection containing the entity to be updated</td> |
| </tr> |
| <tr class="row-odd"><td>uuid|name</td> |
| <td>UUID or name of the data entity to be updated</td> |
| </tr> |
| <tr class="row-even"><td>json_object</td> |
| <td>JSON object with a field for each property to be updated</td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="section" id="id10"> |
| <h3>Example Request/Response<a class="headerlink" href="#id10" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X PUT https://api.usergrid.com/your-org/your-app/items/milk -d '{"varieties":[{"name":"1%","price":"3.25"},{"name":"whole","price":"4.00"}]}' |
| </pre></div> |
| </div> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"put"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"f34f4222-a166-11e2-a7f7-02e81adcf3d0"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/your-org/your-app/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1378405020796</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1378761459069</span><span class="p">,</span> |
| <span class="s">"availability"</span> <span class="p">:</span> <span class="s">"in-stock"</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/your-org/your-app/items/5bb76bca-1657-11e3-903f-9ff6c621a7a4"</span><span class="p">,</span> |
| <span class="s">"varieties"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"1%"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"3.25"</span> |
| <span class="p">},</span> <span class="p">{</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"whole"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"4.00"</span> |
| <span class="p">}</span> <span class="p">]</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1378761459047</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">62</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"your-org"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"your-app"</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| <div class="section" id="deleting-data-entities"> |
| <h2>Deleting Data Entities<a class="headerlink" href="#deleting-data-entities" title="Permalink to this headline">¶</a></h2> |
| <p>This article describes how to delete data entities.</p> |
| <p><strong>Note</strong>:Although not shown in the API examples below, you need to |
| provide a valid access token with each API call. See <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating |
| users and application |
| clients</a> |
| for details.</p> |
| <div class="section" id="deleting-an-entity"> |
| <h3>Deleting an entity<a class="headerlink" href="#deleting-an-entity" title="Permalink to this headline">¶</a></h3> |
| </div> |
| <div class="section" id="id11"> |
| <h3>Request Syntax<a class="headerlink" href="#id11" title="Permalink to this headline">¶</a></h3> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X DELETE https://api.usergrid.com/<org>/<app>/<collection>/<entity> |
| </pre></div> |
| </div> |
| <p>Parameters</p> |
| <table border="1" class="docutils"> |
| <colgroup> |
| <col width="25%" /> |
| <col width="75%" /> |
| </colgroup> |
| <thead valign="bottom"> |
| <tr class="row-odd"><th class="head">Parameter</th> |
| <th class="head">Description</th> |
| </tr> |
| </thead> |
| <tbody valign="top"> |
| <tr class="row-even"><td>org</td> |
| <td>Organization UUID or organization name</td> |
| </tr> |
| <tr class="row-odd"><td>app</td> |
| <td>Application UUID or application name</td> |
| </tr> |
| <tr class="row-even"><td>collection</td> |
| <td>Collection UUID or collection name</td> |
| </tr> |
| <tr class="row-odd"><td>entity</td> |
| <td>Entity UUID or entity name</td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="section" id="id12"> |
| <h3>Example Request/Response<a class="headerlink" href="#id12" title="Permalink to this headline">¶</a></h3> |
| <p>Request:</p> |
| <p>Delete by UUID:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X DELETE "https://api.usergrid.com/your-org/your-app/items/da4a50dc-38dc-11e2-b2e4-02e81adcf3d0" |
| </pre></div> |
| </div> |
| <p>Delete by ‘name’ property:</p> |
| <div class="highlight-python"><div class="highlight"><pre>curl -X DELETE "https://api.usergrid.com/your-org/your-app/items/milk" |
| </pre></div> |
| </div> |
| <p>Response:</p> |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"delete"</span><span class="p">,</span> |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"f34f4222-a166-11e2-a7f7-02e81adcf3d0"</span><span class="p">,</span> |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items"</span><span class="p">,</span> |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"http://api.usergrid.com/your-org/your-app/items"</span><span class="p">,</span> |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"328fe64a-19a0-11e3-8a2a-ebc6f49d1fc4"</span><span class="p">,</span> |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"item"</span><span class="p">,</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1378766158500</span><span class="p">,</span> |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1378766158500</span><span class="p">,</span> |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/items/328fe64a-19a0-11e3-8a2a-ebc6f49d1fc4"</span> |
| <span class="p">},</span> |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"milk"</span><span class="p">,</span> |
| <span class="s">"price"</span> <span class="p">:</span> <span class="s">"3.25"</span> |
| <span class="p">}</span> <span class="p">],</span> |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1378766172016</span><span class="p">,</span> |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">324</span><span class="p">,</span> |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"your-org"</span><span class="p">,</span> |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"your-app"</span> |
| <span class="p">}</span> |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| |
| </div> |
| </div> |
| <footer> |
| |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| |
| <a href="../data-queries/querying-your-data.html" class="btn btn-neutral float-right" title="Querying your data" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="collections.html" class="btn btn-neutral" title="Collections" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| |
| </div> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © Copyright 2013-2015, Apache Usergrid. |
| |
| </p> |
| </div> |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| |
| |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT:'../', |
| VERSION:'1.0', |
| COLLAPSE_INDEX:false, |
| FILE_SUFFIX:'.html', |
| HAS_SOURCE: true |
| }; |
| </script> |
| <script type="text/javascript" src="../_static/jquery.js"></script> |
| <script type="text/javascript" src="../_static/underscore.js"></script> |
| <script type="text/javascript" src="../_static/doctools.js"></script> |
| |
| |
| |
| |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.StickyNav.enable(); |
| }); |
| </script> |
| |
| |
| </body> |
| </html> |