Skip to content

Commit

Permalink
chore(serverless): rename job_run_id to id and job_definition_id to id (
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Nov 8, 2023
1 parent bd863b6 commit ad72f47
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 104 deletions.
66 changes: 29 additions & 37 deletions scaleway-async/scaleway_async/jobs/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,25 @@ async def create_job_definition(
async def get_job_definition(
self,
*,
job_definition_id: str,
id: str,
region: Optional[Region] = None,
) -> JobDefinition:
"""
Usage:
::
result = await api.get_job_definition(job_definition_id="example")
result = await api.get_job_definition(id="example")
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_job_definition_id = validate_path_param(
"job_definition_id", job_definition_id
)
param_id = validate_path_param("id", id)

res = self._request(
"GET",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_id}",
)

self._throw_on_error(res)
Expand Down Expand Up @@ -220,7 +218,7 @@ async def list_job_definitions_all(
async def update_job_definition(
self,
*,
job_definition_id: str,
id: str,
region: Optional[Region] = None,
name: Optional[str] = None,
cpu_limit: Optional[int] = None,
Expand All @@ -236,22 +234,20 @@ async def update_job_definition(
Usage:
::
result = await api.update_job_definition(job_definition_id="example")
result = await api.update_job_definition(id="example")
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_job_definition_id = validate_path_param(
"job_definition_id", job_definition_id
)
param_id = validate_path_param("id", id)

res = self._request(
"PATCH",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_id}",
body=marshal_UpdateJobDefinitionRequest(
UpdateJobDefinitionRequest(
job_definition_id=job_definition_id,
id=id,
region=region,
name=name,
cpu_limit=cpu_limit,
Expand All @@ -272,27 +268,25 @@ async def update_job_definition(
async def delete_job_definition(
self,
*,
job_definition_id: str,
id: str,
region: Optional[Region] = None,
) -> Optional[None]:
"""
Usage:
::
result = await api.delete_job_definition(job_definition_id="example")
result = await api.delete_job_definition(id="example")
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_job_definition_id = validate_path_param(
"job_definition_id", job_definition_id
)
param_id = validate_path_param("id", id)

res = self._request(
"DELETE",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_id}",
)

self._throw_on_error(res)
Expand All @@ -301,27 +295,25 @@ async def delete_job_definition(
async def start_job_definition(
self,
*,
job_definition_id: str,
id: str,
region: Optional[Region] = None,
) -> JobRun:
"""
Usage:
::
result = await api.start_job_definition(job_definition_id="example")
result = await api.start_job_definition(id="example")
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_job_definition_id = validate_path_param(
"job_definition_id", job_definition_id
)
param_id = validate_path_param("id", id)

res = self._request(
"POST",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/start",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_id}/start",
)

self._throw_on_error(res)
Expand All @@ -330,25 +322,25 @@ async def start_job_definition(
async def get_job_run(
self,
*,
job_run_id: str,
id: str,
region: Optional[Region] = None,
) -> JobRun:
"""
Usage:
::
result = await api.get_job_run(job_run_id="example")
result = await api.get_job_run(id="example")
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_job_run_id = validate_path_param("job_run_id", job_run_id)
param_id = validate_path_param("id", id)

res = self._request(
"GET",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-runs/{param_job_run_id}",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-runs/{param_id}",
)

self._throw_on_error(res)
Expand All @@ -357,25 +349,25 @@ async def get_job_run(
async def stop_job_run(
self,
*,
job_run_id: str,
id: str,
region: Optional[Region] = None,
) -> JobRun:
"""
Usage:
::
result = await api.stop_job_run(job_run_id="example")
result = await api.stop_job_run(id="example")
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_job_run_id = validate_path_param("job_run_id", job_run_id)
param_id = validate_path_param("id", id)

res = self._request(
"POST",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-runs/{param_job_run_id}/stop",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-runs/{param_id}/stop",
)

self._throw_on_error(res)
Expand All @@ -388,7 +380,7 @@ async def list_job_runs(
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: ListJobRunsRequestOrderBy = ListJobRunsRequestOrderBy.CREATED_AT_ASC,
job_definition_id: Optional[str] = None,
id: Optional[str] = None,
project_id: Optional[str] = None,
) -> ListJobRunsResponse:
"""
Expand All @@ -407,7 +399,7 @@ async def list_job_runs(
"GET",
f"/serverless-jobs/v1alpha1/regions/{param_region}/job-runs",
params={
"job_definition_id": job_definition_id,
"id": id,
"order_by": order_by,
"page": page,
"page_size": page_size or self.client.default_page_size,
Expand All @@ -425,7 +417,7 @@ async def list_job_runs_all(
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListJobRunsRequestOrderBy] = None,
job_definition_id: Optional[str] = None,
id: Optional[str] = None,
project_id: Optional[str] = None,
) -> List[JobRun]:
"""
Expand All @@ -446,7 +438,7 @@ async def list_job_runs_all(
"page": page,
"page_size": page_size,
"order_by": order_by,
"job_definition_id": job_definition_id,
"id": id,
"project_id": project_id,
},
)
12 changes: 6 additions & 6 deletions scaleway-async/scaleway_async/jobs/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def unmarshal_JobDefinition(data: Any) -> JobDefinition:
field = data.get("environment_variables", None)
args["environment_variables"] = field

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

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

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

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

Expand Down Expand Up @@ -82,12 +82,12 @@ def unmarshal_JobRun(data: Any) -> JobRun:
field = data.get("exit_code", None)
args["exit_code"] = field

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

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

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

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

Expand Down
18 changes: 9 additions & 9 deletions scaleway-async/scaleway_async/jobs/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __str__(self) -> str:

@dataclass
class JobDefinition:
job_definition_id: str
id: str

name: str

Expand Down Expand Up @@ -75,7 +75,7 @@ class JobDefinition:

@dataclass
class JobRun:
job_run_id: str
id: str

job_definition_id: str

Expand Down Expand Up @@ -151,7 +151,7 @@ class GetJobDefinitionRequest:
Region to target. If none is passed will use default region from the config.
"""

job_definition_id: str
id: str


@dataclass
Expand All @@ -177,7 +177,7 @@ class UpdateJobDefinitionRequest:
Region to target. If none is passed will use default region from the config.
"""

job_definition_id: str
id: str

name: Optional[str]

Expand All @@ -203,7 +203,7 @@ class DeleteJobDefinitionRequest:
Region to target. If none is passed will use default region from the config.
"""

job_definition_id: str
id: str


@dataclass
Expand All @@ -213,7 +213,7 @@ class StartJobDefinitionRequest:
Region to target. If none is passed will use default region from the config.
"""

job_definition_id: str
id: str


@dataclass
Expand All @@ -223,7 +223,7 @@ class GetJobRunRequest:
Region to target. If none is passed will use default region from the config.
"""

job_run_id: str
id: str


@dataclass
Expand All @@ -233,7 +233,7 @@ class StopJobRunRequest:
Region to target. If none is passed will use default region from the config.
"""

job_run_id: str
id: str


@dataclass
Expand All @@ -249,6 +249,6 @@ class ListJobRunsRequest:

order_by: Optional[ListJobRunsRequestOrderBy]

job_definition_id: Optional[str]
id: Optional[str]

project_id: Optional[str]
Loading

0 comments on commit ad72f47

Please sign in to comment.