Documentation deprecated: This documentation is no longer being updated as of 3.8.0. For up-to-date information, see the guide information in the IBM Developer Community and the endpoint reference in IBM API Explorer.

/files/filelock and /files/unfilelock

Manage filelocks on files by file path. To manage filelocks using bearer token authorization or get the filelock status of a file, use /files/{id}/filelock.

Requirements
  • Available as of Enterprise Server version 3.8.0.
Access Control
  • HTTP Basic Auth
    Provide a node username and password or an access key ID and secret.
Headers

All requests to this endpoint use the same headers.

Header Name Required Description Values
Content-Type Optional The format of the request data. application/json
Accept Optional The format of the response data. application/json
Status Codes and Errors
Code Description Notes
200 OK Success
400 Bad Request Error Request contains a formatting or syntax error.

Endpoint Actions

Apply a Filelock to a File

Apply a filelock to a file that prevents other users from modifying the file, unless they are admins, in which case they can override the filelock. The filelock creates a backup of the original file as .file.asp-bak and a metadata file, .file.asp-lck, that contains the name of the user who locked the file.

URL
POST https://{domain}:9092/files/filelock

Sample Request
curl -i -u user:secret -X POST https://{domain}:9092/files/filelock \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d @request_body.json

Where request_body.json contains the following:
{
    "paths" : [ 
        {
            "path" : "/path/to/file1",
            "tags" : {"tag" : "tag_string"}
        },
        {
            "path" : "/path/to/file2",
            "tags" : {"tag" : "tag_string"
        }
    ]
}

Request Body
Element Required Type Description
paths Required String JSON object that contains an array of file paths to which to apply filelocks.
path Required String The file path.
tags Optional String JSON string of user-defined tags.
Sample Response
HTTP/1.1 200 OK
Cache: no-cache
Connection: close
Content-Type: application/json; charset=utf-8
{
    "paths" : [ 
        {
            "path" : "/path/to/file1",
            "tags" : {"tag" : "tag_string"
        },
        {
            "path" : "/path/to/file2",
            "error" : 
                {
                    "code" : "404",
                    "reason" : "Not Found",
                    "user_message" : "No such file or directory"
        }
    ]
}

Response
Element Type Description
paths String JSON object that contains the array of file paths.
path String The file path.
tags String JSON string of user-defined tags.
error JSON object Error response.
code Double HTTP error code.
reason String HTTP error message.
user_message String Error description.

Remove a Filelock from a File

Delete the filelock on a file, including the file backup and metadata files. Optionally revert the file to it's original state before the filelock was applied.

URL
POST https://{domain}:9092/files/unfilelock

Sample Request
curl -i -u user:secret -X POST https://{domain}:9092/files/unfilelock \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d @request_body.json

Where request_body.json contains the following:
{
    "paths" : [ 
        {
            "path" : "/path/to/file1",
            "revert" : true
        },
        {
            "path" : "/path/to/file2",
            "revert" : false
        }
    ]
}

Request Body
Element Required Type Description
paths Required String JSON object that contains an array of file paths to which to apply filelocks.
path Required String The file path.
revert Optional Boolean Remove the filelock and revert the file to its original state at the time the filelock was applied.
Sample Response
HTTP/1.1 200 OK
Cache: no-cache
Connection: close
Content-Type: application/json; charset=utf-8
{
    "paths" : [ 
        {
            "path" : "/path/to/file1",
        },
        {
            "path" : "/path/to/file2",
            "error" : 
                {
                    "code" : "404",
                    "reason" : "Not Found",
                    "user_message" : "No such file or directory"
        }
    ]
}

Response
Element Type Description
paths String JSON object that contains the array of file paths.
path String The file path.
tags String JSON string of user-defined tags.
error JSON object Error response.
code Double HTTP error code.
reason String HTTP error message.
user_message String Error description.
Video player

Video

×