13497: Merge branch 'master' into 13497-controller
[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?resource_type={}@.
19
20 h2. create
21
22 The @create@ method creates a new object of the specified type.  Note that:
23
24 * Only the listed attributes (and "standard metadata":resources.html) are set
25 * Unset attributes will get default values
26 * The attributes of a given resource type are fixed (you cannot introduce new toplevel attributes)
27
28 This method corresponds to the HTTP request @POST /arvados/v1/resource_type@.  A successful create call returns a copy of the new object.
29
30 Arguments:
31
32 table(table table-bordered table-condensed).
33 |_. Argument |_. Type |_. Description |_. Location |
34 |{resource_type}|object|Name is the singular form of the resource type, e.g., for the "collections" resource, this argument is "collection"|query||
35
36 h2. delete
37
38 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.
39
40 Arguments:
41
42 table(table table-bordered table-condensed).
43 |_. Argument |_. Type |_. Description |_. Location |
44 {background:#ccffcc}.|uuid|string|The UUID of the object in question.|path|
45
46 h2. get
47
48 The @get@ method gets a single object with the specified @uuid@.  It corresponds to the HTTP request @GET /arvados/v1/resource_type/uuid@.
49
50 Arguments:
51
52 table(table table-bordered table-condensed).
53 |_. Argument |_. Type |_. Description |_. Location |
54 {background:#ccffcc}.|uuid|string|The UUID of the object in question.|path|
55
56 h2(#index). list
57
58 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 "list" method unless otherwise noted.
59
60 Arguments:
61
62 table(table table-bordered table-condensed).
63 |_. Argument |_. Type |_. Description |_. Location |
64 |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|
65 |offset  |integer|Skip the first 'offset' number of resources that would be returned under the given filter conditions.|query|
66 |filters |array  |"Conditions for selecting resources to return.":#filters|query|
67 |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.
68 Example: @["head_uuid asc","modified_at desc"]@
69 Default: @["created_at desc"]@|query|
70 |select  |array  |Set of attributes to include in the response.
71 Example: @["head_uuid","tail_uuid"]@
72 Default: all available attributes.  As a special case, collections do not return "manifest_text" unless explicitly selected.|query|
73 |distinct|boolean|@true@: (default) do not return duplicate objects
74 @false@: permitted to return duplicates|query|
75 |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).
76 @"none"@: Omit the @items_available@ response field. This option will produce a faster response.|query|
77
78 h3(#filters). Available list method filters
79
80 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.
81
82 Each condition is expressed as an array with three elements: @[attribute, operator, operand]@.
83
84 table(table table-bordered table-condensed).
85 |_. Index|_. Element|_. Type|_. Description|_. Examples|
86 |0|attribute|string|Name of the attribute to compare (or "any" to return resources with any matching attribute)|@script_version@, @head_uuid@, @any@|
87 |1|operator|string|Comparison operator|@>@, @>=@, @like@, @not in@|
88 |2|operand|string, array, or null|Value to compare with the resource attribute|@"d00220fb%"@, @"1234"@, @["foo","bar"]@, @nil@|
89
90 The following operators are available.
91
92 table(table table-bordered table-condensed).
93 |_. Operator|_. Operand type|_. Description|_. Example|
94 |@=@, @!=@|string, number, timestamp, or null|Equality comparison|@["tail_uuid","=","xyzzy-j7d0g-fffffffffffffff"]@ @["tail_uuid","!=",null]@|
95 |@<@, @<=@, @>=@, @>@|string, number, or timestamp|Ordering comparison|@["script_version",">","123"]@|
96 |@like@, @ilike@|string|SQL pattern match.  Single character match is @_@ and wildcard is @%@. The @ilike@ operator is case-insensitive|@["script_version","like","d00220fb%"]@|
97 |@in@, @not in@|array of strings|Set membership|@["script_version","in",["master","d00220fb38d4b85ca8fc28a8151702a2b9d1dec5"]]@|
98 |@is_a@|string|Arvados object type|@["head_uuid","is_a","arvados#collection"]@|
99 |@exists@|string|Test if a subproperty is present.|@["properties","exists","my_subproperty"]@|
100
101 h4(#subpropertyfilters). Filtering on subproperties
102
103 Some record type 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.
104
105 table(table table-bordered table-condensed).
106 |_. Operator|_. Operand type|_. Description|_. Example|
107 |@=@, @!=@|string, number or boolean|Equality comparison|@["properties.my_subproperty", "=", "fizzy whizy sparkle pop"]@|
108 |@<@, @<=@, @>=@, @>@|string or number|Ordering comparison|@["properties.my_subproperty", "<", 3]@|
109 |@like@, @ilike@|string|SQL pattern match, single character match is @_@ and wildcard is @%@, ilike is case-insensitive|@["properties.my_subproperty", "like", "d00220fb%"]@|
110 |@in@, @not in@|array of strings|Set membership|@["properties.my_subproperty", "in", ["fizz", "buzz"]]@|
111 |@exists@|boolean|Test if a subproperty is present or not (determined by operand).|@["properties.my_subproperty", "exists", true]@|
112
113 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.
114
115 h3. Results of list method
116
117 A successful call to list will return the following object.
118
119 table(table table-bordered table-condensed).
120 |_. Attribute |_. Type |_. Description |
121 |kind|string|type of objects returned|
122 |offset|integer|query offset in effect|
123 |limit|integer|query limit in effect|
124 |items|array|actual query payload, an array of resource objects|
125 |items_available|integer|total items available matching query|
126
127 h2. update
128
129 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.
130
131 table(table table-bordered table-condensed).
132 |_. Argument |_. Type |_. Description |_. Location |
133 {background:#ccffcc}.|uuid|string|The UUID of the resource in question.|path||
134 |{resource_type}|object||query||