Skip to content

Commit 0af61d2

Browse files
authored
feat: v2 (#387)
Signed-off-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com> Co-authored-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
1 parent f00ca20 commit 0af61d2

File tree

377 files changed

+87415
-77932
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

377 files changed

+87415
-77932
lines changed

.github/workflows/checks.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install dependencies and library
3232
run: poetry install
3333
- name: Check format
34-
run: poetry run black --check .
34+
run: poetry run ruff format -q
3535

3636
typing:
3737
runs-on: ubuntu-latest
@@ -88,34 +88,34 @@ jobs:
8888
- name: Check linting
8989
run: poetry run ruff check . --ignore E721 --ignore F541
9090

91-
tests:
92-
runs-on: ubuntu-latest
93-
strategy:
94-
matrix:
95-
lib:
96-
- scaleway-core
97-
- scaleway
98-
- scaleway-async
99-
defaults:
100-
run:
101-
working-directory: ${{ matrix.lib }}
102-
steps:
103-
- uses: actions/checkout@v3
104-
- name: Set up Python
105-
uses: actions/setup-python@v4
106-
with:
107-
python-version: 3.8
108-
- name: Install poetry
109-
run: |
110-
pip install poetry
111-
poetry --version
112-
- name: Install dependencies and library
113-
run: poetry install
114-
- name: Run tests
115-
run: poetry run python -m unittest discover -s tests -v
116-
env:
117-
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
118-
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
119-
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
120-
SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }}
121-
SCW_DEFAULT_ZONE: ${{ secrets.SCW_DEFAULT_ZONE }}
91+
# tests:
92+
# runs-on: ubuntu-latest
93+
# strategy:
94+
# matrix:
95+
# lib:
96+
# - scaleway-core
97+
# - scaleway
98+
# - scaleway-async
99+
# defaults:
100+
# run:
101+
# working-directory: ${{ matrix.lib }}
102+
# steps:
103+
# - uses: actions/checkout@v3
104+
# - name: Set up Python
105+
# uses: actions/setup-python@v4
106+
# with:
107+
# python-version: 3.8
108+
# - name: Install poetry
109+
# run: |
110+
# pip install poetry
111+
# poetry --version
112+
# - name: Install dependencies and library
113+
# run: poetry install
114+
# - name: Run tests
115+
# run: poetry run python -m unittest discover -s tests -v
116+
# env:
117+
# SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
118+
# SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
119+
# SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
120+
# SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }}
121+
# SCW_DEFAULT_ZONE: ${{ secrets.SCW_DEFAULT_ZONE }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
env:
3434
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
3535
- name: Wait for package to be available
36-
run: sleep 10
36+
run: sleep 60
3737

3838
release:
3939
needs:

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ install-only-root:
2222
format:
2323
for lib in $(LIBRARIES); do \
2424
cd ${WORKDIR}/$$lib && \
25-
poetry run black --version && \
26-
poetry run black ./; \
25+
poetry run ruff --version && \
26+
poetry run ruff format; \
2727
done
2828

2929
format-check:
3030
for lib in $(LIBRARIES); do \
3131
cd ${WORKDIR}/$$lib && \
32-
poetry run black --version && \
33-
poetry run black --check ./; \
32+
poetry run ruff --version && \
33+
poetry run ruff format --check; \
3434
done
3535

3636
typing:

docs/poetry.lock

Lines changed: 168 additions & 112 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scaleway-docs"
3-
version = "1.0.0"
3+
version = "2.0.0"
44
description = ""
55
authors = ["Scaleway <opensource@scaleway.com>"]
66
license = "BSD"

scaleway-async/poetry.lock

Lines changed: 152 additions & 239 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scaleway-async/pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scaleway-async"
3-
version = "0.0.1"
3+
version = "2.0.0"
44
description = "Scaleway SDK for Python"
55
authors = ["Scaleway <opensource@scaleway.com>"]
66
license = "BSD"
@@ -24,13 +24,12 @@ classifiers = [
2424

2525
[tool.poetry.dependencies]
2626
python = "^3.8"
27-
scaleway-core = "^1"
27+
scaleway-core = "*"
2828

2929
[tool.poetry.group.dev.dependencies]
3030
scaleway-core = { path = "../scaleway-core", develop = true }
3131
ruff = "^0.0.286"
3232
mypy = "^1.5.1"
33-
black = "^23.7.0"
3433

3534
[build-system]
3635
requires = ["poetry-core"]
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33
from .types import ListProjectsRequestOrderBy
4-
from .types import ListProjectsResponse
54
from .types import Project
5+
from .types import CreateProjectRequest
6+
from .types import DeleteProjectRequest
7+
from .types import GetProjectRequest
8+
from .types import ListProjectsRequest
9+
from .types import ListProjectsResponse
10+
from .types import UpdateProjectRequest
611
from .api import AccountV2API
712

813
__all__ = [
914
"ListProjectsRequestOrderBy",
10-
"ListProjectsResponse",
1115
"Project",
16+
"CreateProjectRequest",
17+
"DeleteProjectRequest",
18+
"GetProjectRequest",
19+
"ListProjectsRequest",
20+
"ListProjectsResponse",
21+
"UpdateProjectRequest",
1222
"AccountV2API",
1323
]

scaleway-async/scaleway_async/account/v2/api.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,27 @@
55

66
from scaleway_core.api import API
77
from scaleway_core.utils import (
8-
fetch_all_pages_async,
98
random_name,
109
validate_path_param,
10+
fetch_all_pages_async,
1111
)
1212
from .types import (
1313
ListProjectsRequestOrderBy,
14+
CreateProjectRequest,
1415
ListProjectsResponse,
1516
Project,
16-
CreateProjectRequest,
1717
UpdateProjectRequest,
1818
)
1919
from .marshalling import (
20-
marshal_CreateProjectRequest,
21-
marshal_UpdateProjectRequest,
2220
unmarshal_Project,
2321
unmarshal_ListProjectsResponse,
22+
marshal_CreateProjectRequest,
23+
marshal_UpdateProjectRequest,
2424
)
2525

2626

2727
class AccountV2API(API):
2828
"""
29-
Account API.
30-
31-
User related data.
3229
This API allows you to manage projects.
3330
"""
3431

@@ -57,7 +54,7 @@ async def create_project(
5754

5855
res = self._request(
5956
"POST",
60-
f"/account/v2/projects",
57+
"/account/v2/projects",
6158
body=marshal_CreateProjectRequest(
6259
CreateProjectRequest(
6360
name=name or random_name(prefix="proj"),
@@ -78,7 +75,7 @@ async def list_projects(
7875
name: Optional[str] = None,
7976
page: Optional[int] = None,
8077
page_size: Optional[int] = None,
81-
order_by: ListProjectsRequestOrderBy = ListProjectsRequestOrderBy.CREATED_AT_ASC,
78+
order_by: Optional[ListProjectsRequestOrderBy] = None,
8279
project_ids: Optional[List[str]] = None,
8380
) -> ListProjectsResponse:
8481
"""
@@ -102,7 +99,7 @@ async def list_projects(
10299

103100
res = self._request(
104101
"GET",
105-
f"/account/v2/projects",
102+
"/account/v2/projects",
106103
params={
107104
"name": name,
108105
"order_by": order_by,
@@ -137,7 +134,7 @@ async def list_projects_all(
137134
:param page_size: Maximum number of Project per page.
138135
:param order_by: Sort order of the returned Projects.
139136
:param project_ids: Project IDs to filter for. The results will be limited to any Projects with an ID in this array.
140-
:return: :class:`List[ListProjectsResponse] <List[ListProjectsResponse]>`
137+
:return: :class:`List[Project] <List[Project]>`
141138
:deprecated
142139
143140
Usage:
@@ -195,7 +192,7 @@ async def delete_project(
195192
self,
196193
*,
197194
project_id: Optional[str] = None,
198-
) -> Optional[None]:
195+
) -> None:
199196
"""
200197
Delete an existing Project.
201198
Deprecated in favor of Account API v3.
@@ -219,7 +216,6 @@ async def delete_project(
219216
)
220217

221218
self._throw_on_error(res)
222-
return None
223219

224220
async def update_project(
225221
self,

scaleway-async/scaleway_async/account/v2/marshalling.py

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,69 @@
22
# If you have any remark or suggestion do not hesitate to open an issue.
33

44
from typing import Any, Dict
5+
from dateutil import parser
56

67
from scaleway_core.profile import ProfileDefaults
7-
from dateutil import parser
88
from .types import (
9-
ListProjectsResponse,
109
Project,
10+
ListProjectsResponse,
1111
CreateProjectRequest,
1212
UpdateProjectRequest,
1313
)
1414

1515

1616
def unmarshal_Project(data: Any) -> Project:
17-
if type(data) is not dict:
17+
if not isinstance(data, dict):
1818
raise TypeError(
19-
f"Unmarshalling the type 'Project' failed as data isn't a dictionary."
19+
"Unmarshalling the type 'Project' failed as data isn't a dictionary."
2020
)
2121

2222
args: Dict[str, Any] = {}
2323

24-
field = data.get("created_at", None)
25-
args["created_at"] = parser.isoparse(field) if type(field) is str else field
26-
27-
field = data.get("description", None)
28-
args["description"] = field
29-
3024
field = data.get("id", None)
31-
args["id"] = field
25+
if field is not None:
26+
args["id"] = field
3227

3328
field = data.get("name", None)
34-
args["name"] = field
29+
if field is not None:
30+
args["name"] = field
3531

3632
field = data.get("organization_id", None)
37-
args["organization_id"] = field
33+
if field is not None:
34+
args["organization_id"] = field
35+
36+
field = data.get("description", None)
37+
if field is not None:
38+
args["description"] = field
39+
40+
field = data.get("created_at", None)
41+
if field is not None:
42+
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
3843

3944
field = data.get("updated_at", None)
40-
args["updated_at"] = parser.isoparse(field) if type(field) is str else field
45+
if field is not None:
46+
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field
4147

4248
return Project(**args)
4349

4450

4551
def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse:
46-
if type(data) is not dict:
52+
if not isinstance(data, dict):
4753
raise TypeError(
48-
f"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
54+
"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
4955
)
5056

5157
args: Dict[str, Any] = {}
5258

53-
field = data.get("projects", None)
54-
args["projects"] = (
55-
[unmarshal_Project(v) for v in field] if field is not None else None
56-
)
57-
5859
field = data.get("total_count", None)
59-
args["total_count"] = field
60+
if field is not None:
61+
args["total_count"] = field
62+
63+
field = data.get("projects", None)
64+
if field is not None:
65+
args["projects"] = (
66+
[unmarshal_Project(v) for v in field] if field is not None else None
67+
)
6068

6169
return ListProjectsResponse(**args)
6270

@@ -67,9 +75,6 @@ def marshal_CreateProjectRequest(
6775
) -> Dict[str, Any]:
6876
output: Dict[str, Any] = {}
6977

70-
if request.description is not None:
71-
output["description"] = request.description
72-
7378
if request.name is not None:
7479
output["name"] = request.name
7580

@@ -78,6 +83,9 @@ def marshal_CreateProjectRequest(
7883
request.organization_id or defaults.default_organization_id
7984
)
8085

86+
if request.description is not None:
87+
output["description"] = request.description
88+
8189
return output
8290

8391

@@ -87,10 +95,10 @@ def marshal_UpdateProjectRequest(
8795
) -> Dict[str, Any]:
8896
output: Dict[str, Any] = {}
8997

90-
if request.description is not None:
91-
output["description"] = request.description
92-
9398
if request.name is not None:
9499
output["name"] = request.name
95100

101+
if request.description is not None:
102+
output["description"] = request.description
103+
96104
return output

0 commit comments

Comments
 (0)