Skip to content

Commit

Permalink
Add more docs and examples to the Workflows API
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 2d5bad2cc0202eeaba827fa67c8c56d69aac487b
  • Loading branch information
maxdubrinsky committed Aug 21, 2024
1 parent 3d4e003 commit 9942e38
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 36 deletions.
36 changes: 24 additions & 12 deletions src/gretel_client/rest_v1/api/workflows_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,9 @@ def search_workflow_runs(
] = None,
sort: Annotated[
Optional[StrictStr],
Field(description="The sort order for the search results."),
Field(
description="The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`"
),
] = None,
_request_timeout: Union[
None,
Expand All @@ -2141,7 +2143,7 @@ def search_workflow_runs(
:type limit: int
:param skip: The number of results to skip before applying the limit.
:type skip: int
:param sort: The sort order for the search results.
:param sort: The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`
:type sort: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
Expand Down Expand Up @@ -2216,7 +2218,9 @@ def search_workflow_runs_with_http_info(
] = None,
sort: Annotated[
Optional[StrictStr],
Field(description="The sort order for the search results."),
Field(
description="The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`"
),
] = None,
_request_timeout: Union[
None,
Expand All @@ -2242,7 +2246,7 @@ def search_workflow_runs_with_http_info(
:type limit: int
:param skip: The number of results to skip before applying the limit.
:type skip: int
:param sort: The sort order for the search results.
:param sort: The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`
:type sort: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
Expand Down Expand Up @@ -2317,7 +2321,9 @@ def search_workflow_runs_without_preload_content(
] = None,
sort: Annotated[
Optional[StrictStr],
Field(description="The sort order for the search results."),
Field(
description="The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`"
),
] = None,
_request_timeout: Union[
None,
Expand All @@ -2343,7 +2349,7 @@ def search_workflow_runs_without_preload_content(
:type limit: int
:param skip: The number of results to skip before applying the limit.
:type skip: int
:param sort: The sort order for the search results.
:param sort: The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`
:type sort: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
Expand Down Expand Up @@ -2823,7 +2829,9 @@ def search_workflows(
] = None,
sort: Annotated[
Optional[StrictStr],
Field(description="The sort order for the search results."),
Field(
description="The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`"
),
] = None,
limit: Annotated[
Optional[StrictInt],
Expand Down Expand Up @@ -2859,7 +2867,7 @@ def search_workflows(
:param query: The query string for searching workflows. Supported fields are: `id`, `project_id`
:type query: str
:param sort: The sort order for the search results.
:param sort: The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`
:type sort: str
:param limit: The maximum number of results to return.
:type limit: int
Expand Down Expand Up @@ -2924,7 +2932,9 @@ def search_workflows_with_http_info(
] = None,
sort: Annotated[
Optional[StrictStr],
Field(description="The sort order for the search results."),
Field(
description="The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`"
),
] = None,
limit: Annotated[
Optional[StrictInt],
Expand Down Expand Up @@ -2960,7 +2970,7 @@ def search_workflows_with_http_info(
:param query: The query string for searching workflows. Supported fields are: `id`, `project_id`
:type query: str
:param sort: The sort order for the search results.
:param sort: The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`
:type sort: str
:param limit: The maximum number of results to return.
:type limit: int
Expand Down Expand Up @@ -3025,7 +3035,9 @@ def search_workflows_without_preload_content(
] = None,
sort: Annotated[
Optional[StrictStr],
Field(description="The sort order for the search results."),
Field(
description="The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`"
),
] = None,
limit: Annotated[
Optional[StrictInt],
Expand Down Expand Up @@ -3061,7 +3073,7 @@ def search_workflows_without_preload_content(
:param query: The query string for searching workflows. Supported fields are: `id`, `project_id`
:type query: str
:param sort: The sort order for the search results.
:param sort: The sort order for the search results. Supported sort fields are: `created_at`, `updated_at`
:type sort: str
:param limit: The maximum number of results to return.
:type limit: int
Expand Down
33 changes: 29 additions & 4 deletions src/gretel_client/rest_v1/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictStr
from typing_extensions import Self
from typing_extensions import Annotated, Self

from gretel_client.rest_v1.models.project import Project
from gretel_client.rest_v1.models.user_profile import UserProfile
Expand All @@ -34,9 +34,11 @@ class Workflow(BaseModel):
Workflow
""" # noqa: E501

id: StrictStr = Field(description="The unique ID of the workflow.")
id: Annotated[str, Field(strict=True)] = Field(
description="The unique ID of the workflow."
)
name: StrictStr = Field(description="The name of the workflow.")
project_id: StrictStr = Field(
project_id: Annotated[str, Field(strict=True)] = Field(
description="The project ID that this workflow belongs to."
)
project: Optional[Project] = Field(
Expand All @@ -53,7 +55,9 @@ class Workflow(BaseModel):
default=None,
description="The runner mode of the workflow. Can be `cloud` or `hybrid`.",
)
created_by: StrictStr = Field(description="The user ID that created this workflow.")
created_by: Annotated[str, Field(strict=True)] = Field(
description="The user ID that created this workflow."
)
created_by_profile: Optional[UserProfile] = Field(
default=None,
description="The user profile of the user that created this workflow. Provided when the `expand=created_by` query param is present.",
Expand Down Expand Up @@ -98,6 +102,20 @@ class Workflow(BaseModel):
"latest_run",
]

@field_validator("id")
def id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^w_.*$", value):
raise ValueError(r"must validate the regular expression /^w_.*$/")
return value

@field_validator("project_id")
def project_id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^proj_.*$", value):
raise ValueError(r"must validate the regular expression /^proj_.*$/")
return value

@field_validator("runner_mode")
def runner_mode_validate_enum(cls, value):
"""Validates the enum"""
Expand All @@ -117,6 +135,13 @@ def runner_mode_validate_enum(cls, value):
)
return value

@field_validator("created_by")
def created_by_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^user_.*$", value):
raise ValueError(r"must validate the regular expression /^user_.*$/")
return value

model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
Expand Down
40 changes: 35 additions & 5 deletions src/gretel_client/rest_v1/models/workflow_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictInt, StrictStr
from typing_extensions import Self
from typing_extensions import Annotated, Self

from gretel_client.rest_v1.models.project import Project
from gretel_client.rest_v1.models.status_details import StatusDetails
Expand All @@ -37,11 +37,13 @@ class WorkflowRun(BaseModel):
WorkflowRun
""" # noqa: E501

id: StrictStr = Field(description="The unique ID of the workflow run.")
workflow_id: StrictStr = Field(
id: Annotated[str, Field(strict=True)] = Field(
description="The unique ID of the workflow run."
)
workflow_id: Annotated[str, Field(strict=True)] = Field(
description="The ID of the workflow that this run belongs to."
)
project_id: StrictStr = Field(
project_id: Annotated[str, Field(strict=True)] = Field(
description="The project ID that this workflow run belongs to. This will be the same as the project ID of the workflow."
)
project: Optional[Project] = Field(
Expand All @@ -66,7 +68,7 @@ class WorkflowRun(BaseModel):
default=None,
description="Additional details about the status of the workflow run.",
)
created_by: StrictStr = Field(
created_by: Annotated[str, Field(strict=True)] = Field(
description="The user ID that created this workflow run."
)
created_at: datetime = Field(
Expand Down Expand Up @@ -136,6 +138,27 @@ class WorkflowRun(BaseModel):
"total_compute_time_sconds",
]

@field_validator("id")
def id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^wr_.*$", value):
raise ValueError(r"must validate the regular expression /^wr_.*$/")
return value

@field_validator("workflow_id")
def workflow_id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^w_.*$", value):
raise ValueError(r"must validate the regular expression /^w_.*$/")
return value

@field_validator("project_id")
def project_id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^proj_.*$", value):
raise ValueError(r"must validate the regular expression /^proj_.*$/")
return value

@field_validator("runner_mode")
def runner_mode_validate_enum(cls, value):
"""Validates the enum"""
Expand Down Expand Up @@ -173,6 +196,13 @@ def status_validate_enum(cls, value):
)
return value

@field_validator("created_by")
def created_by_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^user_.*$", value):
raise ValueError(r"must validate the regular expression /^user_.*$/")
return value

model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
Expand Down
42 changes: 37 additions & 5 deletions src/gretel_client/rest_v1/models/workflow_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, field_validator, StrictInt, StrictStr
from typing_extensions import Self
from typing_extensions import Annotated, Self

from gretel_client.rest_v1.models.project import Project
from gretel_client.rest_v1.models.user_profile import UserProfile
Expand All @@ -33,11 +33,13 @@ class WorkflowTask(BaseModel):
Next Tag: 25
""" # noqa: E501

id: StrictStr = Field(description="The unique ID of the workflow task.")
workflow_run_id: StrictStr = Field(
id: Annotated[str, Field(strict=True)] = Field(
description="The unique ID of the workflow task."
)
workflow_run_id: Annotated[str, Field(strict=True)] = Field(
description="The ID of the workflow run that this task belongs to."
)
project_id: StrictStr = Field(
project_id: Annotated[str, Field(strict=True)] = Field(
description="The project ID that this workflow task belongs to."
)
project: Optional[Project] = Field(
Expand Down Expand Up @@ -66,7 +68,9 @@ class WorkflowTask(BaseModel):
default=None,
description="A more detailed stack trace that can be used for root cause analysis. This stack trace generally shouldn't be shown in the UI and will span many lines.",
)
created_by: StrictStr = Field(description="The user ID that created this workflow.")
created_by: Annotated[str, Field(strict=True)] = Field(
description="The user ID that created this workflow."
)
created_by_profile: Optional[UserProfile] = Field(
default=None,
description="The user profile of the user that created this workflow. Provided when the `expand=created_by` query param is present.",
Expand Down Expand Up @@ -129,6 +133,27 @@ class WorkflowTask(BaseModel):
"total_compute_time_sconds",
]

@field_validator("id")
def id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^wt_.*$", value):
raise ValueError(r"must validate the regular expression /^wt_.*$/")
return value

@field_validator("workflow_run_id")
def workflow_run_id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^wr_.*$", value):
raise ValueError(r"must validate the regular expression /^wr_.*$/")
return value

@field_validator("project_id")
def project_id_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^proj_.*$", value):
raise ValueError(r"must validate the regular expression /^proj_.*$/")
return value

@field_validator("status")
def status_validate_enum(cls, value):
"""Validates the enum"""
Expand All @@ -150,6 +175,13 @@ def status_validate_enum(cls, value):
)
return value

@field_validator("created_by")
def created_by_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^user_.*$", value):
raise ValueError(r"must validate the regular expression /^user_.*$/")
return value

model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
Expand Down
Loading

0 comments on commit 9942e38

Please sign in to comment.