How to create a Dataiku user using python script

ponselvan
Level 1
How to create a Dataiku user using python script

Hello All,

I am in the process of creating Python code for creating the new user in Dataiku & I would like to have the input sample & output sample as below. can someone help me to create a Dataiku user using python code

Input Jason:

Sample Request JSON Body
-------------------------
{
"accountName": "xxxx",
"accountOwner": "xxxx",
"accountType": "User",
"accountStatus": "Active",
"accessRole": [
{
"roleName": "Admin"
}
]
}
Output Jason:

Sample Response JSON body 1
----------------------------
Response code
200 OK
{
"accountName": "xxxx",
"accountOwner": "xxxx",
"accountType": "User",
"accountStatus": "Active",
"accessRole": [
{
"roleName": "Admin"
}
],
"status": "Success"
"statusMessage": "User account xxx got successfully created"
}

Sample Response body 2
-----------------------
{
"accountName": "xxxx",
"accountOwner": "xxxx",
"status": "Failure",
"statusMessage": "User account 'xxxx' already exists."
}


Operating system used: Red Hat Enterprise Linux Server release 7.9 (Maipo)

0 Kudos
2 Replies
sergeyd
Dataiker

Hi @ponselvan 

Have you had a chance to review our Python API docs related to this topic: 

https://doc.dataiku.com/dss/latest/python-api/users-groups.html#creating-a-user ?

The code should be like this: 

import dataiku

client = dataiku.api_client()
new_user = client.create_user('test_user', 'test_password', display_name='test_user', groups=['test_group'])

 

Alternatively (if you are looking at another automated way of doing this), you can use the dsscli tool: 

https://doc.dataiku.com/dss/10.0/operations/dsscli.html#user-create

 

Please let me know if this is what you were looking for. 

 

0 Kudos
ponselvan
Level 1
Author

@sergeyd Thanks for the update. However, I wanted to give the input as sample request code mentioned below not as hard coded input.

Sample Request JSON Body
-------------------------
{
"accountName": "xxxx",
"accountOwner": "xxxx",
"accountType": "User",
"accountStatus": "Active",
"accessRole": [
{
"roleName": "Admin"
}
]
}

0 Kudos