Automatically create a workspace according to table.field

Hello,

I am using Custom DB authentication from a table that was already in my database, and i would like to use the same system…
In this table I have: username, password and group_id

I was wondering if it is possible to automatically create a workspace for each group_id, so that all usernames with the same group_id will have automatically access to their workspace.
Example:
User1 – group_id=1
user2 – group_id=2
user3 – group_id=1

user 1 and user 3 will automatically see a workspace (because they have both group_id = 1)
user 2 will see another workspace because of group_id=2

is this possible?

Hi,

Yes and No:

Creating automatically workspace, it’s possible by using api/cli with a list of workspace ID (group id)

But matching user and role id (group_id) in Pydio is not possible. It requires an extra works to map groups_id attribute to roleid in PYdio.

Hello,

so, can you explain me how to have one workspace created for each different value of a certain column of the users table?

Hi,
Please visit: https://pydio.com/forum/f/topic/pydio-api-create-workspace/

I did see that… but it was really hard for me to understand :frowning:
don’t you have any example of codes? that would help

even because If i can implement this features… I will use your service, otherwise I will have to look for something else :frowning:

Hi,

Try this command:
curl -u username:password -d "@data.json" -H "Content-Type: application/x-www-form-urlencoded" -X POST {{url}}/api/v2/admin/workspaces?format=json

This command create new workspace newWSP in Pydio

data.json file content:

{
  "securityScope": "USER",
  "slug": "newWSP",
  "display": "newWSP_LABEL",
  "displayStringId": 432,
  "accessType": "fs",
  "writeable": true,
  "isTemplate": false,
  "parameters": {
    "CREATION_TIME": 1468593800,
    "USER_DESCRIPTION": 476,
    "PATH": "AJXP_DATA_PATH/newWSP",
    "CREATE": true,
    "RECYCLE_BIN": "recycle_bin",
    "CHMOD_VALUE": "0600",
    "DEFAULT_RIGHTS": "rw",
    "PAGINATION_THRESHOLD": 500,
    "PAGINATION_NUMBER": 200
  },
  "features": {
    "metastore.serial": {
      "METADATA_FILE": ".ajxp_meta",
      "METADATA_FILE_LOCATION": "infolders"
    },
    "meta.user": {
      "meta_fields": "tags",
      "meta_labels": "Tags",
      "meta_visibility": "hidden"
    },
    "meta.filehasher": [],
    "meta.watch": [],
    "meta.syncable": {
      "REPO_SYNCABLE": true
    },
    "meta.exif": {
      "meta_fields": "COMPUTED_GPS.GPS_Latitude,COMPUTED_GPS.GPS_Longitude",
      "meta_labels": "Latitude,Longitude"
    },
    "index.lucene": {
      "index_meta_fields": "tags",
      "repository_specific_keywords": "AJXP_USER"
    }
  },
  "INFO": {
    "users": 12,
    "shares": 74
  }
}

Hello,

sadly under my web hosting service I can’t use CURL :frowning:

i would like to find a way to create it from php… so that when i create a new user on the DB, a workspace is created too

Hello,

You do not need to get inside the server to execute curl. You can use just one linux (mac) machine to execute curl to interact with api of pydio {{url}}/api/v2/admin/workspaces?format=json