Creating a Resource

Function

This API is used to create a resource. Types of nodes, including DLI Spark, MRS Spark, and MRS MapReduce, can reference files such as JAR and properties through resources.

URI

  • URI format

    POST /v1/{project_id}/resources

  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Message

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

workspace

No

String

Workspace ID.

  • If this parameter is not set, data in the default workspace is queried by default.
  • If you need to query data in other workspaces, this header must be carried.
Table 3 Resource parameter description

Parameter

Mandatory

Type

Description

name

Yes

String

Name of the resource. The name contains a maximum of 32 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

type

Yes

String

Resource type. The value can be:

  • archive
  • file
  • jar

location

Yes

String

OBS path for storing the resource file. When type is set to jar, location is the path for storing the main JAR package. The path contains a maximum of 256 characters. For example, obs://myBucket/test.jar

dependFiles

No

List<String>

JAR package and properties file that the main JAR package depends on. The description contains a maximum of 10,240 characters.

desc

No

String

The description contains a maximum of 255 characters.

directory

No

String

Directory for storing the resource.

Perform the following operations to obtain the directory:

  1. Log in to the management console.
  2. Click Data Lake Factory and choose Configuration > Manage Resource from the list on the left.

In the resource directory tree, you can view the created directories.

The default value is the root directory.

Response Message

Table 4 Parameter description

Parameter

Mandatory

Type

Description

resourceId

Yes

String

Resource ID.

Example

  • Request
    POST /v1/b384b9e9ab9b4ee8994c8633aabc9505/resources
    {
    	"name": "test",
    	"type": "jar",
    	"location": "obs://00000000dlf-test/hadoop-mapreduce-examples-2.4.1.jar",
    	"dependFiles": ["obs://00000000dlf-test/depend1.jar","obs://00000000dlf-test/depend2.jar"],
    	"desc": "test",
    	"directory":"/resource"
    }
  • Success response
    {
    	"resourceId":"3624d1c3-5df5-4f20-9af9-98eadad6c5f9"
    }
  • Failure response

    HTTP status code 400

    {
        "error_code":"DLF.6259",
        "error_msg":"Files of the same name exist in the directory."
    }

Status Code

For details about status codes, see Status Codes.