API usage examples

Logging in and retrieving session key

curl -k -X POST -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo.whl/api/system/login -d
{"username": "api_user", "password": "api_password"}

Result: {"sessionid":"oz2jfky042kz7d3zc2gos1ahxouxehk3"}

Fetching users list

curl -k -X GET -H "Accept:application/json" -H "Content-Type:application/json"
"https://fudo.whl/api/system/users?sessionid={{sessionid}}&page_size=2&page=1"

Result:
{
"count":110,
"next":"https://fudo.whl/api/system/users?page=2&page_size=2&sessionid={{sessionid}}",
"previous":null,"results":
        [{
        "id":688817234205737171,
        "email":"",
        "language":"en",
        "blocked":true,
        "reason":"",
        "name":"Administrator",
        "full_name":"",
        "organization":null,
        "phone":"",
        "ad_domain":"",
        "ldap_base":"",
        "failures":0,
        "external_sync":false,
        "valid_since":"0001-01-01T00:00:00",
        "valid_to":"9999-12-31T23:59:59.999999",
        "role":"user"
        },
        {
        "id":688817234205737275,
        "email":"",
        "language":"en",
        "blocked":false,
        "reason":"",
        "name":"User20000",
        "full_name":"test user",
        "organization":"test organization",
        "phone":"",
        "ad_domain":"test.ad",
        "ldap_base":"",
        "failures":0,
        "external_sync":false,
        "valid_since":"2017-05-19T09:23:14",
        "valid_to":"2017-07-18T09:23:14",
        "role":"user"
}]}

Adding a user

curl -X POST -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo/api/system/users?sessionid={{sessionid}} -d
{"role": "user",  "name": "test-user", "language":"en"}

Result:
{
        "id":688817234205737277,
        "email":"",
        "language":"en",
        "blocked":false,
        "reason":"",
        "name":"test-user-admin",
        "full_name":"",
        "organization":null,
        "phone":"",
        "ad_domain":"",
        "ldap_base":"",
        "failures":0,
        "external_sync":false,
        "valid_since":"0001-01-01T00:00:00",
        "valid_to":"9999-12-31T23:59:59.999999",
        "role":"user"
}

Setting user authentication method - static password

curl -k -X POST -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo/api/system/users/688817234205737277/methods?sessionid={{sessionid}} -d
{"type": "password", "secret": "test-password", "position":0}

Result:
{
"id":688817234205751316,
"needs_change":false,
"position":0,
"type":"password"
}

Setting user authentication method - SSH key

curl -k -X POST -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo.whl/api/system/users/688817234205737277/methods?sessionid={{sessionid}} -d
{
"type": "sshkey",
"secret": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDS7xsCHfD+bnAoKytzwnxCmTfGEvUuA...",
"position":0
}

Result:
{
"id":688817234205752136,
"needs_change":false,
"position":1,
"type":"sshkey"
}

Fetching user authentication methods list

curl -k -X GET -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo.whl/api/system/users/688817234205737277/methods?sessionid={{sessionid}}

Result: {
"id":688817234205751316,
"needs_change":false,
"position":0,
"type":"password"
},{
"id":688817234205752136,
"needs_change":false,
"position":1,
"type":"sshkey"
}

Deleting user authentication method

curl -k -X DELETE -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo.whl/api/system/users/688817234205737277/methods/688817234205751316?sessionid={{sessionid}}

Changing user login

curl -k -X PATCH -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo.whl/api/system/users/688817234205737277?sessionid={{sessionid}} -d
{"name": "new-user"}

Result: {
"id":688817234205737277,
"email":"",
"language":"en",
"blocked":false,
"reason":"",
"name":"new-user",
"full_name":"",
"organization":null,
"phone":"",
"ad_domain":"",
"ldap_base":"",
"failures":0,
"external_sync":false,
"valid_since":"0001-01-01T00:00:00",
"valid_to":"9999-12-31T23:59:59.999999",
"role":"user"
}

Blocking a user

curl -k -X PATCH -H "Accept:application/json" -H "Content-Type:application/json"
https://fudo.whl/api/system/users/688817234205737277?sessionid={{sessionid}} -d
{"blocked": "True"}

Result: {
"id":688817234205737277,
"email":"",
"language":"en",
"blocked":true,
"reason":"",
"name":"new-user",
"full_name":"",
"organization":null,
"phone":"",
"ad_domain":"",
"ldap_base":"",
"failures":0,
"external_sync":false,
"valid_since":"0001-01-01T00:00:00",
"valid_to":"9999-12-31T23:59:59.999999",
"role":"user"
}

Setting a password for an Account with type “forward”

      curl -k -X PUT -H "Accept:application/json" -H "Content-Type:application/json"
      https://fudo.whl/api/system/accounts/688817234205737277?sessionid={{sessionid}} -d
      {
"blocked": false,
"credentials": {
  "login": "",
  "method": "password",
  "secret": "blablabla",
  "public_key": null
},
"dump_mode": "all",
"id": 1992864825355,
"name": "forward",
"ocr_enabled": false,
"password_change_request": "0001-01-01T00:00:00",
"password_checkout_time_limit": null,
"password_lastupdate": "0001-01-01T00:00:00",
"server_id": 1992864825356,
"type": "forward"  }