Skip to content

Commit

Permalink
Merge pull request #25 from fossology/feat/api/obligationmap
Browse files Browse the repository at this point in the history
feat(api): add endpoints to get obligation maps
  • Loading branch information
GMishx authored Jan 4, 2024
2 parents b123f6b + f0ba490 commit aa42310
Show file tree
Hide file tree
Showing 8 changed files with 1,238 additions and 15 deletions.
276 changes: 276 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,206 @@ const docTemplate = `{
}
}
},
"/obligation_maps/license/{license}": {
"get": {
"description": "Get obligation maps for a given license shortname",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Get maps for a license",
"operationId": "GetObligationMapByLicense",
"parameters": [
{
"type": "string",
"description": "Shortname of the license",
"name": "license",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.ObligationMapResponse"
}
},
"404": {
"description": "No license with given shortname found or no map for",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligation_maps/topic/{topic}": {
"get": {
"description": "Get obligation maps for a given obligation topic",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Get maps for an obligation",
"operationId": "GetObligationMapByTopic",
"parameters": [
{
"type": "string",
"description": "Topic of the obligation",
"name": "topic",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.ObligationMapResponse"
}
},
"404": {
"description": "No obligation with given topic found or no map for",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligation_maps/topic/{topic}/license": {
"put": {
"security": [
{
"BasicAuth": []
}
],
"description": "Replaces the license list of an obligation topic with the given list in the obligation map.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Change license list",
"operationId": "UpdateLicenseInObligationMap",
"parameters": [
{
"type": "string",
"description": "Topic of the obligation",
"name": "topic",
"in": "path",
"required": true
},
{
"description": "Shortnames of the licenses to be in map",
"name": "shortnames",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.LicenseShortnamesInput"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.ObligationMapResponse"
}
},
"400": {
"description": "Invalid json body",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"404": {
"description": "No license or obligation found.",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
},
"patch": {
"security": [
{
"BasicAuth": []
}
],
"description": "Add or remove licenses from obligation map for a given obligation topic",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Add or remove licenses from obligation map",
"operationId": "PatchObligationMap",
"parameters": [
{
"type": "string",
"description": "Topic of the obligation",
"name": "topic",
"in": "path",
"required": true
},
{
"description": "Shortnames of the licenses with action",
"name": "shortname",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.LicenseMapShortnamesInput"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.ObligationMapResponse"
}
},
"400": {
"description": "Invalid json body",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"404": {
"description": "No license or obligation found.",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "Failure to insert new maps",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations": {
"get": {
"description": "Get all active obligations from the service",
Expand Down Expand Up @@ -1151,6 +1351,30 @@ const docTemplate = `{
}
}
},
"models.LicenseMapShortnamesElement": {
"type": "object",
"properties": {
"add": {
"type": "boolean",
"example": true
},
"shortname": {
"type": "string",
"example": "GPL-2.0-only"
}
}
},
"models.LicenseMapShortnamesInput": {
"type": "object",
"properties": {
"map": {
"type": "array",
"items": {
"$ref": "#/definitions/models.LicenseMapShortnamesElement"
}
}
}
},
"models.LicenseResponse": {
"type": "object",
"properties": {
Expand All @@ -1169,6 +1393,21 @@ const docTemplate = `{
}
}
},
"models.LicenseShortnamesInput": {
"type": "object",
"properties": {
"shortnames": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"GPL-2.0-only",
"GPL-2.0-or-later"
]
}
}
},
"models.LicenseUpdate": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1351,6 +1590,43 @@ const docTemplate = `{
}
}
},
"models.ObligationMapResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationMapUser"
}
},
"paginationmeta": {
"$ref": "#/definitions/models.PaginationMeta"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ObligationMapUser": {
"type": "object",
"properties": {
"shortnames": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"GPL-2.0-only",
"GPL-2.0-or-later"
]
},
"topic": {
"type": "string",
"example": "copyleft"
}
}
},
"models.ObligationResponse": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit aa42310

Please sign in to comment.