This section describes how to configure Qumulo Core and watch for file attribute and directory changes by using REST.
Qumulo provides REST access to the same change notification system that backs SMB2
CHANGE_NOTIFY
. Because the notification interface and types are easier to work with compared to SMB2, we recommend programming by using REST rather than SMB CHANGE_NOTIFY
.Qumulo Core streams notifications to the client by using HTML server-sent events (SSE). For more information about the SSE syntax, see Server-sent events in the HTML Living Standard documentation.
-
The comment syntax—any line that begins with a colon (
:
)— shows that the call has registered successfully for notifications and periodic keep-alive connections. -
The data syntax (
data: payload
) shows the event content.
Qumulo Core continues to stream events until the client closes the connection.
- Standard file system permissions apply to API requests for non-recursive watching: The system compares the authenticated user that makes the API request with the defined access control list (ACL) permissions for the file and grants or denies access access. The authenticated user must have permission to read a directory in order to request notifications for its changes.
- Because of the complexity of representing and enforcing a permissions model for an arbitrary subtree of the file system, recursive notification requests require an authenticated API user to have the
DATA_ADMINISTRATOR
privilege. This requirement remains true even if you configure your Qumulo cluster to ignore the recursive notification mode.
How SSE Event Payloads are Structured for Recursive Notification Requests
An SSE event payload is a JSON-encoded list of notification objects. The following is a format example of the SSE event payload.
[
{
"type": "<type>",
"path": "<path>",
"spine": ["<file_id_1>", "<file_id_2>", ...],
"stream_name": "<optional_stream_name>"
},
{
...
}
]
-
type
: One of the possible notification types. -
path
: The path to the file for which the notification occurred.This path is relative to the watched directory.
-
spine
: A representation of the file path that uses Qumulo file IDs (rather than path components).-
The first file ID in the spine is the oldest ancestor in the path.
-
The last file ID in the spine is the file for which the system sends the notification.
-
-
stream_name
: The name of an alternate data stream (ADS) for the file.When this value is
null
, the notification is for the file’s default stream. Otherwise, the notification is for the listed stream.
SSE Payload Notification Types
The following is a list of available notification types in SSE event payloads.
-
The
type
field shows a single notification type. -
The
filter
field shows multiple notification types in comma-separated format.
Notification Type | Description |
---|---|
child_acl_changed |
The ACL for the listed or directory has been modified. |
child_atime_changed |
The Note
|
child_btime_changed |
The btime (creation time) of the listed file or directory has been modified. |
child_mtime_changed |
The mtime (modification time) of the listed file or directory has been modified. |
child_data_written |
Data has been written to the listed file. |
child_dir_added |
The listed directory has been created. |
child_dir_removed |
The listed directory has been removed. |
child_dir_moved_from |
A directory has been moved from the listed location. Note
The combination of the *_moved_to and *_moved_from notification type constitutes the renaming of the listed directory. |
child_dir_moved_to |
A directory has been moved to the listed location. Note
The combination of the *_moved_to and *_moved_from notification type constitutes the renaming of the listed directory. |
child_extra_attrs_changed |
The additional attributes for the listed file or directory have been modified. Note
The additional attributes are Windows-specific extra file attributes which include HIDDEN , READ_ONLY , and so on. For more information, see File Attributes in the Microsoft Open Attributes documentation. |
child_file_added |
The listed file has been created. |
child_file_removed |
The listed file has been removed. |
child_file_moved_from |
A file has been moved from the listed location. Note
The combination of the *_moved_to and *_moved_from notification type constitutes the renaming of the listed file. |
child_file_moved_to |
A file has been moved from the listed location. Note
The combination of the *_moved_to and *_moved_from notification type constitutes the renaming of the listed file. |
child_group_changed |
The group for the listed file or directory has been changed. |
child_owner_changed |
The owner for the listed file or directory has been changed. |
child_size_changed |
The size of the listed file has been changed. |
child_stream_added |
The listed alternate data stream (ADS) has been added to the listed file or directory. |
child_stream_data_written |
Data has been written to the listed ADS. |
child_stream_moved_from |
The listed ADS has been moved to the listed file or directory. |
child_stream_moved_to |
The listed ADS has been moved from the listed file or directory. |
child_stream_removed |
The listed ADS has been removed from the listed file or directory. |
child_stream_size_changed |
The size of the listed ADS for the listed file or directory has been changed. |
self_removed |
The directory from which then system streams notifications has been removed from the file system. Note
No notifications follow a self_removed notification. |
Streaming Change Notifications by Using the qq CLI
Run the qq fs_notify
command and specify the path to a directory. For example:
qq fs_notify --path /my/directory
In this example, Qumulo Core streams all notification types for files immediately under the /my/directory
directory.
To terminate the stream, send a SIGQUIT
signal.
Streaming Change Notifications by Using the Qumulo Core REST API
Make a GET
request to the REST endpoint in the following format:
/v1/files/<ref>/notify&filter=<filter>&recursive=<recursive>
In the following example:
-
ref
: An absolute path or a numeric file ID for the directory to watch. -
filter
: A comma-separated list of notification types. -
recursive
: When set totrue
, enables recursive change notifications.
/v1/files/my/directory/notify&filter=child_file_added,child_dir_removed&recursive=true