feat: Update ContainerId controller and Swagger description
parent
c5d994ee94
commit
14a8ebec1b
|
@ -20,7 +20,7 @@ authorizations = {
|
||||||
api = Api(app,
|
api = Api(app,
|
||||||
title='Proxmox container rest API',
|
title='Proxmox container rest API',
|
||||||
version='1.0',
|
version='1.0',
|
||||||
description='The Proxmox Container Management API allows users to interact with Proxmox using its REST API for container management. Key functionalities include creating, updating, editing, deleting, and retrieving information about containers.',
|
description='The Proxmox Container Management API allows users to interact with Proxmox using its REST API for container management. Key functionalities include creating, updating, editing and retrieving information about containers.',
|
||||||
prefix='/api',
|
prefix='/api',
|
||||||
authorizations=authorizations,
|
authorizations=authorizations,
|
||||||
security='apiKey')
|
security='apiKey')
|
||||||
|
|
|
@ -95,11 +95,11 @@ class ContainerId(Resource):
|
||||||
@api.doc('some operation', security='apikey')
|
@api.doc('some operation', security='apikey')
|
||||||
@token_required
|
@token_required
|
||||||
@api.doc(params={'id': 'The container id'},)
|
@api.doc(params={'id': 'The container id'},)
|
||||||
@api.doc(params={'command': 'start, stop, delete'},)
|
@api.doc(params={'command': 'start, stop'},)
|
||||||
@handle_exceptions
|
@handle_exceptions
|
||||||
def get(self, id: int, command: str):
|
def get(self, id: int, command: str):
|
||||||
|
|
||||||
commands = ['start', 'stop', 'delete']
|
commands = ['start', 'stop', 'del_test']
|
||||||
|
|
||||||
if (command not in commands):
|
if (command not in commands):
|
||||||
return {"error": f"Bad Request: Invalid command passed in your route'{command}'. Valid commands are {', '.join(commands)}"}, 400
|
return {"error": f"Bad Request: Invalid command passed in your route'{command}'. Valid commands are {', '.join(commands)}"}, 400
|
||||||
|
@ -110,7 +110,7 @@ class ContainerId(Resource):
|
||||||
endpoint, headers={"Authorization": f"PVEAPIToken={AUTH_TOKEN_PROXMOX}"}, verify=False)
|
endpoint, headers={"Authorization": f"PVEAPIToken={AUTH_TOKEN_PROXMOX}"}, verify=False)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
elif command == "delete":
|
elif command == "del_test":
|
||||||
endpoint = f"{API_BASE_URL}/{id}"
|
endpoint = f"{API_BASE_URL}/{id}"
|
||||||
response = requests.delete(endpoint, headers={
|
response = requests.delete(endpoint, headers={
|
||||||
"Authorization": f"PVEAPIToken={AUTH_TOKEN_PROXMOX}"}, verify=False)
|
"Authorization": f"PVEAPIToken={AUTH_TOKEN_PROXMOX}"}, verify=False)
|
||||||
|
|
Loading…
Reference in New Issue