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

Adding few restAPIs for deployer #194

Merged
merged 1 commit into from
Jul 22, 2022
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
222 changes: 211 additions & 11 deletions api/computes_api.partials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$ref: '#/components/schemas/Error'
description: unexpected error

/computes/{compute}:
/computes/{computeId}:
########################################
# Get the status of a compute cluster
########################################
Expand All @@ -50,8 +50,8 @@
tags:
- computes
parameters:
- name: compute
description: deployer id of compute cluster
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
Expand Down Expand Up @@ -81,8 +81,8 @@
tags:
- computes
parameters:
- name: compute
description: deployer id of compute cluster
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
Expand Down Expand Up @@ -115,8 +115,8 @@
tags:
- computes
parameters:
- name: compute
description: deployer id of compute cluster
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
Expand All @@ -127,7 +127,7 @@
'200':
description: Deleted
'404':
description: Deployer id not found
description: compute id not found
'401':
description: Unauthorized
default:
Expand All @@ -137,7 +137,7 @@
$ref: '#/components/schemas/Error'
description: unexpected error

/computes/{compute}/config:
/computes/{computeId}/config:
########################################
# Get configuration of a compute cluster
########################################
Expand All @@ -147,8 +147,8 @@
tags:
- computes
parameters:
- name: compute
description: deployer id of compute cluster
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
Expand All @@ -162,6 +162,206 @@
schema:
$ref: '#/components/schemas/ComputeSpec'
description: Information about compute cluster
default:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: unexpected error

/computes/{computeId}/deployments:
dhruvsgarg marked this conversation as resolved.
Show resolved Hide resolved
########################################
# Get all deployments within a compute cluster
########################################
get:
operationId: getDeployments
summary: Get all deployments within a compute cluster
tags:
- computes
parameters:
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
style: simple
explode: false
required: true
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DeploymentStatus'
description: An array of status of all deployments in a compute cluster
default:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: unexpected error

/computes/{computeId}/deployments/{jobId}/config:
########################################
# Get the deployment config for a job for a compute cluster
########################################
get:
operationId: getDeploymentConfig
summary: Get the deployment config for a job for a compute cluster
tags:
- computes
parameters:
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
style: simple
explode: false
required: true
- name: jobId
description: job id
in: path
schema:
type: string
style: simple
explode: false
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/DeploymentConfig'
description: Get deployment configs for a job deployment
default:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: unexpected error

/computes/{computeId}/deployments/{jobId}/status:
########################################
# Send the deployment status for a job on a compute cluster
########################################
post:
operationId: addDeploymentStatus
summary: Add the deployment status for a job on a compute cluster
tags:
- computes
parameters:
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
style: simple
explode: false
required: true
- name: jobId
description: job id
in: path
schema:
type: string
style: simple
explode: false
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DeploymentStatus'
description: Status for agents in a job deployment
responses:
"200":
description: Added deployment status
'401':
description: Unauthorized
default:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: unexpected error

########################################
# Update the deployment status for a job on a compute cluster
########################################
put:
operationId: updateDeploymentStatus
summary: Update the deployment status for a job on a compute cluster
tags:
- computes
parameters:
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
style: simple
explode: false
required: true
- name: jobId
description: job id
in: path
schema:
type: string
style: simple
explode: false
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DeploymentStatus'
description: Status for agents in a job deployment
responses:
"200":
description: Updated the deployment status
'401':
description: Unauthorized
default:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: unexpected error

########################################
# Get the deployment status for a job on a compute cluster
########################################
get:
dhruvsgarg marked this conversation as resolved.
Show resolved Hide resolved
operationId: getDeploymentStatus
summary: Get the deployment status for a job on a compute cluster
tags:
- computes
parameters:
- name: computeId
description: compute id of compute cluster
in: path
schema:
type: string
style: simple
explode: false
required: true
- name: jobId
description: job id
in: path
schema:
type: string
style: simple
explode: false
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/DeploymentStatus'
description: Status for agents in a job deployment
default:
content:
application/json:
Expand Down
66 changes: 65 additions & 1 deletion api/computes_components.partials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,68 @@ ComputeState:
enum:
- up
- down
- maintenance
- maintenance

########################################
# Deployment config for agents
########################################
DeploymentConfig:
description: Deployment config for agents
type: object
properties:
jobId:
type: string
imageLoc:
type: string
agentKVs:
type: array
items:
$ref: '#/components/schemas/AgentKV'
required:
- jobId
- imageLoc
- agentKVs

########################################
# Config for agents in the deployment
########################################
AgentKV:
description: Config for agents in the deployment
type: object
additionalProperties:
type: string

########################################
# Deployment status within a compute cluster
########################################
DeploymentStatus:
description: Deployment status within a compute cluster
type: object
properties:
jobId:
type: string
agentStatuses:
type: array
items:
$ref: '#/components/schemas/AgentStatus'
required:
- jobId

########################################
# Status for an agent within a deployment
########################################
AgentStatus:
description: Status for an agent within a deployment
type: object
additionalProperties:
type: object
$ref: '#/components/schemas/AgentState'

########################################
# Agent state
########################################
AgentState:
enum:
- deployed
- revoked
- error
dhruvsgarg marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions pkg/openapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ import (
// The ComputesApiRouter implementation should parse necessary information from the http request,
// pass the data to a ComputesApiServicer to perform the required actions, then write the service results to the http response.
type ComputesApiRouter interface {
AddDeploymentStatus(http.ResponseWriter, *http.Request)
DeleteCompute(http.ResponseWriter, *http.Request)
GetComputeConfig(http.ResponseWriter, *http.Request)
GetComputeStatus(http.ResponseWriter, *http.Request)
GetDeploymentConfig(http.ResponseWriter, *http.Request)
GetDeploymentStatus(http.ResponseWriter, *http.Request)
GetDeployments(http.ResponseWriter, *http.Request)
RegisterCompute(http.ResponseWriter, *http.Request)
UpdateCompute(http.ResponseWriter, *http.Request)
UpdateDeploymentStatus(http.ResponseWriter, *http.Request)
}

// DatasetsApiRouter defines the required methods for binding the api requests to a responses for the DatasetsApi
Expand Down Expand Up @@ -103,11 +108,16 @@ type JobsApiRouter interface {
// while the service implementation can ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type ComputesApiServicer interface {
AddDeploymentStatus(context.Context, string, string, DeploymentStatus) (ImplResponse, error)
DeleteCompute(context.Context, string) (ImplResponse, error)
GetComputeConfig(context.Context, string) (ImplResponse, error)
GetComputeStatus(context.Context, string) (ImplResponse, error)
GetDeploymentConfig(context.Context, string, string) (ImplResponse, error)
GetDeploymentStatus(context.Context, string, string) (ImplResponse, error)
GetDeployments(context.Context, string) (ImplResponse, error)
RegisterCompute(context.Context, ComputeSpec) (ImplResponse, error)
UpdateCompute(context.Context, string, ComputeSpec) (ImplResponse, error)
UpdateDeploymentStatus(context.Context, string, string, DeploymentStatus) (ImplResponse, error)
}

// DatasetsApiServicer defines the api actions for the DatasetsApi service
Expand Down
Loading