API
Please refer to our API Articles, if needed, for setup instructions
You will also need to have a copy of your API key, or Generate A New One
Add User
Using the PUT Command you are able to add a user, or multiple users, to a project. Examples below.
Single User:
curl -X 'PUT' \
'https://<instance>.iriusrisk.com/api/v1/products/<project-id>/users' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'api-token: <API TOKEN>' \
-d '{
"users": [
"<username>"
]
}'
*Be sure to replace any "<>" with the information needed for your command*
For this command, the section you want to set your user would be towards the bottom:
Multiple Users:
curl -X 'PUT' \
'https://<instance>.iriusrisk.com/api/v1/products/<project-id>/users' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'api-token: <API TOKEN>' \
-d '{
"users": [
"<username1>","<username2>"
]
}'
*Making sure each username is surrounded by quotations and separated by a comma*
Remove User
To remove a single user, you can use the following command:
curl -X 'DELETE' \
'https://<instance>.iriusrisk.com/api/v1/products/<project-id>/users/<username>' \
-H 'api-token: <API TOKEN>' \
-H 'accept: application/json'
For this command, the section you want to add the username being removed is in the url:
If you need to remove multiple users, it will require a few more steps, but it is something that can help in a case you are removing a long list of users.
You first want to pull a list of users assigned to that project:
curl -X 'GET' \
'https://<instance>.iriusrisk.com/api/v1/products/<product-id>/users' \
-H 'api-token: <API TOKEN>' \
-H 'accept: application/json' | jq -r
*Using `jq -r` will help with the output, but is not needed if you do not use jq*
The output here would be expected to look similar to the following:
[
"user1",
"user2",
"user3"
]
Placing the users you want to remove into a txt file, you can then run a while loop to complete the process.
<file>.txt
user2
user3
An example of a while loop that can be used (however feel free to use any bash commands you are comfortable with to achieve the same outcome):
cat <file>.txt | while read user; do curl -X 'DELETE' \
'https://<instance>.iriusrisk.com/api/v1/products/<project-id>/users/'${user}'' \
-H 'api-token: <API-TOKEN>' \
-H 'accept: application/json'; done
This command will run for every user listed within your txt file. In the above example, "user2" and "user3" would be removed from the project.
Comments
0 comments
Article is closed for comments.