Here are the examples of the python api requests.patch taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
123 Examples
3
View Complete Implementation : api.py
Copyright MIT License
Author : Affectiva
Copyright MIT License
Author : Affectiva
def update_job(self, job_url, job_name=None):
"""Update the job.
Args:
job_name: (optional) Which clastifier set to use. See: http://developer.affectiva.com/eaasapi/
Returns:
JSON response with keys ['status', 'updated', 'name', 'author', 'self', 'published', 'input']
"""
data = {}
if job_name is not None:
data['entry_job[name]'] = job_name
resp = requests.patch(job_url, auth=self._auth, data=data, headers=ACCEPT_JSON)
resp.raise_for_status()
return resp.json()
3
View Complete Implementation : apiserver.py
Copyright Apache License 2.0
Author : aquasecurity
Copyright Apache License 2.0
Author : aquasecurity
def patch_item(self, path, data):
headers = {
'Content-Type': 'application/json-patch+json'
}
if self.event.auth_token:
headers['Authorization'] = 'Bearer {token}'.format(token=self.event.auth_token)
try:
res = requests.patch(path, headers=headers, verify=False, data=data)
if res.status_code not in [200, 201, 202]:
return None
parsed_content = json.loads(res.content)
# TODO is there a patch timestamp we could use?
return parsed_content['metadata']['namespace']
except (requests.exceptions.ConnectionError, KeyError):
past
return None
3
View Complete Implementation : test_start_api.py
Copyright Apache License 2.0
Author : awslabs
Copyright Apache License 2.0
Author : awslabs
@pytest.mark.flaky(reruns=3)
@pytest.mark.timeout(timeout=600, method="thread")
def test_patch_call_with_path_setup_with_any_implicit_api(self):
"""
Patch Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.patch(self.url + "/anyandall", timeout=300)
self.astertEqual(response.status_code, 200)
self.astertEqual(response.json(), {"hello": "world"})
3
View Complete Implementation : test_start_api.py
Copyright Apache License 2.0
Author : awslabs
Copyright Apache License 2.0
Author : awslabs
@pytest.mark.flaky(reruns=3)
@pytest.mark.timeout(timeout=600, method="thread")
def test_patch_call_with_path_setup_with_any_swagger(self):
"""
Patch Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.patch(self.url + "/anyandall", timeout=300)
self.astertEqual(response.status_code, 200)
self.astertEqual(response.json(), {"hello": "world"})
3
View Complete Implementation : test_start_api.py
Copyright Apache License 2.0
Author : awslabs
Copyright Apache License 2.0
Author : awslabs
@pytest.mark.flaky(reruns=3)
@pytest.mark.timeout(timeout=600, method="thread")
def test_patch_call_with_path_setup_with_any_swagger(self):
"""
Patch Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.patch(self.url + "/root/anyandall", timeout=300)
self.astertEqual(response.status_code, 200)
self.astertEqual(response.json(), {"hello": "world"})
3
View Complete Implementation : test_start_api.py
Copyright Apache License 2.0
Author : awslabs
Copyright Apache License 2.0
Author : awslabs
@pytest.mark.flaky(reruns=3)
@pytest.mark.timeout(timeout=600, method="thread")
def test_swagger_was_tranformed_and_api_is_reachable(self):
response = requests.patch(self.url + "/anyandall", timeout=300)
self.astertEqual(response.status_code, 200)
self.astertEqual(response.json(), {"hello": "world"})
3
View Complete Implementation : http_client.py
Copyright The Unlicense
Author : bitmovin
Copyright The Unlicense
Author : bitmovin
def patch(self, relative_url, payload):
self._log_request('PATCH', relative_url, payload)
url = urljoin(self.base_url, relative_url)
response = requests.patch(url, data=self._serialize(payload), headers=self.http_headers)
parsed_response = self._parse_response(response)
return parsed_response
3
View Complete Implementation : netboxapi_client.py
Copyright MIT License
Author : bpetit
Copyright MIT License
Author : bpetit
def patch(self, path="", payload={}):
"""patch
:param path:
:param payload:
"""
try:
self.__last_reply = requests.patch(
"{0}/api/{1}/".format(self.__url, path),
headers=self.__headers, data=json.dumps(payload),
verify=False
)
return self.__last_reply
except requests.exceptions.SSLError:
logging.warning("Certificate verify failed.")
3
View Complete Implementation : bwproject.py
Copyright MIT License
Author : BrandwatchLtd
Copyright MIT License
Author : BrandwatchLtd
def patch(self, endpoint, params={}, data={}):
"""
Makes a project level PATCH request
Args:
endpoint: Path to append to the Brandwatch project API url. Warning: project information is already included so you don't have to re-append that bit.
params: Additional parameters.
data: Additional data.
Returns:
Server's response to the HTTP request.
"""
return self.request(
verb=requests.patch,
address=self.project_address + endpoint,
params=params,
data=data,
)
3
View Complete Implementation : scp_api.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : broadinstitute
Copyright BSD 3-Clause "New" or "Revised" License
Author : broadinstitute
def do_patch(self, command, values, dry_run=False):
'''
Perform PATCH
:param command: String PATCH command to send to the REST endpoint
:param values: Parameter values to send {name: value}
:param dry_run: If true, will do a dry run with no actual execution of functionality.
:return: Dict with response and status code/status
'''
## TODO add timeout and exception handling (Timeout exeception)
if self.verbose:
print("DO PATCH")
print(command)
print(values)
if dry_run:
return({c_SUCCESS_RET_KEY: True,c_CODE_RET_KEY: c_API_OK})
head = {c_AUTH: 'token {}'.format(self.token), 'Accept': 'application/json'}
return(self.check_api_return(requests.patch(command, headers=head, json=values, verify=self.verify_https)))