Fix API tag data type

This commit is contained in:
Jan Eitzinger 2022-09-16 11:21:27 +02:00
parent 705f76fa3a
commit 24f374ed36
4 changed files with 142 additions and 55 deletions

View File

@ -126,7 +126,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.Job"
"$ref": "#/definitions/schema.JobMeta"
}
}
],
@ -185,7 +185,7 @@
"201": {
"description": "Job resource",
"schema": {
"$ref": "#/definitions/schema.Job"
"$ref": "#/definitions/schema.JobMeta"
}
},
"400": {
@ -296,17 +296,7 @@
"description": "Array of tag-objects for request payload",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "Tag Name",
"type": "string"
},
"type": {
"description": "Tag Type",
"type": "string"
}
}
"$ref": "#/definitions/api.Tag"
}
}
}
@ -385,6 +375,17 @@
}
}
},
"api.Tag": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"schema.Job": {
"type": "object",
"properties": {
@ -462,6 +463,107 @@
}
}
},
"schema.JobMeta": {
"type": "object",
"properties": {
"arrayJobId": {
"type": "integer"
},
"cluster": {
"type": "string"
},
"duration": {
"type": "integer"
},
"exclusive": {
"type": "integer"
},
"id": {
"description": "never used in the job-archive, only available via REST-API",
"type": "integer"
},
"jobId": {
"type": "integer"
},
"jobState": {
"type": "string"
},
"metaData": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"monitoringStatus": {
"type": "integer"
},
"numAcc": {
"type": "integer"
},
"numHwthreads": {
"type": "integer"
},
"numNodes": {
"type": "integer"
},
"partition": {
"type": "string"
},
"project": {
"type": "string"
},
"resources": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.Resource"
}
},
"smt": {
"type": "integer"
},
"startTime": {
"type": "integer"
},
"statistics": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/schema.JobStatistics"
}
},
"subCluster": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.Tag"
}
},
"user": {
"type": "string"
},
"walltime": {
"type": "integer"
}
}
},
"schema.JobStatistics": {
"type": "object",
"properties": {
"avg": {
"type": "number"
},
"max": {
"type": "number"
},
"min": {
"type": "number"
},
"unit": {
"type": "string"
}
}
},
"schema.Resource": {
"type": "object",
"properties": {
@ -508,4 +610,4 @@
"in": "header"
}
}
}
}

View File

@ -38,6 +38,13 @@ definitions:
description: Stop Time as Epoch
type: integer
type: object
api.Tag:
properties:
name:
type: string
type:
type: string
type: object
schema.Job:
properties:
arrayJobId:
@ -305,7 +312,7 @@ paths:
"201":
description: Job resource
schema:
$ref: '#/definitions/schema.Job'
$ref: '#/definitions/schema.JobMeta'
"400":
description: Bad Request
schema:
@ -377,14 +384,7 @@ paths:
schema:
description: Array of tag-objects for request payload
items:
properties:
name:
description: Tag Name
type: string
type:
description: Tag Type
type: string
type: object
$ref: '#/definitions/api.Tag'
type: array
produces:
- application/json

View File

@ -192,7 +192,7 @@ const docTemplate = `{
"201": {
"description": "Job resource",
"schema": {
"$ref": "#/definitions/schema.Job"
"$ref": "#/definitions/schema.JobMeta"
}
},
"400": {
@ -303,17 +303,7 @@ const docTemplate = `{
"description": "Array of tag-objects for request payload",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "Tag Name",
"type": "string"
},
"type": {
"description": "Tag Type",
"type": "string"
}
}
"$ref": "#/definitions/api.Tag"
}
}
}
@ -392,23 +382,17 @@ const docTemplate = `{
}
}
},
"api.TagJobApiRequest": {
"description": "Request to tag a job.",
"type": "array",
"items": {
"type": "object",
"properties": {
"error": {
"description": "Error Message",
"type": "string"
},
"status": {
"description": "Statustext of Errorcode",
"type": "string"
}
"api.Tag": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
},
"schema.Job": {
"type": "object",
"properties": {

View File

@ -112,13 +112,14 @@ type ErrorResponse struct {
Error string `json:"error"` // Error Message
}
type Tag struct {
Type string `json:"type"`
Name string `json:"name"`
}
// TagJobApiRequest model
// @Description Array of tag-objects for request payload
type TagJobApiRequest []*struct {
// Tag Name
Name string `json:"name"`
Type string `json:"type"` // Tag Type
}
type TagJobApiRequest []*Tag
func handleError(err error, statusCode int, rw http.ResponseWriter) {
log.Warnf("REST API: %s", err.Error())