161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (C) 2022-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit CoreFileKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Provides securityLabel APIs
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @namespace securityLabel
2761847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.FileIO
2861847f8eSopenharmony_ci * @since 9
2961847f8eSopenharmony_ci */
3061847f8eSopenharmony_cideclare namespace securityLabel {
3161847f8eSopenharmony_ci  /**
3261847f8eSopenharmony_ci   * The security level.
3361847f8eSopenharmony_ci   *
3461847f8eSopenharmony_ci   * @typedef { 's0' | 's1' | 's2' | 's3' | 's4' }
3561847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
3661847f8eSopenharmony_ci   * @since 9
3761847f8eSopenharmony_ci   */
3861847f8eSopenharmony_ci  type DataLevel = 's0' | 's1' | 's2' | 's3' | 's4';
3961847f8eSopenharmony_ci
4061847f8eSopenharmony_ci  /**
4161847f8eSopenharmony_ci   * Set the SecurityLabel.
4261847f8eSopenharmony_ci   *
4361847f8eSopenharmony_ci   * @param { string } path - path
4461847f8eSopenharmony_ci   * @param { DataLevel } type - type
4561847f8eSopenharmony_ci   * @returns { Promise<void> } return Promise
4661847f8eSopenharmony_ci   * @throws { BusinessError } 13900001 - Operation not permitted
4761847f8eSopenharmony_ci   * @throws { BusinessError } 13900007 - Arg list too long
4861847f8eSopenharmony_ci   * @throws { BusinessError } 13900015 - File exists
4961847f8eSopenharmony_ci   * @throws { BusinessError } 13900020 - Invalid argument
5061847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
5161847f8eSopenharmony_ci   * @throws { BusinessError } 13900037 - No data available
5261847f8eSopenharmony_ci   * @throws { BusinessError } 13900041 - Quota exceeded
5361847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
5461847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
5561847f8eSopenharmony_ci   * @since 9
5661847f8eSopenharmony_ci   */
5761847f8eSopenharmony_ci  function setSecurityLabel(path: string, type: DataLevel): Promise<void>;
5861847f8eSopenharmony_ci
5961847f8eSopenharmony_ci  /**
6061847f8eSopenharmony_ci   * Set the SecurityLabel.
6161847f8eSopenharmony_ci   *
6261847f8eSopenharmony_ci   * @param { string } path - path
6361847f8eSopenharmony_ci   * @param { DataLevel } type - type
6461847f8eSopenharmony_ci   * @param { AsyncCallback<void> } [callback] - callback
6561847f8eSopenharmony_ci   * @throws { BusinessError } 13900001 - Operation not permitted
6661847f8eSopenharmony_ci   * @throws { BusinessError } 13900007 - Arg list too long
6761847f8eSopenharmony_ci   * @throws { BusinessError } 13900015 - File exists
6861847f8eSopenharmony_ci   * @throws { BusinessError } 13900020 - Invalid argument
6961847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
7061847f8eSopenharmony_ci   * @throws { BusinessError } 13900037 - No data available
7161847f8eSopenharmony_ci   * @throws { BusinessError } 13900041 - Quota exceeded
7261847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
7361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
7461847f8eSopenharmony_ci   * @since 9
7561847f8eSopenharmony_ci   */
7661847f8eSopenharmony_ci  function setSecurityLabel(path: string, type: DataLevel, callback: AsyncCallback<void>): void;
7761847f8eSopenharmony_ci
7861847f8eSopenharmony_ci  /**
7961847f8eSopenharmony_ci   * Set the SecurityLabel with sync interface.
8061847f8eSopenharmony_ci   *
8161847f8eSopenharmony_ci   * @param { string } path - path
8261847f8eSopenharmony_ci   * @param { DataLevel } type - type
8361847f8eSopenharmony_ci   * @throws { BusinessError } 13900001 - Operation not permitted
8461847f8eSopenharmony_ci   * @throws { BusinessError } 13900007 - Arg list too long
8561847f8eSopenharmony_ci   * @throws { BusinessError } 13900015 - File exists
8661847f8eSopenharmony_ci   * @throws { BusinessError } 13900020 - Invalid argument
8761847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
8861847f8eSopenharmony_ci   * @throws { BusinessError } 13900037 - No data available
8961847f8eSopenharmony_ci   * @throws { BusinessError } 13900041 - Quota exceeded
9061847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
9161847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
9261847f8eSopenharmony_ci   * @since 9
9361847f8eSopenharmony_ci   */
9461847f8eSopenharmony_ci  function setSecurityLabelSync(path: string, type: DataLevel): void;
9561847f8eSopenharmony_ci
9661847f8eSopenharmony_ci  /**
9761847f8eSopenharmony_ci   * Get the SecurityLabel.
9861847f8eSopenharmony_ci   *
9961847f8eSopenharmony_ci   * @param { string } path - path
10061847f8eSopenharmony_ci   * @returns { Promise<string> } return Promise
10161847f8eSopenharmony_ci   * @throws { BusinessError } 13900001 - Operation not permitted
10261847f8eSopenharmony_ci   * @throws { BusinessError } 13900007 - Arg list too long
10361847f8eSopenharmony_ci   * @throws { BusinessError } 13900015 - File exists
10461847f8eSopenharmony_ci   * @throws { BusinessError } 13900020 - Invalid argument
10561847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
10661847f8eSopenharmony_ci   * @throws { BusinessError } 13900037 - No data available
10761847f8eSopenharmony_ci   * @throws { BusinessError } 13900041 - Quota exceeded
10861847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
10961847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
11061847f8eSopenharmony_ci   * @since 9
11161847f8eSopenharmony_ci   */
11261847f8eSopenharmony_ci  function getSecurityLabel(path: string): Promise<string>;
11361847f8eSopenharmony_ci
11461847f8eSopenharmony_ci  /**
11561847f8eSopenharmony_ci   * Get the SecurityLabel.
11661847f8eSopenharmony_ci   *
11761847f8eSopenharmony_ci   * @param { string } path - path
11861847f8eSopenharmony_ci   * @param { AsyncCallback<string> } [callback] - callback
11961847f8eSopenharmony_ci   * @throws { BusinessError } 13900001 - Operation not permitted
12061847f8eSopenharmony_ci   * @throws { BusinessError } 13900007 - Arg list too long
12161847f8eSopenharmony_ci   * @throws { BusinessError } 13900015 - File exists
12261847f8eSopenharmony_ci   * @throws { BusinessError } 13900020 - Invalid argument
12361847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
12461847f8eSopenharmony_ci   * @throws { BusinessError } 13900037 - No data available
12561847f8eSopenharmony_ci   * @throws { BusinessError } 13900041 - Quota exceeded
12661847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
12761847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
12861847f8eSopenharmony_ci   * @since 9
12961847f8eSopenharmony_ci   */
13061847f8eSopenharmony_ci  function getSecurityLabel(path: string, callback: AsyncCallback<string>): void;
13161847f8eSopenharmony_ci
13261847f8eSopenharmony_ci  /**
13361847f8eSopenharmony_ci   * Get the SecurityLabel with sync interface.
13461847f8eSopenharmony_ci   *
13561847f8eSopenharmony_ci   * @param { string } path - path
13661847f8eSopenharmony_ci   * @returns { string } security label name
13761847f8eSopenharmony_ci   * @throws { BusinessError } 13900001 - Operation not permitted
13861847f8eSopenharmony_ci   * @throws { BusinessError } 13900007 - Arg list too long
13961847f8eSopenharmony_ci   * @throws { BusinessError } 13900015 - File exists
14061847f8eSopenharmony_ci   * @throws { BusinessError } 13900020 - Invalid argument
14161847f8eSopenharmony_ci   * @throws { BusinessError } 13900025 - No space left on device
14261847f8eSopenharmony_ci   * @throws { BusinessError } 13900037 - No data available
14361847f8eSopenharmony_ci   * @throws { BusinessError } 13900041 - Quota exceeded
14461847f8eSopenharmony_ci   * @throws { BusinessError } 13900042 - Unknown error
14561847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.File.FileIO
14661847f8eSopenharmony_ci   * @since 9
14761847f8eSopenharmony_ci   */
14861847f8eSopenharmony_ci  function getSecurityLabelSync(path: string): string;
14961847f8eSopenharmony_ci}
15061847f8eSopenharmony_ci
15161847f8eSopenharmony_ciexport default securityLabel;
152