REST API Files

Unlike other REST APIs, these use the file ID (found in the Browser) or the UUID (found in all payloads or json representations) instead of the configuration ID.

The REST API for files follows the best practices for RESTful API design. Ensure you read the HTTP status codes and interpret them together with the responses.

For each call, you can add the following command:

-w"\n%{http_code}\n"

After the username and password in order to receive more meaningful HTTP errors.

Read a File

Request method - GET

Description

Returns a list of the file information in Datameer.

URI syntax

curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>'

Example response

{
  "createdAt": "2016-01-21T15:45:58.487+01:00",
  "description": "",
  "extension": "upl",
  "folder": [
    "/Data/FileUploads",
    "b618b856-ec00-436e-afd3-3cbe65c8175a"
  ],
  "modifiedAt": "2016-01-21T15:46:55.280+01:00",
  "name": "TestCase",
  "path": "/Data/FileUploads/TestCase.upl",
  "permission": {
    "groups": {},
    "owner": "admin",
    "permissionForOthers": {
      "executable": false,
      "readable": false,
      "writable": false
    },
    "publiclyShared": false
  },
  "uuid": "816ab399-7aae-424f-9f60-a9265cebc9a8",
  "_links": {
    "folder": {
      "href": "/api/filesystem/folders/8"
    },
    "self": {
      "href": "/api/filesystem/files/50"
    },
    "permission": {
      "href": "/api/filesystem/files/50/permission"
    }
  }

Read the Permissions of a File

Request method - GET

Description

Returns a list of the file permissions in Datameer.

URI syntax

curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission'

Example response

{
  "others": {
    "executable": true,
    "readable": true,
    "writable": true
  },
  "owner": "system",
  "_links": {
    "others": {
      "href": "/api/filesystem/files/26/permission/others"
    },
    "file": {
      "href": "/api/filesystem/files/26"
    },
    "owner": {
      "href": "/api/filesystem/files/26/permission/owner"
    },
    "self": {
      "href": "/api/filesystem/files/26/permission"
    },
    "groups": {
      "href": "/api/filesystem/files/26/permission/groups"
    }
  }

Read the Group Permissions of a File

Request method - GET

Description

Returns a list of the file group permissions in Datameer.

URI syntax

curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/groups'

Example response

 
{
  "_links": {
    "self": {
      "href": "/api/filesystem/files/26/permission/groups"
    },
    "permission": {
      "href": "/api/filesystem/files/26/permission"
    }
  },
  "_embedded": {
    "groups": [
      {
        "flags": {
          "executable": true,
          "readable": true,
          "writable": true
        },
        "name": "dasuser",
        "_links": {
          "self": {
            "href": "/api/filesystem/files/26/permission/groups/dasuser"
          },
          "permission": {
            "href": "/api/filesystem/files/26/permission"
          }
        }
      }
    ]
  }

Read the Others Permissions of a File

Request method - GET

Description

Returns a list of the file permissions for others in Datameer.

URI syntax

curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/others'

Example response

{
  "executable": true,
  "readable": true,
  "writable": true,
  "_links": {
    "self": {
      "href": "/api/filesystem/files/26/permission/others"
    },
    "permission": {
      "href": "/api/filesystem/files/26/permission"
    }
  }

Read the Owner of a File

Request method - GET

Description

Returns the owner of file in Datameer.

URI syntax

curl -u '<username>:<password>' -X GET 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/owner'

Example response

 {
  "owner": "system",
  "_links": {
    "self": {
      "href": "/api/filesystem/files/26/permission/owner"
    },
    "permission": {
      "href": "/api/filesystem/files/26/permission"
    }
  }

Change the Owner of a File

Request method - PUT

Description

Changes the owner of file in Datameer.

URI syntax

curl -u <username>:<password> -X PUT -H 'Content-Type:application/json' -H 'Accept: application/json'  -d "{owner:<username>}" 'http://
<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/owner'

Verification

Check through a REST command or in the File Browser.

Create a Group Permission for a File

Request method - POST

Description

Sets permissions for groups created in Datameer. 

URI syntax

curl -u <username>:<password> -X POST -H 'Content-Type:application/json' -d '{name:<groupName>, flags:{fullResults:<true/false>, readable:<true/false>, writable:<true/false>, executable:<true/false> }}' 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/groups'

Verification

Check through a REST command or in the File Browser.

Additional Information

The flag "fullResults" is optional and only useful when using this REST call for a workbook.

Change the Group Permission for a File

Request method - PUT

Description

Changes permissions for groups created in Datameer.

URI syntax

curl -u <username>:<password> -X PUT -H 'Content-Type:application/json' -d '{name:<groupName>, flags:{fullResults:<true/false>, readable:<true/false>, writable:<true/false>, executable:<true/false>}}' 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/groups/<groupName>'

Verification

Check through a REST command or in the File Browser.

Additional Information

The flag "fullResults" is optional and only useful when using this REST call for a workbook.

Change the Others Permissions for a File

Request method - PUT

Description

Changes permissions for others in Datameer.

URI syntax

curl -u <username>:<password> -X PUT -H 'Content-Type:application/json' -d ' {fullResults:<true/false>, readable:<true/false>, writable:<true/false>, executable:<true/false>}' 'http://<Datameer-serverIP:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/others'

Verification

Check through a REST command or in the File Browser.

Additional Information

The flag "fullResults" is optional and only useful when using this REST call for a workbook.

Delete Group Permission of a File

Request method - DELETE

Description

Deletes the group permissions of a file in Datameer.

URI syntax

curl -u <username>:<password> -X DELETE 'http://<Datameer-serverIP>:<port-number>/api/filesystem/files/<file-id> or <uuid>/permission/groups/<group-name>'

Verification

Check through a REST command or in the File Browser.