GoodData | Developer Network

Adding User to Project Programmatically

by ZD (@zsvoboda)

The CL Tool 1.2.35 adds a new AddUsersToProject command that allows you to programmatically add an existing user (previously created by the CreateUser command). No confirmation e-mails are required. The user who is adding new users must be the admin in the project where the new users are added. Moreover the user must be the domain admin. Let us know at support@gooddata.com if you need your own domain.

Once your account is associated with the domain, you can simply run the command from a CL Tool script:

CreateUser(domain="MYDOMAIN", username="admin@domain.com", password="secret", firstName="John", lastName="Doe", company="John.Doe@acme.com", ssoProvider="SALESFORCE", usersFile="users.txt", append="true");

AddUsersToProject(usersFile="users.txt", role="DASHBOARD ONLY");

Each new user created by the CreateUser command is identified by an URI that can be accumulated in the usersFile. The usersFile can be overwritten (append="false") or appended (append="true").

The users represented by the URIs in the usersFile can be added to an existing project using the AddUsersToProject command. This command requires a project context (_CreateProject_, OpenProject, UseProject above). Then it wants the usersFile that contains a user URI on each line and the role parameter that specifies the role (_admin_, editor, dashboard only) that all users will have in the project.

As always the AddUsersToProject command invokes corresponding REST API. You can always check out the API invocation in the CL tool source code.

Let us know what you think!

blog comments powered by Disqus