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

feat(obligations_export): Add functionality to export obligations #53

Merged
merged 1 commit into from
May 20, 2024
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
96 changes: 96 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,36 @@ const docTemplate = `{
}
}
},
"/obligations/export": {
"get": {
"description": "Export all obligations as a json file",
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Export all obligations as a json file",
"operationId": "ExportObligations",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationJSONFileFormat"
}
}
},
"500": {
"description": "Failed to fetch obligations",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/import": {
"post": {
"security": [
Expand Down Expand Up @@ -1824,6 +1854,72 @@ const docTemplate = `{
}
}
},
"models.ObligationJSONFileFormat": {
"type": "object",
"required": [
"active",
"classification",
"comment",
"modifications",
"shortnames",
"text",
"text_updatable",
"topic",
"type"
],
"properties": {
"active": {
"type": "boolean"
},
"classification": {
"type": "string",
"enum": [
"green",
"white",
"yellow",
"red"
]
},
"comment": {
"type": "string",
"example": "This is a comment."
},
"modifications": {
"type": "boolean"
},
"shortnames": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"GPL-2.0-only",
"GPL-2.0-or-later"
]
},
"text": {
"type": "string",
"example": "Source code be made available when distributing the software."
},
"text_updatable": {
"type": "boolean"
},
"topic": {
"description": "binding:\"required\" tag cannot be used as is works only for request body",
"type": "string",
"example": "copyleft"
},
"type": {
"type": "string",
"enum": [
"obligation",
"restriction",
"risk",
"right"
]
}
}
},
"models.ObligationMapResponse": {
"type": "object",
"properties": {
Expand Down
96 changes: 96 additions & 0 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,36 @@
}
}
},
"/obligations/export": {
"get": {
"description": "Export all obligations as a json file",
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Export all obligations as a json file",
"operationId": "ExportObligations",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationJSONFileFormat"
}
}
},
"500": {
"description": "Failed to fetch obligations",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/import": {
"post": {
"security": [
Expand Down Expand Up @@ -1817,6 +1847,72 @@
}
}
},
"models.ObligationJSONFileFormat": {
"type": "object",
"required": [
"active",
"classification",
"comment",
"modifications",
"shortnames",
"text",
"text_updatable",
"topic",
"type"
],
"properties": {
"active": {
"type": "boolean"
},
"classification": {
"type": "string",
"enum": [
"green",
"white",
"yellow",
"red"
]
},
"comment": {
"type": "string",
"example": "This is a comment."
},
"modifications": {
"type": "boolean"
},
"shortnames": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"GPL-2.0-only",
"GPL-2.0-or-later"
]
},
"text": {
"type": "string",
"example": "Source code be made available when distributing the software."
},
"text_updatable": {
"type": "boolean"
},
"topic": {
"description": "binding:\"required\" tag cannot be used as is works only for request body",
"type": "string",
"example": "copyleft"
},
"type": {
"type": "string",
"enum": [
"obligation",
"restriction",
"risk",
"right"
]
}
}
},
"models.ObligationMapResponse": {
"type": "object",
"properties": {
Expand Down
71 changes: 71 additions & 0 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,57 @@ definitions:
example: 200
type: integer
type: object
models.ObligationJSONFileFormat:
properties:
active:
type: boolean
classification:
enum:
- green
- white
- yellow
- red
type: string
comment:
example: This is a comment.
type: string
modifications:
type: boolean
shortnames:
example:
- GPL-2.0-only
- GPL-2.0-or-later
items:
type: string
type: array
text:
example: Source code be made available when distributing the software.
type: string
text_updatable:
type: boolean
topic:
description: binding:"required" tag cannot be used as is works only for request
body
example: copyleft
type: string
type:
enum:
- obligation
- restriction
- risk
- right
type: string
required:
- active
- classification
- comment
- modifications
- shortnames
- text
- text_updatable
- topic
- type
type: object
models.ObligationMapResponse:
properties:
data:
Expand Down Expand Up @@ -1258,6 +1309,26 @@ paths:
summary: Fetches audits corresponding to an obligation
tags:
- Obligations
/obligations/export:
get:
description: Export all obligations as a json file
operationId: ExportObligations
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/models.ObligationJSONFileFormat'
type: array
"500":
description: Failed to fetch obligations
schema:
$ref: '#/definitions/models.LicenseError'
summary: Export all obligations as a json file
tags:
- Obligations
/obligations/import:
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 @@ -81,6 +81,7 @@ func Router() *gin.Engine {
obligations.GET("", GetAllObligation)
obligations.GET(":topic", GetObligation)
obligations.GET(":topic/audits", GetObligationAudits)
obligations.GET("export", ExportObligations)
}
obMap := unAuthorizedv1.Group("/obligation_maps")
{
Expand Down
Loading
Loading