• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import {AsyncCallback} from './basic'
17
18/**
19 * This module provides the capability to manage distributed accounts.
20 * @syscap SystemCapability.Account.OsAccount
21 * @since 7
22 */
23declare namespace distributedAccount {
24    /**
25     * Get the ability of the distributed account.
26     * @permission N/A
27     * @syscap SystemCapability.Account.OsAccount
28     * @returns Ability to manage operations of distributed account.
29     * @since 7
30     */
31    function getDistributedAccountAbility(): DistributedAccountAbility;
32
33    /**
34     * Defines distributed account functions and interfaces.
35     * @name DistributedAccountAbility
36     * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
37     * @syscap SystemCapability.Account.OsAccount
38     * @since 7
39     */
40    interface DistributedAccountAbility {
41        /**
42         * Queries the distributed information of the current OS account.
43         * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC
44         * @returns The distributed information of the current OS account.
45         * @since 7
46         * @deprecated since 9
47         * @useinstead distributedAccount.DistributedAccountAbility#getOsAccountDistributedInfo
48         */
49        queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): void;
50        queryOsAccountDistributedInfo(): Promise<DistributedInfo>;
51
52        /**
53         * Gets the distributed information of the current OS account.
54         * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS or ohos.permission.GET_DISTRIBUTED_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC
55         * @returns The distributed information of the current OS account.
56         * @throws {BusinessError} 201 - permission denied.
57         * @throws {BusinessError} 401 - the parameter check failed.
58         * @throws {BusinessError} 12300001 - system service exception.
59         * @since 9
60         */
61        getOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): void;
62        getOsAccountDistributedInfo(): Promise<DistributedInfo>;
63
64        /**
65         * Updates the distributed information of the OS account.
66         * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
67         * @param accountInfo Indicates the information of the OS account used for a distributed system.
68         * @returns void
69         * @since 7
70         * @deprecated since 9
71         * @useinstead distributedAccount.DistributedAccountAbility#setOsAccountDistributedInfo
72         */
73        updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback<void>): void;
74        updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void>;
75
76        /**
77         * Sets the distributed information of the OS account.
78         * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS
79         * @param accountInfo Indicates the information of the OS account used for a distributed system.
80         * @returns void
81         * @throws {BusinessError} 201 - permission denied.
82         * @throws {BusinessError} 401 - the parameter check failed.
83         * @throws {BusinessError} 12300001 - system service exception.
84         * @throws {BusinessError} 12300002 - invalid accountInfo.
85         * @throws {BusinessError} 12300003 - the account indicated by accountInfo dose not exist.
86         * @since 9
87         */
88        setOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback<void>): void;
89        setOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void>;
90    }
91
92    /**
93     * Provides the distributed information of the OS account.
94     *
95     * @name DistributedInfo
96     * @permission N/A
97     * @syscap SystemCapability.Account.OsAccount
98     * @since 7
99     */
100    interface DistributedInfo {
101        /**
102         * The name in the distributed information of the OS account.
103         *
104         * @since 7
105         */
106        name: string;
107
108        /**
109         * The ID in the distributed information of the OS account.
110         *
111         * @since 7
112         */
113        id: string;
114
115        /**
116         * The event string in the distributed information of the OS account.
117         *
118         * @since 7
119         */
120        event: string;
121
122        /**
123         * The nickname in the distributed information of the OS account.
124         *
125         * @since 9
126         */
127        nickname?: string;
128
129        /**
130         * The avatar in the distributed information of the OS account.
131         *
132         * @since 9
133         */
134        avatar?: string;
135
136        /**
137         * The scalable data in the distributed information of the OS account.
138         */
139        scalableData?: object;
140    }
141}
142
143export default distributedAccount;