Skip to content

Commit

Permalink
Fix model mistype. schemas.ssh_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
LulzLoL231 committed Mar 12, 2023
1 parent ee72165 commit 202bdcd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "timeweb-cloud"
version = "0.12.1"
version = "0.12.2"
description = "Timeweb Cloud API wrapper"
authors = ["Maxim Mosin <max@mosin.pw>"]
license = "MIT"
Expand Down Expand Up @@ -42,7 +42,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.bumpver]
current_version = "0.12.1"
current_version = "0.12.2"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "Bump version {old_version} -> {new_version}"
commit = false
Expand Down
2 changes: 1 addition & 1 deletion src/timeweb/__meta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
'''Timeweb Cloud package metadata'''
__version__ = '0.12.1'
__version__ = '0.12.2'
__author__ = 'Maxim Mosin <max@mosin.pw>'
13 changes: 8 additions & 5 deletions src/timeweb/async_api/ssh_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,17 @@ async def update(
Returns:
schemas.SSHKeyResponse: Обновленный SSH-ключ.
'''
data: dict[str, str] = {}
if name:
data['name'] = name
if body:
data['body'] = body
if is_default:
data['is_default'] = is_default
key = await self._request(
'PATCH',
f'/ssh-keys/{ssh_key_id}',
json={
'name': name,
'body': body,
'is_default': is_default,
},
json=data
)
return schemas.SSHKeyResponse(**key.json())

Expand Down
9 changes: 4 additions & 5 deletions src/timeweb/schemas/ssh_keys/ssh_keys.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
'''Модели для работы с SSH ключами'''
from uuid import UUID
from datetime import datetime

from pydantic import Field
Expand All @@ -12,25 +11,25 @@ class Server(BaseData):
'''Модель сервера.
Attributes:
id (UUID): Уникальный идентификатор сервера.
id (int): Уникальный идентификатор сервера.
name (str): Название сервера.
'''
id: UUID = Field(..., description='Уникальный идентификатор сервера.')
id: int = Field(..., description='Уникальный идентификатор сервера.')
name: str = Field(..., description='Название сервера.')


class SSHKey(BaseData):
'''Модель SSH ключа.
Attributes:
id (UUID): Уникальный идентификатор SSH ключа.
id (int): Уникальный идентификатор SSH ключа.
name (str): Название SSH ключа.
body (str): Тело SSH-ключа.
created_at (datetime): Дата и время создания SSH ключа.
used_by (list[Server]): Массив серверов, на которых используется SSH ключ.
is_default (bool): Будет ли выбираться SSH-ключ по умолчанию при создании сервера
'''
id: UUID = Field(..., description='Уникальный идентификатор SSH ключа.')
id: int = Field(..., description='Уникальный идентификатор SSH ключа.')
name: str = Field(..., description='Название SSH ключа.')
body: str = Field(..., description='Тело SSH-ключа.')
created_at: datetime = Field(
Expand Down
13 changes: 8 additions & 5 deletions src/timeweb/sync_api/ssh_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,17 @@ def update(
Returns:
schemas.SSHKeyResponse: Обновленный SSH-ключ.
'''
data: dict[str, str] = {}
if name:
data['name'] = name
if body:
data['body'] = body
if is_default:
data['is_default'] = is_default
key = self._request(
'PATCH',
f'/ssh-keys/{ssh_key_id}',
json={
'name': name,
'body': body,
'is_default': is_default,
},
json=data
)
return schemas.SSHKeyResponse(**key.json())

Expand Down

0 comments on commit 202bdcd

Please sign in to comment.