MIP SDK - Removing UDP Label

153 Views Asked by At

I am trying to remove a UDP label set on a file in my tenant by using the following code. Could someone point me to a resource that talks about steps that I'll need to perform to remove this type of label? I have come across code to apply this type of label but nothing that talks about how to remove this using the MIP SDK. I am using a service account that has the "Superuser (Add-AipServiceSuperUser)" permissions

LabelingOptions lowerLabelingOptions = new LabelingOptions()
{
    AssignmentMethod = AssignmentMethod.Privileged, //because we are removing a high priority label
    IsDowngradeJustified = true,
    JustificationMessage = "Lowering label via Azure function"
};

if(deleteHandler.Protection != null)
{
    deleteHandler.RemoveProtection();
}
deleteHandler.DeleteLabel(lowerLabelingOptions);
var deleteResult = Task.Run(async () => await deleteHandler.CommitAsync(outputStream)).Result;

The deleteResult variable is returning true (no errors) but the label remains on the file.

1

There are 1 best solutions below

1
On

Once you have the handler, you can check if the file needs protection to be removed, remove it, and then delete the label from the file.

if (handler.Protection != null)
    handler.RemoveProtection();
handler.DeleteLabel(removeLabelingOptions);

Now you can commit changes to some output file. Note that in your example you are committing to a stream that needs to be saved somewhere.