图引擎服务 GES-在线生成SDK代码

时间:2024-04-18 11:08:22

在线生成SDK代码

API Explorer 的代码示例能根据需要填写参数后动态生成SDK代码,降低您使用SDK的难度,推荐使用。

GES在API Explorer仅对接常用Region供用户调试,若动态生成代码的客户端初始化使用的Region不满足使用场景,可参考如下代码:

// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
String ak = System.getenv("CLOUD_SDK_AK");
String sk = System.getenv("CLOUD_SDK_SK");
String projectId = "project_id";

ICredential auth = new BasicCredentials()
        .withProjectId(projectId)
        .withAk(ak)
        .withSk(sk)
        .withIamEndpoint("{{iamEndpoint}}");
GesClient gesClient = GesClient.newBuilder()
        .withCredential(auth)
        .withEndpoints(Arrays.asList("{{gesEndpoint}}"))
        .build();
support.huaweicloud.com/devg-ges/ges_05_0006.html