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 Asset Management (Asset) API #86

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sam-rishi
Copy link

What does this Pull Request accomplish?

This PR adds API Client Module for Asset microservice in the Asset Management service.

Why should this Pull Request be merged?

The AssetManagementClient makes it easier for users to interact with the endpoints of Asset Management service by just creating an instance of it.

What testing has been done?

Automated integration tests are included.

API Link: Swagger Link

@sam-rishi sam-rishi changed the title Users/sam rishi/asset management client feat: Add Client for Asset Management (Asset) API Dec 6, 2024
@santhoshramaraj santhoshramaraj added the enhancement New feature or request label Dec 10, 2024
from nisystemlink.clients.core._http_configuration import HttpConfiguration


def create_an_asset():
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets break the examples up into multiple files. If you just want to know how to query or export you should need to work through all the create and update code


# Update the created asset.
updateAssets = [
AssetUpdate(
Copy link
Contributor

Choose a reason for hiding this comment

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

Once you've updated the update request model so more fields are optional lets revisit this example. We don't need to show every field you can update

...

@post("query-assets")
def query_assets(self, query: models.QueryAssetRequest) -> models.AssetsResponse:
Copy link
Contributor

Choose a reason for hiding this comment

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

query_assets and query_location both have CSV options that change the response format to a file download. We should make separate functions for these two -- query_assets and query_assets_as_csv; query_location_history and query_location_history_as_csv

You will need file download handling for the CSV cases similar to what we do for file download

...

@post("export-assets")
def export_assets(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as for query, for export we should have two separate functions -- export_assets_report and download_assets_report


@post("assets/{asset_id}/history/query-location")
def query_location(
self, query: models.QueryLocationHistoryRequest, asset_id: str
Copy link
Contributor

Choose a reason for hiding this comment

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

Put the asset_id parameter first

class QueryLocationHistoryRequest(JsonModel):
"""Model for object containing options for querying history."""

take: Optional[int] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing doc comment


start_time: Optional[str] = None

end_time: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing doc comments for start and end time


take: Optional[int] = None

continuation_token: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding the continuation_token field you should change the base class to WithPaging to get this field. That will enable use to build some common paging functions.

end_time: Optional[str] = None


class ConnectionHistoryResponse(JsonModel):
Copy link
Contributor

Choose a reason for hiding this comment

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

This will match what we're doing in the other clients

Suggested change
class ConnectionHistoryResponse(JsonModel):
class PagedConnectionHistory(WithPaging):

And remove the continuation_token field now that you're getting it from the base class

Copy link
Contributor

Choose a reason for hiding this comment

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

Do not delete these tests. I'm guessing this was just a bad merge

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.

3 participants