Skip to content

Commit e48169a

Browse files
committed
feat: define routes for fetching app metrics
1 parent 9208e1f commit e48169a

3 files changed

Lines changed: 145 additions & 1 deletion

File tree

api_docs.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,138 @@ paths:
124124
description: "Bad request"
125125
500:
126126
description: "Internal Server Error"
127+
128+
"/projects/{project_id}/apps/{app_id}/metrics/memory":
129+
post:
130+
tags:
131+
- apps
132+
consumes:
133+
- application/json
134+
produces:
135+
- application/json
136+
parameters:
137+
- in: header
138+
name: Authorization
139+
required: true
140+
description: "Bearer [token]"
141+
type: string
142+
- in: path
143+
name: project_id
144+
required: true
145+
type: string
146+
- in: path
147+
name: app_id
148+
required: true
149+
type: string
150+
- in: body
151+
name: app metrics
152+
schema:
153+
properties:
154+
start:
155+
type: number
156+
format: float
157+
end:
158+
type: number
159+
format: float
160+
step:
161+
type: string
162+
163+
responses:
164+
200:
165+
description: "Metrics for a single App"
166+
404:
167+
description: "App metrics not found"
168+
400:
169+
description: "Bad request"
170+
500:
171+
description: "Internal Server Error"
172+
173+
"/projects/{project_id}/apps/{app_id}/metrics/cpu":
174+
post:
175+
tags:
176+
- apps
177+
consumes:
178+
- application/json
179+
produces:
180+
- application/json
181+
parameters:
182+
- in: header
183+
name: Authorization
184+
required: true
185+
description: "Bearer [token]"
186+
type: string
187+
- in: path
188+
name: project_id
189+
required: true
190+
type: string
191+
- in: path
192+
name: app_id
193+
required: true
194+
type: string
195+
- in: body
196+
name: app metrics
197+
schema:
198+
properties:
199+
start:
200+
type: number
201+
format: float
202+
end:
203+
type: number
204+
format: float
205+
step:
206+
type: string
207+
208+
responses:
209+
200:
210+
description: "Cpu metrics for a single App"
211+
404:
212+
description: "App metrics not found"
213+
400:
214+
description: "Bad request"
215+
500:
216+
description: "Internal Server Error"
217+
218+
"/projects/{project_id}/apps/{app_id}/metrics/network":
219+
post:
220+
tags:
221+
- apps
222+
consumes:
223+
- application/json
224+
produces:
225+
- application/json
226+
parameters:
227+
- in: header
228+
name: Authorization
229+
required: true
230+
description: "Bearer [token]"
231+
type: string
232+
- in: path
233+
name: project_id
234+
required: true
235+
type: string
236+
- in: path
237+
name: app_id
238+
required: true
239+
type: string
240+
- in: body
241+
name: app metrics
242+
schema:
243+
properties:
244+
start:
245+
type: number
246+
format: float
247+
end:
248+
type: number
249+
format: float
250+
step:
251+
type: string
252+
253+
responses:
254+
200:
255+
description: "Network metrics for a single App"
256+
404:
257+
description: "App metrics not found"
258+
400:
259+
description: "Bad request"
260+
500:
261+
description: "Internal Server Error"

app/controllers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from .project import (ProjectCPUView, ProjectMemoryUsageView,
22
ProjectNetworkRequestView)
3+
from .app import (AppCpuUsageView, AppMemoryUsageView, AppNetworkUsageView)
34
from .index import (IndexView)

app/routes/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from flask_restful import Api
22
from app.controllers import (
33
IndexView, ProjectCPUView, ProjectMemoryUsageView,
4-
ProjectNetworkRequestView, IndexView)
4+
ProjectNetworkRequestView, AppCpuUsageView, AppMemoryUsageView, AppNetworkUsageView)
55

66
api = Api()
77

@@ -14,3 +14,11 @@
1414
'/projects/<string:project_id>/metrics/memory')
1515
api.add_resource(ProjectNetworkRequestView,
1616
'/projects/<string:project_id>/metrics/network')
17+
18+
# Apps routes
19+
api.add_resource(AppMemoryUsageView,
20+
'/projects/<string:project_id>/apps/<string:app_id>/memory')
21+
api.add_resource(
22+
AppCpuUsageView, '/projects/<string:project_id>/apps/<string:app_id>/cpu')
23+
api.add_resource(AppNetworkUsageView,
24+
'/projects/<string:project_id>/apps/<string:app_id>/network')

0 commit comments

Comments
 (0)