Skip to content

Commit 0ee53eb

Browse files
author
Andrew Cheng
committed
Expose opt-in content_ids on repository version detail
Add a content_ids SerializerMethodField to RepositoryVersionSerializer that returns the version's content unit UUIDs only when the request includes the content_ids=true query parameter (null otherwise). This lets clients diff content sets between versions directly instead of issuing expensive content filter queries. Closes #7831 Assisted by: Claude Opus 4.8
1 parent 94f63c3 commit 0ee53eb

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

CHANGES/7831.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added an opt-in ``content_ids`` field to the repository version detail, returning the list of content unit UUIDs in the version when the request includes the ``content_ids=true`` query parameter. This lets clients diff content sets between versions directly instead of issuing expensive content filter queries.

pulpcore/app/serializers/repository.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,26 @@ class RepositoryVersionSerializer(ModelSerializer, NestedHyperlinkedModelSeriali
291291
vuln_report = serializers.SerializerMethodField(
292292
read_only=True,
293293
)
294+
content_ids = serializers.SerializerMethodField(
295+
help_text=_(
296+
"The list of content unit UUIDs in this version. Only returned when the request "
297+
"includes the 'content_ids=true' query parameter; otherwise null."
298+
),
299+
read_only=True,
300+
)
294301

295302
def get_vuln_report(self, object):
296303
return f"{reverse('vuln_report-list')}?repo_versions={get_prn(object)}"
297304

305+
def get_content_ids(self, object):
306+
request = self.context.get("request")
307+
if request is None:
308+
return None
309+
value = request.query_params.get("content_ids")
310+
if value is None or value.lower() not in ("true", "1", "yes"):
311+
return None
312+
return object.content_ids
313+
298314
class Meta:
299315
model = models.RepositoryVersion
300316
fields = ModelSerializer.Meta.fields + (
@@ -304,6 +320,7 @@ class Meta:
304320
"base_version",
305321
"content_summary",
306322
"vuln_report",
323+
"content_ids",
307324
)
308325

309326

0 commit comments

Comments
 (0)