PropertyKey API

1.2 PropertyKey

Params说明:

  • name:属性类型名称,必填
  • data_type:属性类型数据类型,包括:bool、byte、int、long、float、double、string、date、uuid、blob,默认string类型
  • cardinality:属性类型基数,包括:single、list、set,默认single

请求体字段说明:

  • id:属性类型id值
  • properties:属性的属性,对于属性而言,此项为空
  • user_data:设置属性类型的通用信息,比如可设置age属性的取值范围,最小为0,最大为100;目前此项不做任何校验,只为后期拓展提供预留入口

1.2.1 创建一个 PropertyKey

Method & Url
  1. POST http://localhost:8080/graphs/hugegraph/schema/propertykeys
Request Body
  1. {
  2. "name": "age",
  3. "data_type": "INT",
  4. "cardinality": "SINGLE"
  5. }
Response Status
  1. 202
Response Body
  1. {
  2. "property_key": {
  3. "id": 1,
  4. "name": "age",
  5. "data_type": "INT",
  6. "cardinality": "SINGLE",
  7. "aggregate_type": "NONE",
  8. "write_type": "OLTP",
  9. "properties": [],
  10. "status": "CREATED",
  11. "user_data": {
  12. "~create_time": "2022-05-13 13:47:23.745"
  13. }
  14. },
  15. "task_id": 0
  16. }

1.2.2 为已存在的 PropertyKey 添加或移除 userdata

Params
  • action: 表示当前行为是添加还是移除,取值为append(添加)和eliminate(移除)
Method & Url
  1. PUT http://localhost:8080/graphs/hugegraph/schema/propertykeys/age?action=append
Request Body
  1. {
  2. "name": "age",
  3. "user_data": {
  4. "min": 0,
  5. "max": 100
  6. }
  7. }
Response Status
  1. 202
Response Body
  1. {
  2. "property_key": {
  3. "id": 1,
  4. "name": "age",
  5. "data_type": "INT",
  6. "cardinality": "SINGLE",
  7. "aggregate_type": "NONE",
  8. "write_type": "OLTP",
  9. "properties": [],
  10. "status": "CREATED",
  11. "user_data": {
  12. "min": 0,
  13. "max": 100,
  14. "~create_time": "2022-05-13 13:47:23.745"
  15. }
  16. },
  17. "task_id": 0
  18. }

1.2.3 获取所有的 PropertyKey

Method & Url
  1. GET http://localhost:8080/graphs/hugegraph/schema/propertykeys
Response Status
  1. 200
Response Body
  1. {
  2. "propertykeys": [
  3. {
  4. "id": 3,
  5. "name": "city",
  6. "data_type": "TEXT",
  7. "cardinality": "SINGLE",
  8. "properties": [],
  9. "user_data": {}
  10. },
  11. {
  12. "id": 2,
  13. "name": "age",
  14. "data_type": "INT",
  15. "cardinality": "SINGLE",
  16. "properties": [],
  17. "user_data": {}
  18. },
  19. {
  20. "id": 5,
  21. "name": "lang",
  22. "data_type": "TEXT",
  23. "cardinality": "SINGLE",
  24. "properties": [],
  25. "user_data": {}
  26. },
  27. {
  28. "id": 4,
  29. "name": "weight",
  30. "data_type": "DOUBLE",
  31. "cardinality": "SINGLE",
  32. "properties": [],
  33. "user_data": {}
  34. },
  35. {
  36. "id": 6,
  37. "name": "date",
  38. "data_type": "TEXT",
  39. "cardinality": "SINGLE",
  40. "properties": [],
  41. "user_data": {}
  42. },
  43. {
  44. "id": 1,
  45. "name": "name",
  46. "data_type": "TEXT",
  47. "cardinality": "SINGLE",
  48. "properties": [],
  49. "user_data": {}
  50. },
  51. {
  52. "id": 7,
  53. "name": "price",
  54. "data_type": "INT",
  55. "cardinality": "SINGLE",
  56. "properties": [],
  57. "user_data": {}
  58. }
  59. ]
  60. }

1.2.4 根据name获取PropertyKey

Method & Url
  1. GET http://localhost:8080/graphs/hugegraph/schema/propertykeys/age

其中,age为要获取的 PropertyKey 的名称

Response Status
  1. 200
Response Body
  1. {
  2. "id": 1,
  3. "name": "age",
  4. "data_type": "INT",
  5. "cardinality": "SINGLE",
  6. "aggregate_type": "NONE",
  7. "write_type": "OLTP",
  8. "properties": [],
  9. "status": "CREATED",
  10. "user_data": {
  11. "min": 0,
  12. "max": 100,
  13. "~create_time": "2022-05-13 13:47:23.745"
  14. }
  15. }

1.2.5 根据 name 删除 PropertyKey

Method & Url
  1. DELETE http://localhost:8080/graphs/hugegraph/schema/propertykeys/age

其中,age为要删除的 PropertyKey 的名称

Response Status
  1. 202
Response Body
  1. {
  2. "task_id" : 0
  3. }

Last modified May 19, 2023: Update propertykey.md (#240) (b5fb8fbd)