This interface is used to create clusters, which can be created based on rules or uploaded files.
Path:/openapi/v1/{app_id}/cohorts
Method: POST
Content-type: application/json
Path-parameters : ReferenceAPI Description and Public Parameters
Body:
{ "cohort_name": "cohort name", "cohort_type": 4, "description": "cohort description", "dsl_content": {}, "refresh_rule": 1 }
Field meaning description
Field | Type | Description |
|---|---|---|
cohort_name | int | group name |
cohort_type | int | Cluster type:
|
description | string | grouping description information |
dsl_content | object | Cluster rule or file information created:
|
refresh_rule | int |
|
Response:
{ "code": 200, "message": "success", "data": { "cohort_id": 6 } }
Field meaning description
Field | Type | Description |
|---|---|---|
cohort_id | int | Create a successful cluster ID |
Bc for the creation of RangersClient, its initialization please refer to Instructions for usethe language SDK provides a similar interface
Call (Python):
#For example, app_id = 164314 dsl = { "cohort_name": "openapi-creation", "cohort_type": 4, #4 Represents rule creation "description": "", "dsl_content": { "periods": [], "app_ids": [ 164314 ], "content": { "profile_filters": [], "profile_groups": [], "queries": [ [ { "show_label": "event--A--A", "event_name": "any_event", "event_type": "origin", "next_query_label": null, "sequence_first": true, "logic": true, "condition": { "property_operation": ">", "property_values": [ 0 ], "period": { "granularity": "day", "last": { "amount": 7, "unit": "day" }, "type": "last", "timezone": "Asia/Shanghai" } }, "filters": [ { "expression": { "logic": "and", "conditions": [] } } ], "event_indicator": "events" } ] ], "query_type": "$cohort" }, "version": 3 }, "refresh_rule": 1 #1 means manual refresh, 2 means daily refresh } resp = bc.data_finder("/openapi/v1/164314/cohorts", body=dsl) cohort_id = resp.json()["data"]["cohort_id"]
Return result:
{ "code": 200, "message": "success", "data": { "cohort_id": 6 } }