Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-sources: Add agent data model and endpoint definition for multi sources #41

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirarg Here we would like to have the version in the future.

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
Loading