以下提供了流式计算 Flink版的 SDK 使用说明,如需查看全部的 API 详细信息,请查看 API文档。您可以通过 API Explorer 快速发起 API 调用,获取响应结果和代码示例。
https://central.sonatype.com/artifact/com.volcengine/volcengine-java-sdk-flink20250101/0.2.2
https://github.com/volcengine/volcengine-java-sdk/tree/master/volcengine-java-sdk-flink20250101
<dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.3.2</version> </dependency>
步骤一: 集成服务仓库
<dependencies> <dependency> <groupId>com.volcengine</groupId> <artifactId>volcengine-java-sdk-flink20250101</artifactId> <version>0.2.2</version> </dependency> </dependencies>
<dependencyManagement> <dependencies> <dependency> <groupId>com.volcengine</groupId> <artifactId>volcengine-java-sdk-bom</artifactId> <version>0.2.2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
步骤二: Credentials 配置
通过环境变量导入:
export VOLCENGINE_ACCESS_KEY=your ak export VOLCENGINE_SECRET_KEY=your sk #如果使用token export VOLCENGINE_SESSION_TOKEN=token
如果您要自定义SDK的Endpoint,可以按照以下示例代码设置:
ApiClient apiClient = new ApiClient() .setCredentials(Credentials.getCredentials(ak, sk)) .setRegion(region).setEndpoint("ecs.cn-beijing-autodriving.volcengineapi.com");
火山引擎标准的Endpoint规则说明:
Regional 服务 | Global 服务 |
|---|---|
|
|
注:Service中存在_符号时,Endpoint时需转为-符号。存在大写字母时需转成小写。
以下提供调用【GetApplicationInstance】API的SDK示例代码,实际项目中您可以替换成SDK中已支持的任意API。
/** * Example Code generated by Beijing Volcanoengine Technology. */ package com.volcengine.sdk.example; import com.volcengine.ApiClient; import com.volcengine.ApiException; import com.volcengine.sign.Credentials; import com.volcengine.flink20250101.Flink20250101Api; import com.volcengine.flink20250101.model.*; public class TestGetApplicationInstance { public static void main(String[] args) throws Exception { String ak = "Your AK"; String sk = "Your SK"; String region = "cn-beijing"; ApiClient apiClient = new ApiClient() .setCredentials(Credentials.getCredentials(ak, sk)) .setRegion(region); Flink20250101Api api = new Flink20250101Api(apiClient); GetApplicationInstanceRequest getApplicationInstanceRequest = new GetApplicationInstanceRequest(); try { GetApplicationInstanceResponse response = api.getApplicationInstance(getApplicationInstanceRequest); System.out.println(response); } catch (ApiException e) { System.out.println(e.getResponseBody()); } } }