package com.volcengine.example.tls.demo;
import com.volcengine.model.tls.*;
import com.volcengine.model.tls.exception.LogException;
import com.volcengine.model.tls.request.*;
import com.volcengine.model.tls.response.*;
import com.volcengine.service.tls.TLSLogClient;
import java.util.ArrayList;
public static void main(String[] args) throws LogException {
ClientConfig clientConfig = new ClientConfig(System.getenv("VOLCENGINE_ENDPOINT"), System.getenv("VOLCENGINE_REGION"),
System.getenv("VOLCENGINE_ACCESS_KEY_ID"), System.getenv("VOLCENGINE_ACCESS_KEY_SECRET"), System.getenv("VOLCENGINE_TOKEN"));
TLSLogClient client = ClientBuilder.newClient(clientConfig);
CreateProjectRequest createProjectRequest = new CreateProjectRequest("project-name", "region", "description");
CreateProjectResponse createProjectResponse = client.createProject(createProjectRequest);
String projectID = createProjectResponse.getProjectId();
CreateTopicRequest createTopicRequest = new CreateTopicRequest();
createTopicRequest.setProjectId(projectID);
createTopicRequest.setTopicName("topic-name");
createTopicRequest.setTtl(30);
createTopicRequest.setDescription("description");
createTopicRequest.setShardCount(2);
createTopicRequest.setAutoSplit(true);
createTopicRequest.setMaxSplitShard(10);
createTopicRequest.setEnableTracking(true);
CreateTopicResponse createTopicResponse = client.createTopic(createTopicRequest);
String topicID = createTopicResponse.getTopicId();
FullTextInfo fullText = new FullTextInfo(false, ",-;", false);
ValueInfo textValueInfo = new ValueInfo();
textValueInfo.setValueType("text");
textValueInfo.setDelimiter(",");
textValueInfo.setCaseSensitive(false);
textValueInfo.setIncludeChinese(false);
textValueInfo.setSqlFlag(false);
List<KeyValueInfo> keyValue = new ArrayList<>();
keyValue.add(new KeyValueInfo("key1", textValueInfo));
CreateIndexRequest createIndexRequest = new CreateIndexRequest(topicID, fullText, keyValue);
CreateIndexResponse createIndexResponse = client.createIndex(createIndexRequest);