api update
This commit is contained in:
parent
03b0f7fc8d
commit
a16c55a609
2 changed files with 58 additions and 2 deletions
|
@ -30,5 +30,10 @@ class ControllerDataCenters:
|
||||||
items['items'] = []
|
items['items'] = []
|
||||||
|
|
||||||
for item in dclist.execute():
|
for item in dclist.execute():
|
||||||
items['items'].append(item)
|
items['items'].append({
|
||||||
|
'id': item.id,
|
||||||
|
'name': item.name,
|
||||||
|
'country': item.country,
|
||||||
|
'city': item.city,
|
||||||
|
})
|
||||||
return items
|
return items
|
||||||
|
|
|
@ -16,6 +16,7 @@ from app import models
|
||||||
from app.settings import settings
|
from app.settings import settings
|
||||||
from app.cloud.controllers.users import ControllerUsers
|
from app.cloud.controllers.users import ControllerUsers
|
||||||
from app.cloud.controllers.users import ControllerAPI
|
from app.cloud.controllers.users import ControllerAPI
|
||||||
|
from app.cloud.controllers.datacenters import ControllerDataCenters
|
||||||
from app.cloud.controllers.containers import ControllerContainers
|
from app.cloud.controllers.containers import ControllerContainers
|
||||||
from cloudnsru import CloudnsClient
|
from cloudnsru import CloudnsClient
|
||||||
|
|
||||||
|
@ -44,11 +45,36 @@ def auth():
|
||||||
user_id = ControllerUsers().get_id_by_email(email)
|
user_id = ControllerUsers().get_id_by_email(email)
|
||||||
|
|
||||||
return jsonify(user_id=user_id)
|
return jsonify(user_id=user_id)
|
||||||
|
|
||||||
|
|
||||||
|
@viewAPI.route('/datacenter/list', methods=['POST'])
|
||||||
|
def datacenter_list():
|
||||||
|
"""
|
||||||
|
curl -X POST http://localhost:5000/api/datacenter/list --data 'email=<email>&secret=<secret>'
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
email = request.form['email']
|
||||||
|
secret = request.form['secret']
|
||||||
|
#
|
||||||
|
if not ControllerAPI().auth(email, secret):
|
||||||
|
return jsonify(status=1)
|
||||||
|
#
|
||||||
|
user_id = ControllerUsers().get_id_by_email(email)
|
||||||
|
# get containers list
|
||||||
|
datacenters = ControllerDataCenters().get()
|
||||||
|
#
|
||||||
|
return jsonify(
|
||||||
|
status=0,
|
||||||
|
total=datacenters['total'],
|
||||||
|
items=datacenters['items']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# /container/create
|
# /container/create
|
||||||
# /container/details/<uuid:container_id>
|
# /container/details/<uuid:container_id>
|
||||||
|
|
||||||
|
|
||||||
@viewAPI.route('/container/list', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
@viewAPI.route('/container/list', methods=['POST'])
|
||||||
def container_list():
|
def container_list():
|
||||||
"""
|
"""
|
||||||
curl -X POST http://localhost:5000/api/container/list --data 'email=<email>&secret=<secret>'
|
curl -X POST http://localhost:5000/api/container/list --data 'email=<email>&secret=<secret>'
|
||||||
|
@ -70,3 +96,28 @@ def container_list():
|
||||||
total=containers['total'],
|
total=containers['total'],
|
||||||
items=containers['items']
|
items=containers['items']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@viewAPI.route('/container/create', methods=['POST'])
|
||||||
|
def container_create():
|
||||||
|
"""
|
||||||
|
curl -X POST http://localhost:5000/api/container/create --data 'email=<email>&secret=<secret>&datacenter_id=<datacenter_id>'
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
email = request.form['email']
|
||||||
|
secret = request.form['secret']
|
||||||
|
datacenter_id = request.form['datacenter_id']
|
||||||
|
# expire = request.form['expire']
|
||||||
|
#
|
||||||
|
if not ControllerAPI().auth(email, secret):
|
||||||
|
return jsonify(status=1)
|
||||||
|
#
|
||||||
|
user_id = ControllerUsers().get_id_by_email(email)
|
||||||
|
# get containers list
|
||||||
|
containers = ControllerContainers(user_id).get_items()
|
||||||
|
#
|
||||||
|
return jsonify(
|
||||||
|
status=0,
|
||||||
|
total=containers['total'],
|
||||||
|
items=containers['items']
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue