script

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderWorkspace   = "workspace"
	HeaderContentType = "Content-Type"

	ApplicationJson = "application/json"
)

Variables

This section is empty.

Functions

func Create

func Create(client *golangsdk.ServiceClient, opts Script) error

Create 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, Spark Python, and Impala SQL. Send request POST /v1/{project_id}/scripts

func Delete

func Delete(client *golangsdk.ServiceClient, scriptName string, opts DeleteReq) error

Delete is used to delete a specific script. Send request DELETE /v1/{project_id}/scripts/{script_name}

func Stop

func Stop(client *golangsdk.ServiceClient, scriptName, instanceId, workspace string) error

Stop is used to stop executing a script instance. Send request POST /v1/{project_id}/scripts/{script_name}/instances/{instance_id}/stop

func Update

func Update(client *golangsdk.ServiceClient, scriptName string, script Script) error

Update is used to modify the configuration items or script contents of a script. When modifying a script, specify the name of the script to be modified. The script name and type cannot be modified. Send request PUT /v1/{project_id}/scripts/{script_name}

Types

type DeleteReq

type DeleteReq struct {
	// Workspace ID.
	Workspace string `json:"-"`
	// Approvers is a script approver. This parameter is required if the review function is enabled.
	Approvers []*JobApprover `json:"approvers,omitempty"`
}

type ExecuteReq

type ExecuteReq struct {
	// Workspace ID.
	Workspace string `json:"-"`
	// Execute params
	Params map[string]string `json:"params,omitempty"`
}

type ExecuteResp

type ExecuteResp struct {
	InstanceID string `json:"instanceId"`
}

func Execute

func Execute(client *golangsdk.ServiceClient, scriptName string, opts *ExecuteReq) (*ExecuteResp, error)

Execute is used to execute a specific script, which can be a DWS SQL, DLI SQL, RDS SQL, Flink SQL, Hive SQL, Presto SQL, or Spark SQL script. A script instance is generated each time the script is executed. You can call the API Querying the Execution Result of a Script Instance to obtain script execution results. Send request POST /v1/{project_id}/scripts/{script_name}/execute

type GetExecutionResp

type GetExecutionResp struct {
	// Status is an execution status.
	// Can be:
	// LAUNCHING: The script instance is being submitted.
	// RUNNING: The script instance is running.
	// FINISHED: The script instance is successfully run.
	// FAILED: The script instance fails to be run.
	Status string `json:"status"`
	// Results is an execution result of the script instance.
	Results []*Result `json:"results"`
}

type JobApprover

type JobApprover struct {
	ApproverName string `json:"approverName" required:"true"`
}

type ListOpts

type ListOpts struct {
	Offset     int    `q:"offset"`
	Limit      int    `q:"limit"`
	ScriptName string `q:"scriptName"`
}

type ListResp

type ListResp struct {
	// Total is the total number of scripts.
	Total int `json:"total"`
	// Scripts is a list of scripts.
	Scripts []*Script `json:"scripts"`
}

func List

func List(client *golangsdk.ServiceClient, opts ListOpts, workspace string) (*ListResp, error)

List is used to query the script list. A maximum of 1000 scripts can be returned for each query. Send request GET /v1/{project_id}/scripts?offset={offset}&limit={limit}&scriptName={scriptName}

type Result

type Result struct {
	// Message Execution failure message.
	Message string `json:"message,omitempty"`
	// Duration is a time of executing the script instance. Unit: second
	Duration float64 `json:"duration,omitempty"`
	// RowCount is a number of the result rows.
	RowCount int `json:"rowCount,omitempty"`
	// Rows is a result data.
	Rows [][]interface{} `json:"rows,omitempty"`
	// Schema is a format definition of the result data.
	Schema []map[string]string `json:"schema,omitempty"`
}

type Script

type Script struct {
	// Workspace ID.
	Workspace string `json:"-"`
	// Name is a Script name. The name contains a maximum of 128 characters, including only letters, numbers, hyphens (-), and periods (.). The script name must be unique.
	Name string `json:"name" required:"true"`
	// Type is a script type. Can be: FlinkSQL, DLISQL, SparkSQL, HiveSQL, DWSSQL, RDSSQL, Shell, PRESTO, ClickHouseSQL, HetuEngineSQL, PYTHON, ImpalaSQL, Spark Python
	Type string `json:"type" required:"true"`
	// Content maximum of 4 MB is supported.
	Content string `json:"content,omitempty"`
	// Directory for storing the script. Access the DataArts Studio console and choose Data Development. The default directory is the root directory.
	Directory string `json:"directory,omitempty"`
	// ConnectionName is a 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, Spark Python, or PYTHON.
	// 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.
	ConnectionName string `json:"connectionName" required:"true"`
	// 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.
	Database string `json:"database,omitempty"`
	// 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.
	QueueName string `json:"queueName,omitempty"`
	// 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.
	Configuration map[string]string `json:"configuration,omitempty"`
	// Description contains a maximum of 255 characters.
	Description string `json:"description,omitempty"`
	// 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.
	TargetStatus string `json:"targetStatus,omitempty"`
	// Approvers is a script approver. This parameter is required if the review function is enabled.
	Approvers []*JobApprover `json:"approvers,omitempty"`
}

func Get

func Get(client *golangsdk.ServiceClient, scriptName, workspace string) (*Script, error)

Get is used to query a script, including the script type and script content. Send request GET /v1/{project_id}/scripts/{script_name}

func GetExecutionResult

func GetExecutionResult(client *golangsdk.ServiceClient, scriptName, instanceId, workspace string) (*Script, error)

GetExecutionResult is used to obtain the execution status and result of a script instance. Send request GET /v1/{project_id}/scripts/{script_name}/instances/{instance_id}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL