Skip to content

Commit a34c739

Browse files
committed
Add agent data model and endpoint definition for multi sources
This commit adds the data model for agent resource. The source model has been modified by adding a many2one relationship to the agent. A new endpoint `/api/v1/agents` has been added but not implemented.
1 parent 10ea4ca commit a34c739

File tree

19 files changed

+1361
-46
lines changed

19 files changed

+1361
-46
lines changed

api/v1alpha1/agent/openapi.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,42 @@ paths:
5353
application/json:
5454
schema:
5555
$ref: '../openapi.yaml#/components/schemas/Error'
56+
/api/v1/agents/{id}:
57+
put:
58+
tags:
59+
- agent
60+
description: update status of the agent
61+
operationId: updateAgentStatus
62+
parameters:
63+
- name: id
64+
in: path
65+
description: ID the agent
66+
required: true
67+
schema:
68+
type: string
69+
format: uuid
70+
requestBody:
71+
content:
72+
application/json:
73+
schema:
74+
$ref: '#/components/schemas/AgentStatusUpdate'
75+
responses:
76+
"200":
77+
description: OK
78+
"201":
79+
description: OK
80+
"401":
81+
description: Unauthorized
82+
content:
83+
application/json:
84+
schema:
85+
$ref: '../openapi.yaml#/components/schemas/Error'
86+
"410":
87+
description: Gone
88+
content:
89+
application/json:
90+
schema:
91+
$ref: '../openapi.yaml#/components/schemas/Error'
5692
/health:
5793
get:
5894
tags:
@@ -80,3 +116,19 @@ components:
80116
- status
81117
- statusInfo
82118
- credentialUrl
119+
AgentStatusUpdate:
120+
type: object
121+
properties:
122+
id:
123+
type: string
124+
status:
125+
type: string
126+
statusInfo:
127+
type: string
128+
credentialUrl:
129+
type: string
130+
required:
131+
- status
132+
- statusInfo
133+
- credentialUrl
134+
- id

api/v1alpha1/agent/spec.gen.go

Lines changed: 21 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/agent/types.gen.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/common.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,20 @@ func StringToSourceStatus(s string) SourceStatus {
1616
return SourceStatusNotConnected
1717
}
1818
}
19+
20+
func StringToAgentStatus(s string) AgentStatus {
21+
switch s {
22+
case string(AgentStatusError):
23+
return AgentStatusError
24+
case string(AgentStatusGatheringInitialInventory):
25+
return AgentStatusGatheringInitialInventory
26+
case string(AgentStatusUpToDate):
27+
return AgentStatusUpToDate
28+
case string(AgentStatusWaitingForCredentials):
29+
return AgentStatusWaitingForCredentials
30+
case string(AgentStatusNotConnected):
31+
return AgentStatusNotConnected
32+
default:
33+
return AgentStatusNotConnected
34+
}
35+
}

api/v1alpha1/openapi.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,25 @@ paths:
199199
application/json:
200200
schema:
201201
$ref: '#/components/schemas/Error'
202+
/api/v1/agents:
203+
get:
204+
tags:
205+
- agent
206+
description: list agents
207+
operationId: listAgents
208+
responses:
209+
"200":
210+
description: OK
211+
content:
212+
application/json:
213+
schema:
214+
$ref: "#/components/schemas/AgentList"
215+
"401":
216+
description: Unauthorized
217+
content:
218+
application/json:
219+
schema:
220+
$ref: '#/components/schemas/Error'
202221
/health:
203222
get:
204223
tags:
@@ -436,3 +455,36 @@ components:
436455
type: string
437456
count:
438457
type: integer
458+
459+
Agent:
460+
type: object
461+
properties:
462+
id:
463+
type: string
464+
status:
465+
type: string
466+
enum: [not-connected, waiting-for-credentials, error, gathering-initial-inventory, up-to-date, source-gone]
467+
statusInfo:
468+
type: string
469+
credentialUrl:
470+
type: string
471+
sourceId:
472+
type: string
473+
createdAt:
474+
type: string
475+
format: date-time
476+
updatedAt:
477+
type: string
478+
format: date-time
479+
required:
480+
- id
481+
- status
482+
- statusInfo
483+
- credentialUrl
484+
- createdAt
485+
- updatedAt
486+
487+
AgentList:
488+
type: array
489+
items:
490+
$ref: '#/components/schemas/Agent'

api/v1alpha1/spec.gen.go

Lines changed: 29 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/types.gen.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)