import connexion
import os
+
swagger_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'swagger/'))
def main():
app = connexion.App(__name__, specification_dir=swagger_dir)
app.add_api('swagger.yaml', base_path='/v1.0')
- app.run(host='0.0.0.0', port='5000')
+ app.run(host="0.0.0.0", port=5000)
if __name__ == '__main__':
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import connexion
import httplib
+import connexion
+
+from qtip.base import error
+from qtip.loader import metric
+
def list_metrics():
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'List metrics',
- 'Metrics listing not implemented')
+ metric_list = list(metric.MetricSpec.list_all())
+ return metric_list, httplib.OK
def get_metric(name):
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'Get a metric',
- 'metric retrieval not implemented')
+ try:
+ metric_spec = metric.MetricSpec(name)
+ return {'name': metric_spec.name,
+ 'abspath': metric_spec.abspath,
+ 'content': metric_spec.content}, httplib.OK
+ except error.NotFoundError:
+ return connexion.problem(httplib.NOT_FOUND,
+ 'Metric Not Found',
+ 'Requested metric `' + name + '` not found.')
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import connexion
import httplib
+import connexion
+
+from qtip.base import error
+from qtip.loader import plan
+
def list_plans():
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'List plans',
- 'Plans listing not implemented')
+ plan_list = list(plan.Plan.list_all())
+ return plan_list, httplib.OK
def get_plan(name):
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'Get a plan',
- 'Plan retrieval not implemented')
+ try:
+ plan_spec = plan.Plan(name)
+ return {'name': plan_spec.name,
+ 'abspath': plan_spec.abspath,
+ 'content': plan_spec.content}, httplib.OK
+ except error.NotFoundError:
+ return connexion.problem(httplib.NOT_FOUND,
+ 'Plan Not Found',
+ 'requested plan `' + name + '` not found.')
def run_plan(name, action="run"):
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import connexion
import httplib
+import connexion
+
+from qtip.base import error
+from qtip.loader import qpi
+
def list_qpis():
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'List QPIs',
- 'QPIs listing not implemented')
+ qpi_spec_list = list(qpi.QPISpec.list_all())
+ return qpi_spec_list, httplib.OK
def get_qpi(name):
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'Get a QPI',
- 'QPI retrieval not implemented')
+ try:
+ qpi_spec = qpi.QPISpec(name)
+ return {'name': qpi_spec.name,
+ 'abspath': qpi_spec.abspath,
+ 'content': qpi_spec.content}, httplib.OK
+ except error.NotFoundError:
+ return connexion.problem(httplib.NOT_FOUND,
+ 'QPI Not Found',
+ 'Requested QPI Spec `' + name + '` not found.')
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE -2.0
##############################################################################
swagger: '2.0'
operationId: qtip.api.controllers.plan.list_plans
tags:
- Plan
- - standalone
+ - Standalone
responses:
200:
description: A list of plans
- #TODO (akhil) add item with properties and parameters
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Plans'
501:
description: Resource not implemented
schema:
operationId: qtip.api.controllers.plan.get_plan
tags:
- Plan
- - standalone
+ - Standalone
parameters:
- name: name
in: path
responses:
200:
description: Plan information
- #TODO (akhil) define schema
+ schema:
+ $ref: '#/definitions/Plan'
404:
description: Plan not found
schema:
responses:
200:
description: A list of QPIs
- #TODO (akhil) add item with properties and parameters
+ schema:
+ items:
+ $ref: '#/definitions/QPIs'
501:
description: Resource not implemented
schema:
responses:
200:
description: QPI information
- #TODO (akhil) define schema
+ schema:
+ $ref: '#/definitions/QPI'
404:
description: QPI not found
schema:
responses:
200:
description: A list of metrics
- #TODO (akhil) add item with properties and parameters
+ schema:
+ items:
+ $ref: '#/definitions/Metrics'
501:
description: Resource not implemented
schema:
responses:
200:
description: Metric information
- #TODO (akhil) define schema
+ schema:
+ $ref: '#/definitions/Metric'
404:
description: Metric not found
schema:
schema:
$ref: '#/definitions/Error'
definitions:
+ PlanContent:
+ type: object
+ required:
+ - name
+ properties:
+ name:
+ type: string
+ description:
+ type: string
+ info:
+ type: object
+ config:
+ type: object
+ QPIs:
+ type: array
+ items:
+ type: object
+ Plans:
+ type: object
+ required:
+ - name
+ - abspath
+ properties:
+ name:
+ type: string
+ abspath:
+ type: string
+ Plan:
+ allOf:
+ - $ref: '#/definitions/Plans'
+ - type: object
+ - required:
+ - content
+ properties:
+ content:
+ $ref: '#/definitions/PlanContent'
+ MetricContent:
+ type: object
+ required:
+ - name
+ properties:
+ name:
+ type: string
+ description:
+ type: string
+ links:
+ type: array
+ items:
+ type: string
+ workloads:
+ type: array
+ items:
+ type: string
+ Metrics:
+ type: object
+ required:
+ - name
+ - abspath
+ properties:
+ name:
+ type: string
+ abspath:
+ type: string
+ Metric:
+ allOf:
+ - $ref: '#/definitions/Metrics'
+ - required:
+ - content
+ properties:
+ content:
+ $ref: '#/definitions/MetricContent'
+ QPIContent:
+ type: object
+ required:
+ - name
+ properties:
+ name:
+ type: string
+ description:
+ type: string
+ formula:
+ type: string
+ sections:
+ type: array
+ items:
+ type: object
+ QPIs:
+ type: object
+ required:
+ - name
+ - abspath
+ properties:
+ name:
+ type: string
+ abspath:
+ type: string
+ QPI:
+ allOf:
+ - $ref: '#/definitions/QPIs'
+ - required:
+ - content
+ properties:
+ content:
+ $ref: '#/definitions/QPIContent'
Error:
type: object
properties: