日本語版はAIによる翻訳です。正確な情報については英語版をご参照ください。 英語版を表示
メインコンテンツまでスキップ

Insert DataField

このドキュメントでは、InsertDataField の概要と使い方を説明します。InsertDataField を使うと、DataFieldをAPIで登録でき、登録したDataFieldのnameは、追加設定なしで、GetTreatmentsのコンテキスト属性(contextual attribute)のキーとしてそのまま利用できます。

API定義

POST https://apis.auxia.io/v1/InsertDataField
注記

InsertDataFieldの呼び出しにはTreatment ManagementのAPIキーが必要で、x-api-keyヘッダーで渡します。Treatment Management権限のないキーは403 PERMISSION_DENIEDで拒否されます。

エンティティ

UserPropertyParams

message UserPropertyParams {
// Required.
// The data type of the user property.
// Only BOOLEAN, STRING and INTEGER are supported. Any other value returns INVALID_ARGUMENT.
DataFieldType data_type = 1;
}

enum DataFieldType {
UNSPECIFIED_DATA_FIELD_TYPE = 0;
INTEGER = 1;
DOUBLE = 2;
STRING = 3;
BOOLEAN = 4;
TIMESTAMP_SECONDS = 5;
INTEGER_LIST = 6;
DOUBLE_LIST = 7;
STRING_LIST = 8;
}

DataFieldPb

message DataFieldPb {
// Auxia-assigned identifier for the DataField. Stable across calls.
string data_field_id = 1;

// The project this DataField belongs to.
string project_id = 2;

// The DataField name.
string name = 3;

oneof source {
UserPropertyParams user_property = 4;
}
}

InsertDataField

DataFieldを登録するAPI

message InsertDataFieldRequest {
// Required.
// Numeric project id.
string project_id = 1;

// Required.
// Must be snake_case, matching ^[a-z](?:[a-z0-9_]*[a-z0-9])?$, with a maximum length of 256 characters.
// This name is the key used as a contextual attribute in GetTreatments.
string name = 2;

// Required.
// Exactly one source must be set.
oneof source {
UserPropertyParams user_property = 3;
}
}

message InsertDataFieldResponse {
// The registered DataField (or the pre-existing one, if it already existed).
DataFieldPb data_field = 1;
}
ヒント

InsertDataField は (project_id, name) を複合一意キーとし、べき等性を保証します。同一のキーでリクエストが再送された場合、エラーや重複作成を行わず、すでに保存されている対象の data_field_id を返却します。

サンプル cURL リクエスト

curl --location --request POST 'https://apis.auxia.io/v1/InsertDataField' \
--header 'Content-Type: application/json' \
--header 'x-api-key: API_KEY' \
--data-raw '{
"projectId": "PROJECT_ID",
"name": "loyalty_tier",
"userProperty": {
"dataType": "STRING"
}
}'

サンプルレスポンス

{
"dataField": {
"dataFieldId": "8821",
"projectId": "PROJECT_ID",
"name": "loyalty_tier",
"userProperty": {
"dataType": "STRING"
}
}
}