Skip to content

Commit

Permalink
Add agent data model and endpoint definition for multi sources
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Cosmin Tupangiu <cosmin@redhat.com>
  • Loading branch information
tupyy authored and machacekondra committed Nov 13, 2024
1 parent 4b146dd commit 6ac0f8d
Show file tree
Hide file tree
Showing 18 changed files with 1,360 additions and 48 deletions.
52 changes: 52 additions & 0 deletions api/v1alpha1/agent/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@ paths:
application/json:
schema:
$ref: '../openapi.yaml#/components/schemas/Error'
/api/v1/agents/{id}/status:
put:
tags:
- agent
description: update status of the agent
operationId: updateAgentStatus
parameters:
- name: id
in: path
description: ID the agent
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AgentStatusUpdate'
responses:
"200":
description: OK
"201":
description: OK
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: '../openapi.yaml#/components/schemas/Error'
"410":
description: Gone
content:
application/json:
schema:
$ref: '../openapi.yaml#/components/schemas/Error'
/health:
get:
tags:
Expand Down Expand Up @@ -80,3 +116,19 @@ components:
- status
- statusInfo
- credentialUrl
AgentStatusUpdate:
type: object
properties:
id:
type: string
status:
type: string
statusInfo:
type: string
credentialUrl:
type: string
required:
- status
- statusInfo
- credentialUrl
- id
41 changes: 21 additions & 20 deletions api/v1alpha1/agent/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions api/v1alpha1/agent/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ func StringToSourceStatus(s string) SourceStatus {
return SourceStatusNotConnected
}
}

func StringToAgentStatus(s string) AgentStatus {
switch s {
case string(AgentStatusError):
return AgentStatusError
case string(AgentStatusGatheringInitialInventory):
return AgentStatusGatheringInitialInventory
case string(AgentStatusUpToDate):
return AgentStatusUpToDate
case string(AgentStatusWaitingForCredentials):
return AgentStatusWaitingForCredentials
case string(AgentStatusNotConnected):
return AgentStatusNotConnected
default:
return AgentStatusNotConnected
}
}
52 changes: 52 additions & 0 deletions api/v1alpha1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/agents:
get:
tags:
- agent
description: list agents
operationId: listAgents
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/AgentList"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/health:
get:
tags:
Expand Down Expand Up @@ -442,3 +461,36 @@ components:
type: string
count:
type: integer

Agent:
type: object
properties:
id:
type: string
status:
type: string
enum: [not-connected, waiting-for-credentials, error, gathering-initial-inventory, up-to-date, source-gone]
statusInfo:
type: string
credentialUrl:
type: string
sourceId:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
required:
- id
- status
- statusInfo
- credentialUrl
- createdAt
- updatedAt

AgentList:
type: array
items:
$ref: '#/components/schemas/Agent'
56 changes: 29 additions & 27 deletions api/v1alpha1/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions api/v1alpha1/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6ac0f8d

Please sign in to comment.