17755: Merge branch 'main' into 17755-add-singularity-to-compute-image
[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
41 h2. delete
42
43 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.
44
45 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.
46
47 Arguments:
48
49 table(table table-bordered table-condensed).
50 |_. Argument |_. Type |_. Description |_. Location |
51 {background:#ccffcc}.|uuid|string|The UUID of the object in question.|path|
52
53 h2. get
54
55 The @get@ method gets a single object with the specified @uuid@.  It corresponds to the HTTP request @GET /arvados/v1/resource_type/uuid@.
56
57 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.
58
59 Arguments:
60
61 table(table table-bordered table-condensed).
62 |_. Argument |_. Type |_. Description |_. Location |
63 {background:#ccffcc}.|uuid|string|The UUID of the object in question.|path|
64
65 h2(#index). list
66
67 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.
68
69 Arguments:
70
71 table(table table-bordered table-condensed).
72 |_. Argument |_. Type |_. Description |_. Location |
73 |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|
74 |offset  |integer|Skip the first 'offset' number of resources that would be returned under the given filter conditions.|query|
75 |filters |array  |"Conditions for selecting resources to return.":#filters|query|
76 |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).
77 Example: @["head_uuid asc","modified_at desc"]@
78 Default: @["modified_at desc", "uuid asc"]@|query|
79 |select  |array  |Set of attributes to include in the response.
80 Example: @["head_uuid","tail_uuid"]@
81 Default: all available attributes.  As a special case, collections do not return "manifest_text" unless explicitly selected.|query|
82 |distinct|boolean|@true@: (default) do not return duplicate objects
83 @false@: permitted to return duplicates|query|
84 |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).
85 @"none"@: Omit the @items_available@ response field. This option will produce a faster response.|query|
86
87 h3(#filters). Available list method filters
88
89 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.
90
91 Each condition is expressed as an array with three elements: @[attribute, operator, operand]@.
92
93 table(table table-bordered table-condensed).
94 |_. Index|_. Element|_. Type|_. Description|_. Examples|
95 |0|attribute|string|Name of the attribute to compare (or "any" to return resources with any matching attribute)|@script_version@, @head_uuid@, @any@|
96 |1|operator|string|Comparison operator|@>@, @>=@, @like@, @not in@|
97 |2|operand|string, array, or null|Value to compare with the resource attribute|@"d00220fb%"@, @"1234"@, @["foo","bar"]@, @nil@|
98
99 The following operators are available.
100
101 table(table table-bordered table-condensed).
102 |_. Operator|_. Operand type|_. Description|_. Example|
103 |@=@, @!=@, @<>@|string, number, timestamp, JSON-encoded array, JSON-encoded object, or null|Equality comparison|@["tail_uuid","=","xyzzy-j7d0g-fffffffffffffff"]@
104 @["tail_uuid","!=",null]@
105 @["storage_classes_desired","=","[\"default\"]"]@|
106 |@<@, @<=@, @>=@, @>@|string, number, or timestamp|Ordering comparison|@["script_version",">","123"]@|
107 |@like@, @ilike@|string|SQL pattern match.  Single character match is @_@ and wildcard is @%@. The @ilike@ operator is case-insensitive|@["script_version","like","d00220fb%"]@|
108 |@in@, @not in@|array of strings|Set membership|@["script_version","in",["main","d00220fb38d4b85ca8fc28a8151702a2b9d1dec5"]]@|
109 |@is_a@|string|Arvados object type|@["head_uuid","is_a","arvados#collection"]@|
110 |@exists@|string|Presence of subproperty|@["properties","exists","my_subproperty"]@|
111 |@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"]@)
112 (note @[..., "contains", "foo"]@ is also accepted, and is equivalent to @[..., "contains", ["foo"]]@)|
113
114 h4(#substringsearchfilter). Filtering using substring search
115
116 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:
117
118 * Specify @any@ as the attribute
119 * Use either the @like@ or @ilike@ operator
120 * Have an operand of type @string@ that is wrapped in the SQL pattern match wildcard character @%@
121
122 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.
123
124 h4(#subpropertyfilters). Filtering on subproperties
125
126 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.
127
128 table(table table-bordered table-condensed).
129 |_. Operator|_. Operand type|_. Description|_. Example|
130 |@=@, @!=@|string, number or boolean|Equality comparison|@["properties.my_subproperty", "=", "fizzy whizy sparkle pop"]@|
131 |@<@, @<=@, @>=@, @>@|string or number|Ordering comparison|@["properties.my_subproperty", "<", 3]@|
132 |@like@, @ilike@|string|SQL pattern match, single character match is @_@ and wildcard is @%@, ilike is case-insensitive|@["properties.my_subproperty", "like", "d00220fb%"]@|
133 |@in@, @not in@|array of strings|Set membership|@["properties.my_subproperty", "in", ["fizz", "buzz"]]@|
134 |@exists@|boolean|Test if a subproperty is present or not (determined by operand).|@["properties.my_subproperty", "exists", true]@|
135 |@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"]}@.|
136
137 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.
138
139 h4. Federated listing
140
141 Federated listing forwards a request to multiple clusters and combines the results.  Currently only a very restricted form of the "list" method is supported.
142
143 To query multiple clusters, the list request must:
144
145 * Have filters only matching @[["uuid", "in", [...]]@ or @["uuid", "=", "..."]@
146 * Specify @count=none@
147 * Not specify @limit@, @offset@ or @order@
148 * Not request more items than the maximum response size
149
150 This form may be used to request a specific list of objects by uuid which are owned by multiple clusters.
151
152 h3. Results of list method
153
154 A successful call to list will return the following object.
155
156 table(table table-bordered table-condensed).
157 |_. Attribute |_. Type |_. Description |
158 |kind|string|type of objects returned|
159 |offset|integer|query offset in effect|
160 |limit|integer|query limit in effect|
161 |items|array|actual query payload, an array of resource objects|
162 |items_available|integer|total items available matching query|
163
164 h2. update
165
166 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.
167
168 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.
169
170 table(table table-bordered table-condensed).
171 |_. Argument |_. Type |_. Description |_. Location |
172 {background:#ccffcc}.|uuid|string|The UUID of the resource in question.|path||
173 |{resource_type}|object||query||