更新时间:2024-04-18 GMT+08:00
在线生成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();
父主题: 使用管理面SDK