semvec/pypi-packages huggingface dataset:
permission-manager-drf 1.0.1
A simple way to manage object permissions in drf.
Requires Python: >=3.10
Keywords: drf, permissions, rest framework

# Permission Manager for django rest framework

![PyPI - Version](https://img.shields.io/pypi/v/permission-manager-drf?logo=python)
![example workflow](https://github.com/kindlycat/permission-manager-drf/actions/workflows/tests.yml/badge.svg)
[![codecov](https://codecov.io/gh/kindlycat/permission-manager-drf/graph/badge.svg?token=5XAFJZS6A8)](https://codecov.io/gh/kindlycat/permission-manager-drf)

Use [permission_manager](https://github.com/kindlycat/permission-manager) for 
django rest framework.

Full documentation on [read the docs](https://permission-manager-drf.readthedocs.io/).

## Install

```bash
pip install permission-manager-drf
```

## Example
```python
from django.db import models
from rest_framework.permissions import IsAuthenticated
from rest_framework.viewsets import ModelViewSet
from rest_framework.decorators import action

from permission_manager_drf import DRFPermissionManager, ManagerPermission
from permission_manager import PermissionResult


# Define permission manager
class SomeModelPermissionManager(DRFPermissionManager):
    def has_create_permission(self) -> bool:
        return self.user.is_staff

    def has_update_permission(self) -> bool:
        return self.user.is_staff

    def has_delete_permission(self) -> bool:
        return self.user.is_staff

    def has_view_permission(self) -> bool:
        return True

    def has_list_permission(self) -> bool:
        return True

    def has_custom_permission(self) -> bool:
        return PermissionResult(
            message="You can't do it",
            value=self.user.is_staff,
        )


# Define model with permission manager attribute
class SomeModel(models.Model):
    permission_manager = SomeModelPermissionManager
    ...


# ViewSet
class TestModelViewSet(ModelViewSet):
    permission_classes = [IsAuthenticated, ManagerPermission]
    ...

    @action(detail=True)
    def custom(self, request, **kwargs):
        ...
```
That's all. Now every drf action will be checked by the permission manager.

Also, you can use the serializer field for retrieve permissions you need.

```python
from permission_manager_drf import PermissionField
from rest_framework.serializers import ModelSerializer

class SomeModelSerializer(ModelSerializer):
    permissions = PermissionField(actions=('view', 'custom'),)
    ...

"""
Example output:
{
    ...,
    'permissions': {
        'view': {
            'allow': True,
            'messages': None,
        },
        'custom': {
            'allow': False,
            'messages': ["You can't do it"],
        },
    }
}
"""
```
stackit-observability 0.12.0
STACKIT Observability API
Requires Python: <4.0,>=3.9

# stackit.observability
API endpoints for Observability on STACKIT


This package is part of the STACKIT Python SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-python) of the SDK.


## Installation & Usage
### pip install

```sh
pip install stackit-observability
```

Then import the package:
```python
import stackit.observability
```

## Getting Started

[Examples](https://github.com/stackitcloud/stackit-sdk-python/tree/main/examples) for the usage of the package can be found in the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-python) of the SDK.
tessie_relay 0.3.0
Relay and control for tessie
Requires Python: >=3.9

# tessie relay

A relay and control server for [tessie](https://github.com/ursl/tessie/)
MQTT messages.

## Installation

This project uses [uv](https://docs.astral.sh/uv/) for management and
currently uses Python 3.11.

```shell
pip install tessie_relay
```

## Running coldbox controller

Example script:

```python
from tessie_relay.psi_coldbox import Coldbox
from time import sleep

def handle_error_message(error_payload):
    """
    Custom callback to handle "Error" messages.
    :param error_payload: The parsed "Error" payload
    """
    print("WARNING: Error detected!")
    print(error_payload)


if __name__ == "__main__":

    # initialize the Coldbox controller and provide a callback for alarms
    coldbox = Coldbox(tessie_host=None, error_callback=handle_error_message)

    with coldbox:
        coldbox.flush()
        sleep(5)
        coldbox.throttle_on()
        print("Throttling should be on now")
        sleep(5)
        coldbox.flush()
        print("air temperature    ", coldbox.get_air_temperature())
        print("water temperature  ", coldbox.get_water_temperature())
        print("interlock status   ", coldbox.get_interlock_status(timeout=10))
        print("traffic light      ", coldbox.get_traffic_light())
        print("flow switch        ", coldbox.get_flow_switch())
        print("lid                ", coldbox.get_lid_status())
        print("heater             ", coldbox.get_heater())
        channel = 8
        print(f"voltage probes for channel {channel} = ", coldbox.get_voltage_probe(channel)) 

        try:
            while True:
                print("relative humidity ", coldbox.get_relative_humidity())
                sleep(10)
        except KeyboardInterrupt:
            print('interrupted!')

    print("shutting down")
```

## Running coldbox QuestDB relay

The relay requires a QuestDB instance running.
Furthermore, an environment variable `QDB_CLIENT_CONF` must be set.
In the example below, the QuestDB instance is running on the same machine
as the relay and the client is authenticated with the default credentials.

```shell
export QDB_CLIENT_CONF='http::addr=localhost:9000;username=admin;password=quest;'
uv run -m tessie_relay.relay
```

## Development

**Important**: for local development, please make sure to always prepend `uv`.

After changes have been made to the library (which means code in the `src` directory),
update the local `tessie_relay` installation as follows:

```shell
uv pip install -e .
```

Then to test your changes, take e.g. the code in `examples/run_coldbox.py` and make
the changes that would test the code. Then run:

```shell
uv run examples/run_coldbox.py
```

## Creating a new release

Install `bump-my-version`:

```shell
uv tool install bump-my-version
```

Choose between  `major`, `minor`, and `patch` and run (here for `patch`):

```shell
bump-my-version bump patch --dry-run -vv
```

This displays the changes that would be made.
If you are happy with the changes, run:

```shell
bump-my-version bump patch
```