4343 "ContainerMetadata" ,
4444 "ContainerType" ,
4545 # API methods
46- "get_container_from_key" ,
4746 "get_container" ,
4847 "create_container" ,
4948 "get_container_children" ,
@@ -111,6 +110,7 @@ class ContainerMetadata(PublishableItem):
111110 """
112111 container_key : LibraryContainerLocator
113112 container_type : ContainerType
113+ container_pk : int
114114 published_display_name : str | None
115115
116116 @classmethod
@@ -139,6 +139,7 @@ def from_container(cls, library_key, container: Container, associated_collection
139139 return cls (
140140 container_key = container_key ,
141141 container_type = container_type ,
142+ container_pk = container .pk ,
142143 display_name = draft .title ,
143144 created = container .created ,
144145 modified = draft .created ,
@@ -173,7 +174,7 @@ def library_container_locator(
173174 )
174175
175176
176- def get_container_from_key (container_key : LibraryContainerLocator , isDeleted = False ) -> Container :
177+ def _get_container_from_key (container_key : LibraryContainerLocator , isDeleted = False ) -> Container :
177178 """
178179 Internal method to fetch the Container object from its LibraryContainerLocator
179180
@@ -192,11 +193,15 @@ def get_container_from_key(container_key: LibraryContainerLocator, isDeleted=Fal
192193 raise ContentLibraryContainerNotFound
193194
194195
195- def get_container (container_key : LibraryContainerLocator , include_collections = False ) -> ContainerMetadata :
196+ def get_container (
197+ container_key : LibraryContainerLocator ,
198+ * ,
199+ include_collections = False ,
200+ ) -> ContainerMetadata :
196201 """
197202 Get a container (a Section, Subsection, or Unit).
198203 """
199- container = get_container_from_key (container_key )
204+ container = _get_container_from_key (container_key )
200205 if include_collections :
201206 associated_collections = authoring_api .get_entity_collections (
202207 container .publishable_entity .learning_package_id ,
@@ -268,7 +273,7 @@ def update_container(
268273 """
269274 Update a container (e.g. a Unit) title.
270275 """
271- container = get_container_from_key (container_key )
276+ container = _get_container_from_key (container_key )
272277 library_key = container_key .lib_key
273278
274279 assert container .unit
@@ -297,7 +302,7 @@ def delete_container(
297302 No-op if container doesn't exist or has already been soft-deleted.
298303 """
299304 library_key = container_key .lib_key
300- container = get_container_from_key (container_key )
305+ container = _get_container_from_key (container_key )
301306
302307 affected_collections = authoring_api .get_entity_collections (
303308 container .publishable_entity .learning_package_id ,
@@ -332,7 +337,7 @@ def restore_container(container_key: LibraryContainerLocator) -> None:
332337 Restore the specified library container.
333338 """
334339 library_key = container_key .lib_key
335- container = get_container_from_key (container_key , isDeleted = True )
340+ container = _get_container_from_key (container_key , isDeleted = True )
336341
337342 affected_collections = authoring_api .get_entity_collections (
338343 container .publishable_entity .learning_package_id ,
@@ -372,12 +377,13 @@ def restore_container(container_key: LibraryContainerLocator) -> None:
372377
373378def get_container_children (
374379 container_key : LibraryContainerLocator ,
380+ * ,
375381 published = False ,
376382) -> list [LibraryXBlockMetadata | ContainerMetadata ]:
377383 """
378384 Get the entities contained in the given container (e.g. the components/xblocks in a unit)
379385 """
380- container = get_container_from_key (container_key )
386+ container = _get_container_from_key (container_key )
381387 if container_key .container_type == ContainerType .Unit .value :
382388 child_components = authoring_api .get_components_in_unit (container .unit , published = published )
383389 return [LibraryXBlockMetadata .from_component (
@@ -399,7 +405,7 @@ def get_container_children_count(
399405 """
400406 Get the count of entities contained in the given container (e.g. the components/xblocks in a unit)
401407 """
402- container = get_container_from_key (container_key )
408+ container = _get_container_from_key (container_key )
403409 return authoring_api .get_container_children_count (container , published = published )
404410
405411
@@ -414,7 +420,7 @@ def update_container_children(
414420 """
415421 library_key = container_key .lib_key
416422 container_type = container_key .container_type
417- container = get_container_from_key (container_key )
423+ container = _get_container_from_key (container_key )
418424 match container_type :
419425 case ContainerType .Unit .value :
420426 components = [get_component_from_usage_key (key ) for key in children_ids ] # type: ignore[arg-type]
@@ -459,7 +465,7 @@ def publish_container_changes(container_key: LibraryContainerLocator, user_id: i
459465 Publish all unpublished changes in a container and all its child
460466 containers/blocks.
461467 """
462- container = get_container_from_key (container_key )
468+ container = _get_container_from_key (container_key )
463469 library_key = container_key .lib_key
464470 content_library = ContentLibrary .objects .get_by_key (library_key ) # type: ignore[attr-defined]
465471 learning_package = content_library .learning_package
0 commit comments