Excel.SensitivityLabelAbacAttributeValue interface

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

表示可应用于敏感度标签的基于属性的访问控制 (ABAC) 属性的单个可选值。

注解

API 集:ExcelApi BETA (仅预览版)

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/98-preview-apis/manage-sensitivity-labels.yaml

// Get available ABAC attributes and describe the kind of value each attribute accepts.
const container = document.getElementById("abac-attributes");
while (container.firstChild) {
    container.removeChild(container.firstChild);
}
await Excel.run(async (context) => {
    const labelCatalog: Excel.SensitivityLabelsCatalog = context.sensitivityLabelsCatalog;
    if (!labelCatalog) {
        console.warn("The sensitivity label catalog isn't available in this version of Excel.");
        return;
    }

    labelCatalog.load("getLabelingCapabilities");
    await context.sync();

    const capabilities: Excel.LabelingCapability[] = labelCatalog.getLabelingCapabilities;
    if (capabilities.indexOf(Excel.LabelingCapability.attributeBasedAccessControlEnabled) === -1) {
        console.warn("ABAC attributes aren't enabled or available for the current user.");
        return;
    }

    const catalogAttributes: OfficeExtension.ClientResult<Excel.SensitivityLabelAbacAttribute[]> =
        labelCatalog.getAttributes();
    await context.sync();

    if (catalogAttributes.value.length === 0) {
        console.log("No ABAC attributes are available in the sensitivity label catalog.");
        return;
    }

    console.log("Available ABAC attributes:");
    catalogAttributes.value.forEach((attribute: Excel.SensitivityLabelAbacAttribute) => {
        let dataTypeDescription: string;
        switch (attribute.dataType) {
            case Excel.SensitivityLabelAbacAttributeDataType.booleanValue:
                dataTypeDescription = "Boolean";
                break;
            case Excel.SensitivityLabelAbacAttributeDataType.dateValue:
                dataTypeDescription = "Date";
                break;
            case Excel.SensitivityLabelAbacAttributeDataType.numberValue:
                dataTypeDescription = "Number";
                break;
            case Excel.SensitivityLabelAbacAttributeDataType.stringValue:
                dataTypeDescription = "String";
                break;
            case Excel.SensitivityLabelAbacAttributeDataType.unknown:
                dataTypeDescription = "Unknown";
                break;
            default:
                dataTypeDescription = `Unrecognized (${attribute.dataType})`;
                break;
        }

        console.log(`ABAC attribute: ${attribute.displayName}`, {
            dataType: attribute.dataType,
            dataTypeDescription,
            displayOrder: attribute.displayOrder,
            isActive: attribute.isActive,
            isMultiValued: attribute.isMultiValued,
            values: attribute.values.map((attributeValue: Excel.SensitivityLabelAbacAttributeValue) => ({
                displayName: attributeValue.displayName,
                displayOrder: attributeValue.displayOrder,
                id: attributeValue.id,
                isActive: attributeValue.isActive
            }))
        });
    });

    addAttributeOptions(catalogAttributes.value);
});

属性

displayName

获取 ABAC 属性值的显示名称。 加载项负责呈现面向用户的本地化 UI。

displayOrder

向用户显示时,获取此 ABAC 值在其属性内的建议顺序。

id

获取 ABAC 属性值的唯一标识符。 应用或更新标签的 ABAC 属性选择时使用此标识符。

isActive

获取此 ABAC 属性值是否处于活动状态。 true 如果值处于活动状态;否则为 false.

属性详细信息

displayName

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

获取 ABAC 属性值的显示名称。 加载项负责呈现面向用户的本地化 UI。

displayName: string;

属性值

string

注解

API 集:ExcelApi BETA (仅预览版)

displayOrder

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

向用户显示时,获取此 ABAC 值在其属性内的建议顺序。

displayOrder: number;

属性值

number

注解

API 集:ExcelApi BETA (仅预览版)

id

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

获取 ABAC 属性值的唯一标识符。 应用或更新标签的 ABAC 属性选择时使用此标识符。

id: string;

属性值

string

注解

API 集:ExcelApi BETA (仅预览版)

isActive

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

获取此 ABAC 属性值是否处于活动状态。 true 如果值处于活动状态;否则为 false.

isActive: boolean;

属性值

boolean

注解

API 集:ExcelApi BETA (仅预览版)