Skip to content

Commit 7c39ae5

Browse files
authored
Merge pull request #7 from crane-cloud/ft-update-metrics
feat: refactor metrics routes
2 parents 8775ce3 + 6a908bc commit 7c39ae5

10 files changed

Lines changed: 158 additions & 479 deletions

File tree

api_docs.yml

Lines changed: 18 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
basepath: "/"
33

44
paths:
5-
"/projects/{project_id}/metrics/cpu":
5+
"/projects/{resource}/metrics":
66
post:
77
tags:
88
- projects
@@ -17,7 +17,7 @@ paths:
1717
description: "Bearer [token]"
1818
type: string
1919
- in: path
20-
name: project_id
20+
name: resource
2121
required: true
2222
type: string
2323
- in: body
@@ -32,100 +32,24 @@ paths:
3232
format: float
3333
step:
3434
type: string
35-
36-
responses:
37-
200:
38-
description: "Cpu metrics for a Project"
39-
404:
40-
description: "metrics not found"
41-
400:
42-
description: "Bad request"
43-
500:
44-
description: "Internal Server Error"
45-
46-
"/projects/{project_id}/metrics/memory":
47-
post:
48-
tags:
49-
- projects
50-
consumes:
51-
- application/json
52-
produces:
53-
- application/json
54-
parameters:
55-
- in: header
56-
name: Authorization
57-
required: true
58-
description: "Bearer [token]"
59-
type: string
60-
- in: path
61-
name: project_id
62-
required: true
63-
type: string
64-
- in: body
65-
name: project metrics
66-
schema:
67-
properties:
68-
start:
69-
type: number
70-
format: float
71-
end:
72-
type: number
73-
format: float
74-
step:
35+
prometheus_url:
7536
type: string
76-
77-
responses:
78-
200:
79-
description: "Metrics for a single Project"
80-
404:
81-
description: "Project metrics not found"
82-
400:
83-
description: "Bad request"
84-
500:
85-
description: "Internal Server Error"
86-
87-
"/projects/{project_id}/metrics/network":
88-
post:
89-
tags:
90-
- projects
91-
consumes:
92-
- application/json
93-
produces:
94-
- application/json
95-
parameters:
96-
- in: header
97-
name: Authorization
98-
required: true
99-
description: "Bearer [token]"
100-
type: string
101-
- in: path
102-
name: project_id
103-
required: true
104-
type: string
105-
- in: body
106-
name: project metrics
107-
schema:
108-
properties:
109-
start:
110-
type: number
111-
format: float
112-
end:
113-
type: number
114-
format: float
115-
step:
37+
project_id:
38+
type: string
39+
project_name:
11640
type: string
11741

11842
responses:
11943
200:
120-
description: "Network metrics for a single Project"
44+
description: "Metrics for a single Project"
12145
404:
12246
description: "Project metrics not found"
12347
400:
12448
description: "Bad request"
12549
500:
12650
description: "Internal Server Error"
12751

128-
"/projects/{project_id}/apps/{app_id}/metrics/memory":
52+
"/apps/{resource}/metrics":
12953
post:
13054
tags:
13155
- apps
@@ -140,11 +64,7 @@ paths:
14064
description: "Bearer [token]"
14165
type: string
14266
- in: path
143-
name: project_id
144-
required: true
145-
type: string
146-
- in: path
147-
name: app_id
67+
name: resource
14868
required: true
14969
type: string
15070
- in: body
@@ -159,50 +79,15 @@ paths:
15979
format: float
16080
step:
16181
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:
82+
project_id:
83+
type: string
84+
prometheus_url:
85+
type: string
86+
project_name:
87+
type: string
88+
app_id:
89+
type: string
90+
app_name:
20691
type: string
20792

20893
responses:
@@ -214,48 +99,3 @@ paths:
21499
description: "Bad request"
215100
500:
216101
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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from .project import (ProjectCPUView, ProjectMemoryUsageView,
2-
ProjectNetworkRequestView)
3-
from .app import (AppCpuUsageView, AppMemoryUsageView, AppNetworkUsageView)
1+
from .project import (ProjectUsageView)
2+
from .app import (AppUsageView)
43
from .index import (IndexView)

0 commit comments

Comments
 (0)