Skip to content

feat: v2 #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
64 changes: 32 additions & 32 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies and library
run: poetry install
- name: Check format
run: poetry run black --check .
run: poetry run ruff format -q

typing:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,34 +88,34 @@ jobs:
- name: Check linting
run: poetry run ruff check . --ignore E721 --ignore F541

tests:
runs-on: ubuntu-latest
strategy:
matrix:
lib:
- scaleway-core
- scaleway
- scaleway-async
defaults:
run:
working-directory: ${{ matrix.lib }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install poetry
run: |
pip install poetry
poetry --version
- name: Install dependencies and library
run: poetry install
- name: Run tests
run: poetry run python -m unittest discover -s tests -v
env:
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }}
SCW_DEFAULT_ZONE: ${{ secrets.SCW_DEFAULT_ZONE }}
# tests:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# lib:
# - scaleway-core
# - scaleway
# - scaleway-async
# defaults:
# run:
# working-directory: ${{ matrix.lib }}
# steps:
# - uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.8
# - name: Install poetry
# run: |
# pip install poetry
# poetry --version
# - name: Install dependencies and library
# run: poetry install
# - name: Run tests
# run: poetry run python -m unittest discover -s tests -v
# env:
# SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
# SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
# SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
# SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }}
# SCW_DEFAULT_ZONE: ${{ secrets.SCW_DEFAULT_ZONE }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
- name: Wait for package to be available
run: sleep 10
run: sleep 60

release:
needs:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ install-only-root:
format:
for lib in $(LIBRARIES); do \
cd ${WORKDIR}/$$lib && \
poetry run black --version && \
poetry run black ./; \
poetry run ruff --version && \
poetry run ruff format; \
done

format-check:
for lib in $(LIBRARIES); do \
cd ${WORKDIR}/$$lib && \
poetry run black --version && \
poetry run black --check ./; \
poetry run ruff --version && \
poetry run ruff format --check; \
done

typing:
Expand Down
280 changes: 168 additions & 112 deletions docs/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scaleway-docs"
version = "1.0.0"
version = "2.0.0"
description = ""
authors = ["Scaleway <opensource@scaleway.com>"]
license = "BSD"
Expand Down
391 changes: 152 additions & 239 deletions scaleway-async/poetry.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions scaleway-async/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scaleway-async"
version = "0.0.1"
version = "2.0.0"
description = "Scaleway SDK for Python"
authors = ["Scaleway <opensource@scaleway.com>"]
license = "BSD"
Expand All @@ -24,13 +24,12 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.8"
scaleway-core = "^1"
scaleway-core = "*"

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

[build-system]
requires = ["poetry-core"]
Expand Down
14 changes: 12 additions & 2 deletions scaleway-async/scaleway_async/account/v2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# This file was automatically generated. DO NOT EDIT.
# If you have any remark or suggestion do not hesitate to open an issue.
from .types import ListProjectsRequestOrderBy
from .types import ListProjectsResponse
from .types import Project
from .types import CreateProjectRequest
from .types import DeleteProjectRequest
from .types import GetProjectRequest
from .types import ListProjectsRequest
from .types import ListProjectsResponse
from .types import UpdateProjectRequest
from .api import AccountV2API

__all__ = [
"ListProjectsRequestOrderBy",
"ListProjectsResponse",
"Project",
"CreateProjectRequest",
"DeleteProjectRequest",
"GetProjectRequest",
"ListProjectsRequest",
"ListProjectsResponse",
"UpdateProjectRequest",
"AccountV2API",
]
22 changes: 9 additions & 13 deletions scaleway-async/scaleway_async/account/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,27 @@

from scaleway_core.api import API
from scaleway_core.utils import (
fetch_all_pages_async,
random_name,
validate_path_param,
fetch_all_pages_async,
)
from .types import (
ListProjectsRequestOrderBy,
CreateProjectRequest,
ListProjectsResponse,
Project,
CreateProjectRequest,
UpdateProjectRequest,
)
from .marshalling import (
marshal_CreateProjectRequest,
marshal_UpdateProjectRequest,
unmarshal_Project,
unmarshal_ListProjectsResponse,
marshal_CreateProjectRequest,
marshal_UpdateProjectRequest,
)


class AccountV2API(API):
"""
Account API.

User related data.
This API allows you to manage projects.
"""

Expand Down Expand Up @@ -57,7 +54,7 @@ async def create_project(

res = self._request(
"POST",
f"/account/v2/projects",
"/account/v2/projects",
body=marshal_CreateProjectRequest(
CreateProjectRequest(
name=name or random_name(prefix="proj"),
Expand All @@ -78,7 +75,7 @@ async def list_projects(
name: Optional[str] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: ListProjectsRequestOrderBy = ListProjectsRequestOrderBy.CREATED_AT_ASC,
order_by: Optional[ListProjectsRequestOrderBy] = None,
project_ids: Optional[List[str]] = None,
) -> ListProjectsResponse:
"""
Expand All @@ -102,7 +99,7 @@ async def list_projects(

res = self._request(
"GET",
f"/account/v2/projects",
"/account/v2/projects",
params={
"name": name,
"order_by": order_by,
Expand Down Expand Up @@ -137,7 +134,7 @@ async def list_projects_all(
:param page_size: Maximum number of Project per page.
:param order_by: Sort order of the returned Projects.
:param project_ids: Project IDs to filter for. The results will be limited to any Projects with an ID in this array.
:return: :class:`List[ListProjectsResponse] <List[ListProjectsResponse]>`
:return: :class:`List[Project] <List[Project]>`
:deprecated

Usage:
Expand Down Expand Up @@ -195,7 +192,7 @@ async def delete_project(
self,
*,
project_id: Optional[str] = None,
) -> Optional[None]:
) -> None:
"""
Delete an existing Project.
Deprecated in favor of Account API v3.
Expand All @@ -219,7 +216,6 @@ async def delete_project(
)

self._throw_on_error(res)
return None

async def update_project(
self,
Expand Down
64 changes: 36 additions & 28 deletions scaleway-async/scaleway_async/account/v2/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,69 @@
# If you have any remark or suggestion do not hesitate to open an issue.

from typing import Any, Dict
from dateutil import parser

from scaleway_core.profile import ProfileDefaults
from dateutil import parser
from .types import (
ListProjectsResponse,
Project,
ListProjectsResponse,
CreateProjectRequest,
UpdateProjectRequest,
)


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

args: Dict[str, Any] = {}

field = data.get("created_at", None)
args["created_at"] = parser.isoparse(field) if type(field) is str else field

field = data.get("description", None)
args["description"] = field

field = data.get("id", None)
args["id"] = field
if field is not None:
args["id"] = field

field = data.get("name", None)
args["name"] = field
if field is not None:
args["name"] = field

field = data.get("organization_id", None)
args["organization_id"] = field
if field is not None:
args["organization_id"] = field

field = data.get("description", None)
if field is not None:
args["description"] = field

field = data.get("created_at", None)
if field is not None:
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field

field = data.get("updated_at", None)
args["updated_at"] = parser.isoparse(field) if type(field) is str else field
if field is not None:
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field

return Project(**args)


def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse:
if type(data) is not dict:
if not isinstance(data, dict):
raise TypeError(
f"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("projects", None)
args["projects"] = (
[unmarshal_Project(v) for v in field] if field is not None else None
)

field = data.get("total_count", None)
args["total_count"] = field
if field is not None:
args["total_count"] = field

field = data.get("projects", None)
if field is not None:
args["projects"] = (
[unmarshal_Project(v) for v in field] if field is not None else None
)

return ListProjectsResponse(**args)

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

if request.description is not None:
output["description"] = request.description

if request.name is not None:
output["name"] = request.name

Expand All @@ -78,6 +83,9 @@ def marshal_CreateProjectRequest(
request.organization_id or defaults.default_organization_id
)

if request.description is not None:
output["description"] = request.description

return output


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

if request.description is not None:
output["description"] = request.description

if request.name is not None:
output["name"] = request.name

if request.description is not None:
output["description"] = request.description

return output
Loading