全部产品

快速开始

更新时间:2020-09-23 16:24:59

说明

OpenApI Explorer提供在线调用云产品 API、动态生成 SDK 示例代码和快速检索接口等功能,能显著降低使用API的难度,推荐您使用。

环境准备

创建一个 Maven 工程,添加 Maven 依赖,如下所示。

        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>2.3.9</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-ddi</artifactId>
            <version>0.2.0</version>
        </dependency>

初始化 Client

IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<Your-AccessKeyId>", "<Your-AccessKeySecret>"); DefaultAcsClient client = new DefaultAcsClient(profile);

SDK 中所有对 Databricks 数据洞察的操作都可以使用这个 client 来进行。

示例代码

  1. 创建项目空间

    public void createProject() {
            IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<Your-AccessKeyId>", "<Your-AccessKeySecret>");
            DefaultAcsClient client = new DefaultAcsClient(profile);
            final CreateFlowProjectRequest request = new CreateFlowProjectRequest();
            request.setActionName("CreateFlowProject");
            request.setDescription("项目描述");
            request.setName("Your-Project-Name");
            request.setRegionId("cn-hangzhou");
            try {
                CreateFlowProjectResponse response = client.getAcsResponse(request);
                String projectId = response.getId();
                System.out.println(projectId);
            } catch (Exception e) {
    
            }
        }

  2. 删除项目空间

    public void deleteProject() {
            IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<Your-AccessKeyId>", "<Your-AccessKeySecret>");
            DefaultAcsClient ddiClient = new DefaultAcsClient(profile);
            final DeleteFlowProjectRequest request = new DeleteFlowProjectRequest();
            request.setProjectId("Your-ProjectId");
            request.setRegionId("cn-hangzhou");
            try {
                DeleteFlowProjectResponse response = ddiClient.getAcsResponse(request);
                System.out.println(response.getData());
            } catch (Exception e) {
    
            }
        }