Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shri2k2
Copy link

@shri2k2 shri2k2 commented Jan 8, 2025

What does this Pull Request accomplish?

This PR adds API Client Module for States microservice in the Systems State Service.

Why should this Pull Request be merged?

The SystemsStateClient makes it easier for users to interact with the endpoints of Systems State Service by just creating an instance of it.

What testing has been done?

Automated integration tests are included.

API Link: Swagger Link

@santhoshramaraj santhoshramaraj added the enhancement New feature or request label Jan 8, 2025
Copy link
Member

@santhoshramaraj santhoshramaraj left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines +14 to +15
# prevent pytest from thinking this is a test class
__test__ = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# prevent pytest from thinking this is a test class
__test__ = False

Not relevant as the class name does not start with Test

Comment on lines +49 to +50
architecture: Optional[models.Architecture] = None,
distribution: Optional[models.Distribution] = None,
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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(
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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.

Suggested change
createdTimestamp: datetime
created_timestamp: datetime

camelCase serialization defined at

feeds: Optional[List[Feed]] = None
"""List of all feeds associated with the particular state"""

systemImage: SystemImage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make Pythonic

Suggested change
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"
Copy link
Member

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.

Suggested change
return "846e294a-a007-47ac-9fc2-fac07eab240e"
return ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants