Skip to content

Commit

Permalink
Merge pull request #90 from siemens/feat/admin_obligations
Browse files Browse the repository at this point in the history
feat(admin_obligation_types): Admin apis to create, delete and get obligation types

Reviewed-by: mishra.gaurav@siemens.com
Tested-by: mishra.gaurav@siemens.com
  • Loading branch information
GMishx authored Nov 7, 2024
2 parents 32ba738 + 2127a66 commit a082737
Show file tree
Hide file tree
Showing 8 changed files with 803 additions and 28 deletions.
181 changes: 177 additions & 4 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,160 @@ const docTemplate = `{
}
}
},
"/obligations/types": {
"get": {
"security": [
{
"ApiKeyAuth": [],
"{}": []
}
],
"description": "Get all active obligation types from the service",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Get all active obligation types",
"operationId": "GetAllObligationType",
"parameters": [
{
"type": "boolean",
"description": "Active obligation only",
"name": "active",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.ObligationTypeResponse"
}
},
"404": {
"description": "No obligation types in DB",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Create an obligation type",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Create an obligation type",
"operationId": "CreateObligationType",
"parameters": [
{
"description": "Obligation type to create",
"name": "obligation_type",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ObligationType"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/models.ObligationTypeResponse"
}
},
"400": {
"description": "invalid json body",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"409": {
"description": "obligation type already exists",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "something went wrong while creating new obligation type",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/types/{type}": {
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Deactivate an obligation type",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Deactivate obligation type",
"operationId": "DeleteObligationType",
"parameters": [
{
"type": "string",
"description": "Obligation Type",
"name": "type",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "cannot delete obligation type 'RISK' as it's still referenced by some obligations",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"404": {
"description": "obligation type 'RISK' not found",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "something went wrong while deleting obligation type",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/{topic}": {
"get": {
"security": [
Expand Down Expand Up @@ -2370,12 +2524,31 @@ const docTemplate = `{
},
"models.ObligationType": {
"type": "object",
"required": [
"type"
],
"properties": {
"id": {
"type": "integer"
},
"type": {
"type": "string"
"type": "string",
"example": "PERMISSION"
}
}
},
"models.ObligationTypeResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationType"
}
},
"paginationmeta": {
"$ref": "#/definitions/models.PaginationMeta"
},
"status": {
"type": "integer",
"example": 200
}
}
},
Expand Down
181 changes: 177 additions & 4 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,160 @@
}
}
},
"/obligations/types": {
"get": {
"security": [
{
"ApiKeyAuth": [],
"{}": []
}
],
"description": "Get all active obligation types from the service",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Get all active obligation types",
"operationId": "GetAllObligationType",
"parameters": [
{
"type": "boolean",
"description": "Active obligation only",
"name": "active",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.ObligationTypeResponse"
}
},
"404": {
"description": "No obligation types in DB",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Create an obligation type",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Create an obligation type",
"operationId": "CreateObligationType",
"parameters": [
{
"description": "Obligation type to create",
"name": "obligation_type",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ObligationType"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/models.ObligationTypeResponse"
}
},
"400": {
"description": "invalid json body",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"409": {
"description": "obligation type already exists",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "something went wrong while creating new obligation type",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/types/{type}": {
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Deactivate an obligation type",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Obligations"
],
"summary": "Deactivate obligation type",
"operationId": "DeleteObligationType",
"parameters": [
{
"type": "string",
"description": "Obligation Type",
"name": "type",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "cannot delete obligation type 'RISK' as it's still referenced by some obligations",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"404": {
"description": "obligation type 'RISK' not found",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
},
"500": {
"description": "something went wrong while deleting obligation type",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/obligations/{topic}": {
"get": {
"security": [
Expand Down Expand Up @@ -2363,12 +2517,31 @@
},
"models.ObligationType": {
"type": "object",
"required": [
"type"
],
"properties": {
"id": {
"type": "integer"
},
"type": {
"type": "string"
"type": "string",
"example": "PERMISSION"
}
}
},
"models.ObligationTypeResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ObligationType"
}
},
"paginationmeta": {
"$ref": "#/definitions/models.PaginationMeta"
},
"status": {
"type": "integer",
"example": 200
}
}
},
Expand Down
Loading

0 comments on commit a082737

Please sign in to comment.