Skip to content

Commit

Permalink
Merge pull request #7 from crane-cloud/ft-update-metrics
Browse files Browse the repository at this point in the history
feat: refactor metrics routes
  • Loading branch information
Mubangizi authored May 20, 2024
2 parents 8775ce3 + 6a908bc commit 7c39ae5
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 479 deletions.
196 changes: 18 additions & 178 deletions api_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
basepath: "/"

paths:
"/projects/{project_id}/metrics/cpu":
"/projects/{resource}/metrics":
post:
tags:
- projects
Expand All @@ -17,7 +17,7 @@ paths:
description: "Bearer [token]"
type: string
- in: path
name: project_id
name: resource
required: true
type: string
- in: body
Expand All @@ -32,100 +32,24 @@ paths:
format: float
step:
type: string

responses:
200:
description: "Cpu metrics for a Project"
404:
description: "metrics not found"
400:
description: "Bad request"
500:
description: "Internal Server Error"

"/projects/{project_id}/metrics/memory":
post:
tags:
- projects
consumes:
- application/json
produces:
- application/json
parameters:
- in: header
name: Authorization
required: true
description: "Bearer [token]"
type: string
- in: path
name: project_id
required: true
type: string
- in: body
name: project metrics
schema:
properties:
start:
type: number
format: float
end:
type: number
format: float
step:
prometheus_url:
type: string

responses:
200:
description: "Metrics for a single Project"
404:
description: "Project metrics not found"
400:
description: "Bad request"
500:
description: "Internal Server Error"

"/projects/{project_id}/metrics/network":
post:
tags:
- projects
consumes:
- application/json
produces:
- application/json
parameters:
- in: header
name: Authorization
required: true
description: "Bearer [token]"
type: string
- in: path
name: project_id
required: true
type: string
- in: body
name: project metrics
schema:
properties:
start:
type: number
format: float
end:
type: number
format: float
step:
project_id:
type: string
project_name:
type: string

responses:
200:
description: "Network metrics for a single Project"
description: "Metrics for a single Project"
404:
description: "Project metrics not found"
400:
description: "Bad request"
500:
description: "Internal Server Error"

"/projects/{project_id}/apps/{app_id}/metrics/memory":
"/apps/{resource}/metrics":
post:
tags:
- apps
Expand All @@ -140,11 +64,7 @@ paths:
description: "Bearer [token]"
type: string
- in: path
name: project_id
required: true
type: string
- in: path
name: app_id
name: resource
required: true
type: string
- in: body
Expand All @@ -159,50 +79,15 @@ paths:
format: float
step:
type: string

responses:
200:
description: "Metrics for a single App"
404:
description: "App metrics not found"
400:
description: "Bad request"
500:
description: "Internal Server Error"

"/projects/{project_id}/apps/{app_id}/metrics/cpu":
post:
tags:
- apps
consumes:
- application/json
produces:
- application/json
parameters:
- in: header
name: Authorization
required: true
description: "Bearer [token]"
type: string
- in: path
name: project_id
required: true
type: string
- in: path
name: app_id
required: true
type: string
- in: body
name: app metrics
schema:
properties:
start:
type: number
format: float
end:
type: number
format: float
step:
project_id:
type: string
prometheus_url:
type: string
project_name:
type: string
app_id:
type: string
app_name:
type: string

responses:
Expand All @@ -214,48 +99,3 @@ paths:
description: "Bad request"
500:
description: "Internal Server Error"

"/projects/{project_id}/apps/{app_id}/metrics/network":
post:
tags:
- apps
consumes:
- application/json
produces:
- application/json
parameters:
- in: header
name: Authorization
required: true
description: "Bearer [token]"
type: string
- in: path
name: project_id
required: true
type: string
- in: path
name: app_id
required: true
type: string
- in: body
name: app metrics
schema:
properties:
start:
type: number
format: float
end:
type: number
format: float
step:
type: string

responses:
200:
description: "Network metrics for a single App"
404:
description: "App metrics not found"
400:
description: "Bad request"
500:
description: "Internal Server Error"
5 changes: 2 additions & 3 deletions app/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .project import (ProjectCPUView, ProjectMemoryUsageView,
ProjectNetworkRequestView)
from .app import (AppCpuUsageView, AppMemoryUsageView, AppNetworkUsageView)
from .project import (ProjectUsageView)
from .app import (AppUsageView)
from .index import (IndexView)
Loading

0 comments on commit 7c39ae5

Please sign in to comment.