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", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/schema.Job" "$ref": "#/definitions/schema.JobMeta"
} }
} }
], ],
@ -185,7 +185,7 @@
"201": { "201": {
"description": "Job resource", "description": "Job resource",
"schema": { "schema": {
"$ref": "#/definitions/schema.Job" "$ref": "#/definitions/schema.JobMeta"
} }
}, },
"400": { "400": {
@ -296,17 +296,7 @@
"description": "Array of tag-objects for request payload", "description": "Array of tag-objects for request payload",
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "$ref": "#/definitions/api.Tag"
"properties": {
"name": {
"description": "Tag Name",
"type": "string"
},
"type": {
"description": "Tag Type",
"type": "string"
}
}
} }
} }
} }
@ -385,6 +375,17 @@
} }
} }
}, },
"api.Tag": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"schema.Job": { "schema.Job": {
"type": "object", "type": "object",
"properties": { "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": { "schema.Resource": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

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

View File

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

View File

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