PowerPoint.SensitivityLabelTryUpdateOptions interface

Nota

Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.

Proporciona opciones para SensitivityLabel.tryToUpdate.

Comentarios

Conjunto de API: PowerPointApi BETA (SOLO VERSIÓN PRELIMINAR)

Usada por

Ejemplos

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

// Apply the selected sensitivity label with the chosen ABAC attribute values.
await PowerPoint.run(async (context) => {
  const labelId = (document.getElementById("label-id") as HTMLSelectElement).value;
  if (!labelId) {
    console.warn("Get available labels and select a label first.");
    return;
  }

  const attributeControls = document.getElementById("abac-attributes")
    .querySelectorAll<HTMLSelectElement>("select");
  if (attributeControls.length === 0) {
    console.warn("Get catalog attributes and select attribute values first.");
    return;
  }

  const labelCatalog: PowerPoint.SensitivityLabelsCatalog = context.sensitivityLabelsCatalog;
  if (!labelCatalog) {
    console.warn("The sensitivity label catalog isn't available.");
    return;
  }

  labelCatalog.load("getLabelingCapabilities");
  await context.sync();
  if (labelCatalog.getLabelingCapabilities.indexOf(PowerPoint.LabelingCapability.attributeBasedAccessControlEnabled) === -1) {
    console.warn("ABAC attributes aren't enabled or available for the current user.");
    return;
  }

  // Refresh the catalog to validate selections against the current policy.
  const catalogAttributes: OfficeExtension.ClientResult<PowerPoint.SensitivityLabelAbacAttribute[]> =
    labelCatalog.getAttributes();
  await context.sync();

  const selectedAttributes: PowerPoint.SensitivityLabelAbacAttribute[] = [];
  for (const select of Array.from(attributeControls)) {
    const selectedIds = Array.from(select.selectedOptions)
      .map((option) => option.value).filter((id) => id !== "");
    if (selectedIds.length === 0) {
      continue;
    }

    const attribute: PowerPoint.SensitivityLabelAbacAttribute | undefined =
      catalogAttributes.value.find((attribute) => attribute.displayName === select.name);
    if (!attribute || !attribute.isActive || (!attribute.isMultiValued && selectedIds.length > 1)) {
      console.warn("The attribute selections are no longer valid. Get catalog attributes and select values again.");
      return;
    }

    const selectedValues: PowerPoint.SensitivityLabelAbacAttributeValue[] =
      attribute.values.filter((value) => value.isActive && selectedIds.indexOf(value.id) !== -1);
    if (selectedValues.length !== selectedIds.length) {
      console.warn("The attribute selections are no longer valid. Get catalog attributes and select values again.");
      return;
    }

    const selectedAttribute: PowerPoint.SensitivityLabelAbacAttribute = {
      ...attribute,
      values: selectedValues
    };
    selectedAttributes.push(selectedAttribute);
  }

  if (selectedAttributes.length === 0) {
    console.warn("Select at least one ABAC attribute value first.");
    return;
  }

  const options: PowerPoint.SensitivityLabelTryUpdateOptions = {
    abacAttributes: selectedAttributes
  };
  const presentation: PowerPoint.Presentation = context.presentation;
  const presentationLabel: PowerPoint.SensitivityLabel = presentation.sensitivityLabel;
  const updateResult: OfficeExtension.ClientResult<PowerPoint.SensitivityLabelUpdateResult> =
    presentationLabel.tryToUpdate(labelId, options);
  await context.sync();

  if (updateResult.value.status === PowerPoint.SensitivityLabelUpdateStatus.success) {
    console.log("Applied the sensitivity label and ABAC attributes to the presentation.");
  } else {
    console.error(`The sensitivity label wasn't applied. Status: ${updateResult.value.status}`);
  }
});

Propiedades

abacAttributes

Si se proporciona, especifica los atributos de control de acceso basado en atributos (ABAC) que se aplicarán con la etiqueta. Debe omitirse o estar vacía para las etiquetas que no están habilitadas para ABAC; de lo contrario, el resultado de la actualización tiene un status de SensitivityLabelUpdateStatus.abacAttributesNotAllowed. Necesario cuando la etiqueta de destino está habilitada para ABAC y SensitivityLabelDetails.isAbacAttributesRequired es true.

Detalles de las propiedades

abacAttributes

Nota

Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.

Si se proporciona, especifica los atributos de control de acceso basado en atributos (ABAC) que se aplicarán con la etiqueta. Debe omitirse o estar vacía para las etiquetas que no están habilitadas para ABAC; de lo contrario, el resultado de la actualización tiene un status de SensitivityLabelUpdateStatus.abacAttributesNotAllowed. Necesario cuando la etiqueta de destino está habilitada para ABAC y SensitivityLabelDetails.isAbacAttributesRequired es true.

abacAttributes?: PowerPoint.SensitivityLabelAbacAttribute[];

Valor de propiedad

Comentarios

Conjunto de API: PowerPointApi BETA (SOLO VERSIÓN PRELIMINAR)