|
@@ 122-140 (lines=19) @@
|
| 119 |
|
|
| 120 |
|
return response.json() |
| 121 |
|
|
| 122 |
|
def PUT(self, url, data, timeout=None): |
| 123 |
|
"""Issues a PUT request to the URL with the data specified. Returns an |
| 124 |
|
object that is parsed from the response JSON.""" |
| 125 |
|
data = self._encode_request(data) |
| 126 |
|
|
| 127 |
|
logger.info(f'PUT {url} with {data}') |
| 128 |
|
|
| 129 |
|
response = self.session.put( |
| 130 |
|
url, |
| 131 |
|
data=data, |
| 132 |
|
headers={ |
| 133 |
|
'content-type': 'application/json', |
| 134 |
|
}, |
| 135 |
|
timeout=timeout, |
| 136 |
|
auth=self.auth) |
| 137 |
|
if response.status_code != 200: |
| 138 |
|
self.raise_error(response) |
| 139 |
|
|
| 140 |
|
return response.json() |
| 141 |
|
|
| 142 |
|
def DELETE(self, url, data, timeout=None): |
| 143 |
|
''' |
|
@@ 102-120 (lines=19) @@
|
| 99 |
|
else: |
| 100 |
|
return response.json() |
| 101 |
|
|
| 102 |
|
def POST(self, url, data, timeout=None): |
| 103 |
|
"""Issues a POST request to the URL with the data specified. Returns an |
| 104 |
|
object that is parsed from the response JSON.""" |
| 105 |
|
data = self._encode_request(data) |
| 106 |
|
|
| 107 |
|
logger.info(f'POST {url} with {data}') |
| 108 |
|
response = self.session.post( |
| 109 |
|
url, |
| 110 |
|
data=data, |
| 111 |
|
headers={ |
| 112 |
|
'content-type': 'application/json', |
| 113 |
|
}, |
| 114 |
|
timeout=timeout, |
| 115 |
|
auth=self.auth) |
| 116 |
|
|
| 117 |
|
if response.status_code not in (200, 201): |
| 118 |
|
self.raise_error(response) |
| 119 |
|
|
| 120 |
|
return response.json() |
| 121 |
|
|
| 122 |
|
def PUT(self, url, data, timeout=None): |
| 123 |
|
"""Issues a PUT request to the URL with the data specified. Returns an |