Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions awsmp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,24 @@ def entity_list(entity_type, filter_visibility):
"""
entity_list = _driver.list_entities(entity_type)
t = prettytable.PrettyTable()
t.field_names = ["entity-id", "name", "visibility", "last-changed"]
if entity_type == "AmiProduct":
t.field_names = ["entity-id", "name", "visibility", "last-changed"]
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be explicit on which entity types this is (e.g. in case we add SaaS later or other marketplace types)

Copy link
Collaborator Author

@toabctl toabctl Jun 3, 2024

Choose a reason for hiding this comment

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

you have to give the entity type at the command line. so imo you can't get this wrong:

awsmp inspect entity-list AmiProduct

vs.

awsmp inspect entity-list Offer

Copy link
Contributor

Choose a reason for hiding this comment

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

what about direct library users? if we add more supported entities?

t.field_names = ["entity-id", "Product-Id", "name", "visibility", "last-changed"]
for _, entity in entity_list.items():
if not filter_visibility or entity["Visibility"] in filter_visibility:
t.add_row([entity["EntityId"], entity["Name"], entity["Visibility"], entity["LastModifiedDate"]])
if entity_type == "AmiProduct":
t.add_row([entity["EntityId"], entity["Name"], entity["Visibility"], entity["LastModifiedDate"]])
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

again, explicit on entity_type

t.add_row(
[
entity["EntityId"],
entity["OfferSummary"]["ProductId"],
entity["Name"],
entity["Visibility"],
entity["LastModifiedDate"],
]
)
print(t.get_string(sortby="last-changed"))


Expand Down