Skip to content

Commit

Permalink
Merge pull request #47 from siemens/obligation_import
Browse files Browse the repository at this point in the history
feat(obligation_import): Add functionality to import obligations via …

Reviewed-by: [email protected]
Tested-by: [email protected]
  • Loading branch information
GMishx authored Apr 4, 2024
2 parents 13760df + 9db5946 commit c5a1a8c
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 91 deletions.
104 changes: 104 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,71 @@ const docTemplate = `{
}
}
},
"/obligations/import": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Import obligations by uploading a json file",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Import obligations by uploading a json file",
"operationId": "ImportObligations",
"parameters": [
{
"type": "file",
"description": "obligations json file list",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/models.ImportObligationsResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationImportStatus"
}
}
}
}
]
}
},
"400": {
"description": "input file must be present",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/{topic}": {
"get": {
"description": "Get an active based on given topic",
Expand Down Expand Up @@ -1356,6 +1421,20 @@ const docTemplate = `{
}
}
},
"models.ImportObligationsResponse": {
"type": "object",
"properties": {
"data": {
"description": "can be of type models.LicenseError or models.ObligationImportStatus",
"type": "array",
"items": {}
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.LicenseDB": {
"type": "object",
"required": [
Expand Down Expand Up @@ -1720,6 +1799,31 @@ const docTemplate = `{
}
}
},
"models.ObligationId": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 31
},
"topic": {
"type": "string",
"example": "copyleft"
}
}
},
"models.ObligationImportStatus": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.ObligationId"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ObligationMapResponse": {
"type": "object",
"properties": {
Expand Down
104 changes: 104 additions & 0 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,71 @@
}
}
},
"/obligations/import": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Import obligations by uploading a json file",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Import obligations by uploading a json file",
"operationId": "ImportObligations",
"parameters": [
{
"type": "file",
"description": "obligations json file list",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/models.ImportObligationsResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationImportStatus"
}
}
}
}
]
}
},
"400": {
"description": "input file must be present",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/{topic}": {
"get": {
"description": "Get an active based on given topic",
Expand Down Expand Up @@ -1349,6 +1414,20 @@
}
}
},
"models.ImportObligationsResponse": {
"type": "object",
"properties": {
"data": {
"description": "can be of type models.LicenseError or models.ObligationImportStatus",
"type": "array",
"items": {}
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.LicenseDB": {
"type": "object",
"required": [
Expand Down Expand Up @@ -1713,6 +1792,31 @@
}
}
},
"models.ObligationId": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 31
},
"topic": {
"type": "string",
"example": "copyleft"
}
}
},
"models.ObligationImportStatus": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.ObligationId"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ObligationMapResponse": {
"type": "object",
"properties": {
Expand Down
66 changes: 66 additions & 0 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ definitions:
example: 200
type: integer
type: object
models.ImportObligationsResponse:
properties:
data:
description: can be of type models.LicenseError or models.ObligationImportStatus
items: {}
type: array
status:
example: 200
type: integer
type: object
models.LicenseDB:
properties:
external_ref:
Expand Down Expand Up @@ -318,6 +328,23 @@ definitions:
example: risk
type: string
type: object
models.ObligationId:
properties:
id:
example: 31
type: integer
topic:
example: copyleft
type: string
type: object
models.ObligationImportStatus:
properties:
data:
$ref: '#/definitions/models.ObligationId'
status:
example: 200
type: integer
type: object
models.ObligationMapResponse:
properties:
data:
Expand Down Expand Up @@ -1231,6 +1258,45 @@ paths:
summary: Fetches audits corresponding to an obligation
tags:
- Obligations
/obligations/import:
post:
consumes:
- multipart/form-data
description: Import obligations by uploading a json file
operationId: ImportObligations
parameters:
- description: obligations json file list
in: formData
name: file
required: true
type: file
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/models.ImportObligationsResponse'
- properties:
data:
items:
$ref: '#/definitions/models.ObligationImportStatus'
type: array
type: object
"400":
description: input file must be present
schema:
$ref: '#/definitions/models.LicenseError'
"500":
description: Internal server error
schema:
$ref: '#/definitions/models.LicenseError'
security:
- ApiKeyAuth: []
summary: Import obligations by uploading a json file
tags:
- Obligations
/search:
post:
consumes:
Expand Down
1 change: 1 addition & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func Router() *gin.Engine {
obligations := authorizedv1.Group("/obligations")
{
obligations.POST("", CreateObligation)
obligations.POST("import", ImportObligations)
obligations.PATCH(":topic", UpdateObligation)
obligations.DELETE(":topic", DeleteObligation)
}
Expand Down
Loading

0 comments on commit c5a1a8c

Please sign in to comment.