-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
f1ff3dd
commit 679ce10
Showing
8 changed files
with
358 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
swagger: '2.0' | ||
info: | ||
title: '' | ||
version: '' | ||
basePath: / | ||
paths: | ||
'/v1/{project}/kie/kv': | ||
get: | ||
summary: list key values by labels and key | ||
operationId: List | ||
parameters: | ||
- name: project | ||
in: path | ||
required: true | ||
type: string | ||
- name: label | ||
in: query | ||
description: 'label pairs,for example &label=service:order&label=version:1.0.0' | ||
type: string | ||
- name: wait | ||
in: query | ||
description: 'wait until any kv changed. for example wait=5s, server will not response until 5 seconds during that time window, if any kv changed, server will return 200 and kv list, otherwise return 304 and empty body' | ||
type: string | ||
consumes: | ||
- '*/*' | ||
produces: | ||
- application/json | ||
- text/yaml | ||
responses: | ||
'200': | ||
description: '' | ||
schema: | ||
$ref: '#/definitions/KVResponse' | ||
headers: | ||
X-RateLimit-Limit: | ||
type: integer | ||
description: Request limit per hour. | ||
'304': | ||
description: empty body | ||
delete: | ||
summary: 'delete key by kvID and labelID. Want better performance, give labelID' | ||
operationId: Delete | ||
parameters: | ||
- name: project | ||
in: path | ||
required: true | ||
type: string | ||
- name: kvID | ||
in: query | ||
required: true | ||
type: string | ||
- name: labelID | ||
in: query | ||
type: string | ||
consumes: | ||
- '*/*' | ||
produces: | ||
- '*/*' | ||
responses: | ||
'204': | ||
description: Delete success | ||
'400': | ||
description: 'Failed,check url' | ||
'500': | ||
description: Server error | ||
'/v1/{project}/kie/kv/{key}': | ||
get: | ||
summary: get key values by key and labels | ||
operationId: GetByKey | ||
parameters: | ||
- name: project | ||
in: path | ||
required: true | ||
type: string | ||
- name: key | ||
in: path | ||
required: true | ||
type: string | ||
- name: label | ||
in: query | ||
description: 'label pairs,for example &label=service:order&label=version:1.0.0' | ||
type: string | ||
consumes: | ||
- '*/*' | ||
produces: | ||
- application/json | ||
- text/yaml | ||
responses: | ||
'200': | ||
description: get key value success | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/definitions/KVResponse' | ||
'304': | ||
description: empty body | ||
put: | ||
summary: create or update key value | ||
operationId: Put | ||
parameters: | ||
- name: project | ||
in: path | ||
required: true | ||
type: string | ||
- name: key | ||
in: path | ||
required: true | ||
type: string | ||
- name: body | ||
in: body | ||
required: true | ||
schema: | ||
$ref: '#/definitions/v1.KVBody' | ||
consumes: | ||
- application/json | ||
- text/yaml | ||
produces: | ||
- application/json | ||
- text/yaml | ||
responses: | ||
'200': | ||
description: '' | ||
schema: | ||
$ref: '#/definitions/v1.KVBody' | ||
'/v1/{project}/kie/revision/{label_id}': | ||
get: | ||
summary: get all revisions by label id | ||
operationId: GetRevisions | ||
parameters: | ||
- name: project | ||
in: path | ||
required: true | ||
type: string | ||
- name: label_id | ||
in: path | ||
required: true | ||
type: string | ||
- name: key | ||
in: query | ||
description: only return history about a specific key | ||
type: string | ||
consumes: | ||
- application/json | ||
- text/yaml | ||
produces: | ||
- application/json | ||
- text/yaml | ||
responses: | ||
'200': | ||
description: 'true' | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/definitions/LabelHistoryResponse' | ||
'/v1/{project}/kie/summary': | ||
get: | ||
summary: 'search key values by labels combination, it returns multiple labels group' | ||
operationId: Search | ||
parameters: | ||
- name: project | ||
in: path | ||
required: true | ||
type: string | ||
- name: q | ||
in: query | ||
description: 'the combination format is {label_key}:{label_value}+{label_key}:{label_value} for example: /v1/test/kie/kv?q=app:mall&q=app:mall+service:cart, that will query key values from 2 kinds of labels' | ||
type: string | ||
consumes: | ||
- '*/*' | ||
produces: | ||
- application/json | ||
- text/yaml | ||
responses: | ||
'200': | ||
description: get key value success | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/definitions/KVResponse' | ||
definitions: | ||
KVDoc: | ||
type: object | ||
properties: | ||
_id: | ||
type: string | ||
check: | ||
type: string | ||
domain: | ||
type: string | ||
key: | ||
type: string | ||
label_id: | ||
type: string | ||
labels: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
project: | ||
type: string | ||
revision: | ||
type: integer | ||
format: int32 | ||
value: | ||
type: string | ||
value_type: | ||
type: string | ||
KVResponse: | ||
type: object | ||
properties: | ||
data: | ||
type: array | ||
items: | ||
$ref: '#/definitions/KVDoc' | ||
label: | ||
$ref: '#/definitions/LabelDocResponse' | ||
num: | ||
type: integer | ||
format: int32 | ||
size: | ||
type: integer | ||
format: int32 | ||
total: | ||
type: integer | ||
format: int32 | ||
LabelDocResponse: | ||
type: object | ||
properties: | ||
label_id: | ||
type: string | ||
labels: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
LabelHistoryResponse: | ||
type: object | ||
properties: | ||
data: | ||
type: array | ||
items: | ||
$ref: '#/definitions/KVDoc' | ||
label_id: | ||
type: string | ||
labels: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
revision: | ||
type: integer | ||
format: int32 | ||
v1.KVBody: | ||
type: object | ||
properties: | ||
labels: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
value: | ||
type: string | ||
valueType: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package session_test | ||
|
||
import ( | ||
"context" | ||
"github.com/apache/servicecomb-kie/server/config" | ||
"github.com/apache/servicecomb-kie/server/service/mongo/session" | ||
"github.com/stretchr/testify/assert" | ||
"go.mongodb.org/mongo-driver/bson" | ||
"testing" | ||
) | ||
|
||
func TestGetColInfo(t *testing.T) { | ||
var err error | ||
config.Configurations = &config.Config{DB: config.DB{URI: "mongodb://kie:[email protected]:27017/kie"}} | ||
err = session.Init() | ||
assert.NoError(t, err) | ||
err = session.CreateView(context.Background(), "test_view", session.CollectionKV, []bson.D{ | ||
{{ | ||
"$match", | ||
bson.D{{"domain", "default"}, {"project", "default"}}, | ||
}}, | ||
}) | ||
assert.NoError(t, err) | ||
c, err := session.GetColInfo(context.Background(), "test_view") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "default", c.Options.Pipeline[0]["$match"]["domain"]) | ||
err = session.DropView(context.Background(), "test_view") | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package session | ||
|
||
//CollectionInfo is struct | ||
type CollectionInfo struct { | ||
Options Options `json:"options"` | ||
} | ||
|
||
//Options is struct | ||
type Options struct { | ||
Pipeline []map[string]map[string]string `json:"pipeline"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.