I am working on a script to close all open files within a specific folder. I started down the path of using the REST API, but was unable to get the information needed to run the /protocols/cifs/session/files/{node.uuid}/{svm.uuid}/{identifier}/{connection.identifier}/{session.identifier} command.
According to https://library.netapp.com/ecmdocs/ECMLP2884821/html/#/NAS/cifs_open_file_collection_get You should get the following response:
# The response:
{
"records": [
{
"node": {
"uuid": "9ea96c65-4411-11ec-b358-005056bbdd2c",
"name": "node1"
},
"svm": {
"uuid": "62234287-4412-11ec-b358-005056bbdd2c",
"name": "svm1"
},
"file": {
"identifier": 24,
"type": "regular"
},
"connection": {
"identifier": 127465,
"count": 1
},
"session_id": 1827054073828868097,
"open_mode": "w",
"volume": {
"name": "vol1",
"uuid": "7a5ef257-52de-11e8-95f4-005056952000"
},
"share": {
"name": "root",
"mode": "rwd"
},
"path": "a\\b\\c\\f1",
"continuously_available": "no",
"reconnected": "No",
"range_lock_count": 0
},
{
"node": {
"uuid": "9ea96c65-4411-11ec-b358-005056bbdd2c",
"name": "node2"
},
"svm": {
"uuid": "62234287-4412-11ec-b358-005056bbdd2c",
"name": "svm2"
},
"file": {
"identifier": 14,
"type": "regular"
},
"connection": {
"identifier": 127465,
"count": 1
},
"session_id": 1827054073828868097,
"open_mode": "r",
"volume": {
"name": "vol2",
"uuid": "7a5ef257-52de-11e8-95f4-005056952000"
},
"share": {
"name": "root",
"mode": "rwd"
},
"path": "a\\b\\c\\f2",
"continuously_available": "no",
"reconnected": "No",
"range_lock_count": 0
}
],
"num_records": 2
}
However, the response I get is missing all the information after session_id:
{
"records": [
{
"node": {
"uuid": "XXX",
"name": "XXX",
"_links": {
"self": {
"href": "/api/cluster/nodes/XXX"
}
}
},
"svm": {
"name": "XXX",
"uuid": "XXX"
},
"identifier": XXX,
"connection": {
"identifier": XXX
},
"session": {
"identifier": XXX
},
"_links": {
"self": {
"href": "/api/protocols/cifs/session/files/XXX/XXX/XXX/XXX/XXX"
}
}
}
],
"num_records": 1,
"_links": {
"self": {
"href": "/api/protocols/cifs/session/files?"
}
}
}
My current work around has been to use private cli command:
https://xxx/api/private/cli/cifs/session/file?fields=node,connection_id,session_id,file_id,path
The problem with the private cli command is that I need the svm Uuid and that is not a viable field. Though I do know the SVM of the folder in question, so that won't change, but wanted to make the script a bit more modular to handle any folder/file path combo.