Skip to content

Commit 9d75ea3

Browse files
add method to find app by name
1 parent b553a4a commit 9d75ea3

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

README.md

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

4141
- `get_apps()` : get a list of Veracode applications (JSON format).
4242
- `get_app(guid(opt),legacy_id(opt))`: get information for a single Veracode application using either the `guid` or the `legacy_id` (integer).
43+
- `get_app_by_name(name)`: get list of applications whose names contain the search string `name`.
4344
- `create_app(app_name, business_criticality, business_unit(opt), teams(opt))`: create an application profile.
4445
- `business_criticality`: one of "VERY HIGH", "HIGH", "MEDIUM", "LOW", "VERY LOW"
4546
- `business_unit`: the GUID of the business unit to which the application should be assigned

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name = 'veracode_api_py',
55
packages = ['veracode_api_py'],
6-
version = '0.9.2',
6+
version = '0.9.3',
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',

veracode_api_py/api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ def _rest_request(self, url, method, params=None,body=None,fullresponse=False):
115115
else:
116116
return ""
117117

118-
def _rest_paged_request(self, url, method, element, params=None):
118+
def _rest_paged_request(self, uri, method, element, params=None):
119119
all_data = []
120120
page = 0
121121
more_pages = True
122122

123123
while more_pages:
124124
params['page']=page
125-
page_data = self._rest_request(url,method,params)
125+
page_data = self._rest_request(uri,method,params)
126126
total_pages = page_data.get('page', {}).get('total_pages', 0)
127127
data_page = page_data.get('_embedded', {}).get(element, [])
128128
all_data += data_page
@@ -201,6 +201,11 @@ def get_app (self,guid=None,legacy_id=None):
201201

202202
return self._rest_request(uri,"GET")
203203

204+
def get_app_by_name (self,appname):
205+
"""Gets a list of applications having a name that matches appname, using the Veracode Applications API."""
206+
params = {"name": appname}
207+
return self._rest_paged_request(uri="appsec/v1/applications",method="GET",element="applications",params=params)
208+
204209
def create_app(self,app_name,business_criticality, business_unit=None, teams=[]):
205210
app_def = {'name':app_name, 'business_criticality':business_criticality}
206211

@@ -292,7 +297,6 @@ def create_user (self,email,firstname,lastname,username=None,type="HUMAN",roles=
292297
user_def.update({"roles": rolelist})
293298

294299
payload = json.dumps(user_def)
295-
print(payload)
296300
return self._rest_request('api/authn/v2/users','POST',body=payload)
297301

298302
def update_user (self,user_guid,roles):

0 commit comments

Comments
 (0)