|
| 1 | += Collections [beta betaBackground]^Beta^ |
| 2 | +:toc: true |
| 3 | +:toclevels: 1 |
| 4 | +:page-title: Collections |
| 5 | +:page-pageid: collections |
| 6 | +:page-description: group different ThoughtSpot objects into Collections to manage them more easily. |
| 7 | + |
| 8 | + |
| 9 | +ThoughtSpot now provides REST APIs that enable developers to organize different ThoughtSpot objects into an organizational container called *Collections*. These objects can be Liveboards, Answers, data models, tables, and even other Collections. |
| 10 | +Collections provide a powerful way to manage your data assets, making discovery and collaboration easier, while ensuring the integrity of embedded workflows. |
| 11 | + |
| 12 | +[NOTE] |
| 13 | +==== |
| 14 | +The Collections APIs are in Beta and disabled by default on ThoughtSpot instances. To enable these APIs on your instance, contact ThoughtSpot Support. |
| 15 | +==== |
| 16 | + |
| 17 | +== Before you begin |
| 18 | + |
| 19 | +* For REST API v2 operations, the Org context is determined based on the authentication token used in your API requests. Ensure you log in to the appropriate Org context from which you want to send API requests. |
| 20 | +* When enabled on a ThoughtSpot instance, Collections can be created by any user, and need no special user privileges. |
| 21 | + |
| 22 | + |
| 23 | +== Create a Collection |
| 24 | +To create a new Collection, send a `POST` request to the `POST /api/rest/2.0/collections/create` API endpoint, with the following parameters in the request body. |
| 25 | + |
| 26 | +=== Request parameters |
| 27 | +In your `POST` request body, include the following parameters: |
| 28 | + |
| 29 | +[width="100%" cols="1,4"] |
| 30 | +[options='header'] |
| 31 | +|===== |
| 32 | +|Parameter|Description |
| 33 | + |
| 34 | +|`name` a|__String__. Required. Specify a name for the Collection. |
| 35 | +|`description` a|__String__. Optional. A short description for the Collection. |
| 36 | +|`metadata` a|__Array__. Optional. The details for the metadata objects to be added to the Collection. |
| 37 | + |
| 38 | +* `type` + |
| 39 | +Metadata type. Select one of the following values: |
| 40 | +** `LIVEBOARD` |
| 41 | +** `ANSWER` |
| 42 | +** `LOGICAL_TABLE` |
| 43 | +** `COLLECTION` |
| 44 | ++ |
| 45 | +To create nested collections, assign the `COLLECTION` metadata to a Collection. |
| 46 | + |
| 47 | +* `identifiers` + |
| 48 | +List of unique IDs or names of metadata objects. |
| 49 | +|===== |
| 50 | + |
| 51 | +==== Example request |
| 52 | +[source,CURL] |
| 53 | +---- |
| 54 | +curl -X POST \ |
| 55 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/create' \ |
| 56 | + -H 'Accept: application/json' \ |
| 57 | + -H 'Content-Type: application/json' \ |
| 58 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 59 | + --data-raw '{ |
| 60 | + "name": "Demo Collection", |
| 61 | + "metadata": [ |
| 62 | + { |
| 63 | + "type": "LIVEBOARD", |
| 64 | + "identifiers": [ |
| 65 | + "Retail sales (Sample)", |
| 66 | + "fe307a35-5242-445f-b3cb-b84cd1fc339c" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "type": "COLLECTION", |
| 71 | + "identifiers": [ |
| 72 | + "Collection A" |
| 73 | + ] |
| 74 | + } |
| 75 | + ], |
| 76 | + "description": "For testing" |
| 77 | +}' |
| 78 | +
|
| 79 | +---- |
| 80 | + |
| 81 | +==== API response |
| 82 | + |
| 83 | +If the API request is successful, a Collection with the given metadata objects will be created. |
| 84 | + |
| 85 | +== Search for a Collection |
| 86 | +To get a list of Collections, send a `POST` request to the `POST /api/rest/2.0/collections/search` API endpoint. |
| 87 | + |
| 88 | +If no parameters are specified, the API returns the first 10 collections (or fewer, depending on the total number available). |
| 89 | + |
| 90 | +=== Request parameters |
| 91 | +In your `POST` request body, include the following parameters: |
| 92 | + |
| 93 | +[width="100%" cols="1,4"] |
| 94 | +[options='header'] |
| 95 | +|===== |
| 96 | +|Parameter|Description |
| 97 | + |
| 98 | +|`name_pattern` a|__String__. Optional. Specify any case agnostic pattern to match the name of a Collection. Use `%` to perform a wildcard search by name. |
| 99 | +|`record_offset` a|__Number__. Optional. The index of the first record to be included. Default value is 0. |
| 100 | +|`record_size` a|__Number__. Optional. The total number of records to be searched. Default value is 10. Set to -1 to search across all available collections. |
| 101 | +|`collection_identifiers` a|__Array__. Optional. GUID of the Collection(s) to be searched. `name_pattern` takes precedence over the `collection_identifiers`. |
| 102 | +|`created_by_user_identifiers` a|__Array__. Optional. Searches for Collections by the name of the author. |
| 103 | +|`include_metadata` a|__Boolean__. Optional. When set to `true`, includes the metadata objects within each Collection in the response. |
| 104 | +|`sort_options` a|__Array__. Optional. To sort the search results, specify the field to apply the sort on `field_name`, and the sort order `order`. |
| 105 | +|===== |
| 106 | + |
| 107 | +==== Example request |
| 108 | +[source,CURL] |
| 109 | +---- |
| 110 | +curl -X POST \ |
| 111 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/search' \ |
| 112 | + -H 'Accept: application/json' \ |
| 113 | + -H 'Content-Type: application/json' \ |
| 114 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 115 | + --data-raw '{ |
| 116 | + "record_offset": 2, |
| 117 | + "record_size": 15, |
| 118 | + "include_metadata": false, |
| 119 | + "name_pattern": "%", |
| 120 | + "sort_options": { |
| 121 | + "field_name": "NAME", |
| 122 | + "order": "ASC" |
| 123 | + } |
| 124 | +}' |
| 125 | +---- |
| 126 | + |
| 127 | +==== API response |
| 128 | + |
| 129 | +If the API request is successful, it will return a list of Collection(s) matching the search criteria. |
| 130 | + |
| 131 | +== Update a Collection |
| 132 | +To update an existing Collection, send a `POST` request to the `POST /api/rest/2.0/collections/{collection_identifier}/update` API endpoint. |
| 133 | + |
| 134 | +=== Request parameters |
| 135 | +In your `POST` request body, include the following parameters: |
| 136 | + |
| 137 | +[width="100%" cols="1,4"] |
| 138 | +[options='header'] |
| 139 | +|===== |
| 140 | +|Parameter|Description |
| 141 | + |
| 142 | +|`collection_identifier` a| Required. GUID of the Collection to be updated. `collection_identifier` is passed as a parameter in the API request. |
| 143 | +|`name` a|__String__. Optional. New name for the Collection. |
| 144 | +|`description` a|__String__. Optional. Updated or a newly added description for the Collection. |
| 145 | +|`metadata` a|__Array__. Required. The details for the metadata objects to be added, removed, or replaced in the Collection. |
| 146 | + |
| 147 | +* `type` |
| 148 | +* `identifiers` |
| 149 | +|`operation` a|__Enum__. Required. Specify the nature of the update. Select one of the following values: |
| 150 | + |
| 151 | +* ADD: Adds the specified metadata objects to the existing Collection without removing the current objects. |
| 152 | +* REMOVE: Removes only the specified metadata objects from the Collection. |
| 153 | +* REPLACE. __Default__: This replaces all existing objects in the Collection with the objects specified in this replace request. |
| 154 | +|===== |
| 155 | + |
| 156 | +==== Example request |
| 157 | +[source,CURL] |
| 158 | +---- |
| 159 | +curl -X POST \ |
| 160 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/0e5fd958-cb2b-43f0-b67f-13ac5c805bad/update' \ |
| 161 | + -H 'Accept: application/json' \ |
| 162 | + -H 'Content-Type: application/json' \ |
| 163 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 164 | + --data-raw '{ |
| 165 | + "operation": "ADD", |
| 166 | + "metadata": [ |
| 167 | + { |
| 168 | + "type": "LIVEBOARD", |
| 169 | + "identifiers": [ |
| 170 | + "6fee1adb-1c50-4c15-8d49-4fe0503d0b34" |
| 171 | + ] |
| 172 | + } |
| 173 | + ] |
| 174 | +}' |
| 175 | +---- |
| 176 | +==== API response |
| 177 | + |
| 178 | +If the API request is successful, the object specified in the API request is added to the Collection. |
| 179 | + |
| 180 | +==== Example request |
| 181 | +[source,CURL] |
| 182 | +---- |
| 183 | +curl -X POST \ |
| 184 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/0e5fd958-cb2b-43f0-b67f-13ac5c805bad/update' \ |
| 185 | + -H 'Accept: application/json' \ |
| 186 | + -H 'Content-Type: application/json' \ |
| 187 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 188 | + --data-raw '{ |
| 189 | + "operation": "REMOVE", |
| 190 | + "metadata": [ |
| 191 | + { |
| 192 | + "type": "LIVEBOARD", |
| 193 | + "identifiers": [ |
| 194 | + "6fee1adb-1c50-4c15-8d49-4fe0503d0b34" |
| 195 | + ] |
| 196 | + } |
| 197 | + ] |
| 198 | +}' |
| 199 | +---- |
| 200 | + |
| 201 | +==== API response |
| 202 | + |
| 203 | +If the API request is successful, the object specified in the API request is removed from the Collection. |
| 204 | + |
| 205 | +==== Example request |
| 206 | +[source,CURL] |
| 207 | +---- |
| 208 | +curl -X POST \ |
| 209 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/0e5fd958-cb2b-43f0-b67f-13ac5c805bad/update' \ |
| 210 | + -H 'Accept: application/json' \ |
| 211 | + -H 'Content-Type: application/json' \ |
| 212 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 213 | + --data-raw '{ |
| 214 | + "operation": "REPLACE", |
| 215 | + "metadata": [ |
| 216 | + { |
| 217 | + "type": "LIVEBOARD", |
| 218 | + "identifiers": [ |
| 219 | + "6fee1adb-1c50-4c15-8d49-4fe0503d0b34", |
| 220 | + "87328d32-2bf0-4fc4-ac51-a738712d7e79" |
| 221 | + ] |
| 222 | + }, |
| 223 | + { |
| 224 | + "type": "COLLECTION", |
| 225 | + "identifiers": [ |
| 226 | + "6d85c77c-4822-42ba-8074-6306a90ba8e1" |
| 227 | + ] |
| 228 | + } |
| 229 | + ] |
| 230 | +}' |
| 231 | +---- |
| 232 | + |
| 233 | + |
| 234 | +==== API response |
| 235 | + |
| 236 | +If the API request is successful, the objects in the Collection are replaced with the objects in this API request. |
| 237 | + |
| 238 | +== Delete a Collection |
| 239 | +To remove an existing Collection, send a `POST` request to the `POST /api/rest/2.0/collections/delete` API endpoint. |
| 240 | + |
| 241 | +=== Request parameters |
| 242 | +In your `POST` request body, include the following parameters: |
| 243 | + |
| 244 | +[width="100%" cols="1,4"] |
| 245 | +[options='header'] |
| 246 | +|===== |
| 247 | +|Parameter|Description |
| 248 | + |
| 249 | +|`collection_identifiers` a|__String__. Required. GUID of the Collection to be deleted. |
| 250 | +|`delete_children` a|__String__. Optional. Set to `true` to delete child objects in the Collection where the user has permission. Any objects without delete access will be ignored. |
| 251 | +|`dry_run` a|__String__. Optional. Set to true to preview the deletion process without removing any objects. The response lists the items that would be deleted, so you can review them before proceeding with actual deletion. |
| 252 | +|===== |
| 253 | + |
| 254 | +==== Example request |
| 255 | +To review your deletion request without actually deleting the Collection and its objects, set `dry_run` to `true` and `delete_children` to `true`. |
| 256 | + |
| 257 | +[source,CURL] |
| 258 | +---- |
| 259 | +curl -X POST \ |
| 260 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/delete' \ |
| 261 | + -H 'Accept: application/json' \ |
| 262 | + -H 'Content-Type: application/json' \ |
| 263 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 264 | + --data-raw '{ |
| 265 | + "collection_identifiers": [ |
| 266 | + "6996b262-8733-4af6-8f8e-8d7faefb5be0" |
| 267 | + ], |
| 268 | + "delete_children": true, |
| 269 | + "dry_run": true |
| 270 | +}' |
| 271 | +---- |
| 272 | + |
| 273 | +==== API response |
| 274 | + |
| 275 | +If the API request is successful, it gives you a preview of the deletion operation without actually deleting anything. |
| 276 | + |
| 277 | +* `metadata_deleted`: List of metadata objects that will be deleted |
| 278 | +* `metadata_skipped`: List of metadata objects that will not be deleted for lack of permissions or other constraints |
| 279 | + |
| 280 | +[source,JSON] |
| 281 | +---- |
| 282 | +{"metadata_deleted":[{"type":"COLLECTION","identifiers":[{"id":"6996b262-8733-4af6-8f8e-8d7faefb5be0","name":"Docs Collection"}]},{"type":"LIVEBOARD","identifiers":[{"id":"278d2313-ac3a-44bb-b842-a4c9dff84e68","name":"Demo-lb"},{"id":"1bcdb2c1-e960-4f6b-bbf9-64f3e0cd33b9","name":"Demo-lb1"}]}],"metadata_skipped":[]} |
| 283 | +---- |
| 284 | + |
| 285 | +==== Example request |
| 286 | +To delete the Collection and the objects within it, set `dry_run` to `false` and `delete_children` to `true`. |
| 287 | + |
| 288 | +[source,CURL] |
| 289 | +---- |
| 290 | +curl -X POST \ |
| 291 | + --url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/delete' \ |
| 292 | + -H 'Accept: application/json' \ |
| 293 | + -H 'Content-Type: application/json' \ |
| 294 | + -H 'Authorization: Bearer {AUTH_TOKEN}' \ |
| 295 | + --data-raw '{ |
| 296 | + "collection_identifiers": [ |
| 297 | + "6996b262-8733-4af6-8f8e-8d7faefb5be0" |
| 298 | + ], |
| 299 | + "delete_children": true, |
| 300 | + "dry_run": false |
| 301 | +}' |
| 302 | +---- |
| 303 | + |
| 304 | +==== API response |
| 305 | +If the API request is successful, it deletes the Collection and all objects within it for which you have delete permission. |
| 306 | + |
| 307 | +[source,JSON] |
| 308 | +---- |
| 309 | +{"metadata_deleted":[{"type":"COLLECTION","identifiers":[{"id":"6996b262-8733-4af6-8f8e-8d7faefb5be0","name":"Docs Collection"}]},{"type":"LIVEBOARD","identifiers":[{"id":"278d2313-ac3a-44bb-b842-a4c9dff84e68","name":"Demo-lb"},{"id":"1bcdb2c1-e960-4f6b-bbf9-64f3e0cd33b9","name":"Demo-lb1"}]}],"metadata_skipped":[]} |
| 310 | +---- |
| 311 | + |
| 312 | +== Additional references |
| 313 | + |
| 314 | + |
| 315 | +* For information about creating and managing Collections via ThoughtSpot UI, see link:https://docs.thoughtspot.com/cloud/latest/collections[Collections in ThoughtSpot, window=_blank] |
| 316 | + |
| 317 | + |
0 commit comments