The DataWorks Open Platform provides sample code for various application scenarios to help you understand and use its features, such as OpenAPI, OpenEvent, and Extensions. This topic describes how to run the sample code from GitHub on your local machine. This demonstrates the open capabilities of DataWorks when integrated with different business scenarios.
Background information
The DataWorks Open Platform is an open channel that DataWorks uses to provide data and capabilities. The Open Platform provides features such as OpenAPI, OpenEvent, and Extensions. These features help you quickly connect your application systems to DataWorks. You can then manage data workflows, perform data governance and data administration, and respond promptly to business status changes in your applications. For more information about the Open Platform, see Open Platform overview.
Project initialization
Step 1: Prepare the development environment
Install the Java Development Kit (JDK).
You can download a version of the JDK that is compatible with your operating system from the Oracle official website.
NoteThe JDK version used in this demo must be Java 1.8 or later. After the installation is complete, you can open a command prompt or terminal and run the
java -versioncommand to check the Java version.Install Maven.
Maven is a package management tool for the Java runtime environment. You can download a Maven package that is compatible with your operating system from the Maven official website. After the download is complete, see Install Apache Maven to decompress and install Maven.
Install Node.js.
This demo includes frontend pages. You must install a Node.js environment on your client to run JavaScript code. You can download and install a Node.js environment from the Node.js official website.
NoteThe Node.js version used in this demo must be 14 or later. After the installation is complete, you can open a command prompt or terminal and run the
node --versioncommand to check the Node.js version.Install pnpm.
pnpm is a package management tool for JavaScript projects. This sample library uses the workspace mode to avoid publishing common components to npm. You must install pnpm to proceed. For installation instructions, see the pnpm installation tutorial. If you have already installed Node.js, you can run the following command to install the tool:
npm install -g pnpmCheck the development environment.
After you complete the preceding steps, you can run the following commands to check whether the required environments are installed.
java -version // If the Java JDK is installed, this command displays the Java JDK version number. Otherwise, a "command not found" error is reported. mvn -v // If Maven is installed, this command displays the Maven version number. Otherwise, a "command not found" error is reported. npm -v // If Node.js is installed, this command displays the Node.js version number. Otherwise, a "command not found" error is reported. pnpm -v // If pnpm is installed, this command displays the pnpm version number. Otherwise, a "command not found" error is reported.
Step 2: Run the sample code
Install dependencies.
After you prepare the development environment, download the sample project to your local machine. Then, you can run the following command to install dependencies.
pnpm installEnter your AccessKey and AccessKey secret.
After the installation is complete, find the application.properties configuration file in the root directory. In this file, specify key information such as your AccessKey, AccessKey secret, region ID, and endpoint. This information is read and synchronized to each application demo when the project starts.
NoteWhen the project runs, it uses the key information from the configuration file to connect to the open capabilities of DataWorks.
## The AccessKey ID of the RAM user. api.access-key-id={access-key} ## The AccessKey secret of the RAM user. api.access-key-secret={secret-key} ## The region ID where the DataWorks service resides, such as cn-shanghai or cn-hangzhou. # api.region-id=cn-hangzhou api.region-id={regionId} ## The product of DataWorks OpenAPI. The default value is dataworks-public. api.product=dataworks-public ## The endpoint of DataWorks OpenAPI. ## The default endpoint for public network access is dataworks.${regionId}.aliyuncs.com. ## The endpoint for VPC access is dataworks-vpc.${regionId}.aliyuncs.com. # api.endpoint=dataworks.cn-hangzhou.aliyuncs.com api.endpoint={endpoint} ## Specify the network environment. Set the value to false for public network access or true for VPC access. api.vpc-env=falseRun the demo.
After you complete the configuration, you can run the following commands to start the demos.
npm run example:workbench-screen // Run the Operation Center demo. npm run example:meta-api // Run the metadata demo. npm run example:event-instance-status // Run the demo for subscribing to instance status change messages. npm run example:extension-maxpt // Run the demo for prohibiting the use of the MAX_PT function. npm run example:extension-deploy-control // Run the demo for deployment freeze control.View the results.
After the run is complete, you can check the results in a web browser.
For demos with interactive frontend pages, you can access them at the following URL:
https://localhost:8080For backend-only demos, you can access them at the following URL:
http://localhost:8008
Get sample code for application scenarios
You can obtain sample code for the following scenarios from the Open Platform sample code library: