Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Script

Updated on 2024-11-06 GMT+08:00

Function

This API is used to create a script. Currently, the following script types are supported: DLI SQL, Flink SQL, RDS SQL, Spark SQL, Hive SQL, DWS SQL, Shell, Presto SQL, ClickHouse SQL, HetuEngine SQL, Python, Impala SQL, and Spark Python.

URI

  • URI format

    POST /v1/{project_id}/scripts

  • Parameter description
    Table 1 URI parameter

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID. For details about how to obtain a project ID, see Project ID and Account ID.

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

workspace

No

String

Workspace ID.

  • If this parameter is not set, data in the default workspace is queried by default.
  • To query data in other workspaces, this header must be carried.
Table 3 Script parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Script name. The name contains a maximum of 128 characters, including only letters, numbers, hyphens (-), and periods (.). The script name must be unique.

type

Yes

String

Script type.

  • FlinkSQL
  • DLISQL
  • SparkSQL
  • HiveSQL
  • DWSSQL
  • RDSSQL
  • Shell
  • PRESTO
  • ClickHouseSQL
  • HetuEngineSQL
  • PYTHON
  • ImpalaSQL
  • SparkPython

content

Yes

String

Script content. A maximum of 4 MB is supported.

directory

No

String

Directory for storing the script.

Access the DataArts Studio console and go to the DataArts Factory page. In the left navigation pane, choose Data Development > Develop Script. In the directory tree of the script, you can view the created directories. The default directory is the root directory.

connectionName

No

String

Name of the connection associated with the script. This parameter is mandatory when type is set to DLISQL, SparkSQL, HiveSQL, DWSSQL, Shell, PRESTO, ClickHouseSQL, HetuEngineSQL, RDSSQL, ImpalaSQL, PYTHON, or SparkPython. To obtain the existing connections, refer to the instructions in Querying a Connection List (to Be Taken Offline). By default, this parameter is left blank.

database

No

String

Database associated with an SQL statement. This parameter is available only when type is set to DLISQL, SparkSQL, HiveSQL, DWSSQL, PRESTO, RDSSQL, ClickHouseSQL, ImpalaSQL, or HetuEngineSQL.

  • If type is set to DLI SQL, obtain database information by calling the API for querying all databases in the Data Lake Insight API Reference.
  • This parameter is mandatory when the script is not of any type listed.

queueName

Yes

String

Queue name of the DLI resource. This parameter is available only when type is set to DLISQL. You can obtain the queue information by calling the API for "Querying All Queues" in the Data Lake Insight API Reference. By default, this parameter is left blank.

configuration

No

map <String,Object>

Configuration defined by a user for the job. This parameter is available only when type is set to DLISQL. For details about the supported configuration items, see conf parameter description in the "Submitting a SQL Job" section of the Data Lake Insight API Reference. By default, this parameter is left blank.

description

No

String

The description contains a maximum of 255 characters.

owner

No

String

Owner name

targetStatus

No

String

This parameter is required if the review function is enabled. It indicates the target status of the script. The value can be SAVED, SUBMITTED, or PRODUCTION.

  • SAVED indicates that the script is saved but cannot be scheduled or executed. It can be executed only after submitted and approved.
  • SUBMITTED indicates that the script is automatically submitted after it is saved and can be executed after it is approved.
  • PRODUCTION indicates that the script can be directly executed after it is created. Note: Only the workspace administrator can create scripts in the PRODUCTION state.

approvers

No

List<JobApprover>

Script approver. This parameter is required if the review function is enabled. For details, see Table 4.

Table 4 Approver attributes

Parameter

Mandatory

Type

Description

approverName

Yes

String

Approver name

Response Parameters

None.

Example Request

Create a script named echoTimeShell whose type is Shell, content is echo a, and associated connection is con.
POST /v1/b384b9e9ab9b4ee8994c8633aabc9505/scripts
{
    "name": "echoTimeShell",
    "type": "Shell",
    "content": "echo a",
    "queueName": "default",
    "connectionName": "con"
}
Create a script when the review function is enabled.
POST /v1/b384b9e9ab9b4ee8994c8633aabc9505/scripts
{
    "name": "echoTimeShell",
    "type": "Shell",
    "content": "echo a",
    "queueName": "default",
    "connectionName": "con",
    "targetStatus":"SUBMITTED",
    "approvers": [
      {
        "approverName": "userName1"
      },
      {
        "approverName": "userName2"
      }
    ]
}

Example Response

  • Success response

    HTTP status code 204

  • Failure response

    HTTP status code 400

    {
        "error_code":"DLF.6247",
        "error_msg":"The script type is not specified."
    }

Status Code

See Status Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback