init
This commit is contained in:
parent
ac5356bf9c
commit
3dd06a98d1
78 changed files with 12121 additions and 37 deletions
|
|
@ -0,0 +1,4 @@
|
|||
openapi-python-client
|
||||
https://push.gooyal.com/swagger?base=push.gooyal.com
|
||||
|
||||
npm install -g swagger2openapi
|
||||
|
|
@ -1,9 +1,2 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Config
|
||||
|
||||
|
||||
class ConfigAdmin(admin.ModelAdmin):
|
||||
list_display = ['key', 'value', 'value_type', 'get_value']
|
||||
|
||||
admin.site.register(Config, ConfigAdmin)
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
# Generated by Django 5.1.7 on 2025-05-06 07:03
|
||||
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Config',
|
||||
fields=[
|
||||
('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
|
||||
('key', models.CharField(db_index=True, max_length=255, unique=True, verbose_name='key')),
|
||||
('value', models.TextField(blank=True, null=True, verbose_name='value')),
|
||||
('value_type', models.CharField(choices=[('INT', 'Integer'), ('FLOAT', 'Float'), ('BOOLEAN', 'Boolean'), ('STRING', 'String'), ('DATE', 'Date'), ('DATETIME', 'DateTime'), ('JSON', 'JSON')], max_length=64)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
||||
0
apps/notifications/__init__.py
Normal file
0
apps/notifications/__init__.py
Normal file
6
apps/notifications/admin.py
Normal file
6
apps/notifications/admin.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.contrib import admin
|
||||
from .models import PushUser, Device
|
||||
|
||||
|
||||
admin.site.register(PushUser)
|
||||
admin.site.register(Device)
|
||||
6
apps/notifications/apps.py
Normal file
6
apps/notifications/apps.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class NotificationsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'notifications'
|
||||
0
apps/notifications/migrations/__init__.py
Normal file
0
apps/notifications/migrations/__init__.py
Normal file
19
apps/notifications/models.py
Normal file
19
apps/notifications/models.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from django.db import models
|
||||
|
||||
from apps.users.models import User
|
||||
from utils.models import BaseModel
|
||||
|
||||
|
||||
class PushUser(BaseModel):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
client_token = models.CharField(max_length=32, null=True, blank=True)
|
||||
application_token = models.CharField(max_length=32, null=True, blank=True)
|
||||
|
||||
def get_token(self):
|
||||
return
|
||||
|
||||
def send_push(self):
|
||||
return
|
||||
|
||||
class Device(BaseModel):
|
||||
pass
|
||||
202
apps/notifications/serializers.py
Normal file
202
apps/notifications/serializers.py
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from .models import PushDevice
|
||||
|
||||
from ..core.models import Config
|
||||
|
||||
|
||||
class CategorySerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Category
|
||||
fields = (
|
||||
'uuid',
|
||||
'color',
|
||||
'title',
|
||||
'icon',
|
||||
)
|
||||
|
||||
|
||||
class VisitSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Visit
|
||||
fields = (
|
||||
'uuid',
|
||||
'ad',
|
||||
'state',
|
||||
'reward_amount',
|
||||
'location',
|
||||
'opportunity_until',
|
||||
'display_time',
|
||||
)
|
||||
read_only_fields = ('uuid', 'state', 'reward_amount', 'opportunity_until', 'display_time')
|
||||
|
||||
|
||||
class AdSerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||
tags = TagListSerializerField(read_only=True)
|
||||
category_detail = CategorySerializer(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Ad
|
||||
fields = (
|
||||
'uuid',
|
||||
'title',
|
||||
'content',
|
||||
'content_type',
|
||||
'description',
|
||||
'location',
|
||||
'category',
|
||||
'category_detail',
|
||||
'banner',
|
||||
'reward_amount',
|
||||
'reward_count',
|
||||
'address',
|
||||
'url',
|
||||
'tags',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'display_time',
|
||||
'status',
|
||||
)
|
||||
read_only_fields = fields
|
||||
|
||||
|
||||
class AdWithVisitSerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||
visit = VisitSerializer(read_only=True)
|
||||
|
||||
tags = TagListSerializerField(read_only=True)
|
||||
category_detail = CategorySerializer(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Ad
|
||||
fields = (
|
||||
'uuid',
|
||||
'title',
|
||||
'content',
|
||||
'content_type',
|
||||
'description',
|
||||
'location',
|
||||
'category',
|
||||
'category_detail',
|
||||
'banner',
|
||||
'reward_amount',
|
||||
'reward_count',
|
||||
'address',
|
||||
'url',
|
||||
'tags',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'display_time',
|
||||
'visit'
|
||||
)
|
||||
read_only_fields = fields
|
||||
|
||||
class AdUserSerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||
tags = TagListSerializerField(allow_null=True, allow_empty=True, required=False, read_only=True)
|
||||
category_detail = CategorySerializer(read_only=True)
|
||||
|
||||
# new_tags = TagListSerializerField(allow_null=True, allow_empty=True)
|
||||
new_category_detail = CategorySerializer(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Ad
|
||||
fields = (
|
||||
'uuid',
|
||||
'title',
|
||||
'content',
|
||||
'content_type',
|
||||
'description',
|
||||
'location',
|
||||
'category',
|
||||
'category_detail',
|
||||
'banner',
|
||||
'reward_amount',
|
||||
'reward_count',
|
||||
'address',
|
||||
'url',
|
||||
'tags',
|
||||
|
||||
'new_title',
|
||||
'new_location',
|
||||
'new_category',
|
||||
'new_category_detail',
|
||||
'new_description',
|
||||
'new_banner',
|
||||
'new_content',
|
||||
'new_content_type',
|
||||
'new_url',
|
||||
'new_tags',
|
||||
'new_address',
|
||||
|
||||
'payment_state',
|
||||
'state',
|
||||
'rejection_reason',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'display_time',
|
||||
'status',
|
||||
)
|
||||
read_only_fields = ['uuid',
|
||||
'title',
|
||||
'content',
|
||||
'content_type',
|
||||
'description',
|
||||
'location',
|
||||
'category',
|
||||
'category_detail',
|
||||
'banner',
|
||||
'address',
|
||||
'url',
|
||||
'tags',
|
||||
|
||||
'new_category_detail',
|
||||
|
||||
'payment_state',
|
||||
'state',
|
||||
'rejection_reason',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'display_time',
|
||||
'status'
|
||||
]
|
||||
|
||||
|
||||
class TagSerializer(TaggitSerializer, serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Tag
|
||||
fields = ('name', 'slug')
|
||||
|
||||
|
||||
class ConfigSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Config
|
||||
fields = ['key', 'value', 'value_type']
|
||||
|
||||
|
||||
|
||||
# دریافتی
|
||||
# کل بیلبورد
|
||||
# کل بازدید
|
||||
# درآمد سالیانه
|
||||
|
||||
|
||||
class AdVisitStatisticSerializer(serializers.Serializer):
|
||||
label = serializers.CharField()
|
||||
with_reward_count = serializers.IntegerField()
|
||||
without_reward_count = serializers.IntegerField()
|
||||
reward_amount = serializers.IntegerField()
|
||||
|
||||
|
||||
class StatisticSerializer(serializers.Serializer):
|
||||
total_reward_input = serializers.IntegerField()
|
||||
total_visit_count = serializers.IntegerField()
|
||||
total_ads_count = serializers.IntegerField()
|
||||
|
||||
monthly_data = AdVisitStatisticSerializer(many=True)
|
||||
daily_data = AdVisitStatisticSerializer(many=True)
|
||||
|
||||
|
||||
class ClusterSerializer(serializers.Serializer):
|
||||
cluster = serializers.IntegerField()
|
||||
ads_rewards_amount = serializers.IntegerField()
|
||||
ads_count = serializers.IntegerField()
|
||||
location = GeometryField()
|
||||
3
apps/notifications/tests.py
Normal file
3
apps/notifications/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
apps/notifications/views.py
Normal file
3
apps/notifications/views.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
8
gotify_rest_api_client/__init__.py
Normal file
8
gotify_rest_api_client/__init__.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
"""A client library for accessing Gotify REST-API."""
|
||||
|
||||
from .client import AuthenticatedClient, Client
|
||||
|
||||
__all__ = (
|
||||
"AuthenticatedClient",
|
||||
"Client",
|
||||
)
|
||||
1
gotify_rest_api_client/api/__init__.py
Normal file
1
gotify_rest_api_client/api/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains methods for accessing the API"""
|
||||
1
gotify_rest_api_client/api/application/__init__.py
Normal file
1
gotify_rest_api_client/api/application/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
172
gotify_rest_api_client/api/application/create_app.py
Normal file
172
gotify_rest_api_client/api/application/create_app.py
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.application_model import ApplicationModel
|
||||
from ...models.application_params_model import ApplicationParamsModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: ApplicationParamsModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/application",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApplicationModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Create an application.
|
||||
|
||||
Args:
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ApplicationModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Create an application.
|
||||
|
||||
Args:
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ApplicationModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Create an application.
|
||||
|
||||
Args:
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ApplicationModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Create an application.
|
||||
|
||||
Args:
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ApplicationModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
165
gotify_rest_api_client/api/application/delete_app.py
Normal file
165
gotify_rest_api_client/api/application/delete_app.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/application/{id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
140
gotify_rest_api_client/api/application/get_apps.py
Normal file
140
gotify_rest_api_client/api/application/get_apps.py
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.application_model import ApplicationModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/application",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, list["ApplicationModel"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = ApplicationModel.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, list["ApplicationModel"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["ApplicationModel"]]]:
|
||||
"""Return all applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['ApplicationModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["ApplicationModel"]]]:
|
||||
"""Return all applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['ApplicationModel']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["ApplicationModel"]]]:
|
||||
"""Return all applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['ApplicationModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["ApplicationModel"]]]:
|
||||
"""Return all applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['ApplicationModel']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
169
gotify_rest_api_client/api/application/remove_app_image.py
Normal file
169
gotify_rest_api_client/api/application/remove_app_image.py
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/application/{id}/image",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Deletes an image of an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Deletes an image of an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Deletes an image of an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Deletes an image of an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
189
gotify_rest_api_client/api/application/update_application.py
Normal file
189
gotify_rest_api_client/api/application/update_application.py
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.application_model import ApplicationModel
|
||||
from ...models.application_params_model import ApplicationParamsModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
*,
|
||||
body: ApplicationParamsModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/application/{id}",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApplicationModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Update an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ApplicationModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Update an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ApplicationModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Update an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ApplicationModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ApplicationParamsModel,
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Update an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ApplicationParamsModel): Params allowed to create or update Applications.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ApplicationModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
191
gotify_rest_api_client/api/application/upload_app_image.py
Normal file
191
gotify_rest_api_client/api/application/upload_app_image.py
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.application_model import ApplicationModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.upload_app_image_body import UploadAppImageBody
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
*,
|
||||
body: UploadAppImageBody,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/application/{id}/image",
|
||||
}
|
||||
|
||||
_kwargs["files"] = body.to_multipart()
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApplicationModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UploadAppImageBody,
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Upload an image for an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UploadAppImageBody):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ApplicationModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UploadAppImageBody,
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Upload an image for an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UploadAppImageBody):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ApplicationModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UploadAppImageBody,
|
||||
) -> Response[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Upload an image for an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UploadAppImageBody):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ApplicationModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UploadAppImageBody,
|
||||
) -> Optional[Union[ApplicationModel, ErrorModel]]:
|
||||
"""Upload an image for an application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UploadAppImageBody):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ApplicationModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
1
gotify_rest_api_client/api/client/__init__.py
Normal file
1
gotify_rest_api_client/api/client/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
172
gotify_rest_api_client/api/client/create_client.py
Normal file
172
gotify_rest_api_client/api/client/create_client.py
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.client_model import ClientModel
|
||||
from ...models.client_params_model import ClientParamsModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: ClientParamsModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/client",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ClientModel, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ClientModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ClientModel, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Response[Union[ClientModel, ErrorModel]]:
|
||||
"""Create a client.
|
||||
|
||||
Args:
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ClientModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Optional[Union[ClientModel, ErrorModel]]:
|
||||
"""Create a client.
|
||||
|
||||
Args:
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ClientModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Response[Union[ClientModel, ErrorModel]]:
|
||||
"""Create a client.
|
||||
|
||||
Args:
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ClientModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Optional[Union[ClientModel, ErrorModel]]:
|
||||
"""Create a client.
|
||||
|
||||
Args:
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ClientModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
165
gotify_rest_api_client/api/client/delete_client.py
Normal file
165
gotify_rest_api_client/api/client/delete_client.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/client/{id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
140
gotify_rest_api_client/api/client/get_clients.py
Normal file
140
gotify_rest_api_client/api/client/get_clients.py
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.client_model import ClientModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/client",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, list["ClientModel"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = ClientModel.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, list["ClientModel"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["ClientModel"]]]:
|
||||
"""Return all clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['ClientModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["ClientModel"]]]:
|
||||
"""Return all clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['ClientModel']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["ClientModel"]]]:
|
||||
"""Return all clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['ClientModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["ClientModel"]]]:
|
||||
"""Return all clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['ClientModel']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
189
gotify_rest_api_client/api/client/update_client.py
Normal file
189
gotify_rest_api_client/api/client/update_client.py
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.client_model import ClientModel
|
||||
from ...models.client_params_model import ClientParamsModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
*,
|
||||
body: ClientParamsModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/client/{id}",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ClientModel, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ClientModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ClientModel, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Response[Union[ClientModel, ErrorModel]]:
|
||||
"""Update a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ClientModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Optional[Union[ClientModel, ErrorModel]]:
|
||||
"""Update a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ClientModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Response[Union[ClientModel, ErrorModel]]:
|
||||
"""Update a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ClientModel, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: ClientParamsModel,
|
||||
) -> Optional[Union[ClientModel, ErrorModel]]:
|
||||
"""Update a client.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (ClientParamsModel): Params allowed to create or update Clients.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ClientModel, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
1
gotify_rest_api_client/api/health/__init__.py
Normal file
1
gotify_rest_api_client/api/health/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
126
gotify_rest_api_client/api/health/get_health.py
Normal file
126
gotify_rest_api_client/api/health/get_health.py
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.health_model import HealthModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/health",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[HealthModel]:
|
||||
if response.status_code == 200:
|
||||
response_200 = HealthModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 500:
|
||||
response_500 = HealthModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[HealthModel]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[HealthModel]:
|
||||
"""Get health information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[HealthModel]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[HealthModel]:
|
||||
"""Get health information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
HealthModel
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[HealthModel]:
|
||||
"""Get health information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[HealthModel]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[HealthModel]:
|
||||
"""Get health information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
HealthModel
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
1
gotify_rest_api_client/api/message/__init__.py
Normal file
1
gotify_rest_api_client/api/message/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
183
gotify_rest_api_client/api/message/create_message.py
Normal file
183
gotify_rest_api_client/api/message/create_message.py
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.message_external_model import MessageExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: MessageExternalModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/message",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, MessageExternalModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = MessageExternalModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, MessageExternalModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: MessageExternalModel,
|
||||
) -> Response[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Create a message.
|
||||
|
||||
__NOTE__: This API ONLY accepts an application token as authentication.
|
||||
|
||||
Args:
|
||||
body (MessageExternalModel): The MessageExternal holds information about a message which
|
||||
was sent by an Application.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, MessageExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: MessageExternalModel,
|
||||
) -> Optional[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Create a message.
|
||||
|
||||
__NOTE__: This API ONLY accepts an application token as authentication.
|
||||
|
||||
Args:
|
||||
body (MessageExternalModel): The MessageExternal holds information about a message which
|
||||
was sent by an Application.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, MessageExternalModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: MessageExternalModel,
|
||||
) -> Response[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Create a message.
|
||||
|
||||
__NOTE__: This API ONLY accepts an application token as authentication.
|
||||
|
||||
Args:
|
||||
body (MessageExternalModel): The MessageExternal holds information about a message which
|
||||
was sent by an Application.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, MessageExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: MessageExternalModel,
|
||||
) -> Optional[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Create a message.
|
||||
|
||||
__NOTE__: This API ONLY accepts an application token as authentication.
|
||||
|
||||
Args:
|
||||
body (MessageExternalModel): The MessageExternal holds information about a message which
|
||||
was sent by an Application.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, MessageExternalModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
165
gotify_rest_api_client/api/message/delete_app_messages.py
Normal file
165
gotify_rest_api_client/api/message/delete_app_messages.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/application/{id}/message",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
165
gotify_rest_api_client/api/message/delete_message.py
Normal file
165
gotify_rest_api_client/api/message/delete_message.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/message/{id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Deletes a message with an id.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Deletes a message with an id.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Deletes a message with an id.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Deletes a message with an id.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
133
gotify_rest_api_client/api/message/delete_messages.py
Normal file
133
gotify_rest_api_client/api/message/delete_messages.py
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": "/message",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Delete all messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
203
gotify_rest_api_client/api/message/get_app_messages.py
Normal file
203
gotify_rest_api_client/api/message/get_app_messages.py
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.paged_messages_model import PagedMessagesModel
|
||||
from ...types import UNSET, Response, Unset
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
*,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["limit"] = limit
|
||||
|
||||
params["since"] = since
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/application/{id}/message",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, PagedMessagesModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = PagedMessagesModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, PagedMessagesModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Response[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, PagedMessagesModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
limit=limit,
|
||||
since=since,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Optional[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, PagedMessagesModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
limit=limit,
|
||||
since=since,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Response[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, PagedMessagesModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
limit=limit,
|
||||
since=since,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Optional[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages from a specific application.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, PagedMessagesModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
limit=limit,
|
||||
since=since,
|
||||
)
|
||||
).parsed
|
||||
186
gotify_rest_api_client/api/message/get_messages.py
Normal file
186
gotify_rest_api_client/api/message/get_messages.py
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.paged_messages_model import PagedMessagesModel
|
||||
from ...types import UNSET, Response, Unset
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["limit"] = limit
|
||||
|
||||
params["since"] = since
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/message",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, PagedMessagesModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = PagedMessagesModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, PagedMessagesModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Response[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages.
|
||||
|
||||
Args:
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, PagedMessagesModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
limit=limit,
|
||||
since=since,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Optional[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages.
|
||||
|
||||
Args:
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, PagedMessagesModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
limit=limit,
|
||||
since=since,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Response[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages.
|
||||
|
||||
Args:
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, PagedMessagesModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
limit=limit,
|
||||
since=since,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
limit: Union[Unset, int] = 100,
|
||||
since: Union[Unset, int] = UNSET,
|
||||
) -> Optional[Union[ErrorModel, PagedMessagesModel]]:
|
||||
"""Return all messages.
|
||||
|
||||
Args:
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
since (Union[Unset, int]):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, PagedMessagesModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
limit=limit,
|
||||
since=since,
|
||||
)
|
||||
).parsed
|
||||
143
gotify_rest_api_client/api/message/stream_messages.py
Normal file
143
gotify_rest_api_client/api/message/stream_messages.py
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.message_external_model import MessageExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/stream",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, MessageExternalModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = MessageExternalModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, MessageExternalModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Websocket, return newly created messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, MessageExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Websocket, return newly created messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, MessageExternalModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Websocket, return newly created messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, MessageExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, MessageExternalModel]]:
|
||||
"""Websocket, return newly created messages.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, MessageExternalModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
1
gotify_rest_api_client/api/plugin/__init__.py
Normal file
1
gotify_rest_api_client/api/plugin/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
165
gotify_rest_api_client/api/plugin/disable_plugin.py
Normal file
165
gotify_rest_api_client/api/plugin/disable_plugin.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/plugin/{id}/disable",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Disable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Disable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Disable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Disable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
165
gotify_rest_api_client/api/plugin/enable_plugin.py
Normal file
165
gotify_rest_api_client/api/plugin/enable_plugin.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/plugin/{id}/enable",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Enable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Enable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Enable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Enable a plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
91
gotify_rest_api_client/api/plugin/get_plugin_config.py
Normal file
91
gotify_rest_api_client/api/plugin/get_plugin_config.py
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/plugin/{id}/config",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Any]:
|
||||
"""Get YAML configuration for Configurer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Any]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Any]:
|
||||
"""Get YAML configuration for Configurer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Any]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
165
gotify_rest_api_client/api/plugin/get_plugin_display.py
Normal file
165
gotify_rest_api_client/api/plugin/get_plugin_display.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/plugin/{id}/display",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, str]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(str, response.json())
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, str]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, str]]:
|
||||
"""Get display info for a Displayer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, str]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, str]]:
|
||||
"""Get display info for a Displayer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, str]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, str]]:
|
||||
"""Get display info for a Displayer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, str]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, str]]:
|
||||
"""Get display info for a Displayer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, str]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
148
gotify_rest_api_client/api/plugin/get_plugins.py
Normal file
148
gotify_rest_api_client/api/plugin/get_plugins.py
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.plugin_conf_external_model import PluginConfExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/plugin",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, list["PluginConfExternalModel"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = PluginConfExternalModel.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, list["PluginConfExternalModel"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["PluginConfExternalModel"]]]:
|
||||
"""Return all plugins.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['PluginConfExternalModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["PluginConfExternalModel"]]]:
|
||||
"""Return all plugins.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['PluginConfExternalModel']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["PluginConfExternalModel"]]]:
|
||||
"""Return all plugins.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['PluginConfExternalModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["PluginConfExternalModel"]]]:
|
||||
"""Return all plugins.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['PluginConfExternalModel']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
169
gotify_rest_api_client/api/plugin/update_plugin_config.py
Normal file
169
gotify_rest_api_client/api/plugin/update_plugin_config.py
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/plugin/{id}/config",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Update YAML configuration for Configurer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Update YAML configuration for Configurer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Update YAML configuration for Configurer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Update YAML configuration for Configurer plugin.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
1
gotify_rest_api_client/api/user/__init__.py
Normal file
1
gotify_rest_api_client/api/user/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
184
gotify_rest_api_client/api/user/create_user.py
Normal file
184
gotify_rest_api_client/api/user/create_user.py
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.create_user_external_model import CreateUserExternalModel
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.user_external_model import UserExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: CreateUserExternalModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/user",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UserExternalModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: CreateUserExternalModel,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Create a user.
|
||||
|
||||
With enabled registration: non admin users can be created without authentication.
|
||||
With disabled registrations: users can only be created by admin users.
|
||||
|
||||
Args:
|
||||
body (CreateUserExternalModel): Used for user creation.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: CreateUserExternalModel,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Create a user.
|
||||
|
||||
With enabled registration: non admin users can be created without authentication.
|
||||
With disabled registrations: users can only be created by admin users.
|
||||
|
||||
Args:
|
||||
body (CreateUserExternalModel): Used for user creation.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: CreateUserExternalModel,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Create a user.
|
||||
|
||||
With enabled registration: non admin users can be created without authentication.
|
||||
With disabled registrations: users can only be created by admin users.
|
||||
|
||||
Args:
|
||||
body (CreateUserExternalModel): Used for user creation.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: CreateUserExternalModel,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Create a user.
|
||||
|
||||
With enabled registration: non admin users can be created without authentication.
|
||||
With disabled registrations: users can only be created by admin users.
|
||||
|
||||
Args:
|
||||
body (CreateUserExternalModel): Used for user creation.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
135
gotify_rest_api_client/api/user/current_user.py
Normal file
135
gotify_rest_api_client/api/user/current_user.py
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.user_external_model import UserExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/current/user",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UserExternalModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Return the current user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Return the current user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Return the current user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Return the current user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
165
gotify_rest_api_client/api/user/delete_user.py
Normal file
165
gotify_rest_api_client/api/user/delete_user.py
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/user/{id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Deletes a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Deletes a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Deletes a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Deletes a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
167
gotify_rest_api_client/api/user/get_user.py
Normal file
167
gotify_rest_api_client/api/user/get_user.py
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.user_external_model import UserExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/user/{id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UserExternalModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Get a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Get a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Get a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Get a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
140
gotify_rest_api_client/api/user/get_users.py
Normal file
140
gotify_rest_api_client/api/user/get_users.py
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.user_external_model import UserExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/user",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, list["UserExternalModel"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = UserExternalModel.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, list["UserExternalModel"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["UserExternalModel"]]]:
|
||||
"""Return all users.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['UserExternalModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["UserExternalModel"]]]:
|
||||
"""Return all users.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['UserExternalModel']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Union[ErrorModel, list["UserExternalModel"]]]:
|
||||
"""Return all users.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, list['UserExternalModel']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Union[ErrorModel, list["UserExternalModel"]]]:
|
||||
"""Return all users.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, list['UserExternalModel']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
170
gotify_rest_api_client/api/user/update_current_user.py
Normal file
170
gotify_rest_api_client/api/user/update_current_user.py
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.user_external_pass_model import UserExternalPassModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: UserExternalPassModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/current/user/password",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = cast(Any, None)
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UserExternalPassModel,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Update the password of the current user.
|
||||
|
||||
Args:
|
||||
body (UserExternalPassModel): The Password for updating the user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UserExternalPassModel,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Update the password of the current user.
|
||||
|
||||
Args:
|
||||
body (UserExternalPassModel): The Password for updating the user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UserExternalPassModel,
|
||||
) -> Response[Union[Any, ErrorModel]]:
|
||||
"""Update the password of the current user.
|
||||
|
||||
Args:
|
||||
body (UserExternalPassModel): The Password for updating the user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[Any, ErrorModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UserExternalPassModel,
|
||||
) -> Optional[Union[Any, ErrorModel]]:
|
||||
"""Update the password of the current user.
|
||||
|
||||
Args:
|
||||
body (UserExternalPassModel): The Password for updating the user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[Any, ErrorModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
189
gotify_rest_api_client/api/user/update_user.py
Normal file
189
gotify_rest_api_client/api/user/update_user.py
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error_model import ErrorModel
|
||||
from ...models.update_user_external_model import UpdateUserExternalModel
|
||||
from ...models.user_external_model import UserExternalModel
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: int,
|
||||
*,
|
||||
body: UpdateUserExternalModel,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/user/{id}",
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UserExternalModel.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_400
|
||||
if response.status_code == 401:
|
||||
response_401 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_403
|
||||
if response.status_code == 404:
|
||||
response_404 = ErrorModel.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UpdateUserExternalModel,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Update a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UpdateUserExternalModel): Used for updating a user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UpdateUserExternalModel,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Update a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UpdateUserExternalModel): Used for updating a user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UpdateUserExternalModel,
|
||||
) -> Response[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Update a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UpdateUserExternalModel): Used for updating a user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Union[ErrorModel, UserExternalModel]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: int,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UpdateUserExternalModel,
|
||||
) -> Optional[Union[ErrorModel, UserExternalModel]]:
|
||||
"""Update a user.
|
||||
|
||||
Args:
|
||||
id (int):
|
||||
body (UpdateUserExternalModel): Used for updating a user.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Union[ErrorModel, UserExternalModel]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
1
gotify_rest_api_client/api/version/__init__.py
Normal file
1
gotify_rest_api_client/api/version/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
122
gotify_rest_api_client/api/version/get_version.py
Normal file
122
gotify_rest_api_client/api/version/get_version.py
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.version_info import VersionInfo
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/version",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[VersionInfo]:
|
||||
if response.status_code == 200:
|
||||
response_200 = VersionInfo.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[VersionInfo]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[VersionInfo]:
|
||||
"""Get version information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[VersionInfo]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[VersionInfo]:
|
||||
"""Get version information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
VersionInfo
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[VersionInfo]:
|
||||
"""Get version information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[VersionInfo]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[VersionInfo]:
|
||||
"""Get version information.
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
VersionInfo
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
268
gotify_rest_api_client/client.py
Normal file
268
gotify_rest_api_client/client.py
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
import ssl
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
from attrs import define, evolve, field
|
||||
|
||||
|
||||
@define
|
||||
class Client:
|
||||
"""A class for keeping track of data related to the API
|
||||
|
||||
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
||||
|
||||
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
||||
|
||||
``cookies``: A dictionary of cookies to be sent with every request
|
||||
|
||||
``headers``: A dictionary of headers to be sent with every request
|
||||
|
||||
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
||||
httpx.TimeoutException if this is exceeded.
|
||||
|
||||
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
||||
but can be set to False for testing purposes.
|
||||
|
||||
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
||||
|
||||
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
||||
|
||||
|
||||
Attributes:
|
||||
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
||||
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
||||
argument to the constructor.
|
||||
"""
|
||||
|
||||
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
||||
_base_url: str = field(alias="base_url")
|
||||
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
||||
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
||||
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
|
||||
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
|
||||
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
||||
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
||||
_client: Optional[httpx.Client] = field(default=None, init=False)
|
||||
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
||||
|
||||
def with_headers(self, headers: dict[str, str]) -> "Client":
|
||||
"""Get a new client matching this one with additional headers"""
|
||||
if self._client is not None:
|
||||
self._client.headers.update(headers)
|
||||
if self._async_client is not None:
|
||||
self._async_client.headers.update(headers)
|
||||
return evolve(self, headers={**self._headers, **headers})
|
||||
|
||||
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
||||
"""Get a new client matching this one with additional cookies"""
|
||||
if self._client is not None:
|
||||
self._client.cookies.update(cookies)
|
||||
if self._async_client is not None:
|
||||
self._async_client.cookies.update(cookies)
|
||||
return evolve(self, cookies={**self._cookies, **cookies})
|
||||
|
||||
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
||||
"""Get a new client matching this one with a new timeout (in seconds)"""
|
||||
if self._client is not None:
|
||||
self._client.timeout = timeout
|
||||
if self._async_client is not None:
|
||||
self._async_client.timeout = timeout
|
||||
return evolve(self, timeout=timeout)
|
||||
|
||||
def set_httpx_client(self, client: httpx.Client) -> "Client":
|
||||
"""Manually set the underlying httpx.Client
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._client = client
|
||||
return self
|
||||
|
||||
def get_httpx_client(self) -> httpx.Client:
|
||||
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
||||
if self._client is None:
|
||||
self._client = httpx.Client(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._client
|
||||
|
||||
def __enter__(self) -> "Client":
|
||||
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
||||
self.get_httpx_client().__enter__()
|
||||
return self
|
||||
|
||||
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
||||
self.get_httpx_client().__exit__(*args, **kwargs)
|
||||
|
||||
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
|
||||
"""Manually the underlying httpx.AsyncClient
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._async_client = async_client
|
||||
return self
|
||||
|
||||
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
||||
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
||||
if self._async_client is None:
|
||||
self._async_client = httpx.AsyncClient(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._async_client
|
||||
|
||||
async def __aenter__(self) -> "Client":
|
||||
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aenter__()
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
||||
|
||||
|
||||
@define
|
||||
class AuthenticatedClient:
|
||||
"""A Client which has been authenticated for use on secured endpoints
|
||||
|
||||
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
||||
|
||||
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
||||
|
||||
``cookies``: A dictionary of cookies to be sent with every request
|
||||
|
||||
``headers``: A dictionary of headers to be sent with every request
|
||||
|
||||
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
||||
httpx.TimeoutException if this is exceeded.
|
||||
|
||||
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
||||
but can be set to False for testing purposes.
|
||||
|
||||
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
||||
|
||||
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
||||
|
||||
|
||||
Attributes:
|
||||
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
||||
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
||||
argument to the constructor.
|
||||
token: The token to use for authentication
|
||||
prefix: The prefix to use for the Authorization header
|
||||
auth_header_name: The name of the Authorization header
|
||||
"""
|
||||
|
||||
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
||||
_base_url: str = field(alias="base_url")
|
||||
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
||||
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
||||
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
|
||||
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
|
||||
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
||||
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
||||
_client: Optional[httpx.Client] = field(default=None, init=False)
|
||||
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
||||
|
||||
token: str
|
||||
prefix: str = "Bearer"
|
||||
auth_header_name: str = "Authorization"
|
||||
|
||||
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
||||
"""Get a new client matching this one with additional headers"""
|
||||
if self._client is not None:
|
||||
self._client.headers.update(headers)
|
||||
if self._async_client is not None:
|
||||
self._async_client.headers.update(headers)
|
||||
return evolve(self, headers={**self._headers, **headers})
|
||||
|
||||
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
||||
"""Get a new client matching this one with additional cookies"""
|
||||
if self._client is not None:
|
||||
self._client.cookies.update(cookies)
|
||||
if self._async_client is not None:
|
||||
self._async_client.cookies.update(cookies)
|
||||
return evolve(self, cookies={**self._cookies, **cookies})
|
||||
|
||||
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
||||
"""Get a new client matching this one with a new timeout (in seconds)"""
|
||||
if self._client is not None:
|
||||
self._client.timeout = timeout
|
||||
if self._async_client is not None:
|
||||
self._async_client.timeout = timeout
|
||||
return evolve(self, timeout=timeout)
|
||||
|
||||
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
|
||||
"""Manually set the underlying httpx.Client
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._client = client
|
||||
return self
|
||||
|
||||
def get_httpx_client(self) -> httpx.Client:
|
||||
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
||||
if self._client is None:
|
||||
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
||||
self._client = httpx.Client(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._client
|
||||
|
||||
def __enter__(self) -> "AuthenticatedClient":
|
||||
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
||||
self.get_httpx_client().__enter__()
|
||||
return self
|
||||
|
||||
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
||||
self.get_httpx_client().__exit__(*args, **kwargs)
|
||||
|
||||
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":
|
||||
"""Manually the underlying httpx.AsyncClient
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._async_client = async_client
|
||||
return self
|
||||
|
||||
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
||||
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
||||
if self._async_client is None:
|
||||
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
||||
self._async_client = httpx.AsyncClient(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._async_client
|
||||
|
||||
async def __aenter__(self) -> "AuthenticatedClient":
|
||||
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aenter__()
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
||||
16
gotify_rest_api_client/errors.py
Normal file
16
gotify_rest_api_client/errors.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"""Contains shared errors types that can be raised from API functions"""
|
||||
|
||||
|
||||
class UnexpectedStatus(Exception):
|
||||
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
||||
|
||||
def __init__(self, status_code: int, content: bytes):
|
||||
self.status_code = status_code
|
||||
self.content = content
|
||||
|
||||
super().__init__(
|
||||
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["UnexpectedStatus"]
|
||||
39
gotify_rest_api_client/models/__init__.py
Normal file
39
gotify_rest_api_client/models/__init__.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
"""Contains all the data models used in inputs/outputs"""
|
||||
|
||||
from .application_model import ApplicationModel
|
||||
from .application_params_model import ApplicationParamsModel
|
||||
from .client_model import ClientModel
|
||||
from .client_params_model import ClientParamsModel
|
||||
from .create_user_external_model import CreateUserExternalModel
|
||||
from .error_model import ErrorModel
|
||||
from .health_model import HealthModel
|
||||
from .message_external_model import MessageExternalModel
|
||||
from .message_external_model_extras import MessageExternalModelExtras
|
||||
from .paged_messages_model import PagedMessagesModel
|
||||
from .paging_model import PagingModel
|
||||
from .plugin_conf_external_model import PluginConfExternalModel
|
||||
from .update_user_external_model import UpdateUserExternalModel
|
||||
from .upload_app_image_body import UploadAppImageBody
|
||||
from .user_external_model import UserExternalModel
|
||||
from .user_external_pass_model import UserExternalPassModel
|
||||
from .version_info import VersionInfo
|
||||
|
||||
__all__ = (
|
||||
"ApplicationModel",
|
||||
"ApplicationParamsModel",
|
||||
"ClientModel",
|
||||
"ClientParamsModel",
|
||||
"CreateUserExternalModel",
|
||||
"ErrorModel",
|
||||
"HealthModel",
|
||||
"MessageExternalModel",
|
||||
"MessageExternalModelExtras",
|
||||
"PagedMessagesModel",
|
||||
"PagingModel",
|
||||
"PluginConfExternalModel",
|
||||
"UpdateUserExternalModel",
|
||||
"UploadAppImageBody",
|
||||
"UserExternalModel",
|
||||
"UserExternalPassModel",
|
||||
"VersionInfo",
|
||||
)
|
||||
154
gotify_rest_api_client/models/application_model.py
Normal file
154
gotify_rest_api_client/models/application_model.py
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="ApplicationModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ApplicationModel:
|
||||
"""The Application holds information about an app which can send notifications.
|
||||
|
||||
Attributes:
|
||||
description (Union[None, str]): The description of the application. Example: Backup server for the interwebs.
|
||||
id (int): The application id. Example: 5.
|
||||
image (str): The image of the application. Example: image/image.jpeg.
|
||||
internal (bool): Whether the application is an internal application. Internal applications should not be
|
||||
deleted.
|
||||
name (str): The application name. This is how the application should be displayed to the user. Example: Backup
|
||||
Server.
|
||||
token (str): The application token. Can be used as `appToken`. See Authentication. Example: AWH0wZ5r0Mbac.r.
|
||||
default_priority (Union[Unset, int]): The default priority of messages sent by this application. Defaults to 0.
|
||||
Example: 4.
|
||||
last_used (Union[None, Unset, datetime.datetime]): The last time the application token was used. Example:
|
||||
2019-01-01 00:00:00+00:00.
|
||||
"""
|
||||
|
||||
description: Union[None, str]
|
||||
id: int
|
||||
image: str
|
||||
internal: bool
|
||||
name: str
|
||||
token: str
|
||||
default_priority: Union[Unset, int] = UNSET
|
||||
last_used: Union[None, Unset, datetime.datetime] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
description: Union[None, str]
|
||||
description = self.description
|
||||
|
||||
id = self.id
|
||||
|
||||
image = self.image
|
||||
|
||||
internal = self.internal
|
||||
|
||||
name = self.name
|
||||
|
||||
token = self.token
|
||||
|
||||
default_priority = self.default_priority
|
||||
|
||||
last_used: Union[None, Unset, str]
|
||||
if isinstance(self.last_used, Unset):
|
||||
last_used = UNSET
|
||||
elif isinstance(self.last_used, datetime.datetime):
|
||||
last_used = self.last_used.isoformat()
|
||||
else:
|
||||
last_used = self.last_used
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"description": description,
|
||||
"id": id,
|
||||
"image": image,
|
||||
"internal": internal,
|
||||
"name": name,
|
||||
"token": token,
|
||||
}
|
||||
)
|
||||
if default_priority is not UNSET:
|
||||
field_dict["defaultPriority"] = default_priority
|
||||
if last_used is not UNSET:
|
||||
field_dict["lastUsed"] = last_used
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
|
||||
def _parse_description(data: object) -> Union[None, str]:
|
||||
if data is None:
|
||||
return data
|
||||
return cast(Union[None, str], data)
|
||||
|
||||
description = _parse_description(d.pop("description"))
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
image = d.pop("image")
|
||||
|
||||
internal = d.pop("internal")
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
token = d.pop("token")
|
||||
|
||||
default_priority = d.pop("defaultPriority", UNSET)
|
||||
|
||||
def _parse_last_used(data: object) -> Union[None, Unset, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
last_used_type_1 = isoparse(data)
|
||||
|
||||
return last_used_type_1
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.datetime], data)
|
||||
|
||||
last_used = _parse_last_used(d.pop("lastUsed", UNSET))
|
||||
|
||||
application_model = cls(
|
||||
description=description,
|
||||
id=id,
|
||||
image=image,
|
||||
internal=internal,
|
||||
name=name,
|
||||
token=token,
|
||||
default_priority=default_priority,
|
||||
last_used=last_used,
|
||||
)
|
||||
|
||||
application_model.additional_properties = d
|
||||
return application_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
82
gotify_rest_api_client/models/application_params_model.py
Normal file
82
gotify_rest_api_client/models/application_params_model.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="ApplicationParamsModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ApplicationParamsModel:
|
||||
"""Params allowed to create or update Applications.
|
||||
|
||||
Attributes:
|
||||
name (str): The application name. This is how the application should be displayed to the user. Example: Backup
|
||||
Server.
|
||||
default_priority (Union[Unset, int]): The default priority of messages sent by this application. Defaults to 0.
|
||||
Example: 5.
|
||||
description (Union[Unset, str]): The description of the application. Example: Backup server for the interwebs.
|
||||
"""
|
||||
|
||||
name: str
|
||||
default_priority: Union[Unset, int] = UNSET
|
||||
description: Union[Unset, str] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
name = self.name
|
||||
|
||||
default_priority = self.default_priority
|
||||
|
||||
description = self.description
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"name": name,
|
||||
}
|
||||
)
|
||||
if default_priority is not UNSET:
|
||||
field_dict["defaultPriority"] = default_priority
|
||||
if description is not UNSET:
|
||||
field_dict["description"] = description
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
name = d.pop("name")
|
||||
|
||||
default_priority = d.pop("defaultPriority", UNSET)
|
||||
|
||||
description = d.pop("description", UNSET)
|
||||
|
||||
application_params_model = cls(
|
||||
name=name,
|
||||
default_priority=default_priority,
|
||||
description=description,
|
||||
)
|
||||
|
||||
application_params_model.additional_properties = d
|
||||
return application_params_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
111
gotify_rest_api_client/models/client_model.py
Normal file
111
gotify_rest_api_client/models/client_model.py
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="ClientModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ClientModel:
|
||||
"""The Client holds information about a device which can receive notifications (and other stuff).
|
||||
|
||||
Attributes:
|
||||
id (int): The client id. Example: 5.
|
||||
name (str): The client name. This is how the client should be displayed to the user. Example: Android Phone.
|
||||
token (str): The client token. Can be used as `clientToken`. See Authentication. Example: CWH0wZ5r0Mbac.r.
|
||||
last_used (Union[None, Unset, datetime.datetime]): The last time the client token was used. Example: 2019-01-01
|
||||
00:00:00+00:00.
|
||||
"""
|
||||
|
||||
id: int
|
||||
name: str
|
||||
token: str
|
||||
last_used: Union[None, Unset, datetime.datetime] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
id = self.id
|
||||
|
||||
name = self.name
|
||||
|
||||
token = self.token
|
||||
|
||||
last_used: Union[None, Unset, str]
|
||||
if isinstance(self.last_used, Unset):
|
||||
last_used = UNSET
|
||||
elif isinstance(self.last_used, datetime.datetime):
|
||||
last_used = self.last_used.isoformat()
|
||||
else:
|
||||
last_used = self.last_used
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"id": id,
|
||||
"name": name,
|
||||
"token": token,
|
||||
}
|
||||
)
|
||||
if last_used is not UNSET:
|
||||
field_dict["lastUsed"] = last_used
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
id = d.pop("id")
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
token = d.pop("token")
|
||||
|
||||
def _parse_last_used(data: object) -> Union[None, Unset, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
last_used_type_1 = isoparse(data)
|
||||
|
||||
return last_used_type_1
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.datetime], data)
|
||||
|
||||
last_used = _parse_last_used(d.pop("lastUsed", UNSET))
|
||||
|
||||
client_model = cls(
|
||||
id=id,
|
||||
name=name,
|
||||
token=token,
|
||||
last_used=last_used,
|
||||
)
|
||||
|
||||
client_model.additional_properties = d
|
||||
return client_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
60
gotify_rest_api_client/models/client_params_model.py
Normal file
60
gotify_rest_api_client/models/client_params_model.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="ClientParamsModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ClientParamsModel:
|
||||
"""Params allowed to create or update Clients.
|
||||
|
||||
Attributes:
|
||||
name (str): The client name Example: My Client.
|
||||
"""
|
||||
|
||||
name: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
name = self.name
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"name": name,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
name = d.pop("name")
|
||||
|
||||
client_params_model = cls(
|
||||
name=name,
|
||||
)
|
||||
|
||||
client_params_model.additional_properties = d
|
||||
return client_params_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
76
gotify_rest_api_client/models/create_user_external_model.py
Normal file
76
gotify_rest_api_client/models/create_user_external_model.py
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="CreateUserExternalModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class CreateUserExternalModel:
|
||||
"""Used for user creation.
|
||||
|
||||
Attributes:
|
||||
admin (bool): If the user is an administrator. Example: True.
|
||||
name (str): The user name. For login. Example: unicorn.
|
||||
pass_ (str): The user password. For login. Example: nrocinu.
|
||||
"""
|
||||
|
||||
admin: bool
|
||||
name: str
|
||||
pass_: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
admin = self.admin
|
||||
|
||||
name = self.name
|
||||
|
||||
pass_ = self.pass_
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"admin": admin,
|
||||
"name": name,
|
||||
"pass": pass_,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
admin = d.pop("admin")
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
pass_ = d.pop("pass")
|
||||
|
||||
create_user_external_model = cls(
|
||||
admin=admin,
|
||||
name=name,
|
||||
pass_=pass_,
|
||||
)
|
||||
|
||||
create_user_external_model.additional_properties = d
|
||||
return create_user_external_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
77
gotify_rest_api_client/models/error_model.py
Normal file
77
gotify_rest_api_client/models/error_model.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="ErrorModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ErrorModel:
|
||||
"""The Error contains error relevant information.
|
||||
|
||||
Attributes:
|
||||
error (str): The general error message Example: Unauthorized.
|
||||
error_code (int): The http error code. Example: 401.
|
||||
error_description (str): The http error code. Example: you need to provide a valid access token or user
|
||||
credentials to access this api.
|
||||
"""
|
||||
|
||||
error: str
|
||||
error_code: int
|
||||
error_description: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
error = self.error
|
||||
|
||||
error_code = self.error_code
|
||||
|
||||
error_description = self.error_description
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"error": error,
|
||||
"errorCode": error_code,
|
||||
"errorDescription": error_description,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
error = d.pop("error")
|
||||
|
||||
error_code = d.pop("errorCode")
|
||||
|
||||
error_description = d.pop("errorDescription")
|
||||
|
||||
error_model = cls(
|
||||
error=error,
|
||||
error_code=error_code,
|
||||
error_description=error_description,
|
||||
)
|
||||
|
||||
error_model.additional_properties = d
|
||||
return error_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
68
gotify_rest_api_client/models/health_model.py
Normal file
68
gotify_rest_api_client/models/health_model.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="HealthModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class HealthModel:
|
||||
"""Health represents how healthy the application is.
|
||||
|
||||
Attributes:
|
||||
database (str): The health of the database connection. Example: green.
|
||||
health (str): The health of the overall application. Example: green.
|
||||
"""
|
||||
|
||||
database: str
|
||||
health: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
database = self.database
|
||||
|
||||
health = self.health
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"database": database,
|
||||
"health": health,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
database = d.pop("database")
|
||||
|
||||
health = d.pop("health")
|
||||
|
||||
health_model = cls(
|
||||
database=database,
|
||||
health=health,
|
||||
)
|
||||
|
||||
health_model.additional_properties = d
|
||||
return health_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
139
gotify_rest_api_client/models/message_external_model.py
Normal file
139
gotify_rest_api_client/models/message_external_model.py
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.message_external_model_extras import MessageExternalModelExtras
|
||||
|
||||
|
||||
T = TypeVar("T", bound="MessageExternalModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class MessageExternalModel:
|
||||
"""The MessageExternal holds information about a message which was sent by an Application.
|
||||
|
||||
Attributes:
|
||||
appid (int): The application id that send this message. Example: 5.
|
||||
date (datetime.datetime): The date the message was created. Example: 2018-02-27 19:36:10.504504+01:00.
|
||||
id (int): The message id. Example: 25.
|
||||
message (str): The message. Markdown (excluding html) is allowed. Example: **Backup** was successfully
|
||||
finished..
|
||||
extras (Union[Unset, MessageExternalModelExtras]): The extra data sent along the message.
|
||||
|
||||
The extra fields are stored in a key-value scheme. Only accepted in CreateMessage requests with application/json
|
||||
content-type.
|
||||
|
||||
The keys should be in the following format: <top-namespace>::[<sub-namespace>::]<action>
|
||||
|
||||
These namespaces are reserved and might be used in the official clients: gotify android ios web server client.
|
||||
Do not use them for other purposes. Example: {'home::appliances::lighting::on': {'brightness': 15},
|
||||
'home::appliances::thermostat::change_temperature': {'temperature': 23}}.
|
||||
priority (Union[Unset, int]): The priority of the message. If unset, then the default priority of the
|
||||
application will be used. Example: 2.
|
||||
title (Union[Unset, str]): The title of the message. Example: Backup.
|
||||
"""
|
||||
|
||||
appid: int
|
||||
date: datetime.datetime
|
||||
id: int
|
||||
message: str
|
||||
extras: Union[Unset, "MessageExternalModelExtras"] = UNSET
|
||||
priority: Union[Unset, int] = UNSET
|
||||
title: Union[Unset, str] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
appid = self.appid
|
||||
|
||||
date = self.date.isoformat()
|
||||
|
||||
id = self.id
|
||||
|
||||
message = self.message
|
||||
|
||||
extras: Union[Unset, dict[str, Any]] = UNSET
|
||||
if not isinstance(self.extras, Unset):
|
||||
extras = self.extras.to_dict()
|
||||
|
||||
priority = self.priority
|
||||
|
||||
title = self.title
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"appid": appid,
|
||||
"date": date,
|
||||
"id": id,
|
||||
"message": message,
|
||||
}
|
||||
)
|
||||
if extras is not UNSET:
|
||||
field_dict["extras"] = extras
|
||||
if priority is not UNSET:
|
||||
field_dict["priority"] = priority
|
||||
if title is not UNSET:
|
||||
field_dict["title"] = title
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.message_external_model_extras import MessageExternalModelExtras
|
||||
|
||||
d = dict(src_dict)
|
||||
appid = d.pop("appid")
|
||||
|
||||
date = isoparse(d.pop("date"))
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
message = d.pop("message")
|
||||
|
||||
_extras = d.pop("extras", UNSET)
|
||||
extras: Union[Unset, MessageExternalModelExtras]
|
||||
if isinstance(_extras, Unset):
|
||||
extras = UNSET
|
||||
else:
|
||||
extras = MessageExternalModelExtras.from_dict(_extras)
|
||||
|
||||
priority = d.pop("priority", UNSET)
|
||||
|
||||
title = d.pop("title", UNSET)
|
||||
|
||||
message_external_model = cls(
|
||||
appid=appid,
|
||||
date=date,
|
||||
id=id,
|
||||
message=message,
|
||||
extras=extras,
|
||||
priority=priority,
|
||||
title=title,
|
||||
)
|
||||
|
||||
message_external_model.additional_properties = d
|
||||
return message_external_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="MessageExternalModelExtras")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class MessageExternalModelExtras:
|
||||
"""The extra data sent along the message.
|
||||
|
||||
The extra fields are stored in a key-value scheme. Only accepted in CreateMessage requests with application/json
|
||||
content-type.
|
||||
|
||||
The keys should be in the following format: <top-namespace>::[<sub-namespace>::]<action>
|
||||
|
||||
These namespaces are reserved and might be used in the official clients: gotify android ios web server client. Do
|
||||
not use them for other purposes.
|
||||
|
||||
Example:
|
||||
{'home::appliances::lighting::on': {'brightness': 15}, 'home::appliances::thermostat::change_temperature':
|
||||
{'temperature': 23}}
|
||||
|
||||
"""
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
message_external_model_extras = cls()
|
||||
|
||||
message_external_model_extras.additional_properties = d
|
||||
return message_external_model_extras
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
84
gotify_rest_api_client/models/paged_messages_model.py
Normal file
84
gotify_rest_api_client/models/paged_messages_model.py
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.message_external_model import MessageExternalModel
|
||||
from ..models.paging_model import PagingModel
|
||||
|
||||
|
||||
T = TypeVar("T", bound="PagedMessagesModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class PagedMessagesModel:
|
||||
"""Wrapper for the paging and the messages.
|
||||
|
||||
Attributes:
|
||||
messages (list['MessageExternalModel']): The messages.
|
||||
paging (PagingModel): The Paging holds information about the limit and making requests to the next page.
|
||||
"""
|
||||
|
||||
messages: list["MessageExternalModel"]
|
||||
paging: "PagingModel"
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
messages = []
|
||||
for messages_item_data in self.messages:
|
||||
messages_item = messages_item_data.to_dict()
|
||||
messages.append(messages_item)
|
||||
|
||||
paging = self.paging.to_dict()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"messages": messages,
|
||||
"paging": paging,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.message_external_model import MessageExternalModel
|
||||
from ..models.paging_model import PagingModel
|
||||
|
||||
d = dict(src_dict)
|
||||
messages = []
|
||||
_messages = d.pop("messages")
|
||||
for messages_item_data in _messages:
|
||||
messages_item = MessageExternalModel.from_dict(messages_item_data)
|
||||
|
||||
messages.append(messages_item)
|
||||
|
||||
paging = PagingModel.from_dict(d.pop("paging"))
|
||||
|
||||
paged_messages_model = cls(
|
||||
messages=messages,
|
||||
paging=paging,
|
||||
)
|
||||
|
||||
paged_messages_model.additional_properties = d
|
||||
return paged_messages_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
89
gotify_rest_api_client/models/paging_model.py
Normal file
89
gotify_rest_api_client/models/paging_model.py
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PagingModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class PagingModel:
|
||||
"""The Paging holds information about the limit and making requests to the next page.
|
||||
|
||||
Attributes:
|
||||
limit (int): The limit of the messages for the current request. Example: 123.
|
||||
since (int): The ID of the last message returned in the current request. Use this as alternative to the next
|
||||
link. Example: 5.
|
||||
size (int): The amount of messages that got returned in the current request. Example: 5.
|
||||
next_ (Union[Unset, str]): The request url for the next page. Empty/Null when no next page is available.
|
||||
Example: http://example.com/message?limit=50&since=123456.
|
||||
"""
|
||||
|
||||
limit: int
|
||||
since: int
|
||||
size: int
|
||||
next_: Union[Unset, str] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
limit = self.limit
|
||||
|
||||
since = self.since
|
||||
|
||||
size = self.size
|
||||
|
||||
next_ = self.next_
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"limit": limit,
|
||||
"since": since,
|
||||
"size": size,
|
||||
}
|
||||
)
|
||||
if next_ is not UNSET:
|
||||
field_dict["next"] = next_
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
limit = d.pop("limit")
|
||||
|
||||
since = d.pop("since")
|
||||
|
||||
size = d.pop("size")
|
||||
|
||||
next_ = d.pop("next", UNSET)
|
||||
|
||||
paging_model = cls(
|
||||
limit=limit,
|
||||
since=since,
|
||||
size=size,
|
||||
next_=next_,
|
||||
)
|
||||
|
||||
paging_model.additional_properties = d
|
||||
return paging_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
129
gotify_rest_api_client/models/plugin_conf_external_model.py
Normal file
129
gotify_rest_api_client/models/plugin_conf_external_model.py
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PluginConfExternalModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class PluginConfExternalModel:
|
||||
"""Holds information about a plugin instance for one user.
|
||||
|
||||
Attributes:
|
||||
capabilities (list[str]): Capabilities the plugin provides Example: ['webhook', 'display'].
|
||||
enabled (bool): Whether the plugin instance is enabled. Example: True.
|
||||
id (int): The plugin id. Example: 25.
|
||||
module_path (str): The module path of the plugin. Example: github.com/gotify/server/plugin/example/echo.
|
||||
name (str): The plugin name. Example: RSS poller.
|
||||
token (str): The user name. For login. Example: P1234.
|
||||
author (Union[Unset, str]): The author of the plugin. Example: jmattheis.
|
||||
license_ (Union[Unset, str]): The license of the plugin. Example: MIT.
|
||||
website (Union[Unset, str]): The website of the plugin. Example: gotify.net.
|
||||
"""
|
||||
|
||||
capabilities: list[str]
|
||||
enabled: bool
|
||||
id: int
|
||||
module_path: str
|
||||
name: str
|
||||
token: str
|
||||
author: Union[Unset, str] = UNSET
|
||||
license_: Union[Unset, str] = UNSET
|
||||
website: Union[Unset, str] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
capabilities = self.capabilities
|
||||
|
||||
enabled = self.enabled
|
||||
|
||||
id = self.id
|
||||
|
||||
module_path = self.module_path
|
||||
|
||||
name = self.name
|
||||
|
||||
token = self.token
|
||||
|
||||
author = self.author
|
||||
|
||||
license_ = self.license_
|
||||
|
||||
website = self.website
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"capabilities": capabilities,
|
||||
"enabled": enabled,
|
||||
"id": id,
|
||||
"modulePath": module_path,
|
||||
"name": name,
|
||||
"token": token,
|
||||
}
|
||||
)
|
||||
if author is not UNSET:
|
||||
field_dict["author"] = author
|
||||
if license_ is not UNSET:
|
||||
field_dict["license"] = license_
|
||||
if website is not UNSET:
|
||||
field_dict["website"] = website
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
capabilities = cast(list[str], d.pop("capabilities"))
|
||||
|
||||
enabled = d.pop("enabled")
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
module_path = d.pop("modulePath")
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
token = d.pop("token")
|
||||
|
||||
author = d.pop("author", UNSET)
|
||||
|
||||
license_ = d.pop("license", UNSET)
|
||||
|
||||
website = d.pop("website", UNSET)
|
||||
|
||||
plugin_conf_external_model = cls(
|
||||
capabilities=capabilities,
|
||||
enabled=enabled,
|
||||
id=id,
|
||||
module_path=module_path,
|
||||
name=name,
|
||||
token=token,
|
||||
author=author,
|
||||
license_=license_,
|
||||
website=website,
|
||||
)
|
||||
|
||||
plugin_conf_external_model.additional_properties = d
|
||||
return plugin_conf_external_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
79
gotify_rest_api_client/models/update_user_external_model.py
Normal file
79
gotify_rest_api_client/models/update_user_external_model.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="UpdateUserExternalModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UpdateUserExternalModel:
|
||||
"""Used for updating a user.
|
||||
|
||||
Attributes:
|
||||
admin (bool): If the user is an administrator. Example: True.
|
||||
name (str): The user name. For login. Example: unicorn.
|
||||
pass_ (Union[Unset, str]): The user password. For login. Empty for using old password Example: nrocinu.
|
||||
"""
|
||||
|
||||
admin: bool
|
||||
name: str
|
||||
pass_: Union[Unset, str] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
admin = self.admin
|
||||
|
||||
name = self.name
|
||||
|
||||
pass_ = self.pass_
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"admin": admin,
|
||||
"name": name,
|
||||
}
|
||||
)
|
||||
if pass_ is not UNSET:
|
||||
field_dict["pass"] = pass_
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
admin = d.pop("admin")
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
pass_ = d.pop("pass", UNSET)
|
||||
|
||||
update_user_external_model = cls(
|
||||
admin=admin,
|
||||
name=name,
|
||||
pass_=pass_,
|
||||
)
|
||||
|
||||
update_user_external_model.additional_properties = d
|
||||
return update_user_external_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
73
gotify_rest_api_client/models/upload_app_image_body.py
Normal file
73
gotify_rest_api_client/models/upload_app_image_body.py
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
from collections.abc import Mapping
|
||||
from io import BytesIO
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from .. import types
|
||||
from ..types import File
|
||||
|
||||
T = TypeVar("T", bound="UploadAppImageBody")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UploadAppImageBody:
|
||||
"""
|
||||
Attributes:
|
||||
file (File): the application image
|
||||
"""
|
||||
|
||||
file: File
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
file = self.file.to_tuple()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"file": file,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
files.append(("file", self.file.to_tuple()))
|
||||
|
||||
for prop_name, prop in self.additional_properties.items():
|
||||
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
||||
|
||||
return files
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
file = File(payload=BytesIO(d.pop("file")))
|
||||
|
||||
upload_app_image_body = cls(
|
||||
file=file,
|
||||
)
|
||||
|
||||
upload_app_image_body.additional_properties = d
|
||||
return upload_app_image_body
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
76
gotify_rest_api_client/models/user_external_model.py
Normal file
76
gotify_rest_api_client/models/user_external_model.py
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="UserExternalModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserExternalModel:
|
||||
"""The User holds information about permission and other stuff.
|
||||
|
||||
Attributes:
|
||||
admin (bool): If the user is an administrator. Example: True.
|
||||
id (int): The user id. Example: 25.
|
||||
name (str): The user name. For login. Example: unicorn.
|
||||
"""
|
||||
|
||||
admin: bool
|
||||
id: int
|
||||
name: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
admin = self.admin
|
||||
|
||||
id = self.id
|
||||
|
||||
name = self.name
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"admin": admin,
|
||||
"id": id,
|
||||
"name": name,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
admin = d.pop("admin")
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
user_external_model = cls(
|
||||
admin=admin,
|
||||
id=id,
|
||||
name=name,
|
||||
)
|
||||
|
||||
user_external_model.additional_properties = d
|
||||
return user_external_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
60
gotify_rest_api_client/models/user_external_pass_model.py
Normal file
60
gotify_rest_api_client/models/user_external_pass_model.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="UserExternalPassModel")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserExternalPassModel:
|
||||
"""The Password for updating the user.
|
||||
|
||||
Attributes:
|
||||
pass_ (str): The user password. For login. Example: nrocinu.
|
||||
"""
|
||||
|
||||
pass_: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
pass_ = self.pass_
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"pass": pass_,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
pass_ = d.pop("pass")
|
||||
|
||||
user_external_pass_model = cls(
|
||||
pass_=pass_,
|
||||
)
|
||||
|
||||
user_external_pass_model.additional_properties = d
|
||||
return user_external_pass_model
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
77
gotify_rest_api_client/models/version_info.py
Normal file
77
gotify_rest_api_client/models/version_info.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="VersionInfo")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class VersionInfo:
|
||||
"""VersionInfo Model
|
||||
|
||||
Attributes:
|
||||
build_date (str): The date on which this binary was built. Example: 2018-02-27 19:36:10.504504+01:00.
|
||||
commit (str): The git commit hash on which this binary was built. Example:
|
||||
ae9512b6b6feea56a110d59a3353ea3b9c293864.
|
||||
version (str): The current version. Example: 5.2.6.
|
||||
"""
|
||||
|
||||
build_date: str
|
||||
commit: str
|
||||
version: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
build_date = self.build_date
|
||||
|
||||
commit = self.commit
|
||||
|
||||
version = self.version
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"buildDate": build_date,
|
||||
"commit": commit,
|
||||
"version": version,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
build_date = d.pop("buildDate")
|
||||
|
||||
commit = d.pop("commit")
|
||||
|
||||
version = d.pop("version")
|
||||
|
||||
version_info = cls(
|
||||
build_date=build_date,
|
||||
commit=commit,
|
||||
version=version,
|
||||
)
|
||||
|
||||
version_info.additional_properties = d
|
||||
return version_info
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
1
gotify_rest_api_client/py.typed
Normal file
1
gotify_rest_api_client/py.typed
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Marker file for PEP 561
|
||||
54
gotify_rest_api_client/types.py
Normal file
54
gotify_rest_api_client/types.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
"""Contains some shared types for properties"""
|
||||
|
||||
from collections.abc import Mapping, MutableMapping
|
||||
from http import HTTPStatus
|
||||
from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union
|
||||
|
||||
from attrs import define
|
||||
|
||||
|
||||
class Unset:
|
||||
def __bool__(self) -> Literal[False]:
|
||||
return False
|
||||
|
||||
|
||||
UNSET: Unset = Unset()
|
||||
|
||||
# The types that `httpx.Client(files=)` can accept, copied from that library.
|
||||
FileContent = Union[IO[bytes], bytes, str]
|
||||
FileTypes = Union[
|
||||
# (filename, file (or bytes), content_type)
|
||||
tuple[Optional[str], FileContent, Optional[str]],
|
||||
# (filename, file (or bytes), content_type, headers)
|
||||
tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
|
||||
]
|
||||
RequestFiles = list[tuple[str, FileTypes]]
|
||||
|
||||
|
||||
@define
|
||||
class File:
|
||||
"""Contains information for file uploads"""
|
||||
|
||||
payload: BinaryIO
|
||||
file_name: Optional[str] = None
|
||||
mime_type: Optional[str] = None
|
||||
|
||||
def to_tuple(self) -> FileTypes:
|
||||
"""Return a tuple representation that httpx will accept for multipart/form-data"""
|
||||
return self.file_name, self.payload, self.mime_type
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
@define
|
||||
class Response(Generic[T]):
|
||||
"""A response from an endpoint"""
|
||||
|
||||
status_code: HTTPStatus
|
||||
content: bytes
|
||||
headers: MutableMapping[str, str]
|
||||
parsed: Optional[T]
|
||||
|
||||
|
||||
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
|
||||
|
|
@ -54,7 +54,7 @@ INSTALLED_APPS = [
|
|||
'apps.core',
|
||||
'apps.users',
|
||||
'apps.gooyal_oauth2',
|
||||
'apps.stores',
|
||||
# 'apps.stores',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
|||
140
utils/clients/gotify.py
Normal file
140
utils/clients/gotify.py
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
import time
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import requests
|
||||
# from django.conf import settings
|
||||
# from django.core.cache import cache
|
||||
from django.db import models
|
||||
from httpx import Request
|
||||
|
||||
from gotify_rest_api_client import AuthenticatedClient
|
||||
from gotify_rest_api_client.models import *
|
||||
from gotify_rest_api_client.api.message import create_message
|
||||
from gotify_rest_api_client.api.user import create_user
|
||||
from gotify_rest_api_client.api.client import create_client
|
||||
from gotify_rest_api_client.api.application import create_app
|
||||
|
||||
ADMIN_CLIENT_TOKEN = 'CbWdsJrmRTDzbuD'
|
||||
|
||||
import logging
|
||||
|
||||
# logging.basicConfig(
|
||||
# format="%(levelname)s [%(asctime)s] %(name)s - %(message)s",
|
||||
# datefmt="%Y-%m-%d %H:%M:%S",
|
||||
# level=logging.DEBUG
|
||||
# )
|
||||
logger = logging.getLogger('utils.gotify_clients')
|
||||
|
||||
|
||||
def log_request(request: Request):
|
||||
logger.debug(f'authorization: {request.headers["authorization"]}')
|
||||
logger.debug(
|
||||
f"Request event hook: {request.method} {request.url} {request.method} {request.headers} - Waiting for response")
|
||||
|
||||
|
||||
def log_response(response):
|
||||
request = response.request
|
||||
logger.debug(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
||||
# logger.debug(f"Response event hook: {response.read()}")
|
||||
|
||||
|
||||
def get_client(access_token):
|
||||
client = AuthenticatedClient(base_url="https://push.gooyal.com", token=access_token,
|
||||
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
||||
)
|
||||
return client
|
||||
|
||||
|
||||
def get_basic_client(username, password):
|
||||
auth = httpx.BasicAuth(username=username, password=password)
|
||||
prefix, token = auth._auth_header.split()
|
||||
|
||||
# httpx_client = httpx.Client(auth=auth, base_url="https://push.gooyal.com")
|
||||
client = AuthenticatedClient(base_url="https://push.gooyal.com", token=token, prefix=prefix,
|
||||
httpx_args={
|
||||
"event_hooks": {"request": [log_request], "response": [log_response]},
|
||||
# "auth": auth,
|
||||
# "base_url": "https://push.gooyal.com"
|
||||
}
|
||||
)
|
||||
# client.set_httpx_client(httpx_client)
|
||||
return client
|
||||
|
||||
|
||||
def send_notif(data):
|
||||
class Tmp():
|
||||
def to_dict(self):
|
||||
return data
|
||||
|
||||
final_data = Tmp()
|
||||
client = get_client()
|
||||
response: Any = create_message.sync(client=client, body=final_data)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def submit_user(user_uuid):
|
||||
data_dict = {
|
||||
"admin": False,
|
||||
"name": user_uuid,
|
||||
"pass": user_uuid
|
||||
}
|
||||
|
||||
class Tmp():
|
||||
def to_dict(self):
|
||||
return data_dict
|
||||
|
||||
final_data = Tmp()
|
||||
client = get_client(ADMIN_CLIENT_TOKEN)
|
||||
response: Any = create_user.sync(client=client, body=final_data)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def submit_client(user_uuid):
|
||||
data_dict = {
|
||||
"name": user_uuid,
|
||||
}
|
||||
|
||||
class Tmp():
|
||||
def to_dict(self):
|
||||
return data_dict
|
||||
|
||||
final_data = Tmp()
|
||||
client = get_basic_client(user_uuid, user_uuid)
|
||||
response: Any = create_client.sync(client=client, body=final_data)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def submit_application(token, user_uuid):
|
||||
data_dict = {
|
||||
"defaultPriority": 5,
|
||||
"description": None,
|
||||
"name": user_uuid
|
||||
}
|
||||
|
||||
class Tmp():
|
||||
def to_dict(self):
|
||||
return data_dict
|
||||
|
||||
final_data = Tmp()
|
||||
client = get_client(token)
|
||||
response: Any = create_app.sync(client=client, body=final_data)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
sample_data = {
|
||||
"message": "**Backup** was successfully finished.",
|
||||
"priority": 2,
|
||||
"title": "Backup"
|
||||
}
|
||||
|
||||
# ClientModel(id=20, name='820c1110-a3bd-47ce-a3f4-f8d2dd70fa9f', token='CbNecn03yWNIl93', last_used=None, additional_properties={})
|
||||
|
||||
# send_notif(sample_data)
|
||||
# print(submit_user('820c1110-a3bd-47ce-a3f4-f8d2dd70fa9f'))
|
||||
# print(submit_client('820c1110-a3bd-47ce-a3f4-f8d2dd70fa9f'))
|
||||
print(submit_application('CbNecn03yWNIl93','820c1110-a3bd-47ce-a3f4-f8d2dd70fa9f'))
|
||||
2678
utils/clients/openapi.json
Normal file
2678
utils/clients/openapi.json
Normal file
File diff suppressed because it is too large
Load diff
2002
utils/clients/openapi.yaml
Normal file
2002
utils/clients/openapi.yaml
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue