Skip to content

Commit

Permalink
feat(api version): add an api_version key to DTOs
Browse files Browse the repository at this point in the history
Data Transfer Objects (DTOs) are any object that we expect to be used to be used by an external API
(ie: not-queenbee) to be parsed and computed. I have opted for a version and maturity flag for API
versions (ie: version = v1 and maturity = beta1). This versioning schema should ideally work like
described for the Kubernetes project:
https://kubernetes.io/docs/concepts/overview/kubernetes-api/#api-groups-and-versioning
  • Loading branch information
AntoineDao committed Dec 9, 2020
1 parent 77452e7 commit 59b87ca
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions queenbee/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Job(BaseModel):
A Job is an object to submit a list of arguments to execute a Queenbee recipe.
"""
api_version: constr(regex='^Job$') = 'Job'

type: constr(regex='^Job$') = 'Job'

source: str = Field(
Expand Down
2 changes: 2 additions & 0 deletions queenbee/job/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class StepStatus(BaseStatus):

class JobStatus(BaseStatus):
"""Job Status."""
api_version: constr(regex='^v1beta1$') = 'v1beta1'

type: constr(regex='^JobStatus$') = 'JobStatus'

id: str = Field(
Expand Down
2 changes: 2 additions & 0 deletions queenbee/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class Plugin(BaseModel):
A plugin contains runtime configuration for a Command Line Interface (CLI) and
a list of functions that can be executed using this CLI tool.
"""
api_version: constr(regex='^v1beta1$') = 'v1beta1'

type: constr(regex='^Plugin') = 'Plugin'

metadata: MetaData = Field(
Expand Down
4 changes: 4 additions & 0 deletions queenbee/recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def from_plugin(cls, plugin: Plugin) -> list:

class Recipe(BaseModel):
"""A Queenbee Recipe"""
api_version: constr(regex='^v1beta1$') = 'v1beta1'

type: constr(regex='^Recipe$') = 'Recipe'

metadata: MetaData = Field(
Expand Down Expand Up @@ -688,6 +690,8 @@ class RecipeInterface(BaseModel):
Recipe information only includes metadata, source, inputs and outputs of a Recipe.
This object is useful for creating user interface for Recipes.
"""
api_version: constr(regex='^v1beta1$') = 'v1beta1'

type: constr(regex='^RecipeInterface$') = 'RecipeInterface'

metadata: MetaData = Field(
Expand Down
1 change: 1 addition & 0 deletions queenbee/repository/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class RepositoryMetadata(BaseModel):

class RepositoryIndex(BaseModel):
"""A searchable index for a Queenbee Plugin and Recipe repository"""
api_version: constr(regex='^v1beta1$') = 'v1beta1'

type: constr(regex='^RepositoryIndex$') = 'RepositoryIndex'

Expand Down

0 comments on commit 59b87ca

Please sign in to comment.