@@ -230,16 +230,54 @@ def nodes_get(self, uniqueIds):
230230 method , url , body_json = self ._prepare_nodes_get (uniqueIds = uniqueIds )
231231 return self .send_request (method , url , body_json = body_json )
232232
233- def node_add (self , parentNodeId , * , name , nodeType , auth = None , ** kwargs ):
233+ def node_add (self , parentNodeId , * , node , auth = None , ** kwargs ):
234234 """
235- Creates a new node under the specified parent node. Required parameters:
236- ``name`` and ``nodeType``. Supported types: ``"FOLDER"``, ``"CONFIGURATION"``.
235+ Creates a new node under the specified parent node.
237236
238237 API: PUT /node?parentNodeId={parentNodeId}
238+
239+ Parameters
240+ ----------
241+ parentNodeId : str
242+ Unique ID of the parent node.
243+ node : dict
244+ Node metadata. The required fields are ``name`` and ``nodeType``.
245+ Supported node types: ``"FOLDER"``, ``"CONFIGURATION"``.
246+ auth : httpx.BasicAuth
247+ Object with authentication data (generated using ``auth_gen`` method). If not specified or None,
248+ then the authentication set using ``auth_set`` method is used.
249+
250+ Returns
251+ -------
252+ dict
253+ Created node metadata as returned by the server.
254+
255+ Examples
256+ --------
257+
258+ .. code-block:: python
259+
260+ from save_and_restore_api import SaveRestoreAPI
261+
262+ with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR:
263+ SR.auth_set(username="user", password="user_password")
264+ root_folder_uid = SR.ROOT_NODE_UID
265+ folder = SR.node_add(root_folder_uid, node={"name": "My Folder", "nodeType": "FOLDER"})
266+ print(f"Created folder metadata: {folder}")
267+
268+ Async version:
269+
270+ .. code-block:: python
271+
272+ from save_and_restore_api.aio import SaveRestoreAPI
273+
274+ async with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR:
275+ await SR.auth_set(username="user", password="user_password")
276+ root_folder_uid = SR.ROOT_NODE_UID
277+ folder = await SR.node_add(root_folder_uid, node={"name": "My Folder", "nodeType": "FOLDER"})
278+ print(f"Created folder metadata: {folder}")
239279 """
240- method , url , params , body_json = self ._prepare_node_add (
241- parentNodeId = parentNodeId , name = name , nodeType = nodeType , ** kwargs
242- )
280+ method , url , params , body_json = self ._prepare_node_add (parentNodeId = parentNodeId , node = node )
243281 return self .send_request (method , url , params = params , body_json = body_json , auth = auth )
244282
245283 def node_delete (self , nodeId , * , auth = None ):
0 commit comments