Method for Working with Administrator Accounts

To work with administrator accounts, execute requests using the "accounts" API method (determine administrator token before executing the request):

curl -X POST -v '<IP address or DNS server name>/api/v2/accounts/staff/local/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{
    "username": "<local administrator login>",
    "password": "<local administrator password>",
    "confirmed_password": "<repeat local administrator password>",
    "is_active": <indicates whether local administrator is active (true/false)>,
    "full_name": "<Full name>",
    "email": "<e-mail>",
    "time_zone": "<time zone>"
}'

In the <time zone> substitution use one of the values contained in the Time Zone drop-down list.

The example of response:

{
    "id": 2,
    "username": "new_admin",
    "is_active": true,
    "full_name": "FIO",
    "email": "user@example.com",
    "time_zone": "(UTC+03:00) Europe/Chisinau"
}

curl -v '<IP address or DNS server name>/api/v2/accounts/staff/local/<requested administrator>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested administrator identifier> substitution use value of the id parameter returned on getting the list of all administrator accounts.

The example of response:

{
    "id": 3,
    "username": "admin",
    "is_active": true,
    "full_name": "admin admin admin",
    "email": "admin@example.com",
    "time_zone": "Europe/Moscow"
}

curl -X PUT -v '<IP address or DNS server name>/api/v2/accounts/staff/local/<requested administrator identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{
    "username": "<local administrator login>",
    "is_active": <indicates whether local administrator is active (true/false)>,
    "full_name": "<Full name>",
    "email": "<e-mail>",
    "time_zone": "<time zone>"
}'

In the <requested administrator identifier> substitution use value of the id parameter returned on getting all administrator accounts, and in the <time zone> substitution use one of the values contained in the Time Zone drop-down list.

The example of response:

{
    "id": 3,
    "username": "admin_3",
    "is_active": false,
    "full_name": "admin admin admin",
    "email": "admin@example.com",
    "time_zone": "Europe/Moscow"
}

curl -X POST -v '<IP address or DNS server name>/api/v2/accounts/staff/local/<requested administrator identifier>/reset-password/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{ "password": "<new password>", "confirmed_password": "<repeat new password>"}'

In the <requested administrator identifier> substitution use value of the id parameter returned on getting the list of all administrator accounts.

The example of response:

200

curl -X POST -v '<IP address or DNS server name>/api/v2/accounts/staff/ldap/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{"time_zone": <time zone>, "ldap_sid": <SID identifier of administrator from LDAP>}'

In the <time zone> substitution use one of the values contained in the Time Zone drop-down list.

The example of response:

{
    "id": 4,
    "is_active": true,
    "full_name": "testusers_3249",
    "email": "",
    "time_zone": "Europe/Moscow"
}

curl -v '<IP address or DNS server name>/api/v2/accounts/staff/ldap/<requested administrator identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested administrator identifier> substitution use value of the id parameter returned on getting the list of all administrator accounts.

The example of response:

{
    "id": 5,
    "is_active": true,
    "full_name": "testusers_3251",
    "email": "",
    "time_zone": "Europe/Moscow"
}

curl -X PUT -v '<IP address or DNS server name>/api/v2/accounts/staff/ldap/<requested administrator identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{"time_zone": <time zone>, "ldap_sid" :<SID identifier of administrator from LDAP>}'

In the <requested administrator identifier> substitution use value of the id parameter returned on getting all administrator accounts, and in the <time zone> substitution use one of the values contained in the Time Zone drop-down list.

The example of response:

{
    "id": 5,
    "is_active": true,
    "full_name": "testusers_3251",
    "email": "",
    "time_zone": "Europe/Chisinau"
}

curl -v '<IP address or DNS server name>/api/v2/accounts/staff/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

The example of response:

{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 5,
            "username": "admin",
            "full_name": "",
            "is_active": true,
            "is_ldap": false,
            "is_superuser": false,
            "is_request_user": false,
            "time_zone": "Europe/Moscow"
        },
        {
            "id": 1,
            "username": "superuser",
            "full_name": "",
            "is_active": true,
            "is_ldap": false,
            "is_superuser": true,
            "is_request_user": true,
            "time_zone": "Europe/Moscow"
        }
    ]
}

curl -X DELETE -v '<IP address or DNS server name>/api/v2/accounts/staff/<requested administrator identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested administrator identifier> substitution use value of the id parameter returned on getting the list of all administrator accounts.

The example of response:

204 No Content

See also:

Server API