Skip to content

Commit

Permalink
feat(license_import): Add endpoint to import licenses via a json file
Browse files Browse the repository at this point in the history
  • Loading branch information
deo002 committed May 10, 2024
1 parent 90acd1a commit 1cb6521
Show file tree
Hide file tree
Showing 7 changed files with 656 additions and 0 deletions.
104 changes: 104 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,71 @@ const docTemplate = `{
}
}
},
"/licenses/import": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Import licenses by uploading a json file",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"Licenses"
],
"summary": "Import licenses by uploading a json file",
"operationId": "ImportLicenses",
"parameters": [
{
"type": "file",
"description": "licenses json file list",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/models.ImportLicensesResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.LicenseImportStatus"
}
}
}
}
]
}
},
"400": {
"description": "input file must be present",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/licenses/{shortname}": {
"get": {
"description": "Get a single license by its shortname",
Expand Down Expand Up @@ -1421,6 +1486,20 @@ const docTemplate = `{
}
}
},
"models.ImportLicensesResponse": {
"type": "object",
"properties": {
"data": {
"description": "can be of type models.LicenseError or models.LicenseImportStatus",
"type": "array",
"items": {}
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ImportObligationsResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1541,6 +1620,31 @@ const docTemplate = `{
}
}
},
"models.LicenseId": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 31
},
"shortname": {
"type": "string",
"example": "MIT"
}
}
},
"models.LicenseImportStatus": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.LicenseId"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.LicenseMapShortnamesElement": {
"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 @@ -418,6 +418,71 @@
}
}
},
"/licenses/import": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Import licenses by uploading a json file",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"Licenses"
],
"summary": "Import licenses by uploading a json file",
"operationId": "ImportLicenses",
"parameters": [
{
"type": "file",
"description": "licenses json file list",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/models.ImportLicensesResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.LicenseImportStatus"
}
}
}
}
]
}
},
"400": {
"description": "input file must be present",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/licenses/{shortname}": {
"get": {
"description": "Get a single license by its shortname",
Expand Down Expand Up @@ -1414,6 +1479,20 @@
}
}
},
"models.ImportLicensesResponse": {
"type": "object",
"properties": {
"data": {
"description": "can be of type models.LicenseError or models.LicenseImportStatus",
"type": "array",
"items": {}
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ImportObligationsResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1534,6 +1613,31 @@
}
}
},
"models.LicenseId": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 31
},
"shortname": {
"type": "string",
"example": "MIT"
}
}
},
"models.LicenseImportStatus": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.LicenseId"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.LicenseMapShortnamesElement": {
"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.ImportLicensesResponse:
properties:
data:
description: can be of type models.LicenseError or models.LicenseImportStatus
items: {}
type: array
status:
example: 200
type: integer
type: object
models.ImportObligationsResponse:
properties:
data:
Expand Down Expand Up @@ -147,6 +157,23 @@ definitions:
example: "2023-12-01T10:00:51+05:30"
type: string
type: object
models.LicenseId:
properties:
id:
example: 31
type: integer
shortname:
example: MIT
type: string
type: object
models.LicenseImportStatus:
properties:
data:
$ref: '#/definitions/models.LicenseId'
status:
example: 200
type: integer
type: object
models.LicenseMapShortnamesElement:
properties:
add:
Expand Down Expand Up @@ -874,6 +901,45 @@ paths:
summary: Update a license
tags:
- Licenses
/licenses/import:
post:
consumes:
- multipart/form-data
description: Import licenses by uploading a json file
operationId: ImportLicenses
parameters:
- description: licenses json file list
in: formData
name: file
required: true
type: file
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/models.ImportLicensesResponse'
- properties:
data:
items:
$ref: '#/definitions/models.LicenseImportStatus'
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 licenses by uploading a json file
tags:
- Licenses
/login:
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 @@ -104,6 +104,7 @@ func Router() *gin.Engine {
{
licenses.POST("", CreateLicense)
licenses.PATCH(":shortname", UpdateLicense)
licenses.POST("import", ImportLicenses)
}
users := authorizedv1.Group("/users")
{
Expand Down
Loading

0 comments on commit 1cb6521

Please sign in to comment.