Skip to content

Commit

Permalink
execute_patch added to HubInstance per NXP
Browse files Browse the repository at this point in the history
  • Loading branch information
Murat Kumykov committed Jan 16, 2025
1 parent 61f333d commit 726e1f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions blackduck/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ def execute_put(self, url, data, custom_headers={}):
response = requests.put(url, headers=headers, data=json_data, verify = not self.config['insecure'])
return response

def execute_patch(self, url, data, custom_headers={}) -> requests.Response:
'''
Work-around to add missing execute_patch()
'''
json_data = self._validated_json_data(data)
headers = self.get_headers()
headers["Content-Type"] = "application/json"
headers.update(custom_headers)
response = requests.patch(url, headers=headers, data=json_data, verify=not self.config['insecure'])
return response

def _create(self, url, json_body):
response = self.execute_post(url, json_body)
# v4+ returns the newly created location in the response headers
Expand Down
2 changes: 1 addition & 1 deletion blackduck/HubRestApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class HubInstance(object):
_create,_get_hub_rest_api_version_info,_get_major_version,_get_parameter_string,_validated_json_data,
execute_delete,execute_get,execute_post,execute_put,get_api_version,get_apibase,get_auth_token,get_headers,
get_limit_paramstring,get_link,get_matched_components,get_tags_url,get_urlbase,read_config,write_config,
_check_version_compatibility
_check_version_compatibility,execute_patch
)
from .Roles import (
_get_role_url, assign_role_given_role_url, assign_role_to_user_or_group,
Expand Down

0 comments on commit 726e1f7

Please sign in to comment.