Skip to content

Commit 1c916a9

Browse files
author
Glenn Snyder
authored
Merge pull request #88 from blackducksoftware/gsnyder/fix-cf-methods-accept-values
removing hard-coded media type values
2 parents 9ff0964 + 3a43292 commit 1c916a9

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

blackduck/HubRestApi.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,7 @@ def get_cf_objects(self):
14171417
url = self._get_cf_url()
14181418
if not hasattr(self, "_cf_objects"):
14191419
logging.debug("retrieving objects")
1420-
custom_headers = {'Accept': 'application/vnd.blackducksoftware.admin-4+json'}
1421-
response = self.execute_get(url, custom_headers=custom_headers)
1420+
response = self.execute_get(url)
14221421
self._cf_objects = response.json()
14231422
return self._cf_objects
14241423

@@ -1431,8 +1430,7 @@ def get_cf_object(self, object_name):
14311430
assert object_name in self.supported_cf_object_types(), "Object name {} not one of the supported types ({})".format(object_name, self.supported_cf_object_types())
14321431

14331432
object_url = self._get_cf_object_url(object_name)
1434-
custom_headers = {'Accept': 'application/vnd.blackducksoftware.admin-4+json'}
1435-
response = self.execute_get(object_url, custom_headers=custom_headers)
1433+
response = self.execute_get(object_url)
14361434
return response.json()
14371435

14381436
def _get_cf_obj_rel_path(self, object_name):
@@ -1462,11 +1460,7 @@ def create_cf(self, object_name, field_type, description, label, position, activ
14621460
}
14631461
if field_type in types_using_initial_options and initial_options:
14641462
cf_request.update({"initialOptions": initial_options})
1465-
custom_headers = {
1466-
'Content-Type': 'application/vnd.blackducksoftware.admin-4+json',
1467-
'Accept': 'application/json'
1468-
}
1469-
response = self.execute_post(post_url, data=cf_request, custom_headers=custom_headers)
1463+
response = self.execute_post(post_url, data=cf_request)
14701464
return response
14711465

14721466
def delete_cf(self, object_name, field_id):
@@ -1486,8 +1480,7 @@ def get_custom_fields(self, object_name):
14861480

14871481
url = self._get_cf_object_url(object_name) + "/fields"
14881482

1489-
custom_headers = {'Accept': 'application/vnd.blackducksoftware.admin-4+json'}
1490-
response = self.execute_get(url, custom_headers=custom_headers)
1483+
response = self.execute_get(url)
14911484
return response.json()
14921485

14931486
def get_cf_values(self, obj):
@@ -1496,8 +1489,7 @@ def get_cf_values(self, obj):
14961489
The obj is expected to be the JSON document for a project, project-version, component, etc
14971490
'''
14981491
url = self.get_link(obj, "custom-fields")
1499-
custom_headers = {'Accept': 'application/vnd.blackducksoftware.component-detail-5+json'}
1500-
response = self.execute_get(url, custom_headers=custom_headers)
1492+
response = self.execute_get(url)
15011493
return response.json()
15021494

15031495
def get_cf_value(self, obj, field_id):
@@ -1506,16 +1498,14 @@ def get_cf_value(self, obj, field_id):
15061498
The obj is expected to be the JSON document for a project, project-version, component, etc
15071499
'''
15081500
url = self.get_link(obj, "custom-fields") + "/{}".format(field_id)
1509-
custom_headers = {'Accept': 'application/vnd.blackducksoftware.component-detail-5+json'}
1510-
response = self.execute_get(url, custom_headers=custom_headers)
1501+
response = self.execute_get(url)
15111502
return response.json()
15121503

15131504
def put_cf_value(self, cf_url, new_cf_obj):
15141505
'''new_cf_obj is expected to be a modified custom field value object with the values updated accordingly, e.g.
15151506
call get_cf_value, modify the object, and then call put_cf_value
15161507
'''
1517-
custom_headers = {'Accept': 'application/vnd.blackducksoftware.component-detail-5+json'}
1518-
return self.execute_put(cf_url, new_cf_obj, custom_headers=custom_headers)
1508+
return self.execute_put(cf_url, new_cf_obj)
15191509

15201510
##
15211511
#

blackduck/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = (0, 0, 44)
1+
VERSION = (0, 0, 45)
22

33
__version__ = '.'.join(map(str, VERSION))

0 commit comments

Comments
 (0)