doc-exports/docs/dataartsstudio/api-ref/dataartsstudio_02_0102.html
Xiong, Chen Xiao 14a6d65e8c DataArts API 20240130 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Xiong, Chen Xiao <chenxiaoxiong@huawei.com>
Co-committed-by: Xiong, Chen Xiao <chenxiaoxiong@huawei.com>
2024-03-01 11:46:15 +00:00

182 lines
18 KiB
HTML

<a name="dataartsstudio_02_0102"></a><a name="dataartsstudio_02_0102"></a>
<h1 class="topictitle1">Creating a Resource</h1>
<div id="body0000001104494742"><div class="section" id="dataartsstudio_02_0102__en-us_topic_0181281323_section1738101810182"><h4 class="sectiontitle">Function</h4><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1912913467404">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.</p>
</div>
<div class="section" id="dataartsstudio_02_0102__en-us_topic_0181281323_section7934966101819"><h4 class="sectiontitle">URI</h4><ul id="dataartsstudio_02_0102__en-us_topic_0181281323_ul145591424184717"><li id="dataartsstudio_02_0102__en-us_topic_0181281323_li356152404715">URI format<p id="dataartsstudio_02_0102__en-us_topic_0181281323_p076674419427"><a name="dataartsstudio_02_0102__en-us_topic_0181281323_li356152404715"></a><a name="en-us_topic_0181281323_li356152404715"></a>POST /v1/{project_id}/resources</p>
</li></ul>
<ul id="dataartsstudio_02_0102__en-us_topic_0181281323_ul1370917277482"><li id="dataartsstudio_02_0102__en-us_topic_0181281323_li170972720484">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_table46023801181358" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameter</caption><thead align="left"><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_row26974916181358"><th align="left" class="cellrowborder" valign="top" width="20.39%" id="mcps1.3.2.3.1.1.2.5.1.1"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p37484572181358">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.15%" id="mcps1.3.2.3.1.1.2.5.1.2"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p16351468181358">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.24%" id="mcps1.3.2.3.1.1.2.5.1.3"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p49400541181358">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="53.22%" id="mcps1.3.2.3.1.1.2.5.1.4"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p42020886181358">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_row48248640181358"><td class="cellrowborder" valign="top" width="20.39%" headers="mcps1.3.2.3.1.1.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p15825795181358">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="10.15%" headers="mcps1.3.2.3.1.1.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p6820998181358">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="16.24%" headers="mcps1.3.2.3.1.1.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0093082049_p15629937181358">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.22%" headers="mcps1.3.2.3.1.1.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p8672138175612">Project ID. For details about how to obtain a project ID, see <a href="projectid_accountid.html">Project ID and Account ID</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="dataartsstudio_02_0102__en-us_topic_0181281323_section10789431145710"><h4 class="sectiontitle">Request Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_02_0102__en-us_topic_0181281323_table25071810112414" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request header parameter</caption><thead align="left"><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_row3746915131710"><th align="left" class="cellrowborder" valign="top" width="15.010000000000002%" id="mcps1.3.3.2.2.5.1.1"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p131491731112013">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.93%" id="mcps1.3.3.2.2.5.1.2"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p3149113112204">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18.73%" id="mcps1.3.3.2.2.5.1.3"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p13149173119204">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="49.33%" id="mcps1.3.3.2.2.5.1.4"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p11149331122017">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_row174620159179"><td class="cellrowborder" valign="top" width="15.010000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p1150183116205">workspace</p>
</td>
<td class="cellrowborder" valign="top" width="16.93%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p4150531152016">No</p>
</td>
<td class="cellrowborder" valign="top" width="18.73%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p181505317209">String</p>
</td>
<td class="cellrowborder" valign="top" width="49.33%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_p169341251122511">Workspace ID.</p>
<ul id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_ul776685742514"><li id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_li076655782516">If this parameter is not set, data in the <strong id="dataartsstudio_02_0102__b168488579473">default</strong> workspace is queried by default.</li><li id="dataartsstudio_02_0102__en-us_topic_0181281323_en-us_topic_0181281363_li788605918251">To query data in other workspaces, this header must be carried.</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_02_0102__en-us_topic_0181281323_table19750184493418" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Resource parameters</caption><thead align="left"><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row1475134418345"><th align="left" class="cellrowborder" valign="top" width="21.39%" id="mcps1.3.3.3.2.5.1.1"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1275244423417">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.33%" id="mcps1.3.3.3.2.5.1.2"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1375504413341">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.67%" id="mcps1.3.3.3.2.5.1.3"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p675774416349">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="52.61%" id="mcps1.3.3.3.2.5.1.4"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p475920448344">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row1760344113410"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.3.3.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p5760124443410">name</p>
</td>
<td class="cellrowborder" valign="top" width="10.33%" headers="mcps1.3.3.3.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p476174473411">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.67%" headers="mcps1.3.3.3.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p6763114463415">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.3.3.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1376304411342">Name of the resource. The name contains a maximum of 32 characters, including only letters, numbers, underscores (_), and hyphens (-).</p>
</td>
</tr>
<tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row7763244193418"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.3.3.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1676464463414">type</p>
</td>
<td class="cellrowborder" valign="top" width="10.33%" headers="mcps1.3.3.3.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p776544410349">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.67%" headers="mcps1.3.3.3.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p7766174423419">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.3.3.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p0767244123410">Resource type.</p>
<ul id="dataartsstudio_02_0102__en-us_topic_0181281323_ul1276716442349"><li id="dataartsstudio_02_0102__en-us_topic_0181281323_li676811443344">archive</li><li id="dataartsstudio_02_0102__en-us_topic_0181281323_li176818449341">file</li><li id="dataartsstudio_02_0102__en-us_topic_0181281323_li167711644103416">jar</li></ul>
</td>
</tr>
<tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row2416130182519"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.3.3.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1141615072518">location</p>
</td>
<td class="cellrowborder" valign="top" width="10.33%" headers="mcps1.3.3.3.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1416120152512">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.67%" headers="mcps1.3.3.3.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p2416001259">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.3.3.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p74165052512">OBS path for storing the resource file. When <strong id="dataartsstudio_02_0102__en-us_topic_0181281323_b14806446204615">type</strong> is set to <strong id="dataartsstudio_02_0102__en-us_topic_0181281323_b6120175212465">jar</strong>, <strong id="dataartsstudio_02_0102__en-us_topic_0181281323_b1984341684711">location</strong> is the path for storing the main JAR package. The path contains a maximum of 1,023 characters. For example, obs://myBucket/test.jar</p>
</td>
</tr>
<tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row477184415342"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.3.3.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p8364132164320">dependFiles</p>
</td>
<td class="cellrowborder" valign="top" width="10.33%" headers="mcps1.3.3.3.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p14363821194310">No</p>
</td>
<td class="cellrowborder" valign="top" width="15.67%" headers="mcps1.3.3.3.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p13627210437">List&lt;String&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.3.3.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p336182124313">JAR package and properties file that the main JAR package depends on. The description contains a maximum of 10,240 characters.</p>
</td>
</tr>
<tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row97741244163419"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.3.3.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p53611021124318">desc</p>
</td>
<td class="cellrowborder" valign="top" width="10.33%" headers="mcps1.3.3.3.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1035842120431">No</p>
</td>
<td class="cellrowborder" valign="top" width="15.67%" headers="mcps1.3.3.3.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p10357121114319">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.3.3.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p163571221134318">Description of the resource. The description contains a maximum of 255 characters.</p>
</td>
</tr>
<tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row47771744133413"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.3.3.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1135513219431">directory</p>
</td>
<td class="cellrowborder" valign="top" width="10.33%" headers="mcps1.3.3.3.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p163541215438">No</p>
</td>
<td class="cellrowborder" valign="top" width="15.67%" headers="mcps1.3.3.3.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p8352102118434">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.3.3.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1275984817177">Directory for storing the resource.</p>
<p id="dataartsstudio_02_0102__en-us_topic_0181281323_p123051357125016">Access the <span id="dataartsstudio_02_0102__text154341119123813">DataArts Studio</span> console and choose <strong id="dataartsstudio_02_0102__b9434151917387">Data Development</strong>. In the left navigation pane, choose <span class="menucascade" id="dataartsstudio_02_0102__menucascade64361519133811"><b><span class="uicontrol" id="dataartsstudio_02_0102__uicontrol34351819163816">Development</span></b> &gt; <b><span class="uicontrol" id="dataartsstudio_02_0102__uicontrol17435181993817">Develop Script</span></b></span>. In the directory tree of the script, you can view the created directories. The default directory is the <strong id="dataartsstudio_02_0102__b5637824124812">root</strong> directory.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dataartsstudio_02_0102__en-us_topic_0181281323_section561243517589"><h4 class="sectiontitle">Response Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_02_0102__en-us_topic_0181281323_table28596431819" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Response parameter</caption><thead align="left"><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row138621543814"><th align="left" class="cellrowborder" valign="top" width="21.39%" id="mcps1.3.4.2.2.5.1.1"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p13863743414">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.45%" id="mcps1.3.4.2.2.5.1.2"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p7863543317">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.55%" id="mcps1.3.4.2.2.5.1.3"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1186410432112">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="52.61%" id="mcps1.3.4.2.2.5.1.4"><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p12865843915">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dataartsstudio_02_0102__en-us_topic_0181281323_row188676434119"><td class="cellrowborder" valign="top" width="21.39%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p13868104319115">resourceId</p>
</td>
<td class="cellrowborder" valign="top" width="10.45%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p78681343612">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.55%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p1871643112">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.61%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p5872243419">Resource ID.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dataartsstudio_02_0102__en-us_topic_0181281323_section358155716277"><h4 class="sectiontitle">Example Request</h4><p id="dataartsstudio_02_0102__p832895583611">Create a resource named <strong id="dataartsstudio_02_0102__b5418463415">test</strong>. The resource type is <strong id="dataartsstudio_02_0102__b12991348765">jar</strong>. The OBS path where the resource file is located is <strong id="dataartsstudio_02_0102__b15110183619279">obs://dlf-test/hadoop-mapreduce-examples-2.4.1.jar</strong>. The JAR package and properties file on which the resource's main JAR package depends are <strong id="dataartsstudio_02_0102__b10988139122919">obs://dlf-test/depend1.jar","obs://dlf-test/depend2.jar</strong>. The description is <strong id="dataartsstudio_02_0102__b98415441660">test</strong>. The directory where the resource is located is <strong id="dataartsstudio_02_0102__b897003212507">/resource</strong>.</p>
<pre class="screen" id="dataartsstudio_02_0102__en-us_topic_0181281323_screen165211354306">POST /v1/b384b9e9ab9b4ee8994c8633aabc9505/resources
{
"name": "test",
"type": "jar",
"location": "obs://dlf-test/hadoop-mapreduce-examples-2.4.1.jar",
"dependFiles": ["obs://dlf-test/depend1.jar","obs://dlf-test/depend2.jar"],
"desc": "test",
"directory":"/resource"
}</pre>
</div>
<div class="section" id="dataartsstudio_02_0102__section11448413401"><h4 class="sectiontitle">Example Response</h4><ul id="dataartsstudio_02_0102__ul1314474114019"><li id="dataartsstudio_02_0102__li31446420408">Success response<pre class="screen" id="dataartsstudio_02_0102__screen15144104104020">{
"resourceId":"3624d1c3-5df5-4f20-9af9-98eadad6c5f9"
}</pre>
</li><li id="dataartsstudio_02_0102__li014417464011">Failure response<p id="dataartsstudio_02_0102__p16144341402"><a name="dataartsstudio_02_0102__li014417464011"></a><a name="li014417464011"></a>HTTP status code 400</p>
<pre class="screen" id="dataartsstudio_02_0102__screen12144741409">{
"error_code":"DLF.6259",
"error_msg":"Files of the same name exist in the directory."
}</pre>
</li></ul>
</div>
<div class="section" id="dataartsstudio_02_0102__en-us_topic_0181281323_section5716345106"><h4 class="sectiontitle">Status Codes</h4><p id="dataartsstudio_02_0102__en-us_topic_0181281323_p7799441908">See <a href="dataartsstudio_02_0310.html">Status Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dataartsstudio_02_0060.html">Resource Management APIs</a></div>
</div>
</div>