21700: Install Bundler system-wide in Rails postinst
[arvados.git] / doc / api / methods.html.textile.liquid
1 ---
2 layout: default
3 navsection: api
4 navmenu: Concepts
5 title: Common resource methods
6
7 ...
8 {% comment %}
9 Copyright (C) The Arvados Authors. All rights reserved.
10
11 SPDX-License-Identifier: CC-BY-SA-3.0
12 {% endcomment %}
13
14 The following methods are available for most resources.  Some resources may limit who can perform certain operations.  Consult documentation for individual resource types for details.
15
16 The methods are relative to the base URI, e.g., @/arvados/v1/resource_type@.  For arguments specifying a *Location* of @path@, the value of the argument is incorporated into the path portion of the URI.  For example, a @uuid@ of @aaaaa-bbbbb-ccccccccccccccc@ in a path position yields a URI of @/arvados/v1/resource_type/aaaaa-bbbbb-ccccccccccccccc@.
17
18 Arguments specifying a *Location* of "query" are incorporated into the query portion of the URI or request body.  For example, @/arvados/v1/resource_type?count=none@.
19
20 Certain method calls on certain object types support "federation":{{site.baseurl}}/architecture/federation.html , that is, the ability to operate on objects owned by different clusters.   API pages for specific object types list which federated operations are supported for that type (if any) in the "Methods" section.  Methods which implicitly include a cluster id (such as @GET@ on a specific uuid, using the uuid prefix) will be directed to the appropriate cluster.  Methods that don't implicitly include the cluster id (such as @create@) use the @cluster_id@ query parameter to specify which cluster to direct the request.
21
22 h2. create
23
24 The @create@ method creates a new object of the specified type.  Note that:
25
26 * Only the listed attributes (and "standard metadata":resources.html) are set
27 * Unset attributes will get default values
28 * The attributes of a given resource type are fixed (you cannot introduce new toplevel attributes)
29
30 This method corresponds to the HTTP request @POST /arvados/v1/resource_type@.  A successful create call returns a copy of the new object.
31
32 To create an object on a remote cluster (federated create), provide the @cluster_id@ of the target cluster.
33
34 Arguments:
35
36 table(table table-bordered table-condensed).
37 |_. Argument |_. Type |_. Description |_. Location |
38 |{resource_type}|object|Name is the singular form of the resource type, e.g., for the "collections" resource, this argument is "collection"|body|
39 |{cluster_id}|string|Optional, the cluster on which to create the object if not the current cluster.|query|
40 |select  |array  |Attributes of the new object to return in the response (by default, all available attributes are returned).
41 Example: @["uuid","name","modified_at"]@|query|
42
43 h2. delete
44
45 The @delete@ method deletes an object of the specified type.  It corresponds to the HTTP request @DELETE /arvados/v1/resource_type/uuid@.  A successful delete call returns a copy of the deleted object.
46
47 The cluster id portion of the @uuid@ is used to determine which cluster owns the object, a federated delete request will be routed to that cluster.
48
49 Arguments:
50
51 table(table table-bordered table-condensed).
52 |_. Argument |_. Type |_. Description |_. Location |
53 {background:#ccffcc}.|uuid|string|The UUID of the object in question.|path|
54 |select  |array  |Attributes of the deleted object to return in the response (by default, all available attributes are returned).
55 Example: @["uuid","name","modified_at"]@|query|
56
57 h2. get
58
59 The @get@ method gets a single object with the specified @uuid@.  It corresponds to the HTTP request @GET /arvados/v1/resource_type/uuid@.
60
61 The cluster id portion of the @uuid@ is used to determine which cluster owns the object, a federated get request will be routed to that cluster.
62
63 Arguments:
64
65 table(table table-bordered table-condensed).
66 |_. Argument |_. Type |_. Description |_. Location |
67 {background:#ccffcc}.|uuid|string|The UUID of the object in question.|path|
68 |select  |array  |Attributes of the object to return in the response (by default, all available attributes are returned).
69 Example: @["uuid","name","modified_at"]@|query|
70
71 h2(#index). list
72
73 The @list@ method requests an list of resources of that type.  It corresponds to the HTTP request @GET /arvados/v1/resource_type@.  All resources support the @list@ method unless otherwise noted.
74
75 Arguments:
76
77 table(table table-bordered table-condensed).
78 |_. Argument |_. Type |_. Description |_. Location |
79 |limit   |integer|Maximum number of resources to return.  If not provided, server will provide a default limit.  Server may also impose a maximum number of records that can be returned in a single request.|query|
80 |offset  |integer|Skip the first 'offset' number of resources that would be returned under the given filter conditions.|query|
81 |filters |array  |"Conditions for selecting resources to return.":#filters|query|
82 |order   |array  |Attributes to use as sort keys to determine the order resources are returned, each optionally followed by @asc@ or @desc@ to indicate ascending or descending order.  (If not specified, it will be ascending).
83 Example: @["head_uuid asc","modified_at desc"]@
84 Default: @["modified_at desc", "uuid asc"]@|query|
85 |select  |array  |Attributes of each object to return in the response (by default, all available attributes are returned, except collections, which do not return @manifest_text@ unless explicitly selected).
86 Example: @["uuid","name","modified_at"]@|query|
87 |distinct|boolean|When returning multiple records whose selected attributes (see @select@) are equal, return them as a single response entry.
88 Default is @false@.|query|
89 |count|string|@"exact"@ (default): Include an @items_available@ response field giving the number of distinct matching items that can be retrieved (irrespective of @limit@ and @offset@ arguments).
90 @"none"@: Omit the @items_available@ response field. This option will produce a faster response.|query|
91
92 h3(#filters). Available list method filters
93
94 The value of the @filters@ parameter is an array of conditions. The @list@ method returns only the resources that satisfy all of the given conditions. In other words, the conjunction @AND@ is implicit.
95
96 Each condition is expressed as an array with three elements: @[attribute, operator, operand]@.
97
98 table(table table-bordered table-condensed).
99 |_. Index|_. Element|_. Type|_. Description|_. Examples|
100 |0|attribute|string|Name of the attribute to compare (or "any" to return resources with any matching attribute)|@script_version@, @head_uuid@, @any@|
101 |1|operator|string|Comparison operator|@>@, @>=@, @like@, @not in@|
102 |2|operand|string, array, or null|Value to compare with the resource attribute|@"d00220fb%"@, @"1234"@, @["foo","bar"]@, @nil@|
103
104 The following operators are available.
105
106 table(table table-bordered table-condensed).
107 |_. Operator|_. Operand type|_. Description|_. Example|
108 |@=@, @!=@, @<>@|string, number, timestamp, JSON-encoded array, JSON-encoded object, or null|Equality comparison|@["tail_uuid","=","xyzzy-j7d0g-fffffffffffffff"]@
109 @["tail_uuid","!=",null]@
110 @["storage_classes_desired","=","[\"default\"]"]@|
111 |@<@, @<=@, @>=@, @>@|string, number, or timestamp|Ordering comparison|@["script_version",">","123"]@|
112 |@like@, @ilike@|string|SQL pattern match.  Single character match is @_@ and wildcard is @%@. The @ilike@ operator is case-insensitive|@["script_version","like","d00220fb%"]@|
113 |@in@, @not in@|array of strings or integers|Set membership|@["script_version","in",["main","d00220fb38d4b85ca8fc28a8151702a2b9d1dec5"]]@|
114 |@is_a@|string|Arvados object type|@["head_uuid","is_a","arvados#collection"]@|
115 |@exists@|string|Presence of subproperty|@["properties","exists","my_subproperty"]@|
116 |@contains@|string, array of strings|Presence of one or more keys or array elements|@["storage_classes_desired", "contains", ["foo", "bar"]]@ (matches both @["foo", "bar"]@ and @["foo", "bar", "baz"]@)
117 (note @[..., "contains", "foo"]@ is also accepted, and is equivalent to @[..., "contains", ["foo"]]@)|
118
119 h4(#substringsearchfilter). Filtering using substring search
120
121 Resources can also be filtered by searching for a substring in attributes of type @string@, @array of strings@, @text@, and @hash@, which are indexed in the database specifically for search. To use substring search, the filter must:
122
123 * Specify @any@ as the attribute
124 * Use either the @like@ or @ilike@ operator
125 * Have an operand of type @string@ that is wrapped in the SQL pattern match wildcard character @%@
126
127 For example, the @["any", "like", "%foo%"]@ filter will return all resources that contain @foo@ in the content of at least one attribute of the previously defined types. This is the recommended way to do keyword and file name search across the entire database. Note that only exact substring matches are returned and results are unranked and returned in the order specified by the @list@ @order@ argument.
128
129 h4(#subpropertyfilters). Filtering on subproperties
130
131 Some record types have an additional @properties@ attribute that allows recording and filtering on additional key-value pairs.  To filter on a subproperty, the value in the @attribute@ position has the form @properties.user_property@.  You may also use JSON-LD / RDF style URIs for property keys by enclosing them in @<...>@ for example @properties.<http://example.com/user_property>@.  Alternately you may also provide a JSON-LD "@context" field, however at this time JSON-LD contexts are not interpreted by Arvados.
132
133 table(table table-bordered table-condensed).
134 |_. Operator|_. Operand type|_. Description|_. Example|
135 |@=@, @!=@|string, number or boolean|Equality comparison|@["properties.my_subproperty", "=", "fizzy whizy sparkle pop"]@|
136 |@<@, @<=@, @>=@, @>@|string or number|Ordering comparison|@["properties.my_subproperty", "<", 3]@|
137 |@like@, @ilike@|string|SQL pattern match, single character match is @_@ and wildcard is @%@, ilike is case-insensitive|@["properties.my_subproperty", "like", "d00220fb%"]@|
138 |@in@, @not in@|array of strings|Set membership|@["properties.my_subproperty", "in", ["fizz", "buzz"]]@|
139 |@exists@|boolean|Test if a subproperty is present or not (determined by operand).|@["properties.my_subproperty", "exists", true]@|
140 |@contains@|string, number|Filter where subproperty has a value either by exact match or value is element of subproperty list.|@["properties.foo", "contains", "bar"]@ will find both @{"foo": "bar"}@ and @{"foo": ["bar", "baz"]}@.|
141
142 Note that exclusion filters @!=@ and @not in@ will return records for which the property is not defined at all.  To restrict filtering to records on which the subproperty is defined, combine with an @exists@ filter.
143
144 h4(#filterexpression). Filtering using boolean expressions
145
146 In addition to the three-element array form described above, a string containing a boolean expression is also accepted. The following restrictions apply:
147 * The expression must contain exactly one operator.
148 * The operator must be @=@, @<@, @<=@, @>@, or @>=@.
149 * There must be exactly one pair of parentheses, surrounding the entire expression.
150 * Each operand must be the name of a numeric attribute like @replication_desired@ (literal values like @3@ and non-numeric attributes like @uuid@ are not accepted).
151 * The expression must not contain whitespace other than an ASCII space (newline and tab characters are not accepted).
152
153 Examples:
154 * @(replication_desired > replication_confirmed)@
155 * @(replication_desired = replication_confirmed)@
156
157 Both types of filter (boolean expressions and @[attribute, operator, operand]@ filters) can be combined in the same API call. Example:
158 * @{"filters": ["(replication_desired > replication_confirmed)", ["replication_desired", "<", 2]]}@
159
160 h4. Federated listing
161
162 Federated listing forwards a request to multiple clusters and combines the results.  Currently only a very restricted form of the "list" method is supported.
163
164 To query multiple clusters, the list request must:
165
166 * Have filters only matching @[["uuid", "in", [...]]@ or @["uuid", "=", "..."]@
167 * Specify @count=none@
168 * Not specify @limit@, @offset@ or @order@
169 * Not request more items than the maximum response size
170
171 This form may be used to request a specific list of objects by uuid which are owned by multiple clusters.
172
173 h3. Results of list method
174
175 A successful call to list will return the following object.
176
177 table(table table-bordered table-condensed).
178 |_. Attribute |_. Type |_. Description |
179 |kind|string|type of objects returned|
180 |offset|integer|query offset in effect|
181 |limit|integer|query limit in effect|
182 |items|array|actual query payload, an array of resource objects|
183 |items_available|integer|total items available matching query|
184
185 h2. update
186
187 The @update@ method updates fields on the object with the specified @uuid@.  It corresponds to the HTTP request @PUT /arvados/v1/resource_type/uuid@.  Note that only the listed attributes (and "standard metadata":resources.html) are updated, unset attributes will retain their previous values, and the attributes of a given resource type are fixed (you cannot introduce new toplevel attributes).  Also note that updates replace the value of the attribute, so if an attribute has an object value, the entire object is replaced.  A successful update call returns the updated copy of the object.
188
189 The cluster id portion of the @uuid@ is used to determine which cluster owns the object, a federated update request will be routed to that cluster.
190
191 table(table table-bordered table-condensed).
192 |_. Argument |_. Type |_. Description |_. Location |
193 {background:#ccffcc}.|uuid|string|The UUID of the resource in question.|path||
194 |{resource_type}|object||query||
195 |select  |array  |Attributes of the updated object to return in the response (by default, all available attributes are returned).
196 Example: @["uuid","name","modified_at"]@|query|