-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: Add Client for Systems State Service APIs #89
base: master
Are you sure you want to change the base?
feat: Add Client for Systems State Service APIs #89
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending tests review
Overview | ||
~~~~~~~~ | ||
|
||
The :class:`.SystemsStateClient` class is the primary entry point of the Product API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The :class:`.SystemsStateClient` class is the primary entry point of the Product API. | |
The :class:`.SystemsStateClient` class is the primary entry point of the Systems State API. |
# prevent pytest from thinking this is a test class | ||
__test__ = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# prevent pytest from thinking this is a test class | |
__test__ = False |
Not relevant as the class name does not start with Test
architecture: Optional[models.Architecture] = None, | ||
distribution: Optional[models.Distribution] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum
is not supported by Uplink and hence create a wrapper method to take care of Enum to str conversion.
Reference -
order_by_str = order_by.value if order_by is not None else None |
... | ||
|
||
@post("states", args=[Body]) | ||
def create_state(self, new_state: models.StateRequest) -> models.StateResponse: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def create_state(self, new_state: models.StateRequest) -> models.StateResponse: | |
def create_state(self, state: models.StateRequest) -> models.StateResponse: |
... | ||
|
||
@post("export-state", args=[Body]) | ||
def export_state(self, export_state_request: models.ExportStateRequest) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def export_state(self, export_state_request: models.ExportStateRequest) -> str: | |
def export_state(self, query: models.ExportStateRequest) -> str: |
Part(name="File", type=str), | ||
], | ||
) | ||
def import_state( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are models.Architecture
and models.Distribution
, use the same as inputs for this method as well, do handle the enum to str conversion using the wrapper function
... | ||
|
||
@post("delete-states", args=[Body]) | ||
def delete_states(self, states_id_list: List[str]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def delete_states(self, states_id_list: List[str]) -> None: | |
def delete_states(self, ids: List[str]) -> None: |
id: Optional[str] = None | ||
"""Gets or sets the ID of the state.""" | ||
|
||
createdTimestamp: datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all model fields, use snake_case and let the JsonModel
convert it to camelCase at runtime serialization.
createdTimestamp: datetime | |
created_timestamp: datetime |
camelCase serialization defined at
def _camelcase(s: str) -> str: |
feeds: Optional[List[Feed]] = None | ||
"""List of all feeds associated with the particular state""" | ||
|
||
systemImage: SystemImage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make Pythonic
systemImage: SystemImage | |
system_image: SystemImage |
@pytest.fixture | ||
def default_work_space() -> str: | ||
"""Fixture that returns the default workspace id""" | ||
return "846e294a-a007-47ac-9fc2-fac07eab240e" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests should be agnostic of the SLE instance and equipped to work with a fresh deployment by taking care of creating/deleting any necessary entities or mock them in the requests response.
return "846e294a-a007-47ac-9fc2-fac07eab240e" | |
return "" |
What does this Pull Request accomplish?
This PR adds API Client Module for
States
microservice in theSystems State Service
.Why should this Pull Request be merged?
The
SystemsStateClient
makes it easier for users to interact with the endpoints ofSystems State Service
by just creating an instance of it.What testing has been done?
Automated integration tests are included.
API Link: Swagger Link