stash
This commit is contained in:
parent
8cba1f52e8
commit
ebd0db4b43
27 changed files with 326 additions and 329 deletions
|
|
@ -8,9 +8,9 @@ from nacl.signing import SigningKey
|
|||
from json import dumps, loads
|
||||
|
||||
COMMANDS = {
|
||||
'getinventory': {'path': '/api/inventory_items/{handle}/', 'method': 'get'},
|
||||
'additem': {'path': '/api/inventory_items/{handle}/', 'method': 'post'},
|
||||
'delitem': {'path': '/api/inventory_items/{handle}/{internal_id}/', 'method': 'delete'},
|
||||
'getinventory': {'path': '/api/v1/inventory_items/{handle}/', 'method': 'get'},
|
||||
'additem': {'path': '/api/v1/inventory_items/{handle}/', 'method': 'post'},
|
||||
'delitem': {'path': '/api/v1/inventory_items/{handle}/{internal_id}/', 'method': 'delete'},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ class ToolshedApi:
|
|||
|
||||
def get_raw(self, target):
|
||||
"""Like get(), but returns the raw response body instead of parsing it as JSON - for
|
||||
endpoints like /api/export/ that hand back a zip file, not a JSON document."""
|
||||
endpoints like /api/v1/export/ that hand back a zip file, not a JSON document."""
|
||||
response = self._send('GET', target)
|
||||
if not response.ok:
|
||||
raise ApiError("{} {} from {}: {}".format(
|
||||
|
|
@ -199,7 +199,7 @@ def build_request(api, spec, command, cmd_args, json_input):
|
|||
def run_command(api, cmd, cmd_args, json_input):
|
||||
if cmd == 'export':
|
||||
path = cmd_args[0] if cmd_args else 'toolshed-export.zip'
|
||||
data = api.get_raw("/api/export/")
|
||||
data = api.get_raw("/api/v1/export/")
|
||||
with open(path, 'wb') as f:
|
||||
f.write(data)
|
||||
return {'exported_to': path, 'bytes': len(data)}
|
||||
|
|
@ -209,7 +209,7 @@ def run_command(api, cmd, cmd_args, json_input):
|
|||
path = cmd_args[0]
|
||||
with open(path, 'rb') as f:
|
||||
data = f.read()
|
||||
return api.post("/api/import/", {"zip": base64.b64encode(data).decode('ascii')})
|
||||
return api.post("/api/v1/import/", {"zip": base64.b64encode(data).decode('ascii')})
|
||||
|
||||
command = COMMANDS.get(cmd)
|
||||
if command is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue