• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.cloudData (端云服务)(系统接口)
2<!--Kit: ArkData-->
3<!--Subsystem: DistributedDataManager-->
4<!--Owner: @lvcong_oh-->
5<!--Designer: @lvcong_oh-->
6<!--Tester: @ltttjs; @logic42-->
7<!--Adviser: @ge-yafang-->
8
9端云服务提供端云协同、端云共享和端云策略。
10
11端云协同提供结构化数据(RDB Store)端云同步的能力。即:云作为数据的中心节点,通过与云的数据同步,实现数据云备份、同账号设备间的数据一致性。
12
13端云共享是在端云协同能力基础上,实现跨账号的数据共享。其中,端云共享资源标识是指:对于应用发起共享的每一条数据记录,该条数据在进行端云同步时会生成唯一的共享资源标识(字符串类型的值),此标识则作为该条数据记录共享时的识别标识。
14
15端云共享参与者是指: 共享发起者根据好友列表选中的参与当前数据共享的所有人员。
16
17端云共享邀请码是指: 共享发起后,在共享的服务端会生成当前共享操作的邀请码,并将该邀请码附加到当前共享邀请中,通过push消息推送到被邀请者的设备端,被邀请者可以通过该邀请码进行邀请的确认。
18
19该模块提供以下端云服务相关的常用功能:
20
21- [Config](#config):提供配置端云协同的方法,包括云同步打开、关闭、清理数据、数据变化通知。
22- [sharing](#sharing11):提供端云共享的方法,包括发起共享、取消共享、退出共享、更改共享数据权限、查找共享参与者、确认邀请、更改已确认的邀请、查找共享资源。
23
24> **说明:**
25>
26> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
27>
28> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.data.cloudData (端云服务)](js-apis-data-cloudData.md)。
29>
30> - 使用本模块需要实现云服务功能。
31
32## 导入模块
33
34```ts
35import { cloudData } from '@kit.ArkData';
36```
37
38## ClearAction
39
40清除本地下载的云端数据的行为枚举。
41
42**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
43
44| 名称      | 说明                         |
45| --------- | ---------------------------- |
46| CLEAR_CLOUD_INFO | 清除从云端下载的数据的云标识,相关数据作为本地数据保存。 |
47| CLEAR_CLOUD_DATA_AND_INFO |清除从云端下载的数据,不包括本地已修改的云端数据。   |
48
49## ExtraData<sup>11+</sup>
50
51透传数据,携带通知数据变更所需要的信息。
52
53**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
54
55| 名称      | 类型   | 必填 | 说明                                                         |
56| --------- | ------ | ---- | ------------------------------------------------------------ |
57| eventId   | string | 是   | 如果传值为"cloud_data_change",表示云数据变更。              |
58| extraData | string | 是   | 透传数据,extraData是json结构的字符串,其中必须包括"data"字段,"data"中是通知变更所需要的信息,包含账号、应用名、数据库名、数据库类型和数据库表名,所有字段均不能为空。
59
60**示例:**
61
62```ts
63// accountId:用户打开的云账号ID
64// bundleName:应用包名
65// containerName:云上数据库名称
66// databaseScopes:云上数据库类型
67// recordTypes:云上数据库表名
68
69interface ExtraData {
70  eventId: "cloud_data_change",
71  extraData: '{
72    "data": "{
73     "accountId": "aaa",
74     "bundleName": "com.bbb.xxx",
75     "containerName": "alias",
76     "databaseScopes": ["private", "shared"],
77     "recordTypes": ["xxx", "yyy", "zzz"]
78    }"
79  }'
80}
81
82```
83
84## StatisticInfo<sup>12+</sup>
85
86返回数据,携带端云同步统计信息所需要的信息。
87
88**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
89
90| 名称      | 类型   | 必填 | 说明                                                  |
91| --------- | ------ | ---- |-----------------------------------------------------|
92| table   | string | 是   | 查询的表名。如返回值为"cloud_notes",表示查询结果是表名为"cloud_notes"的同步信息。 |
93| inserted   | number | 是   | 本地新增且云端还未同步数据的条数,如返回值为2,表示本地新增2条数据且云端还未同步。          |
94| updated   | number | 是   | 云端同步之后本地或云端修改还未同步的条数,如返回值为2,表示本地或云端修改还有2条数据未同步。     |
95| normal | number | 是   | 端云一致的数据。如返回值为2,表示本地与云端一致的数据为2条。                     |
96
97## SyncStatus<sup>18+</sup>
98
99端云同步任务的状态。
100
101**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
102
103| 名称      | 值   | 说明              |
104| -------- |-----|-----------------|
105| RUNNING | 0  | 表示端云同步任务处于运行状态。 |
106| FINISHED | 1   | 表示端云同步任务处于完成状态。 |
107
108## SyncInfo<sup>12+</sup>
109
110返回数据,最近一次端云同步所需要的信息。
111
112**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
113
114| 名称       | 类型                                                         | 必填 | 说明                       |
115| ---------- | ------------------------------------------------------------ | ---- | -------------------------- |
116| startTime  | Date                                                         | 是   | 最近一次端云同步的开始时间。 |
117| finishTime | Date                                                         | 是   | 最近一次端云同步的结束时间。 |
118| code       | [relationalStore.ProgressCode](arkts-apis-data-relationalStore-e.md#progresscode10) | 是   | 最近一次端云同步的结果。 |
119| syncStatus<sup>18+</sup> | [SyncStatus](#syncstatus18) | 否 | 最近一次端云同步的状态,默认值cloudData.SyncStatus.RUNNING。 |
120
121## Config
122
123提供配置端云协同的方法,包括云同步打开、关闭、清理数据、数据变化通知。
124
125### enableCloud
126
127static enableCloud(accountId: string, switches: Record<string, boolean>, callback: AsyncCallback&lt;void&gt;): void
128
129打开端云协同,使用callback异步回调。
130
131**需要权限**:ohos.permission.CLOUDDATA_CONFIG
132
133**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
134
135**参数:**
136
137| 参数名    | 类型                            | 必填 | 说明                                                         |
138| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
139| accountId | string                          | 是   | 具体打开的云账号ID。                                         |
140| switches  | Record<string, boolean>         | 是   | 各应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
141| callback  | AsyncCallback&lt;void&gt;       | 是   | 回调函数。                                                   |
142
143**错误码:**
144
145以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
146
147| 错误码ID | 错误信息                                             |
148| -------- | ---------------------------------------------------- |
149| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
150| 202      | Permission verification failed, application which is not a system application uses system API.|
151| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
152| 801      | Capability not supported.|
153
154**示例:**
155
156```ts
157import { BusinessError } from '@kit.BasicServicesKit';
158
159let account: string = 'test_id';
160let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
161try {
162  cloudData.Config.enableCloud(account, switches, (err: BusinessError) => {
163    if (err === undefined) {
164      console.info('Succeeded in enabling cloud');
165    } else {
166      console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
167    }
168  });
169} catch (e) {
170  let error = e as BusinessError;
171  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
172}
173```
174
175### enableCloud
176
177static enableCloud(accountId: string, switches: Record<string, boolean>): Promise&lt;void&gt;
178
179打开端云协同,使用Promise异步回调。
180
181**需要权限**:ohos.permission.CLOUDDATA_CONFIG
182
183**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
184
185**参数:**
186
187| 参数名    | 类型                            | 必填 | 说明                                                         |
188| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
189| accountId | string                          | 是   | 具体打开的云账号ID。                                         |
190| switches  | Record<string, boolean>         | 是   | 各应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
191
192**返回值:**
193
194| 类型                | 说明                      |
195| ------------------- | ------------------------- |
196| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
197
198**错误码:**
199
200以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
201
202| 错误码ID | 错误信息                                             |
203| -------- | ---------------------------------------------------- |
204| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
205| 202      | Permission verification failed, application which is not a system application uses system API.|
206| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
207| 801      | Capability not supported.|
208
209**示例:**
210
211```ts
212import { BusinessError } from '@kit.BasicServicesKit';
213
214let account: string = 'test_id';
215let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
216try {
217  cloudData.Config.enableCloud(account, switches).then(() => {
218    console.info('Succeeded in enabling cloud');
219  }).catch((err: BusinessError) => {
220    console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
221  });
222} catch (e) {
223  let error = e as BusinessError;
224  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
225}
226```
227
228### disableCloud
229
230static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;): void
231
232关闭端云协同,使用callback异步回调。
233
234**需要权限**:ohos.permission.CLOUDDATA_CONFIG
235
236**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
237
238**参数:**
239
240| 参数名    | 类型                      | 必填 | 说明                 |
241| --------- | ------------------------- | ---- | -------------------- |
242| accountId | string                    | 是   | 具体打开的云账号ID。 |
243| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
244
245**错误码:**
246
247以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
248
249| 错误码ID | 错误信息                                             |
250| -------- | ---------------------------------------------------- |
251| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
252| 202      | Permission verification failed, application which is not a system application uses system API.|
253| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
254| 801      | Capability not supported.|
255
256**示例:**
257
258```ts
259import { BusinessError } from '@kit.BasicServicesKit';
260
261let account: string = 'test_id';
262try {
263  cloudData.Config.disableCloud(account, (err: BusinessError) => {
264    if (err === undefined) {
265      console.info('Succeeded in disabling cloud');
266    } else {
267      console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
268    }
269  });
270} catch (e) {
271  let error = e as BusinessError;
272  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
273}
274```
275
276### disableCloud
277
278static disableCloud(accountId: string): Promise&lt;void&gt;
279
280关闭端云协同,使用Promise异步回调。
281
282**需要权限**:ohos.permission.CLOUDDATA_CONFIG
283
284**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
285
286**参数:**
287
288| 参数名    | 类型   | 必填 | 说明                 |
289| --------- | ------ | ---- | -------------------- |
290| accountId | string | 是   | 具体打开的云账号ID。 |
291
292**返回值:**
293
294| 类型                | 说明                      |
295| ------------------- | ------------------------- |
296| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
297
298**错误码:**
299
300以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
301
302| 错误码ID | 错误信息                                             |
303| -------- | ---------------------------------------------------- |
304| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
305| 202      | Permission verification failed, application which is not a system application uses system API.|
306| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
307| 801      | Capability not supported.|
308
309**示例:**
310
311```ts
312import { BusinessError } from '@kit.BasicServicesKit';
313
314let account: string = 'test_id';
315try {
316  cloudData.Config.disableCloud(account).then(() => {
317    console.info('Succeeded in disabling cloud');
318  }).catch((err: BusinessError) => {
319    console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
320  });
321} catch (e) {
322  let error = e as BusinessError;
323  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
324}
325```
326
327### changeAppCloudSwitch
328
329static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback&lt;void&gt;): void
330
331修改单个应用端云协同开关,使用callback异步回调。
332
333**需要权限**:ohos.permission.CLOUDDATA_CONFIG
334
335**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
336
337**参数:**
338
339| 参数名    | 类型                            | 必填 | 说明                         |
340| --------- | ------------------------------- | ---- | ---------------------------- |
341| accountId | string                          | 是   | 具体打开的云账号ID。 |
342| bundleName| string                         | 是   | 应用名。 |
343| status    | boolean                        | 是   | 应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
344| callback  | AsyncCallback&lt;void&gt;       | 是   | 回调函数。                   |
345
346**错误码:**
347
348以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
349
350| 错误码ID | 错误信息                                             |
351| -------- | ---------------------------------------------------- |
352| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
353| 202      | Permission verification failed, application which is not a system application uses system API.|
354| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
355| 801      | Capability not supported.|
356
357**示例:**
358
359```ts
360import { BusinessError } from '@kit.BasicServicesKit';
361
362let account: string = 'test_id';
363let bundleName: string = 'test_bundleName';
364try {
365  cloudData.Config.changeAppCloudSwitch(account, bundleName, true, (err: BusinessError) => {
366    if (err === undefined) {
367      console.info('Succeeded in changing App cloud switch');
368    } else {
369      console.error(`Failed to change App cloud switch. Code: ${err.code}, message: ${err.message}`);
370    }
371  });
372} catch (e) {
373  let error = e as BusinessError;
374  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
375}
376```
377
378### changeAppCloudSwitch
379
380static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise&lt;void&gt;
381
382修改单个应用端云协同开关,使用Promise异步回调。
383
384**需要权限**:ohos.permission.CLOUDDATA_CONFIG
385
386**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
387
388**参数:**
389
390| 参数名    | 类型                            | 必填 | 说明                         |
391| --------- | ------------------------------- | ---- | ---------------------------- |
392| accountId | string                          | 是   | 具体打开的云账号ID。 |
393| bundleName| string                         | 是   | 应用名。 |
394| status    | boolean                        | 是   | 应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
395
396**返回值:**
397
398| 类型                | 说明                      |
399| ------------------- | ------------------------- |
400| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
401
402**错误码:**
403
404以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
405
406| 错误码ID | 错误信息                                             |
407| -------- | ---------------------------------------------------- |
408| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
409| 202      | Permission verification failed, application which is not a system application uses system API.|
410| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
411| 801      | Capability not supported.|
412
413**示例:**
414
415```ts
416import { BusinessError } from '@kit.BasicServicesKit';
417
418let account: string = 'test_id';
419let bundleName: string = 'test_bundleName';
420try {
421  cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
422    console.info('Succeeded in changing App cloud switch');
423  }).catch((err: BusinessError) => {
424    console.error(`Failed to change App cloud switch. Code is ${err.code}, message is ${err.message}`);
425  });
426} catch (e) {
427  let error = e as BusinessError;
428  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
429}
430```
431
432### notifyDataChange
433
434static notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
435
436通知云端的数据变更,使用callback异步回调。
437
438**需要权限**:ohos.permission.CLOUDDATA_CONFIG
439
440**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
441
442**参数:**
443
444| 参数名     | 类型                      | 必填 | 说明                 |
445| ---------- | ------------------------- | ---- | -------------------- |
446| accountId  | string                    | 是   | 具体打开的云账号ID。 |
447| bundleName | string                    | 是   | 应用名。             |
448| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
449
450**错误码:**
451
452以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
453
454| 错误码ID | 错误信息                                             |
455| -------- | ---------------------------------------------------- |
456| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
457| 202      | Permission verification failed, application which is not a system application uses system API.|
458| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
459| 801      | Capability not supported.|
460
461**示例:**
462
463```ts
464import { BusinessError } from '@kit.BasicServicesKit';
465
466let account: string = 'test_id';
467let bundleName: string = 'test_bundleName';
468try {
469  cloudData.Config.notifyDataChange(account, bundleName, (err: BusinessError) => {
470    if (err === undefined) {
471      console.info('Succeeded in notifying the change of data');
472    } else {
473      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
474    }
475  });
476} catch (e) {
477  let error = e as BusinessError;
478  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
479}
480```
481
482### notifyDataChange
483
484static notifyDataChange(accountId: string,bundleName: string): Promise&lt;void&gt;
485
486通知云端的数据变更,使用Promise异步回调。
487
488**需要权限**:ohos.permission.CLOUDDATA_CONFIG
489
490**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
491
492**参数:**
493
494| 参数名     | 类型   | 必填 | 说明                 |
495| ---------- | ------ | ---- | -------------------- |
496| accountId  | string | 是   | 具体打开的云账号ID。 |
497| bundleName | string | 是   | 应用名。             |
498
499**返回值:**
500
501| 类型                | 说明                      |
502| ------------------- | ------------------------- |
503| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
504
505**错误码:**
506
507以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
508
509| 错误码ID | 错误信息                                             |
510| -------- | ---------------------------------------------------- |
511| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
512| 202      | Permission verification failed, application which is not a system application uses system API.|
513| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
514| 801      | Capability not supported.|
515
516**示例:**
517
518```ts
519import { BusinessError } from '@kit.BasicServicesKit';
520
521let account: string = 'test_id';
522let bundleName: string = 'test_bundleName';
523try {
524  cloudData.Config.notifyDataChange(account, bundleName).then(() => {
525    console.info('Succeeded in notifying the change of data');
526  }).catch((err: BusinessError) => {
527    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
528  });
529} catch (e) {
530  let error = e as BusinessError;
531  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
532}
533```
534
535### notifyDataChange<sup>11+</sup>
536
537 static notifyDataChange(extInfo: ExtraData, callback: AsyncCallback&lt;void&gt;):void
538
539通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,使用callback异步回调。
540
541**需要权限**:ohos.permission.CLOUDDATA_CONFIG
542
543**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
544
545**参数:**
546
547| 参数名   | 类型                      | 必填 | 说明                                    |
548| -------- | ------------------------- | ---- | --------------------------------------- |
549| extInfo  | [ExtraData](#extradata11)   | 是   | 透传数据,包含通知数据变更后的应用信息。 |
550| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当数据变更通知成功,err为undefined,否则为错误对象。|
551
552**错误码:**
553
554以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
555
556| 错误码ID | 错误信息                                             |
557| -------- | ---------------------------------------------------- |
558| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
559| 202      | Permission verification failed, application which is not a system application uses system API.|
560| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
561| 801      | Capability not supported.|
562
563**示例:**
564
565```ts
566import { BusinessError } from '@kit.BasicServicesKit';
567
568let eventId: string = "cloud_data_change";
569let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
570try {
571  cloudData.Config.notifyDataChange({
572    eventId: eventId, extraData: extraData
573  }, (err: BusinessError) => {
574    if (err === undefined) {
575      console.info('Succeeded in notifying the change of data');
576    } else {
577      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
578    }
579  });
580} catch (e) {
581  let error = e as BusinessError;
582  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
583}
584```
585
586### notifyDataChange<sup>11+</sup>
587
588static notifyDataChange(extInfo: ExtraData, userId: number,callback: AsyncCallback&lt;void&gt;):void
589
590通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,可通过userId指定用户ID,使用callback异步回调。
591
592**需要权限**:ohos.permission.CLOUDDATA_CONFIG
593
594**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
595
596**参数:**
597
598| 参数名   | 类型                      | 必填 | 说明                                            |
599| -------- | ------------------------- | ---- | ----------------------------------------------- |
600| extInfo  | [ExtraData](#extradata11)   | 是   | 透传数据,包含通知数据变更后的应用信息。        |
601| userId   | number                    | 是   | 用户ID。对应为系统中现有的用户ID。 |
602| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当数据变更通知成功,err为undefined,否则为错误对象。|
603
604**错误码:**
605
606以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
607
608| 错误码ID | 错误信息                                             |
609| -------- | ---------------------------------------------------- |
610| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
611| 202      | Permission verification failed, application which is not a system application uses system API.|
612| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
613| 801      | Capability not supported.|
614
615**示例:**
616
617```ts
618import { BusinessError } from '@kit.BasicServicesKit';
619
620let eventId: string = "cloud_data_change";
621let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
622let userId: number = 100;
623try {
624  cloudData.Config.notifyDataChange({
625    eventId: eventId, extraData: extraData
626  }, userId, (err: BusinessError) => {
627    if (err === undefined) {
628      console.info('Succeeded in notifying the change of data');
629    } else {
630      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
631    }
632  });
633} catch (e) {
634  let error = e as BusinessError;
635  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
636}
637```
638
639### notifyDataChange<sup>11+</sup>
640
641static notifyDataChange(extInfo: ExtraData, userId?: number): Promise&lt;void&gt;
642
643通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,可通过userId指定用户ID,使用Promise异步回调。
644
645**需要权限**:ohos.permission.CLOUDDATA_CONFIG
646
647**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
648
649**参数:**
650
651| 参数名  | 类型                    | 必填 | 说明                                            |
652| ------- | ----------------------- | ---- | ----------------------------------------------- |
653| extInfo | [ExtraData](#extradata11) | 是   | 透传数据 包含通知数据变更后的应用信息。         |
654| userId  | number                  | 否   | 表示用户ID。此参数是可选的,默认值是当前用户ID,如果指定了此参数,则该值必须是系统中现有的用户ID。 |
655
656**返回值:**
657
658| 类型                | 说明                      |
659| ------------------- | ------------------------- |
660| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
661
662**错误码:**
663
664以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
665
666| 错误码ID | 错误信息                                             |
667| -------- | ---------------------------------------------------- |
668| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
669| 202      | Permission verification failed, application which is not a system application uses system API.|
670| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
671| 801      | Capability not supported.|
672
673**示例:**
674
675```ts
676import { BusinessError } from '@kit.BasicServicesKit';
677
678let eventId: string = "cloud_data_change";
679let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
680let userId: number = 100;
681try {
682  cloudData.Config.notifyDataChange({
683    eventId: eventId, extraData: extraData
684  }, userId).then(() => {
685    console.info('Succeeded in notifying the change of data');
686  }).catch((err: BusinessError) => {
687    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
688  });
689} catch (e) {
690  let error = e as BusinessError;
691  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
692}
693```
694
695### queryStatistics<sup>12+</sup>
696
697static queryStatistics(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record&lt;string, Array&lt;StatisticInfo&gt;&gt;&gt;
698
699查询端云统计信息,返回未同步、已同步且端云信息一致和已同步且端云信息不一致的统计信息,使用Promise异步回调。
700
701**需要权限**:ohos.permission.CLOUDDATA_CONFIG
702
703**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
704
705**参数:**
706
707| 参数名  | 类型      | 必填 | 说明                                |
708| ------- |---------| ---- |-----------------------------------|
709| accountId | string  | 是   | 具体打开的云账号ID。                       |
710| bundleName | string  | 是   | 应用包名。                             |
711| storeId  | string  | 否   | 数据库名称。默认值为空字符串,此时将查询当前应用所有的本地数据库。 |
712
713**返回值:**
714
715| 类型                                                                                   | 说明                     |
716|--------------------------------------------------------------------------------------| ------------------------ |
717| Promise&lt;Record&lt;string, Array&lt;[StatisticInfo](#statisticinfo12)&gt;&gt;&gt; | 返回表名以及统计信息结果集。 |
718
719**错误码:**
720
721以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
722
723| 错误码ID | 错误信息                                             |
724| -------- | ---------------------------------------------------- |
725| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
726| 202      | Permission verification failed, application which is not a system application uses system API.|
727| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
728| 801      | Capability not supported.|
729
730**示例:**
731
732```ts
733import { BusinessError } from '@kit.BasicServicesKit';
734
735const accountId:string = "accountId";
736const bundleName:string = "bundleName";
737const storeId:string = "storeId";
738
739cloudData.Config.queryStatistics(accountId, bundleName, storeId).then((result) => {
740    console.info(`Succeeded in querying statistics. Info is ${JSON.stringify(result)}`);
741}).catch((err: BusinessError) => {
742    console.error(`Failed to query statistics. Error code is ${err.code}, message is ${err.message}`);
743});
744```
745
746### queryLastSyncInfo<sup>12+</sup>
747
748static queryLastSyncInfo(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record<string, SyncInfo>>
749
750查询上一次端云同步信息,使用Promise异步回调。
751
752**需要权限**:ohos.permission.CLOUDDATA_CONFIG
753
754**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
755
756**参数:**
757
758| 参数名     | 类型   | 必填 | 说明                                                         |
759| ---------- | ------ | ---- | ------------------------------------------------------------ |
760| accountId  | string | 是   | 具体打开的云账号ID。                                         |
761| bundleName | string | 是   | 应用包名。                                                   |
762| storeId    | string | 否   | 数据库名称。默认值为空字符串,此时查询当前应用下所有数据库上一次端云同步信息。 |
763
764**返回值:**
765
766| 类型                                                         | 说明                                         |
767| ------------------------------------------------------------ | -------------------------------------------- |
768| Promise&lt;Record&lt;string, [SyncInfo](#syncinfo12)&gt;&gt; | 返回数据库名以及上一次端云同步的信息结果集。 |
769
770**错误码:**
771
772以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
773
774| 错误码ID | 错误信息                                             |
775| -------- | ---------------------------------------------------- |
776| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
777| 202      | Permission verification failed, application which is not a system application uses system API.|
778| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
779| 801      | Capability not supported.|
780
781**示例:**
782
783```ts
784import { BusinessError } from '@kit.BasicServicesKit';
785
786const accountId:string = "accountId";
787const bundleName:string = "bundleName";
788const storeId:string = "storeId";
789try {
790    cloudData.Config.queryLastSyncInfo(accountId, bundleName, storeId).then((result) => {
791    	console.info(`Succeeded in querying last syncinfo. Info is ${JSON.stringify(result)}`);
792	}).catch((err: BusinessError) => {
793    	console.error(`Failed to query last syncinfo. Error code is ${err.code}, message is ${err.message}`);
794	});
795} catch(e) {
796    let error = e as BusinessError;
797  	console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
798}
799```
800
801### setGlobalCloudStrategy<sup>12+</sup>
802
803static setGlobalCloudStrategy(strategy: StrategyType, param?: Array&lt;commonType.ValueType&gt;): Promise&lt;void&gt;
804
805设置全局云同步策略,使用Promise异步回调。
806
807**需要权限**:ohos.permission.CLOUDDATA_CONFIG
808
809**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
810
811**参数:**
812
813| 参数名     | 类型                                                                     | 必填 | 说明                |
814| ---------- |------------------------------------------------------------------------| ---- |-------------------|
815| strategy  | [StrategyType](js-apis-data-cloudData.md#strategytype)    | 是   | 配置的策略类型。          |
816| param | Array&lt;[commonType.ValueType](js-apis-data-commonType.md#valuetype)&gt; | 否   | 策略参数。不填写默认为空,默认取消所有配置。 |
817
818**返回值:**
819
820| 类型                | 说明                      |
821| ------------------- | ------------------------- |
822| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
823
824**错误码:**
825
826以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
827
828| 错误码ID | 错误信息                                             |
829| -------- | ---------------------------------------------------- |
830| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
831| 202      | Permission verification failed, application which is not a system application uses system API.|
832| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
833| 801      | Capability not supported.|
834
835**示例:**
836
837```ts
838import { BusinessError } from '@kit.BasicServicesKit';
839
840cloudData.Config.setGlobalCloudStrategy(cloudData.StrategyType.NETWORK, [cloudData.NetWorkStrategy.WIFI]).then(() => {
841    console.info('Succeeded in setting the global cloud strategy');
842}).catch((err: BusinessError) => {
843    console.error(`Failed to set global cloud strategy. Code: ${err.code}, message: ${err.message}`);
844});
845```
846
847### cloudSync<sup>20+</sup>
848
849static cloudSync(bundleName: string, storeId: string, mode: relationalStore.SyncMode, progress: Callback&lt;relationalStore.ProgressDetails&gt;): Promise&lt;void&gt;
850
851对指定应用的数据进行端云同步,使用Promise异步回调。
852
853**需要权限**:ohos.permission.CLOUDDATA_CONFIG
854
855**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
856
857**参数:**
858
859| 参数名      | 类型   | 必填 | 说明                  |
860| ---------- |--------| ---- |-----------------------|
861| bundleName | string | 是   | 待端云同步数据的应用名。|
862| storeId    | string | 是   | 待端云同步的数据库名。  |
863| mode       | [relationalStore.SyncMode](arkts-apis-data-relationalStore-e.md#syncmode) | 是 | 端云同步类型。|
864| progress | Callback&lt;[relationalStore.ProgressDetails](arkts-apis-data-relationalStore-i.md#progressdetails10)&gt; | 是 | 同步进度回调。 |
865
866**返回值:**
867
868| 类型                | 说明                     |
869| ------------------- | ----------------------- |
870| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
871
872**错误码:**
873
874以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[关系型数据库错误码](errorcode-data-rdb.md)。
875
876| 错误码ID | 错误信息                                             |
877| -------- | ---------------------------------------------------- |
878| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
879| 202      | Permission verification failed, application which is not a system application uses system API.|
880| 801      | Capability not supported.|
881| 14800001 | Invalid arguments. Possible causes: 1. Parameter is out of valid range. |
882
883**示例:**
884
885```ts
886import { BusinessError } from '@kit.BasicServicesKit';
887import { relationalStore } from '@kit.ArkData';
888
889try{
890  cloudData.Config.cloudSync("bundleName", "storeId", relationalStore.SyncMode.SYNC_MODE_TIME_FIRST, (progress)=>{
891    console.info('Succeeded in getting progress details.');
892  }).then(() => {
893      console.info('Succeeded in syncing cloud data.');
894  }).catch((err: BusinessError) => {
895      console.error(`Failed to sync cloud data. Code: ${err.code}, message: ${err.message}`);
896  });
897} catch (e) {
898  let error = e as BusinessError;
899  console.error(`Failed to sync cloud data. Code: ${e.code}, message: ${e.message}`);
900}
901```
902
903###  clear
904
905static clear(accountId: string, appActions: Record<string, ClearAction>,  callback: AsyncCallback&lt;void&gt;): void
906
907清除本地下载的云端数据,使用callback异步回调。
908
909**需要权限**:ohos.permission.CLOUDDATA_CONFIG
910
911**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
912
913**参数:**
914
915| 参数名     | 类型                                                | 必填 | 说明                             |
916| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
917| accountId  | string                                              | 是   | 具体打开的云账号ID。             |
918| appActions | Record<string, [ClearAction](#clearaction)>         | 是   | 要清除数据的应用信息及清除规则。 |
919| callback   | AsyncCallback&lt;void&gt;                           | 是   | 回调函数。                       |
920
921**错误码:**
922
923以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
924
925| 错误码ID | 错误信息                                             |
926| -------- | ---------------------------------------------------- |
927| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
928| 202      | Permission verification failed, application which is not a system application uses system API.|
929| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
930| 801      | Capability not supported.|
931
932**示例:**
933
934```ts
935import { BusinessError } from '@kit.BasicServicesKit';
936
937let account: string = "test_id";
938type dataType = Record<string, cloudData.ClearAction>
939let appActions: dataType = {
940  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
941  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
942};
943try {
944  cloudData.Config.clear(account, appActions, (err: BusinessError) => {
945    if (err === undefined) {
946      console.info('Succeeding in clearing cloud data');
947    } else {
948      console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
949    }
950  });
951} catch (e) {
952  let error = e as BusinessError;
953  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
954}
955```
956
957### clear
958
959static clear(accountId: string, appActions: Record<string, ClearAction>): Promise&lt;void&gt;
960
961清除本地下载的云端数据,使用Promise异步回调。
962
963**需要权限**:ohos.permission.CLOUDDATA_CONFIG
964
965**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
966
967**参数:**
968
969| 参数名     | 类型                                                | 必填 | 说明                             |
970| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
971| accountId  | string                                              | 是   | 具体打开的云账号ID。             |
972| appActions | Record<string, [ClearAction](#clearaction)>         | 是   | 要清除数据的应用信息及清除规则。 |
973
974**返回值:**
975
976| 类型                | 说明                      |
977| ------------------- | ------------------------- |
978| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
979
980**错误码:**
981
982以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
983
984| 错误码ID | 错误信息                                             |
985| -------- | ---------------------------------------------------- |
986| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
987| 202      | Permission verification failed, application which is not a system application uses system API.|
988| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
989| 801      | Capability not supported.|
990
991**示例:**
992
993```ts
994import { BusinessError } from '@kit.BasicServicesKit';
995
996let account: string = "test_id";
997type dataType = Record<string, cloudData.ClearAction>;
998let appActions: dataType = {
999  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
1000  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
1001};
1002try {
1003  cloudData.Config.clear(account, appActions).then(() => {
1004    console.info('Succeeding in clearing cloud data');
1005  }).catch((err: BusinessError) => {
1006    console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
1007  });
1008} catch (e) {
1009  let error = e as BusinessError;
1010  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
1011}
1012```
1013
1014## sharing<sup>11+</sup>
1015
1016提供端云共享的方法,包括发起共享、取消共享、退出共享、更改共享数据权限、查找共享参与者、确认邀请、更改已确认的邀请、查找共享资源。
1017
1018### Role<sup>11+</sup>
1019
1020端云共享参与者的角色。
1021
1022**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1023
1024| 名称           | 值   | 说明                               |
1025| --------------| ---- | ---------------------------------- |
1026| ROLE_INVITER  | 0    | 端云共享邀请者。请使用枚举名称而非枚举值。 |
1027| ROLE_INVITEE  | 1    | 端云共享被邀请者。请使用枚举名称而非枚举值。 |
1028
1029### State<sup>11+</sup>
1030
1031端云共享状态。
1032
1033**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1034
1035| 名称           | 值   | 说明                               |
1036| --------------| ---- | ---------------------------------- |
1037| STATE_UNKNOWN    | 0    | 未知状态。请使用枚举名称而非枚举值。   |
1038| STATE_ACCEPTED   | 1    | 端云共享已接受。请使用枚举名称而非枚举值。 |
1039| STATE_REJECTED   | 2    | 端云共享被拒绝。请使用枚举名称而非枚举值。 |
1040| STATE_SUSPENDED  | 3    | 端云共享被暂时挂起,未作处理。请使用枚举名称而非枚举值。 |
1041| STATE_UNAVAILABLE<sup>12+</sup>   | 4    | 端云共享不可用。请使用枚举名称而非枚举值。 |
1042
1043### SharingCode<sup>11+</sup>
1044
1045端云共享错误码。
1046
1047**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1048
1049| 名称           | 值   | 说明                               |
1050| --------------| ---- | ---------------------------------- |
1051| SUCCESS                 | 0    | 成功。请使用枚举名称而非枚举值。   |
1052| REPEATED_REQUEST        | 1    | 重复邀请,表示当前参与者已被邀请。请使用枚举名称而非枚举值。 |
1053| NOT_INVITER             | 2    | 非端云共享的邀请者,表示当前参与者不是端云共享的邀请者。请使用枚举名称而非枚举值。 |
1054| NOT_INVITER_OR_INVITEE  | 3    | 非法参与者,表示当前参与者既不是共享的邀请者,也不是共享的被邀请者。请使用枚举名称而非枚举值。 |
1055| OVER_QUOTA              | 4    | 端云共享次数达到上限,表示当前账号可共享的次数达到上限。请使用枚举名称而非枚举值。   |
1056| TOO_MANY_PARTICIPANTS   | 5    | 端云共享参与者数量达到上限。请使用枚举名称而非枚举值。 |
1057| INVALID_ARGS            | 6    | 无效的参数。请使用枚举名称而非枚举值。 |
1058| NETWORK_ERROR           | 7    | 网络错误。请使用枚举名称而非枚举值。 |
1059| CLOUD_DISABLED          | 8    | 云开关未打开。请使用枚举名称而非枚举值。   |
1060| SERVER_ERROR            | 9    | 服务端发生错误。请使用枚举名称而非枚举值。 |
1061| INNER_ERROR             | 10   | 系统发生内部错误。请使用枚举名称而非枚举值。 |
1062| INVALID_INVITATION      | 11   | 无效的邀请,表示当前邀请已失效或不存在。请使用枚举名称而非枚举值。 |
1063| RATE_LIMIT              | 12   | 速率限制,表示单次同步的数据量达到上限。请使用枚举名称而非枚举值。   |
1064| CUSTOM_ERROR            | 1000 | 定制错误,小于该枚举值的错误码用于定义系统内部的标准错误码,大于该枚举值的错误码用于使用者自定义错误码。请使用枚举名称而非枚举值。 |
1065
1066### Result&lt;T&gt;<sup>11+</sup>
1067
1068端云共享结果的返回值。
1069
1070**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1071
1072| 名称          | 类型                          | 必填  | 说明           |
1073| ----------- | --------------------------- | --- | ------------ |
1074| code        | number                      | 是   | 错误码。       |
1075| description | string                      | 否   | 错误码详细描述,默认为undefined。       |
1076| value       | T                           | 否   | 返回结果的值,具体类型由参数T指定,默认为undefined。 |
1077
1078### Privilege<sup>11+</sup>
1079
1080指定的端云共享数据的权限。
1081
1082**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1083
1084| 名称          | 类型                          | 必填  | 说明           |
1085| ----------- | --------------------------- | --- | ------------ |
1086| writable    | boolean              | 否   | 被共享者是否可修改共享的数据。true表示可修改,false表示不可修改,默认不可修改。   |
1087| readable    | boolean              | 否   | 被共享者是否可读取共享的数据。true表示可读取,false表示不可读取,默认不可读取。   |
1088| creatable   | boolean              | 否   | 被共享者是否可创建新的共享数据。true表示可创建,false表示不可创建,默认不可创建。  |
1089| deletable   | boolean              | 否   | 被共享者是否可删除共享的数据。true表示可删除,false表示不可删除,默认不可删除。  |
1090| shareable   | boolean              | 否   | 被共享者是否可将共享的数据再次共享给其他参与者。true表示可再次共享,false表示不可再次共享,默认不可再次共享。  |
1091
1092### Participant<sup>11+</sup>
1093
1094端云共享的参与者。
1095
1096**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1097
1098| 名称          | 类型                          | 必填  | 说明           |
1099| ----------- | --------------------------- | --- | ------------ |
1100| identity    | string                  | 是   | 参与者的ID。              |
1101| role        | [Role](#role11)           | 否   | 参与者的角色,为邀请者或被邀请者。默认为undefined。  |
1102| state       | [State](#state11)         | 否   | 共享的状态。默认为undefined。 |
1103| privilege   | [Privilege](#privilege11) | 否   | 指定的共享数据权限。默认为[Privilege](#privilege11)的默认值。 |
1104| attachInfo  | string                  | 否   | 附加信息,用于拓展额外的参与者信息。如用于参与者身份校验的校验码等,默认为空字符串。 |
1105
1106### allocResourceAndShare<sup>11+</sup>
1107
1108allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns?: Array&lt;string&gt;): Promise&lt;relationalStore.ResultSet&gt;
1109
1110根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集。如果指定了列字段,则返回的结果集中同时包含对应列的字段值,使用Promise异步回调。
1111
1112**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1113
1114**参数:**
1115
1116| 参数名    | 类型                            | 必填 | 说明                         |
1117| --------- | ------------------------------- | ---- | ---------------------------- |
1118| storeId      | string                        | 是   | 数据库名称。 |
1119| predicates   | [relationalStore.RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1120| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1121| columns      | Array&lt;string&gt;           | 否   | 表示要查找的列字段名。默认为undefined,不返回列字段。 |
1122
1123**返回值:**
1124
1125| 类型                | 说明                      |
1126| ------------------- | ------------------------- |
1127| Promise&lt;[relationalStore.ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt; | Promise对象,返回查询并共享的共享资源标识结果集。 |
1128
1129**错误码:**
1130
1131以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1132
1133| 错误码ID | 错误信息                                             |
1134| -------- | ---------------------------------------------------- |
1135| 202      | Permission verification failed, application which is not a system application uses system API.|
1136| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1137| 801      | Capability not supported.|
1138
1139**示例:**
1140
1141```ts
1142import { BusinessError } from '@kit.BasicServicesKit';
1143import { relationalStore } from '@kit.ArkData';
1144
1145let participants = new Array<cloudData.sharing.Participant>();
1146participants.push({
1147  identity: '000000000',
1148  role: cloudData.sharing.Role.ROLE_INVITER,
1149  state: cloudData.sharing.State.STATE_UNKNOWN,
1150  privilege: {
1151    writable: true,
1152    readable: true,
1153    creatable: false,
1154    deletable: false,
1155    shareable: false
1156  },
1157  attachInfo: ''
1158})
1159let sharingResource: string;
1160let predicates = new relationalStore.RdbPredicates('test_table');
1161predicates.equalTo('data', 'data_test');
1162cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data']).then((resultSet) => {
1163  if (!resultSet.goToFirstRow()) {
1164    console.error(`row error`);
1165    return;
1166  }
1167  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1168  console.info(`sharing resource: ${res}`);
1169  sharingResource = res;
1170}).catch((err: BusinessError) => {
1171  console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1172})
1173
1174```
1175
1176### allocResourceAndShare<sup>11+</sup>
1177
1178allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1179
1180根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集。并根据指定的列字段,返回的结果集中同时包含对应列的字段值,使用callback异步回调。
1181
1182**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1183
1184**参数:**
1185
1186| 参数名    | 类型                            | 必填 | 说明                         |
1187| --------- | ------------------------------- | ---- | ---------------------------- |
1188| storeId      | string                        | 是   | 数据库名称。 |
1189| predicates   | [relationalStore.RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1190| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1191| columns      | Array&lt;string&gt;           | 是   | 表示要查找的列字段名。 |
1192| callback     | AsyncCallback&lt;[relationalStore.ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt;  | 是  | 回调函数。 返回查询并共享的共享资源标识结果集。 |
1193
1194**错误码:**
1195
1196以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1197
1198| 错误码ID | 错误信息                                             |
1199| -------- | ---------------------------------------------------- |
1200| 202      | Permission verification failed, application which is not a system application uses system API.|
1201| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1202| 801      | Capability not supported.|
1203
1204**示例:**
1205
1206```ts
1207import { relationalStore } from '@kit.ArkData';
1208import { BusinessError } from '@kit.BasicServicesKit';
1209
1210let participants = new Array<cloudData.sharing.Participant>();
1211participants.push({
1212  identity: '000000000',
1213  role: cloudData.sharing.Role.ROLE_INVITER,
1214  state: cloudData.sharing.State.STATE_UNKNOWN,
1215  privilege: {
1216    writable: true,
1217    readable: true,
1218    creatable: false,
1219    deletable: false,
1220    shareable: false
1221  },
1222  attachInfo: ''
1223})
1224let sharingResource: string;
1225let predicates = new relationalStore.RdbPredicates('test_table');
1226predicates.equalTo('data', 'data_test');
1227cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data'], (err: BusinessError, resultSet) => {
1228  if (err) {
1229    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1230    return;
1231  }
1232  if (!resultSet.goToFirstRow()) {
1233    console.error(`row error`);
1234    return;
1235  }
1236  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1237  console.info(`sharing resource: ${res}`);
1238  sharingResource = res;
1239})
1240
1241```
1242
1243### allocResourceAndShare<sup>11+</sup>
1244
1245allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1246
1247根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集,使用callback异步回调。
1248
1249**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1250
1251**参数:**
1252
1253| 参数名    | 类型                            | 必填 | 说明                         |
1254| --------- | ------------------------------- | ---- | ---------------------------- |
1255| storeId      | string                        | 是   | 数据库名称。 |
1256| predicates   | [relationalStore.RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1257| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1258| callback     | AsyncCallback&lt;[relationalStore.ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt;  | 是   | 回调函数。返回查询并共享的共享资源标识结果集。 |
1259
1260**错误码:**
1261
1262以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1263
1264| 错误码ID | 错误信息                                             |
1265| -------- | ---------------------------------------------------- |
1266| 202      | Permission verification failed, application which is not a system application uses system API.|
1267| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1268| 801      | Capability not supported.|
1269
1270**示例:**
1271
1272```ts
1273import { relationalStore } from '@kit.ArkData';
1274import { BusinessError } from '@kit.BasicServicesKit';
1275
1276let participants = new Array<cloudData.sharing.Participant>();
1277participants.push({
1278  identity: '000000000',
1279  role: cloudData.sharing.Role.ROLE_INVITER,
1280  state: cloudData.sharing.State.STATE_UNKNOWN,
1281  privilege: {
1282    writable: true,
1283    readable: true,
1284    creatable: false,
1285    deletable: false,
1286    shareable: false
1287  },
1288  attachInfo: ''
1289})
1290let sharingResource: string;
1291let predicates = new relationalStore.RdbPredicates('test_table');
1292predicates.equalTo('data', 'data_test');
1293cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, (err: BusinessError, resultSet) => {
1294  if (err) {
1295    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1296    return;
1297  }
1298  if (!resultSet.goToFirstRow()) {
1299    console.error(`row error`);
1300    return;
1301  }
1302  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1303  console.info(`sharing resource: ${res}`);
1304  sharingResource = res;
1305})
1306
1307```
1308
1309### share<sup>11+</sup>
1310
1311share(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1312
1313根据指定的共享资源标识和共享参与者发起共享邀请,使用Promise异步回调。
1314
1315**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1316
1317**参数:**
1318
1319| 参数名    | 类型                            | 必填 | 说明                         |
1320| --------- | ------------------------------- | ---- | ---------------------------- |
1321| sharingResource   | string                                     | 是   | 端云共享数据的资源标识。 |
1322| participants      | Array&lt;[Participant](#participant11)&gt;   | 是   | 端云共享的参与者。 |
1323
1324**返回值:**
1325
1326| 类型                | 说明                      |
1327| ------------------- | ------------------------- |
1328| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回端云共享的结果。 |
1329
1330**错误码:**
1331
1332以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1333
1334| 错误码ID | 错误信息                                             |
1335| -------- | ---------------------------------------------------- |
1336| 202      | Permission verification failed, application which is not a system application uses system API.|
1337| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1338| 801      | Capability not supported.|
1339
1340**示例:**
1341
1342```ts
1343import { BusinessError } from '@kit.BasicServicesKit';
1344
1345let participants = new Array<cloudData.sharing.Participant>();
1346participants.push({
1347  identity: '000000000',
1348  role: cloudData.sharing.Role.ROLE_INVITER,
1349  state: cloudData.sharing.State.STATE_UNKNOWN,
1350  privilege: {
1351    writable: true,
1352    readable: true,
1353    creatable: false,
1354    deletable: false,
1355    shareable: false
1356  },
1357  attachInfo: ''
1358})
1359cloudData.sharing.share('sharing_resource_test', participants).then((result) => {
1360  console.info(`share success, result: ${result}`);
1361}).catch((err: BusinessError) => {
1362  console.error(`share failed, code is ${err.code},message is ${err.message}`);
1363})
1364
1365```
1366
1367### share<sup>11+</sup>
1368
1369share(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1370
1371根据指定的共享资源标识和共享参与者发起共享邀请,使用callback异步回调。
1372
1373**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1374
1375**参数:**
1376
1377| 参数名    | 类型                            | 必填 | 说明                         |
1378| --------- | ------------------------------- | ---- | ---------------------------- |
1379| sharingResource  | string                                     | 是   | 端云共享数据的资源标识。 |
1380| participants     | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1381| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回端云共享的结果。 |
1382
1383**错误码:**
1384
1385以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1386
1387| 错误码ID | 错误信息                                             |
1388| -------- | ---------------------------------------------------- |
1389| 202      | Permission verification failed, application which is not a system application uses system API.|
1390| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1391| 801      | Capability not supported.|
1392
1393**示例:**
1394
1395```ts
1396import { BusinessError } from '@kit.BasicServicesKit';
1397
1398let participants = new Array<cloudData.sharing.Participant>();
1399participants.push({
1400  identity: '000000000',
1401  role: cloudData.sharing.Role.ROLE_INVITER,
1402  state: cloudData.sharing.State.STATE_UNKNOWN,
1403  privilege: {
1404    writable: true,
1405    readable: true,
1406    creatable: false,
1407    deletable: false,
1408    shareable: false
1409  },
1410  attachInfo: ''
1411})
1412cloudData.sharing.share('sharing_resource_test', participants, ((err: BusinessError, result) => {
1413  if (err) {
1414    console.error(`share failed, code is ${err.code},message is ${err.message}`);
1415    return;
1416  }
1417  console.info(`share succeeded, result: ${result}`);
1418}))
1419
1420```
1421
1422### unshare<sup>11+</sup>
1423
1424unshare(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1425
1426根据指定的共享资源标识和共享参与者取消共享,使用Promise异步回调。
1427
1428**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1429
1430**参数:**
1431
1432| 参数名    | 类型                            | 必填 | 说明                         |
1433| --------- | ------------------------------- | ---- | ---------------------------- |
1434| sharingResource   | string                                     | 是   | 端云共享数据的资源标识。 |
1435| participants      | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1436
1437**返回值:**
1438
1439| 类型                | 说明                      |
1440| ------------------- | ------------------------- |
1441| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回取消共享的结果。 |
1442
1443**错误码:**
1444
1445以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1446
1447| 错误码ID | 错误信息                                             |
1448| -------- | ---------------------------------------------------- |
1449| 202      | Permission verification failed, application which is not a system application uses system API.|
1450| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1451| 801      | Capability not supported.|
1452
1453**示例:**
1454
1455```ts
1456import { BusinessError } from '@kit.BasicServicesKit';
1457
1458let participants = new Array<cloudData.sharing.Participant>();
1459participants.push({
1460  identity: '000000000',
1461  role: cloudData.sharing.Role.ROLE_INVITER,
1462  state: cloudData.sharing.State.STATE_UNKNOWN,
1463  privilege: {
1464    writable: true,
1465    readable: true,
1466    creatable: false,
1467    deletable: false,
1468    shareable: false
1469  },
1470  attachInfo: ''
1471})
1472cloudData.sharing.unshare('sharing_resource_test', participants).then((result) => {
1473  console.info(`unshare succeeded, result: ${result}`);
1474}).catch((err: BusinessError) => {
1475  console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1476})
1477
1478```
1479
1480### unshare<sup>11+</sup>
1481
1482unshare(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1483
1484根据指定的共享资源标识和共享参与者取消共享,使用callback异步回调。
1485
1486**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1487
1488**参数:**
1489
1490| 参数名    | 类型                            | 必填 | 说明                         |
1491| --------- | ------------------------------- | ---- | ---------------------------- |
1492| sharingResource  | string                                     | 是   | 共享数据的资源标志。 |
1493| participants     | Array&lt;[Participant](#participant11)&gt; | 是   | 共享参与者。 |
1494| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回取消共享的结果。 |
1495
1496**错误码:**
1497
1498以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1499
1500| 错误码ID | 错误信息                                             |
1501| -------- | ---------------------------------------------------- |
1502| 202      | Permission verification failed, application which is not a system application uses system API.|
1503| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1504| 801      | Capability not supported.|
1505
1506**示例:**
1507
1508```ts
1509import { BusinessError } from '@kit.BasicServicesKit';
1510
1511let participants = new Array<cloudData.sharing.Participant>();
1512participants.push({
1513  identity: '000000000',
1514  role: cloudData.sharing.Role.ROLE_INVITER,
1515  state: cloudData.sharing.State.STATE_UNKNOWN,
1516  privilege: {
1517    writable: true,
1518    readable: true,
1519    creatable: false,
1520    deletable: false,
1521    shareable: false
1522  },
1523  attachInfo: ''
1524})
1525cloudData.sharing.unshare('sharing_resource_test', participants, ((err: BusinessError, result) => {
1526  if (err) {
1527    console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1528    return;
1529  }
1530  console.info(`unshare succeeded, result: ${result}`);
1531}))
1532
1533```
1534
1535### exit<sup>11+</sup>
1536
1537exit(sharingResource: string): Promise&lt;Result&lt;void&gt;&gt;
1538
1539根据指定的共享资源标识退出共享,使用Promise异步回调。
1540
1541**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1542
1543**参数:**
1544
1545| 参数名    | 类型                            | 必填 | 说明                         |
1546| --------- | ------------------------------- | ---- | ---------------------------- |
1547| sharingResource   | string       | 是   | 端云共享数据的资源标识。 |
1548
1549**返回值:**
1550
1551| 类型                | 说明                      |
1552| ------------------- | ------------------------- |
1553| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; | Promise对象,返回退出端云共享的结果。 |
1554
1555**错误码:**
1556
1557以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1558
1559| 错误码ID | 错误信息                                             |
1560| -------- | ---------------------------------------------------- |
1561| 202      | Permission verification failed, application which is not a system application uses system API.|
1562| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1563| 801      | Capability not supported.|
1564
1565**示例:**
1566
1567```ts
1568import { BusinessError } from '@kit.BasicServicesKit';
1569
1570cloudData.sharing.exit('sharing_resource_test').then((result) => {
1571  console.info(`exit share success, result: ${result}`);
1572}).catch((err: BusinessError) => {
1573  console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1574})
1575
1576```
1577
1578### exit<sup>11+</sup>
1579
1580exit(sharingResource: string, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void
1581
1582根据指定的共享资源标识退出共享,使用callback异步回调。
1583
1584**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1585
1586**参数:**
1587
1588| 参数名    | 类型                            | 必填 | 说明                         |
1589| --------- | ------------------------------- | ---- | ---------------------------- |
1590| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1591| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt;  | 是   | 回调函数。返回退出共享的结果。 |
1592
1593**错误码:**
1594
1595以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1596
1597| 错误码ID | 错误信息                                             |
1598| -------- | ---------------------------------------------------- |
1599| 202      | Permission verification failed, application which is not a system application uses system API.|
1600| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1601| 801      | Capability not supported.|
1602
1603**示例:**
1604
1605```ts
1606import { BusinessError } from '@kit.BasicServicesKit';
1607
1608cloudData.sharing.exit('sharing_resource_test', ((err: BusinessError, result) => {
1609  if (err) {
1610    console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1611    return;
1612  }
1613  console.info(`exit share succeeded, result: ${result}`);
1614}))
1615
1616```
1617
1618### changePrivilege<sup>11+</sup>
1619
1620changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1621
1622根据指定的共享资源标识更改共享参与者对共享数据的操作权限,使用Promise异步回调。
1623
1624**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1625
1626**参数:**
1627
1628| 参数名    | 类型                            | 必填 | 说明                         |
1629| --------- | ------------------------------- | ---- | ---------------------------- |
1630| sharingResource   | string                                    | 是   | 端云共享数据的资源标识。 |
1631| participants      | Array&lt;[Participant](#participant11)&gt;  | 是   | 端云共享的参与者。 |
1632
1633**返回值:**
1634
1635| 类型                | 说明                      |
1636| ------------------- | ------------------------- |
1637| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回更改共享参与者权限的结果。 |
1638
1639**错误码:**
1640
1641以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1642
1643| 错误码ID | 错误信息                                             |
1644| -------- | ---------------------------------------------------- |
1645| 202      | Permission verification failed, application which is not a system application uses system API.|
1646| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1647| 801      | Capability not supported.|
1648
1649**示例:**
1650
1651```ts
1652import { BusinessError } from '@kit.BasicServicesKit';
1653
1654let participants = new Array<cloudData.sharing.Participant>();
1655participants.push({
1656  identity: '000000000',
1657  role: cloudData.sharing.Role.ROLE_INVITER,
1658  state: cloudData.sharing.State.STATE_UNKNOWN,
1659  privilege: {
1660    writable: true,
1661    readable: true,
1662    creatable: false,
1663    deletable: false,
1664    shareable: false
1665  },
1666  attachInfo: ''
1667})
1668
1669cloudData.sharing.changePrivilege('sharing_resource_test', participants).then((result) => {
1670  console.info(`change privilege succeeded, result: ${result}`);
1671}).catch((err: BusinessError) => {
1672  console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1673})
1674
1675```
1676
1677### changePrivilege<sup>11+</sup>
1678
1679changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1680
1681根据指定的共享资源标识更改共享参与者对共享数据的操作权限,使用callback异步回调。
1682
1683**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1684
1685**参数:**
1686
1687| 参数名    | 类型                            | 必填 | 说明                         |
1688| --------- | ------------------------------- | ---- | ---------------------------- |
1689| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1690| participants     | Array&lt;[Participant](#participant11)&gt;  | 是   | 端云共享的参与者。 |
1691| callback         | callback: AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回更改权限的结果。 |
1692
1693**错误码:**
1694
1695以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1696
1697| 错误码ID | 错误信息                                             |
1698| -------- | ---------------------------------------------------- |
1699| 202      | Permission verification failed, application which is not a system application uses system API.|
1700| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1701| 801      | Capability not supported.|
1702
1703**示例:**
1704
1705```ts
1706import { BusinessError } from '@kit.BasicServicesKit';
1707
1708let participants = new Array<cloudData.sharing.Participant>();
1709participants.push({
1710  identity: '000000000',
1711  role: cloudData.sharing.Role.ROLE_INVITER,
1712  state: cloudData.sharing.State.STATE_UNKNOWN,
1713  privilege: {
1714    writable: true,
1715    readable: true,
1716    creatable: false,
1717    deletable: false,
1718    shareable: false
1719  },
1720  attachInfo: ''
1721})
1722
1723cloudData.sharing.changePrivilege('sharing_resource_test', participants, ((err: BusinessError, result) => {
1724  if (err) {
1725    console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1726    return;
1727  }
1728  console.info(`change privilege succeeded, result: ${result}`);
1729}))
1730
1731```
1732
1733### queryParticipants<sup>11+</sup>
1734
1735queryParticipants(sharingResource: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1736
1737根据指定的共享资源标识查询当前共享的参与者,使用Promise异步回调。
1738
1739**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1740
1741**参数:**
1742
1743| 参数名    | 类型                            | 必填 | 说明                         |
1744| --------- | ------------------------------- | ---- | ---------------------------- |
1745| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1746
1747**返回值:**
1748
1749| 类型                | 说明                      |
1750| ------------------- | ------------------------- |
1751| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise对象,返回查询共享参与者的结果。 |
1752
1753**错误码:**
1754
1755以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1756
1757| 错误码ID | 错误信息                                             |
1758| -------- | ---------------------------------------------------- |
1759| 202      | Permission verification failed, application which is not a system application uses system API.|
1760| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1761| 801      | Capability not supported.|
1762
1763**示例:**
1764
1765```ts
1766import { BusinessError } from '@kit.BasicServicesKit';
1767
1768cloudData.sharing.queryParticipants('sharing_resource_test').then((result) => {
1769  console.info(`query participants succeeded, result: ${result}`);
1770}).catch((err: BusinessError) => {
1771  console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1772})
1773
1774```
1775
1776### queryParticipants<sup>11+</sup>
1777
1778queryParticipants(sharingResource: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1779
1780根据指定的共享资源标识查询当前共享的参与者,使用callback异步回调。
1781
1782**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1783
1784**参数:**
1785
1786| 参数名    | 类型                            | 必填 | 说明                         |
1787| --------- | ------------------------------- | ---- | ---------------------------- |
1788| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1789| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt;  | 是   | 回调函数。返回查找共享参与者的结果。 |
1790
1791**错误码:**
1792
1793以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1794
1795| 错误码ID | 错误信息                                             |
1796| -------- | ---------------------------------------------------- |
1797| 202      | Permission verification failed, application which is not a system application uses system API.|
1798| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1799| 801      | Capability not supported.|
1800
1801**示例:**
1802
1803```ts
1804import { BusinessError } from '@kit.BasicServicesKit';
1805
1806cloudData.sharing.queryParticipants('sharing_resource_test', ((err: BusinessError, result) => {
1807  if (err) {
1808    console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1809    return;
1810  }
1811  console.info(`query participants succeeded, result: ${result}`);
1812}))
1813
1814```
1815
1816### queryParticipantsByInvitation<sup>11+</sup>
1817
1818queryParticipantsByInvitation(invitationCode: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1819
1820根据指定的共享邀请码查询当前共享的参与者,使用Promise异步回调。
1821
1822**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1823
1824**参数:**
1825
1826| 参数名    | 类型                            | 必填 | 说明                         |
1827| --------- | ------------------------------- | ---- | ---------------------------- |
1828| invitationCode   | string                 | 是   | 端云共享的邀请码。 |
1829
1830**返回值:**
1831
1832| 类型                | 说明                      |
1833| ------------------- | ------------------------- |
1834| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise对象,返回查找共享参与者的结果。|
1835
1836**错误码:**
1837
1838以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1839
1840| 错误码ID | 错误信息                                             |
1841| -------- | ---------------------------------------------------- |
1842| 202      | Permission verification failed, application which is not a system application uses system API.|
1843| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1844| 801      | Capability not supported.|
1845
1846**示例:**
1847
1848```ts
1849import { BusinessError } from '@kit.BasicServicesKit';
1850
1851cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test').then((result) => {
1852  console.info(`query participants by invitation succeeded, result: ${result}`);
1853}).catch((err: BusinessError) => {
1854  console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1855})
1856
1857```
1858
1859### queryParticipantsByInvitation<sup>11+</sup>
1860
1861queryParticipantsByInvitation(invitationCode: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1862
1863根据指定的共享邀请码查询当前共享的参与者,使用callback异步回调。
1864
1865**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1866
1867**参数:**
1868
1869| 参数名    | 类型                            | 必填 | 说明                         |
1870| --------- | ------------------------------- | ---- | ---------------------------- |
1871| invitationCode  | string                | 是   | 端云共享的邀请码。 |
1872| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | 是   | 回调函数。返回查找共享参与者的结果。 |
1873
1874**错误码:**
1875
1876以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1877
1878| 错误码ID | 错误信息                                             |
1879| -------- | ---------------------------------------------------- |
1880| 202      | Permission verification failed, application which is not a system application uses system API.|
1881| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1882| 801      | Capability not supported.|
1883
1884**示例:**
1885
1886```ts
1887import { BusinessError } from '@kit.BasicServicesKit';
1888
1889cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test', ((err: BusinessError, result) => {
1890  if (err) {
1891    console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1892    return;
1893  }
1894  console.info(`query participants by invitation succeeded, result: ${result}`);
1895}))
1896
1897```
1898
1899### confirmInvitation<sup>11+</sup>
1900
1901confirmInvitation(invitationCode: string, state: State): Promise&lt;Result&lt;string&gt;&gt;
1902
1903被邀请者根据共享邀请码确认当前邀请,并获取当前邀请的共享资源标识,使用Promise异步回调。
1904
1905**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1906
1907**参数:**
1908
1909| 参数名    | 类型                            | 必填 | 说明                         |
1910| --------- | ------------------------------- | ---- | ---------------------------- |
1911| invitationCode   | string                 | 是   | 端云共享的邀请码。 |
1912| state            | [State](#state11)        | 是   | 确认邀请的状态。 |
1913
1914**返回值:**
1915
1916| 类型                | 说明                      |
1917| ------------------- | ------------------------- |
1918| Promise&lt;[Result](#resultt11)&lt;string&gt;&gt; | Promise对象,返回确认共享邀请的结果。 |
1919
1920**错误码:**
1921
1922以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1923
1924| 错误码ID | 错误信息                                             |
1925| -------- | ---------------------------------------------------- |
1926| 202      | Permission verification failed, application which is not a system application uses system API.|
1927| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1928| 801      | Capability not supported.|
1929
1930**示例:**
1931
1932```ts
1933import { BusinessError } from '@kit.BasicServicesKit';
1934
1935let shareResource: string | undefined;
1936cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED).then((result: cloudData.sharing.Result<string>) => {
1937  console.info(`confirm invitation succeeded, result: ${result}`);
1938  shareResource = result.value;
1939}).catch((err: BusinessError) => {
1940  console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1941})
1942
1943```
1944
1945### confirmInvitation<sup>11+</sup>
1946
1947confirmInvitation(invitationCode: string, state: State, callback: AsyncCallback&lt;Result&lt;string&gt;&gt;): void
1948
1949被邀请者根据共享邀请码确认当前邀请,并获取当前邀请的共享资源标识,使用callback异步回调。
1950
1951**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1952
1953**参数:**
1954
1955| 参数名    | 类型                            | 必填 | 说明                         |
1956| --------- | ------------------------------- | ---- | ---------------------------- |
1957| invitationCode  | string                | 是   | 端云共享的邀请码。 |
1958| state           | [State](#state11)       | 是   | 确认邀请的状态。 |
1959| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;string&gt;&gt; | 是   | 回调函数。返回确认邀请的结果。 |
1960
1961**错误码:**
1962
1963以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1964
1965| 错误码ID | 错误信息                                             |
1966| -------- | ---------------------------------------------------- |
1967| 202      | Permission verification failed, application which is not a system application uses system API.|
1968| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1969| 801      | Capability not supported.|
1970
1971**示例:**
1972
1973```ts
1974import { BusinessError } from '@kit.BasicServicesKit';
1975
1976let shareResource: string;
1977cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED, ((err: BusinessError, result) => {
1978  if (err) {
1979    console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1980    return;
1981  }
1982  console.info(`confirm invitation succeeded, result: ${result}`);
1983  shareResource = result.value;
1984}))
1985
1986```
1987
1988### changeConfirmation<sup>11+</sup>
1989
1990changeConfirmation(sharingResource: string, state: State): Promise&lt;Result&lt;void&gt;&gt;
1991
1992根据共享资源标识更改共享邀请的状态,使用Promise异步回调。
1993
1994**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1995
1996**参数:**
1997
1998| 参数名    | 类型                            | 必填 | 说明                         |
1999| --------- | ------------------------------- | ---- | ---------------------------- |
2000| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
2001| state             | [State](#state11)        | 是   | 更改邀请的状态。 |
2002
2003**返回值:**
2004
2005| 类型                | 说明                      |
2006| ------------------- | ------------------------- |
2007| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; |  Promise对象,返回更改共享邀请状态的结果。 |
2008
2009**错误码:**
2010
2011以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
2012
2013| 错误码ID | 错误信息                                             |
2014| -------- | ---------------------------------------------------- |
2015| 202      | Permission verification failed, application which is not a system application uses system API.|
2016| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
2017| 801      | Capability not supported.|
2018
2019**示例:**
2020
2021```ts
2022import { BusinessError } from '@kit.BasicServicesKit';
2023
2024cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED).then((result) => {
2025  console.info(`change confirmation succeeded, result: ${result}`);
2026}).catch((err: BusinessError) => {
2027  console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
2028})
2029
2030```
2031
2032### changeConfirmation<sup>11+</sup>
2033
2034changeConfirmation(sharingResource: string, state: State, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void;
2035
2036根据共享资源标识更改共享邀请的状态,使用callback异步回调。
2037
2038**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
2039
2040**参数:**
2041
2042| 参数名    | 类型                            | 必填 | 说明                         |
2043| --------- | ------------------------------- | ---- | ---------------------------- |
2044| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
2045| state             | [State](#state11)        | 是   | 更改邀请的状态。 |
2046| callback          | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt; | 是   | 回调函数。返回更改邀请状态的结果。 |
2047
2048**错误码:**
2049
2050以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
2051
2052| 错误码ID | 错误信息                                             |
2053| -------- | ---------------------------------------------------- |
2054| 202      | Permission verification failed, application which is not a system application uses system API.|
2055| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
2056| 801      | Capability not supported.|
2057
2058**示例:**
2059
2060```ts
2061import { BusinessError } from '@kit.BasicServicesKit';
2062
2063cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED, ((err: BusinessError, result) => {
2064  if (err) {
2065    console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
2066    return;
2067  }
2068  console.info(`change confirmation succeeded, result: ${result}`);
2069}))
2070
2071```
2072<!--no_check-->
2073