@@ -113,23 +113,23 @@ def __init__(self, *item_ids: str):
113
113
114
114
def delete (self ):
115
115
items = self .stac_client .get_items (* self ._item_ids )
116
- collections : set [ pystac . Collection ] = set ()
116
+ collection_ids = set ()
117
117
for item in items :
118
- collection = item .get_parent ()
119
- collections .add (collection ) # type: ignore
118
+ collection_ids .add (item .collection_id )
120
119
121
- for collection in collections :
122
- collection_item_ids = {item_in_collection .id for item_in_collection in collection .get_items ()}
120
+ for collection_id in collection_ids :
121
+ collection_items = self .stac_client .get_collection (collection_id ).get_items ()
122
+ collection_item_ids = {item_in_collection .id for item_in_collection in collection_items }
123
123
missing_items = collection_item_ids - self ._item_ids
124
124
if missing_items :
125
125
error_msg = (
126
126
f"The deletion request failed because the submitted items are part of a group that must be deleted "
127
- f"together. The submitted items belong to the following collection: '{ collection . id } '. All items "
127
+ f"together. The submitted items belong to the following collection: '{ collection_id } '. All items "
128
128
f"from this collection must be deleted at once. To proceed, please add these missing item IDs "
129
129
f"to your request: { list (missing_items )} ."
130
130
)
131
131
raise IncompleteCollectionDeletionError (error_msg )
132
132
133
- for collection in collections :
134
- url = host .endpoint (f"/v2/assets/stac/collections/{ collection . id } " )
133
+ for collection_id in collection_ids :
134
+ url = host .endpoint (f"/v2/assets/stac/collections/{ collection_id } " )
135
135
self .session .delete (url = url )
0 commit comments