Skip to content

Commit 19637c5

Browse files
committed
DOC: docstrings for composite snapshot API group
1 parent 390c465 commit 19637c5

File tree

1 file changed

+99
-6
lines changed

1 file changed

+99
-6
lines changed

src/save_and_restore_api/_api_threads.py

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,21 @@ def snapshots_get(self):
743743

744744
def composite_snapshot_get(self, uniqueId):
745745
"""
746-
Returns composite snapshot data (``compositeSnapshotData``). The composite snapshot is
747-
specified by ``uniqueId``. The data includes uniqueId and the list of referencedSnapshotNodes
748-
(no PV information).
746+
Returns composite snapshot data (``compositeSnapshotData``) specified by ``uniqueId``.
747+
The data includes uniqueId and the list of referencedSnapshotNodes (no PV information).
748+
The composite snapshot node metadata can be obtained using ``node_get()``.
749749
750750
API: GET /composite-snapshot/{uniqueId}
751+
752+
Parameters
753+
----------
754+
uniqueId : str
755+
Unique ID of the composite snapshot node.
756+
757+
Returns
758+
-------
759+
dict
760+
Composite snapshot data (``compositeSnapshotData``) as returned by the server.
751761
"""
752762
method, url = self._prepare_composite_snapshot_get(uniqueId=uniqueId)
753763
return self.send_request(method, url)
@@ -758,16 +768,38 @@ def composite_snapshot_get_nodes(self, uniqueId):
758768
specified by ``uniqueId``.
759769
760770
API: GET /composite-snapshot/{uniqueId}/nodes
771+
772+
Parameters
773+
----------
774+
uniqueId : str
775+
Unique ID of the composite snapshot node.
776+
777+
Returns
778+
-------
779+
list[dict]
780+
List of snapshot nodes. Each snapshot node is represented as a dictionary with
781+
node metadata. No composite snapshot data is returned.
761782
"""
762783
method, url = self._prepare_composite_snapshot_get_nodes(uniqueId=uniqueId)
763784
return self.send_request(method, url)
764785

765786
def composite_snapshot_get_items(self, uniqueId):
766787
"""
767-
Returns a list of restorable items referenced by the composite snapshot. The composite snapshot is
768-
specified by ``uniqueId``.
788+
Returns a list of restorable items (PV data) referenced by the composite snapshot.
789+
The composite snapshot is specified by ``uniqueId``.
769790
770791
API: GET /composite-snapshot/{uniqueId}/items
792+
793+
Parameters
794+
----------
795+
uniqueId : str
796+
Unique ID of the composite snapshot node.
797+
798+
Returns
799+
-------
800+
list[dict]
801+
List of snapshot items (PVs). The format is consistent with the format of
802+
``snapshotData["snapshotItems"]``
771803
"""
772804
method, url = self._prepare_composite_snapshot_get_items(uniqueId=uniqueId)
773805
return self.send_request(method, url)
@@ -778,6 +810,27 @@ def composite_snapshot_add(self, parentNodeId, *, compositeSnapshotNode, composi
778810
specified by ``parentNodeId``.
779811
780812
API: PUT /composite-snapshot?parentNodeId={parentNodeId}
813+
814+
Parameters
815+
----------
816+
parentNodeId : str
817+
Unique ID of the parent configuration node.
818+
compositeSnapshotNode : dict
819+
Composite snapshot node (``compositeSnapshotNode``) metadata. The required field is ``"name"``.
820+
compositeSnapshotData : dict
821+
Composite snapshot data (``compositeSnapshotData``). The required field is
822+
``"referencedSnapshotNodes"``, which points to the list of UIDs of the nodes included in
823+
the composite snapshot.
824+
auth : httpx.BasicAuth, optional
825+
Object with authentication data (generated using ``auth_gen`` method). If not specified or None,
826+
then the authentication set using ``auth_set`` method is used.
827+
828+
Returns
829+
-------
830+
dict
831+
Dictionary contains composite snapshot node metadata and composite snapshot data
832+
of the node that was added. The dictionary contains two keys: ``compositeSnapshotNode`` and
833+
``compositeSnapshotData`` as returned by the server.
781834
"""
782835
method, url, params, body_json = self._prepare_composite_snapshot_add(
783836
parentNodeId=parentNodeId,
@@ -792,6 +845,25 @@ def composite_snapshot_update(self, *, compositeSnapshotNode, compositeSnapshotD
792845
must have valid ``uniqueId`` fields pointing to an existing node.
793846
794847
API: POST /composite-snapshot
848+
849+
Parameters
850+
----------
851+
compositeSnapshotNode : dict
852+
Composite snapshot node (``compositeSnapshotNode``) metadata. ``uniqueId`` field must point to
853+
an existing composite snapshot node.
854+
compositeSnapshotData : dict
855+
Composite snapshot data (``compositeSnapshotData``). ``uniqueId`` field must be identical to the
856+
``uniqueId`` field in ``compositeSnapshotNode``.
857+
auth : httpx.BasicAuth, optional
858+
Object with authentication data (generated using ``auth_gen`` method). If not specified or None,
859+
then the authentication set using ``auth_set`` method is used.
860+
861+
Returns
862+
-------
863+
dict
864+
Dictionary contains composite snapshot node metadata and composite snapshot data
865+
of the node that was updated. The dictionary contains two keys: ``compositeSnapshotNode`` and
866+
``compositeSnapshotData`` as returned by the server.
795867
"""
796868
method, url, body_json = self._prepare_composite_snapshot_update(
797869
compositeSnapshotNode=compositeSnapshotNode,
@@ -801,9 +873,30 @@ def composite_snapshot_update(self, *, compositeSnapshotNode, compositeSnapshotD
801873

802874
def composite_snapshot_consistency_check(self, uniqueNodeIds, *, auth=None):
803875
"""
804-
Check consistency of the composite snapshots.
876+
Check consistency of the composite snapshots. The snapshot is specified by the list of
877+
UIDs of snapshots and composite snapshots included in the composite snapshot.
878+
One of the use cases is to check if a snapshot can be added to an existing composite
879+
snapshot. In this case the list of UIDs includes the UID of the exisitng composite
880+
snapshot and the UID of the new snapshot to be added. The function returns a list
881+
of PV data for each conflicting PV (composite snapshot items may not contain duplicate
882+
PVs).
805883
806884
API: POST /composite-snapshot-consistency-check
885+
886+
Parameters
887+
----------
888+
uniqueNodeIds : list of str
889+
List of UIDs of snapshots and composite snapshots included in the composite snapshot.
890+
auth : httpx.BasicAuth, optional
891+
Object with authentication data (generated using ``auth_gen`` method). If not specified or None,
892+
then the authentication set using ``auth_set`` method is used.
893+
894+
Returns
895+
-------
896+
list[dict]
897+
List of conflicting PVs. Each PV is represented as a dictionary of parameters.
898+
If the list is empty, then there are no conflicts and the composite snapshot
899+
can be created or updated.
807900
"""
808901
method, url, body_json = self._prepare_composite_snapshot_consistency_check(uniqueNodeIds=uniqueNodeIds)
809902
return self.send_request(method, url, body_json=body_json, auth=auth)

0 commit comments

Comments
 (0)