Skip to content

AskRedaction

The redaction functionality in Werk24 allows users to request automated redaction of specific areas within a technical drawing. This includes the removal of logos, company data, personal data, and keywords.

Important

The Redaction returns both, the redacated drawing, as well as a list of regions that were redacted. This allow you to implement your own validation system.

Request

AskRedaction represents the request to redact specified content from a technical drawing. This includes options for redacting logos, company and personal data, specific keywords, and customizing the output format and appearance of the redacted areas.

Attributes

Bases: AskV2

A class that represents a request for redaction from the server.

PARAMETER DESCRIPTION
ask_version

TYPE: Literal[str] DEFAULT: 'v2'

ask_type

TYPE: Literal[AskType] DEFAULT: <AskType.REDACTION: 'REDACTION'>

redact_logos

Whether to redact logos from the drawing.

TYPE: bool DEFAULT: True

redact_company_data

Whether to redact company data.

TYPE: bool DEFAULT: True

redact_personal_data

Whether to redact personal data.

TYPE: bool DEFAULT: True

redact_keywords

A list of keywords to redact from the drawing. Keywords are specified as strings.

TYPE: list[RedactionKeyword] DEFAULT: []

output_format

The desired output format for the redacted drawing

TYPE: ThumbnailFileFormat DEFAULT: <ThumbnailFileFormat.PDF: 'PDF'>

fill_color

The fill color for the redacted areas. If None, only the polygon outlines for redacted areas are returned, and the user can perform the redaction themselves.

TYPE: str | None DEFAULT: '#ffffff'

Source code in werk24/models/v2/asks.py
class AskRedaction(AskV2):
    """
    A class that represents a request for redaction from the server.
    """

    ask_type: Literal[AskType.REDACTION] = AskType.REDACTION
    redact_logos: bool = Field(
        True, description="Whether to redact logos from the drawing."
    )
    redact_company_data: bool = Field(
        True, description="Whether to redact company data."
    )
    redact_personal_data: bool = Field(
        True, description="Whether to redact personal data."
    )
    redact_keywords: list[RedactionKeyword] = Field(
        [],
        description="A list of keywords to redact from the drawing. Keywords are specified as strings.",
    )
    output_format: ThumbnailFileFormat = Field(
        ThumbnailFileFormat.PDF,
        description="The desired output format for the redacted drawing",
    )
    fill_color: Optional[str] = Field(
        "#ffffff",
        description="The fill color for the redacted areas. If None, only the polygon outlines for redacted areas are returned, and the user can perform the redaction themselves.",
    )

Example Usage

from werk24 import AskRedaction, RedactionKeyword, read_example_drawing

# Create an AskRedaction object with custom settings
ask = AskRedaction(
    redact_logos=True,
    redact_company_data=True,
    redact_personal_data=False,
    redact_keywords=[RedactionKeyword(keyword="confidential"), RedactionKeyword(keyword="draft")],
    output_format="PDF",
    fill_color="#ffffff"
)

# Send the redaction request
response = read_example_drawing([ask])

# Print the redaction.
print(response["ASK_REDACTION"][0].payload_dict)

Binary Response

You can obtain the binary reponse by accessing the attribute payload_bytes.

Note

If you implement your own client, you need to perform the downloading and decryption of the payload yourself. You can obtain the download your by accessing the attribute payload_url.

Dictionary Response

ResponseRedaction represents the server's response to a redaction request. It contains the list of redaction zones which define the areas in the drawing that have been redacted.

Attributes

  • redaction_zones (List[RedactionZone]): A list of redacted areas in the drawing. Each redacted area is represented by a RedactionZone object containing information about the coordinates and shape of the redacted area.

Example Response

{
    "ask_type": "REDACTION",
    "redaction_zones": [
        {
            "polygon": [[100, 120], [150, 120], [150, 180], [100, 180]],
            "redaction_zone_type": "LOGO"
        },
        {
            "polygon": [[200, 240], [250, 240], [250, 300], [200, 300]],
            "redaction_zone_type": "PERSONAL_DATA"
        }
    ]
}