Skip to content

Commit

Permalink
fix: timespan to string
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuochi committed Mar 20, 2023
1 parent fe2c5dc commit 2091423
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 139 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Sonarr API docs
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 3.0.0
- Package version: 0.0.1
- Package version: 0.5.1
- Build package: org.openapitools.codegen.languages.PythonNextgenClientCodegen

## Requirements.
Expand Down Expand Up @@ -295,7 +295,7 @@ Class | Method | HTTP request | Description
*SeriesEditorApi* | [**delete_series_editor**](docs/SeriesEditorApi.md#delete_series_editor) | **DELETE** /api/v3/series/editor |
*SeriesEditorApi* | [**put_series_editor**](docs/SeriesEditorApi.md#put_series_editor) | **PUT** /api/v3/series/editor |
*SeriesImportApi* | [**create_series_import**](docs/SeriesImportApi.md#create_series_import) | **POST** /api/v3/series/import |
*SeriesLookupApi* | [**get_series_lookup**](docs/SeriesLookupApi.md#get_series_lookup) | **GET** /api/v3/series/lookup |
*SeriesLookupApi* | [**list_series_lookup**](docs/SeriesLookupApi.md#list_series_lookup) | **GET** /api/v3/series/lookup |
*StaticResourceApi* | [**get**](docs/StaticResourceApi.md#get) | **GET** / |
*StaticResourceApi* | [**get_by_path**](docs/StaticResourceApi.md#get_by_path) | **GET** /{path} |
*StaticResourceApi* | [**get_content_by_path**](docs/StaticResourceApi.md#get_content_by_path) | **GET** /content/{path} |
Expand Down Expand Up @@ -364,7 +364,6 @@ Class | Method | HTTP request | Description
- [HistoryResource](docs/HistoryResource.md)
- [HistoryResourcePagingResource](docs/HistoryResourcePagingResource.md)
- [HostConfigResource](docs/HostConfigResource.md)
- [HttpUri](docs/HttpUri.md)
- [ImportListExclusionResource](docs/ImportListExclusionResource.md)
- [ImportListResource](docs/ImportListResource.md)
- [ImportListType](docs/ImportListType.md)
Expand Down Expand Up @@ -437,7 +436,6 @@ Class | Method | HTTP request | Description
- [TagDetailsResource](docs/TagDetailsResource.md)
- [TagResource](docs/TagResource.md)
- [TaskResource](docs/TaskResource.md)
- [TimeSpan](docs/TimeSpan.md)
- [TrackedDownloadState](docs/TrackedDownloadState.md)
- [TrackedDownloadStatus](docs/TrackedDownloadStatus.md)
- [TrackedDownloadStatusMessage](docs/TrackedDownloadStatusMessage.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/CommandResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Name | Type | Description | Notes
**queued** | **datetime** | | [optional]
**started** | **datetime** | | [optional]
**ended** | **datetime** | | [optional]
**duration** | [**TimeSpan**](TimeSpan.md) | | [optional]
**duration** | **str** | | [optional]
**exception** | **str** | | [optional]
**trigger** | [**CommandTrigger**](CommandTrigger.md) | | [optional]
**client_user_agent** | **str** | | [optional]
Expand Down
2 changes: 1 addition & 1 deletion docs/ImportListResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Name | Type | Description | Notes
**season_folder** | **bool** | | [optional]
**list_type** | [**ImportListType**](ImportListType.md) | | [optional]
**list_order** | **int** | | [optional]
**min_refresh_interval** | [**TimeSpan**](TimeSpan.md) | | [optional]
**min_refresh_interval** | **str** | | [optional]

## Example

Expand Down
2 changes: 1 addition & 1 deletion docs/QueueResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Name | Type | Description | Notes
**size** | **float** | | [optional]
**title** | **str** | | [optional]
**sizeleft** | **float** | | [optional]
**timeleft** | [**TimeSpan**](TimeSpan.md) | | [optional]
**timeleft** | **str** | | [optional]
**estimated_completion_time** | **datetime** | | [optional]
**status** | **str** | | [optional]
**tracked_download_status** | [**TrackedDownloadStatus**](TrackedDownloadStatus.md) | | [optional]
Expand Down
2 changes: 1 addition & 1 deletion docs/TaskResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Name | Type | Description | Notes
**last_execution** | **datetime** | | [optional]
**last_start_time** | **datetime** | | [optional]
**next_execution** | **datetime** | | [optional]
**last_duration** | [**TimeSpan**](TimeSpan.md) | | [optional]
**last_duration** | **str** | | [optional]

## Example

Expand Down
3 changes: 1 addition & 2 deletions sonarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import absolute_import

__version__ = "0.0.1"
__version__ = "0.5.1"

# import apis into sdk package
from sonarr.api.api_info_api import ApiInfoApi
Expand Down Expand Up @@ -208,7 +208,6 @@
from sonarr.models.tag_details_resource import TagDetailsResource
from sonarr.models.tag_resource import TagResource
from sonarr.models.task_resource import TaskResource
from sonarr.models.time_span import TimeSpan
from sonarr.models.tracked_download_state import TrackedDownloadState
from sonarr.models.tracked_download_status import TrackedDownloadStatus
from sonarr.models.tracked_download_status_message import TrackedDownloadStatusMessage
Expand Down
1 change: 0 additions & 1 deletion sonarr/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
from sonarr.models.tag_details_resource import TagDetailsResource
from sonarr.models.tag_resource import TagResource
from sonarr.models.task_resource import TaskResource
from sonarr.models.time_span import TimeSpan
from sonarr.models.tracked_download_state import TrackedDownloadState
from sonarr.models.tracked_download_status import TrackedDownloadStatus
from sonarr.models.tracked_download_status_message import TrackedDownloadStatusMessage
Expand Down
14 changes: 8 additions & 6 deletions sonarr/models/command_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from sonarr.models.command_priority import CommandPriority
from sonarr.models.command_status import CommandStatus
from sonarr.models.command_trigger import CommandTrigger
from sonarr.models.time_span import TimeSpan

class CommandResource(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand All @@ -41,7 +40,7 @@ class CommandResource(BaseModel):
queued: Optional[datetime]
started: Optional[datetime]
ended: Optional[datetime]
duration: Optional[TimeSpan]
duration: Optional[str]
exception: Optional[str]
trigger: Optional[CommandTrigger]
client_user_agent: Optional[str]
Expand All @@ -51,6 +50,12 @@ class CommandResource(BaseModel):
last_execution_time: Optional[datetime]
__properties = ["id", "name", "commandName", "message", "body", "priority", "status", "queued", "started", "ended", "duration", "exception", "trigger", "clientUserAgent", "stateChangeTime", "sendUpdatesToClient", "updateScheduledTask", "lastExecutionTime"]

@validator('duration')
def duration_validate_regular_expression(cls, v):
if not re.match(r"\d{2}:\d{2}:\d{2}", v):
raise ValueError(r"must validate the regular expression /\d{2}:\d{2}:\d{2}/")
return v

class Config:
allow_population_by_field_name = True
validate_assignment = True
Expand Down Expand Up @@ -81,9 +86,6 @@ def to_dict(self):
# override the default output from pydantic by calling `to_dict()` of body
if self.body:
_dict['body'] = self.body.to_dict()
# override the default output from pydantic by calling `to_dict()` of duration
if self.duration:
_dict['duration'] = self.duration.to_dict()
# set to None if name (nullable) is None
if self.name is None:
_dict['name'] = None
Expand Down Expand Up @@ -142,7 +144,7 @@ def from_dict(cls, obj: dict) -> CommandResource:
"queued": obj.get("queued"),
"started": obj.get("started"),
"ended": obj.get("ended"),
"duration": TimeSpan.from_dict(obj.get("duration")) if obj.get("duration") is not None else None,
"duration": obj.get("duration"),
"exception": obj.get("exception"),
"trigger": obj.get("trigger"),
"client_user_agent": obj.get("clientUserAgent"),
Expand Down
14 changes: 8 additions & 6 deletions sonarr/models/import_list_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from sonarr.models.monitor_types import MonitorTypes
from sonarr.models.provider_message import ProviderMessage
from sonarr.models.series_types import SeriesTypes
from sonarr.models.time_span import TimeSpan

class ImportListResource(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand All @@ -50,9 +49,15 @@ class ImportListResource(BaseModel):
season_folder: Optional[bool]
list_type: Optional[ImportListType]
list_order: Optional[int]
min_refresh_interval: Optional[TimeSpan]
min_refresh_interval: Optional[str]
__properties = ["id", "name", "fields", "implementationName", "implementation", "configContract", "infoLink", "message", "tags", "presets", "enableAutomaticAdd", "shouldMonitor", "rootFolderPath", "qualityProfileId", "seriesType", "seasonFolder", "listType", "listOrder", "minRefreshInterval"]

@validator('min_refresh_interval')
def min_refresh_interval_validate_regular_expression(cls, v):
if not re.match(r"\d{2}:\d{2}:\d{2}", v):
raise ValueError(r"must validate the regular expression /\d{2}:\d{2}:\d{2}/")
return v

class Config:
allow_population_by_field_name = True
validate_assignment = True
Expand Down Expand Up @@ -97,9 +102,6 @@ def to_dict(self):
if _item:
_items.append(_item.to_dict())
_dict['presets'] = _items
# override the default output from pydantic by calling `to_dict()` of min_refresh_interval
if self.min_refresh_interval:
_dict['minRefreshInterval'] = self.min_refresh_interval.to_dict()
# set to None if name (nullable) is None
if self.name is None:
_dict['name'] = None
Expand Down Expand Up @@ -166,7 +168,7 @@ def from_dict(cls, obj: dict) -> ImportListResource:
"season_folder": obj.get("seasonFolder"),
"list_type": obj.get("listType"),
"list_order": obj.get("listOrder"),
"min_refresh_interval": TimeSpan.from_dict(obj.get("minRefreshInterval")) if obj.get("minRefreshInterval") is not None else None
"min_refresh_interval": obj.get("minRefreshInterval")
})
return _obj

14 changes: 8 additions & 6 deletions sonarr/models/queue_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from sonarr.models.language import Language
from sonarr.models.quality_model import QualityModel
from sonarr.models.series_resource import SeriesResource
from sonarr.models.time_span import TimeSpan
from sonarr.models.tracked_download_state import TrackedDownloadState
from sonarr.models.tracked_download_status import TrackedDownloadStatus
from sonarr.models.tracked_download_status_message import TrackedDownloadStatusMessage
Expand All @@ -47,7 +46,7 @@ class QueueResource(BaseModel):
size: Optional[float]
title: Optional[str]
sizeleft: Optional[float]
timeleft: Optional[TimeSpan]
timeleft: Optional[str]
estimated_completion_time: Optional[datetime]
status: Optional[str]
tracked_download_status: Optional[TrackedDownloadStatus]
Expand All @@ -61,6 +60,12 @@ class QueueResource(BaseModel):
output_path: Optional[str]
__properties = ["id", "seriesId", "episodeId", "series", "episode", "languages", "quality", "customFormats", "size", "title", "sizeleft", "timeleft", "estimatedCompletionTime", "status", "trackedDownloadStatus", "trackedDownloadState", "statusMessages", "errorMessage", "downloadId", "protocol", "downloadClient", "indexer", "outputPath"]

@validator('timeleft')
def timeleft_validate_regular_expression(cls, v):
if not re.match(r"\d{2}:\d{2}:\d{2}", v):
raise ValueError(r"must validate the regular expression /\d{2}:\d{2}:\d{2}/")
return v

class Config:
allow_population_by_field_name = True
validate_assignment = True
Expand Down Expand Up @@ -111,9 +116,6 @@ def to_dict(self):
if _item:
_items.append(_item.to_dict())
_dict['customFormats'] = _items
# override the default output from pydantic by calling `to_dict()` of timeleft
if self.timeleft:
_dict['timeleft'] = self.timeleft.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in status_messages (list)
_items = []
if self.status_messages:
Expand Down Expand Up @@ -196,7 +198,7 @@ def from_dict(cls, obj: dict) -> QueueResource:
"size": obj.get("size"),
"title": obj.get("title"),
"sizeleft": obj.get("sizeleft"),
"timeleft": TimeSpan.from_dict(obj.get("timeleft")) if obj.get("timeleft") is not None else None,
"timeleft": obj.get("timeleft"),
"estimated_completion_time": obj.get("estimatedCompletionTime"),
"status": obj.get("status"),
"tracked_download_status": obj.get("trackedDownloadStatus"),
Expand Down
14 changes: 8 additions & 6 deletions sonarr/models/task_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from datetime import datetime
from typing import Optional
from pydantic import BaseModel
from sonarr.models.time_span import TimeSpan

class TaskResource(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand All @@ -34,9 +33,15 @@ class TaskResource(BaseModel):
last_execution: Optional[datetime]
last_start_time: Optional[datetime]
next_execution: Optional[datetime]
last_duration: Optional[TimeSpan]
last_duration: Optional[str]
__properties = ["id", "name", "taskName", "interval", "lastExecution", "lastStartTime", "nextExecution", "lastDuration"]

@validator('last_duration')
def last_duration_validate_regular_expression(cls, v):
if not re.match(r"\d{2}:\d{2}:\d{2}", v):
raise ValueError(r"must validate the regular expression /\d{2}:\d{2}:\d{2}/")
return v

class Config:
allow_population_by_field_name = True
validate_assignment = True
Expand Down Expand Up @@ -64,9 +69,6 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of last_duration
if self.last_duration:
_dict['lastDuration'] = self.last_duration.to_dict()
# set to None if name (nullable) is None
if self.name is None:
_dict['name'] = None
Expand Down Expand Up @@ -94,7 +96,7 @@ def from_dict(cls, obj: dict) -> TaskResource:
"last_execution": obj.get("lastExecution"),
"last_start_time": obj.get("lastStartTime"),
"next_execution": obj.get("nextExecution"),
"last_duration": TimeSpan.from_dict(obj.get("lastDuration")) if obj.get("lastDuration") is not None else None
"last_duration": obj.get("lastDuration")
})
return _obj

104 changes: 0 additions & 104 deletions sonarr/models/time_span.py

This file was deleted.

0 comments on commit 2091423

Please sign in to comment.