Skip to content

Commit c960393

Browse files
add method for updating teams
1 parent 9d75ea3 commit c960393

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ The following methods call Veracode REST APIs and return JSON.
6969

7070
- `get_teams(all_for_org)`: get the list of teams for the user, or (if `all_for_org` is `True`) all teams in the organization.
7171
- `create_team(team_name,business_unit,members)`: create a team named `team_name`. Optionally pass the business unit guid and/or a list of user names to add to the team.
72+
- `update_team(team_guid,team_name(opt),business_unit(opt),members(opt))`: update the team identified by `team_guid` with the provided information.
7273
- `delete_team(team_guid)`: delete the team identified by `team_guid`.
7374

7475
#### Business Units

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
setup(
44
name = 'veracode_api_py',
55
packages = ['veracode_api_py'],
6-
version = '0.9.3',
6+
version = '0.9.4',
77
license='MIT',
88
description = 'Python helper library for working with the Veracode APIs. Handles retries, pagination, and other features of the modern Veracode REST APIs.',
99
author = 'Tim Jarrett',
1010
author_email = 'tjarrett@veracode.com',
1111
url = 'https://github.com/tjarrettveracode',
12-
download_url = 'https://github.com/tjarrettveracode/veracode-api-py/archive/v_092.tar.gz',
12+
download_url = 'https://github.com/tjarrettveracode/veracode-api-py/archive/v_094.tar.gz',
1313
keywords = ['veracode', 'veracode-api'],
1414
install_requires=[
1515
'veracode-api-signing'

veracode_api_py/api.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,29 @@ def create_team (self, team_name, business_unit=None, members=[]):
339339
payload = json.dumps(team_def)
340340
return self._rest_request('api/authn/v2/teams','POST',body=payload)
341341

342+
def update_team (self, team_guid, team_name="", business_unit=None, members=[]):
343+
requestbody = {}
344+
345+
if team_name != "":
346+
requestbody.update({"team_name": team_name})
347+
348+
if business_unit != None:
349+
requestbody.update({"business_unit": {"bu_id": business_unit}})
350+
351+
if len(members) > 0:
352+
users = []
353+
for member in members:
354+
users.append({"user_name": member})
355+
requestbody.update({"users": users})
356+
357+
if requestbody == {}:
358+
logging.error("No update specified for team {}".format(team_guid))
359+
360+
payload = json.dumps(requestbody)
361+
params = {"partial":True, "incremental":True}
362+
uri = 'api/authn/v2/teams/{}'.format(team_guid)
363+
return self._rest_request(uri,'PUT',body=payload,params=params)
364+
342365
def delete_team (self, team_guid):
343366
uri = 'api/authn/v2/teams/{}'.format(team_guid)
344367
return self._rest_request(uri,"DELETE")
@@ -361,8 +384,11 @@ def get_workspace_by_name(self,name):
361384
return self._rest_paged_request(self.sca_base_url,"GET",params=request_params,element="workspaces")
362385

363386
def create_workspace(self,name):
364-
r = self._rest_request(self.sca_base_url,"POST",body=name,fullresponse=True)
365-
return r.headers.get('location','')
387+
#pass payload with name, return guid to workspace
388+
payload = json.dumps({"name": name})
389+
r = self._rest_request(self.sca_base_url,"POST",body=payload,fullresponse=True)
390+
loc = r.headers.get('location','')
391+
return loc.split("/")[-1]
366392

367393
def add_workspace_team(self,workspace_guid,team_id):
368394
return self._rest_request(self.sca_base_url + "/{}/teams/{}".format(workspace_guid,team_id),"PUT")

0 commit comments

Comments
 (0)