Skip to content
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
6 changes: 3 additions & 3 deletions migrations/20190129_organization_config.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
--
CREATE TABLE org_config (
id bigint NOT NULL,
orgId character varying(45) NOT NULL,
configName character varying(45) NOT NULL,
configValue character varying(512),
"orgId" character varying(45) NOT NULL,
"configName" character varying(45) NOT NULL,
"configValue" character varying(512),
"deletedAt" timestamp with time zone,
"createdAt" timestamp with time zone,
"updatedAt" timestamp with time zone,
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 93 additions & 57 deletions postman.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "e810fc27-5518-4cc5-8f90-6b1423c6b0b4",
"_postman_id": "d9f6cae1-30c2-4c85-96c3-428b1f2fc08d",
"name": "tc-project-service",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -3303,173 +3303,209 @@
},
{
"name": "Organization Config",
"description": "",
"item": [
{
"name": "Create organization config",
"request": {
"url": "{{api-url}}/v4/projects/metadata/orgConfig",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}",
"description": ""
"value": "Bearer {{jwt-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"param\":{\r\n \"orgId\": \"20000013\",\r\n \"configName\": \"project_catalog_url\",\r\n \"configValue\": \"/projects/1\"\r\n }\r\n}"
},
"description": ""
"url": {
"raw": "{{api-url}}/v4/projects/metadata/orgConfig",
"host": [
"{{api-url}}"
],
"path": [
"v4",
"projects",
"metadata",
"orgConfig"
]
}
},
"response": []
},
{
"name": "List organization config",
"name": "List organization config - error without filter",
"request": {
"url": "{{api-url}}/v4/projects/metadata/orgConfig",
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}",
"description": ""
"value": "Bearer {{jwt-token}}"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"description": ""
},
"response": []
},
{
"name": "List organization config - filter",
"request": {
"url": {
"raw": "{{api-url}}/v4/projects/metadata/orgConfig?filter=orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
"raw": "{{api-url}}/v4/projects/metadata/orgConfig",
"host": [
"{{api-url}}"
],
"path": [
"v4",
"projects",
"metadata",
"orgConfig"
],
"query": [
{
"key": "filter",
"value": "orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
"equals": true,
"description": ""
}
],
"variable": []
},
]
}
},
"response": []
},
{
"name": "List organization config - filter",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}",
"description": ""
"value": "Bearer {{jwt-token}}"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"description": ""
"url": {
"raw": "{{api-url}}/v4/orgConfig?filter=orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
"host": [
"{{api-url}}"
],
"path": [
"v4",
"orgConfig"
],
"query": [
{
"key": "filter",
"value": "orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url"
}
]
}
},
"response": []
},
{
"name": "Get organization config",
"request": {
"url": "{{api-url}}/v4/projects/metadata/orgConfig/1",
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}",
"description": ""
"value": "Bearer {{jwt-token}}"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"description": ""
"url": {
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
"host": [
"{{api-url}}"
],
"path": [
"v4",
"projects",
"metadata",
"orgConfig",
"1"
]
}
},
"response": []
},
{
"name": "Update organization config",
"request": {
"url": "{{api-url}}/v4/projects/metadata/orgConfig/1",
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}",
"description": ""
"value": "Bearer {{jwt-token}}"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"param\":{\r\n \"configName\": \"project_catalog_url\"\r\n }\r\n}"
},
"description": ""
"url": {
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
"host": [
"{{api-url}}"
],
"path": [
"v4",
"projects",
"metadata",
"orgConfig",
"1"
]
}
},
"response": []
},
{
"name": "Delete organization config",
"request": {
"url": "{{api-url}}/v4/projects/metadata/orgConfig/1",
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}",
"description": ""
"value": "Bearer {{jwt-token}}"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"description": ""
"url": {
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
"host": [
"{{api-url}}"
],
"path": [
"v4",
"projects",
"metadata",
"orgConfig",
"1"
]
}
},
"response": []
}
Expand Down Expand Up @@ -5184,4 +5220,4 @@
]
}
]
}
}
13 changes: 13 additions & 0 deletions src/routes/orgConfig/list.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
/**
* API to list organization config
*/
import validate from 'express-validation';
import Joi from 'joi';
import { middleware as tcMiddleware } from 'tc-core-library-js';
import models from '../../models';
import util from '../../util';

const permissions = tcMiddleware.permissions;

const schema = {
query: {
filter: Joi.string().required(),
},
};

module.exports = [
validate(schema),
permissions('orgConfig.view'),
(req, res, next) => {
// handle filters
const filters = util.parseQueryFilter(req.query.filter);
// Throw error if orgId is not present in filter
if (!filters.orgId) {
return next(util.buildApiError('Missing filter orgId', 422));
}
if (!util.isValidFilter(filters, ['orgId', 'configName'])) {
return util.handleError('Invalid filters', null, req, next);
}
Expand Down
Loading