Word.SensitivityLabelAbacAttribute interface

注意

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

表示敏感度标签 (ABAC) 属性的基于属性的访问控制。

注解

API 集:WordApi BETA (仅预览版)

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-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 Word.run(async (context) => {
  const labelCatalog: Word.SensitivityLabelsCatalog = context.sensitivityLabelsCatalog;
  if (!labelCatalog) {
    console.warn("The sensitivity label catalog isn't available.");
    return;
  }

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

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

  const catalogAttributes: OfficeExtension.ClientResult<Word.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: Word.SensitivityLabelAbacAttribute) => {
    let dataTypeDescription: string;
    switch (attribute.dataType) {
      case Word.SensitivityLabelAbacAttributeDataType.booleanValue:
        dataTypeDescription = "Boolean";
        break;
      case Word.SensitivityLabelAbacAttributeDataType.dateValue:
        dataTypeDescription = "Date";
        break;
      case Word.SensitivityLabelAbacAttributeDataType.numberValue:
        dataTypeDescription = "Number";
        break;
      case Word.SensitivityLabelAbacAttributeDataType.stringValue:
        dataTypeDescription = "String";
        break;
      case Word.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: Word.SensitivityLabelAbacAttributeValue) => ({
        displayName: attributeValue.displayName,
        displayOrder: attributeValue.displayOrder,
        id: attributeValue.id,
        isActive: attributeValue.isActive
      }))
    });
  });

  addAttributeOptions(catalogAttributes.value);
});

属性

dataType

此 ABAC 属性的值的数据类型。

displayName

ABAC 属性的显示名称。

displayOrder

ABAC 属性的显示顺序。

isActive

指示 ABAC 属性是否处于活动状态。

isMultiValued

指示 ABAC 属性是否可以有多个值。

values

可用于 ABAC 属性的值。

属性详细信息

dataType

注意

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

此 ABAC 属性的值的数据类型。

dataType: Word.SensitivityLabelAbacAttributeDataType | "Unknown" | "StringValue" | "BooleanValue" | "NumberValue" | "DateValue";

属性值

Word.SensitivityLabelAbacAttributeDataType | "Unknown" | "StringValue" | "BooleanValue" | "NumberValue" | "DateValue"

注解

API 集:WordApi BETA (仅预览版)

displayName

注意

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

ABAC 属性的显示名称。

displayName: string;

属性值

string

注解

API 集:WordApi BETA (仅预览版)

displayOrder

注意

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

ABAC 属性的显示顺序。

displayOrder: number;

属性值

number

注解

API 集:WordApi BETA (仅预览版)

isActive

注意

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

指示 ABAC 属性是否处于活动状态。

isActive: boolean;

属性值

boolean

注解

API 集:WordApi BETA (仅预览版)

isMultiValued

注意

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

指示 ABAC 属性是否可以有多个值。

isMultiValued: boolean;

属性值

boolean

注解

API 集:WordApi BETA (仅预览版)

values

注意

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

可用于 ABAC 属性的值。

values: Word.SensitivityLabelAbacAttributeValue[];

属性值

注解

API 集:WordApi BETA (仅预览版)