Skip to content

Commit

Permalink
manage creation and update role's user with the console
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmi151 committed Jan 21, 2025
1 parent 1f3cbd9 commit 7f6f75b
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,43 @@ def delorgs(self, id):
# def updateorgs(self):

# ROLES
# def createnewroles(self):
def createnewroles(self, cn="NEWROLE", description="Default description"):
newrole = {
"cn": cn,
"description": description,
}
url = self.server + "/console/private/roles"

response = self.session.post(url,
data=json.dumps(newrole),
auth=(self.username, self.password),
headers=self.headers)

if (response.status_code == 200):
return response.text
else:
print(response.status_code)
return "Error while creating the role"

def updaterolesuser(self, uuid="testadmin", cn="ROLE"):
updateroles = {
"users": [uuid],
"PUT": [cn],
"DELETE": []
}
url = self.server + "/console/private/roles_users"

response = self.session.post(url,
data=json.dumps(updateroles),
auth=(self.username, self.password),
headers=self.headers)

if (response.status_code == 200):
return response.text
else:
print(response.status_code)
return "Error while updating the role's users"

def getroles(self, uid=""):
headers = {'Accept': 'application/json'}
url = self.server + "/console/private/roles/" + uid
Expand Down

0 comments on commit 7f6f75b

Please sign in to comment.