Skip to content

Commit

Permalink
feat(api): add endpoints to get 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 b123f6b commit f338879
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 5 deletions.
115 changes: 115 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,84 @@ 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"
}
}
}
}
},
"/obligations": {
"get": {
"description": "Get all active obligations from the service",
Expand Down Expand Up @@ -1351,6 +1429,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
115 changes: 115 additions & 0 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,84 @@
}
}
},
"/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"
}
}
}
}
},
"/obligations": {
"get": {
"description": "Get all active obligations from the service",
Expand Down Expand Up @@ -1345,6 +1423,43 @@
}
}
},
"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
77 changes: 77 additions & 0 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,31 @@ definitions:
- topic
- type
type: object
models.ObligationMapResponse:
properties:
data:
items:
$ref: '#/definitions/models.ObligationMapUser'
type: array
paginationmeta:
$ref: '#/definitions/models.PaginationMeta'
status:
example: 200
type: integer
type: object
models.ObligationMapUser:
properties:
shortnames:
example:
- GPL-2.0-only
- GPL-2.0-or-later
items:
type: string
type: array
topic:
example: copyleft
type: string
type: object
models.ObligationResponse:
properties:
data:
Expand Down Expand Up @@ -754,6 +779,58 @@ paths:
summary: Update a license
tags:
- Licenses
/obligation_maps/license/{license}:
get:
consumes:
- application/json
description: Get obligation maps for a given license shortname
operationId: GetObligationMapByLicense
parameters:
- description: Shortname of the license
in: path
name: license
required: true
type: string
produces:
- application/json
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'
summary: Get maps for a license
tags:
- Obligations
/obligation_maps/topic/{topic}:
get:
consumes:
- application/json
description: Get obligation maps for a given obligation topic
operationId: GetObligationMapByTopic
parameters:
- description: Topic of the obligation
in: path
name: topic
required: true
type: string
produces:
- application/json
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'
summary: Get maps for an obligation
tags:
- Obligations
/obligations:
get:
consumes:
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func Router() *gin.Engine {
obligations.GET("", GetAllObligation)
obligations.GET(":topic", GetObligation)
}
obMap := unAuthorizedv1.Group("/obligation_maps")
{
obMap.GET("topic/:topic", GetObligationMapByTopic)
obMap.GET("license/:license", GetObligationMapByLicense)
}
}

authorizedv1 := r.Group("/api/v1")
Expand Down
Loading

0 comments on commit f338879

Please sign in to comment.