Skip to main content

defendai-wozway



Summary

DefendAi Documentation: Wozway Python SDK

Table of Contents

SDK Installation

The SDK can be installed with either pip package manager.

PIP

pip install defendai-wozway

SDK Example Usage

Simple Getting Started Example

from defendai_wozway import Wozway
import os

with Wozway(
    bearer_auth=os.getenv("WOZWAY_BEARER_AUTH", ""),
) as s:
    res = s.activities.get_activities()
    if res is not None:
        print(rs)
      pass
from defendai_wozway import Wozway
import os

with Wozway(
    bearer_auth=os.getenv("WOZWAY_BEARER_AUTH", ""),
) as s:
    res = s.activities.get_activities(request={
        "search": "Prompt description",
        "filters": "{\"verdicts\":[\"BLOCK\"],\"appNames\":[\"openai-app\"],\"modelNames\":[\"openai\"]}",
    })

    if res is not None:
        # handle response
        pass

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme Environment Variable
bearer_auth https HTTP Bearer WOZWAY_BEARER_AUTH

To authenticate with the API the bearer_auth parameter must be set when initializing the SDK client instance. For example:

Available Resources and Operations

Available methods

activities

  • get_activities - Retrieve paginated activity data with filtering, sorting, and search options.

api_keys

applications

connections

incidents

policies

users

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.

By default, an API error will raise a models.APIError exception, which has the following properties:

Property Type Description
.status_code int The HTTP status code
.message str The error message
.raw_response httpx.Response The raw HTTP response
.body str The response content

When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the delete_api_key_async method may raise the following exceptions:

Error Type Status Code Content Type
models.DeleteAPIKeyAPIKeysResponseBody 400 application/json
models.DeleteAPIKeyAPIKeysResponseResponseBody 500 application/json
models.APIError 4XX, 5XX */*

Example

from defendai_wozway import Wozway, models
import os

with Wozway(
    bearer_auth=os.getenv("WOZWAY_BEARER_AUTH", ""),
) as s:
    res = None
    try:
        res = s.api_keys.delete_api_key(api_key="<value>")

        if res is not None:
            # handle response
            pass

    except models.DeleteAPIKeyAPIKeysResponseBody as e:
        # handle e.data: models.DeleteAPIKeyAPIKeysResponseBodyData
        raise(e)
    except models.DeleteAPIKeyAPIKeysResponseResponseBody as e:
        # handle e.data: models.DeleteAPIKeyAPIKeysResponseResponseBodyData
        raise(e)
    except models.APIError as e:
        # handle exception
        raise(e)

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the server_idx: int optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

# Server
1 https://api.defendai.tech

Example

from defendai_wozway import Wozway
import os

with Wozway(
    server_idx=1,
    bearer_auth=os.getenv("WOZWAY_BEARER_AUTH", ""),
) as s:
    res = s.activities.get_activities(request={
        "search": "Example text",
        "filters": "{\"verdicts\":[\"BLOCK\"],\"appNames\":[\"app1\",\"app2\"],\"modelNames\":[\"modelA\",\"modelB\"]}",
    })

    if res is not None:
        # handle response
        pass

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:

from defendai_wozway import Wozway
import os

with Wozway(
    server_url="http://playground.defendai.tech",
    bearer_auth=os.getenv("WOZWAY_BEARER_AUTH", ""),
) as s:
    res = s.activities.get_activities(request={
        "search": "Example text",
        "filters": "{\"verdicts\":[\"BLOCK\"],\"appNames\":[\"app1\",\"app2\"],\"modelNames\":[\"modelA\",\"modelB\"]}",
    })

    if res is not None:
        # handle response
        pass

Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass your own logger class directly into your SDK.

from defendai_wozway import Wozway
import logging

logging.basicConfig(level=logging.DEBUG)
s = Wozway(debug_logger=logging.getLogger("defendai_wozway"))

You can also enable a default debug logger by setting an environment variable WOZWAY_DEBUG to true.

Metadata

Release files for defendai-wozway 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for defendai-wozway 0.1.2
File Size Uploaded
defendai_wozway-0.1.2.tar.gz 37.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for defendai-wozway 0.1.2
File Interpreter ABI Platform
defendai_wozway-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 98.2 kB

Release files / defendai_wozway-0.1.2.tar.gz

Download URL defendai_wozway-0.1.2.tar.gz
Size 37.6 kB
Tags Source
SHA-256 checksum
How to use checksums
835f9049b86196afc0fe62cd6f1a78386308005c818334c7e9e85465d8f9853d
BLAKE2b-256 checksum
How to use checksums
9463e2591a563bdbf95f15dbb5abb91e4b86e5e28be1738c2986f082d6d23ddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / defendai_wozway-0.1.2-py3-none-any.whl

Download URL defendai_wozway-0.1.2-py3-none-any.whl
Size 60.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54651a858d5f5f41dccc9125b4cdf79162c3b04fdddbfad9bb8073153935df48
BLAKE2b-256 checksum
How to use checksums
ab20400f687f3c33a3adfe11c0df8a93004839806afe40bf164c329bf8455c9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page