From 9c807a3de7f962ec8a5dfff36eaa31467e463614 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Wed, 29 May 2024 15:08:34 +0200 Subject: [PATCH] feat: show product-id for each offer when listing offers A product can have multiple offers but a offer can have only a single product. So listing the product-id for each offer when showing a list of available offers is useful to get the relationship. --- awsmp/cli.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/awsmp/cli.py b/awsmp/cli.py index eb0e98e..b1b9e48 100644 --- a/awsmp/cli.py +++ b/awsmp/cli.py @@ -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: + 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: + t.add_row( + [ + entity["EntityId"], + entity["OfferSummary"]["ProductId"], + entity["Name"], + entity["Visibility"], + entity["LastModifiedDate"], + ] + ) print(t.get_string(sortby="last-changed"))