Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update README with current API state
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Mar 10, 2022
commit 2f26726fe06aca365cfaf12aa1862bb587620823
88 changes: 86 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
### the Files Lock app

# Temporary files lock

![](screenshots/0.7.0.png)

Expand All @@ -25,3 +24,88 @@ Administrators can also lock files using the `./occ` command:

![](screenshots/cli.png)

## API

### Fetching lock details

WebDAV returns the following additional properties if requests through a `PROPFIND`:

- `{http://nextcloud.org/ns}lock`: `true` if the file is locked, otherwise `false`
- `{http://nextcloud.org/ns}lock-owner`: User id of the lock owner
- `{http://nextcloud.org/ns}lock-owner-displayname`: Display name of the lock owner
- `{http://nextcloud.org/ns}lock-time`: Timestamp of the log creation time

### Locking a file

`PUT /apps/files_lock/lock/{fileId}`

```bash
curl -X PUT 'http://admin:[email protected]/ocs/v2.php/apps/files_lock/lock/123' -H 'OCS-APIREQUEST: true'`
```

#### Success
```
<?xml version="1.0"?>
<ocs>
<meta>
<status>ok</status>
<statuscode>200</statuscode>
<message>OK</message>
</meta>
</ocs>
```

#### Failure
```
<?xml version="1.0"?>
<ocs>
<meta>
<status>failure</status>
<statuscode>500</statuscode>
<message/>
</meta>
<data>
<status>-1</status>
<exception>OCA\FilesLock\Exceptions\AlreadyLockedException</exception>
<message>File is already locked by admin</message>
</data>
</ocs>
```


### Unlocking a file

`DELETE /apps/files_lock/lock/{fileId}`

```bash
curl -X DELETE 'http://admin:[email protected]/ocs/v2.php/apps/files_lock/lock/123' -H 'OCS-APIREQUEST: true'
```

#### Success
```
<?xml version="1.0"?>
<ocs>
<meta>
<status>ok</status>
<statuscode>200</statuscode>
<message>OK</message>
</meta>
</ocs>
```

#### Failure
```
<?xml version="1.0"?>
<ocs>
<meta>
<status>failure</status>
<statuscode>500</statuscode>
<message/>
</meta>
<data>
<status>-1</status>
<exception>OCA\FilesLock\Exceptions\LockNotFoundException</exception>
<message></message>
</data>
</ocs>
```