Skip to content

Commit

Permalink
feat(api): add endpoints to modify obligation maps
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Mishra <[email protected]>
  • Loading branch information
GMishx committed Jan 4, 2024
1 parent f338879 commit f0ba490
Show file tree
Hide file tree
Showing 8 changed files with 758 additions and 13 deletions.
161 changes: 161 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,128 @@ const docTemplate = `{
}
}
},
"/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 @@ -1229,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 @@ -1247,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
163 changes: 162 additions & 1 deletion cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,128 @@
}
}
},
"/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 @@ -1223,6 +1345,30 @@
}
}
},
"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 @@ -1241,6 +1387,21 @@
}
}
},
"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 @@ -1639,4 +1800,4 @@
"type": "basic"
}
}
}
}
Loading

0 comments on commit f0ba490

Please sign in to comment.