Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This documents the possibility to interact with the admin system using REST calls (GET, POST, PUT, PATCH, DELETE) allowing automation of tasks like creating projects and users.

...

This is a separate API from the normal REST API and the base url should be the same as the admin system (i.e. https://adm-us.drofus.com/)  you are trying to access.

E.g. the link http://[admin-url]/projects gives the normal HTML project listing while http://[url]/projects.xml gives the same list in XML format and http://[admin-url]/projects.json gives the list with project and project users in JSON format

...

Code Block
curl -H "Accept: application/json" -s -u testadmin:testpw http://localhost:3000[admin-url]/users/hakonhc

will give the same as 

Code Block
curl -s -u testadmin:testpw http://localhost:3000[admin-url]/users/hakonhc.json

Resources:

...

ResouceDescription
/node/loginsGet login statistics for projects for the last 5 years, grouped by type of client used(Revit, dRofus etc.)
/node/logins?from_date=2018-01-01&to_date=2019-12-31Get login statistics for projects for the given time period, grouped by type of client used(Revit, dRofus etc.)
/node/unique_usersGets number of unique users for each project for the last 5 years
/node/unique_users?from_date=2018-01-01&to_date=2019-12-31Gets number of unique users for each project for the given period.
/project_data?from_date=2018-01-01&to_date=2019-12-31Get statstics values on projects, to_date and from_date are optional limits on date
/password/request_resetA post request with a valid username will trigger a password reset email
/password/resetUse this with a token to change password with the API

...

Code Block
$ curl -s -u testadmin:testpw http://localhost:3000[admin-url]/projects.json?query=template|json_reformat 
[
    {
        "project": {
            "active": true,
            "contact": null,
            "created_at": "2016-11-01T09:39:14Z",
            "created_by": null,
            "database_id": "akl-test",
            "description": null,
            "gross_area": null,
            "id": 399,
            "name": "dRofus dev template",
            "no": "01",
            "owner_id": 5,
            "status": null,
            "updated": null,
            "updated_by": null,
			"unit_type": "SM" #SM for square meters or SF for square feet
        }
    },
.....

...

Code Block
$ curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -u testadmin:testpw -d '{"owner":{"name":"Test"}}' http://localhost:3000[admin-url]/owners


{"owner":{"address":null,"billing_address":null,"contact":null,"id":11,"image":null,"name":"Test","network":null,"note":null,"tech_contact":null}}

...

Code Block
$ curl -H "Accept: application/json" -H "Content-type: application/json; charset=UTF-8" -X POST -u testadmin:testpw -d @data.json http://localhost:3000[admin-url]/project_users

{"project_user":{"created_at":"2016-11-28T12:22:35Z","project_id":408,"role":null,"superuser":null,"user_role_id":null,"username":"hakonhc"}}

...

Code Block
$ curl -H "Accept: application/json" -H "Content-type: application/json; charset=UTF-8" -X PATCH -u testadmin:testpw -d @data.json http://localhost:3000[admin-url]/projects/1

Wherer data.json contains

...

Code Block
$ curl -H "Accept: application/json" -H "Content-type: application/json; charset=UTF-8" -X PATCH -u testadmin:testpw -d @data.json http://localhost:3000[admin-url]/project_user/testuser,1

Wherer data.json contains

...

Code Block
curl -H "Accept: application/json" -s -u http://localhost:3000[admin-url]/project_users/[username],[project_id] -X DELETE

...