Loading TOC...

admin:forest-rename

admin:forest-rename(
   $config as element(configuration),
   $forest-id as xs:unsignedLong,
   $new-name as xs:string
) as element(configuration)

Summary

This function renames a forest.

Parameters
$config A configuration specification, typically as returned from one of the Admin module functions.
$forest-id The ID of the forest.
$new-name New name to give the forest.

Example


xquery version "1.0-ml";

import module namespace admin = "http://marklogic.com/xdmp/admin"
      at "/MarkLogic/admin.xqy";

let $config := admin:forest-rename(admin:get-configuration(), 15096846875773626521, "blah")
return admin:save-configuration($config)

   => returns the new configuration element -- use admin:save-configuration
      to save the changes to the configuration or pass the configuration
      to other Admin API functions to make other changes.
    

Comments

  • It appears that this does not work in 8.0-3 or previous releases. It will work in the next and subsequent releases. Apologies for any inconvenience.
    • I have the following xquery that works perfectly fine in the console: xquery version "1.0-ml"; import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; declare variable $oldname := "oldname"; declare variable $newname := "newname"; let $config := admin:get-configuration() let $config := admin:forest-rename($config, admin:forest-get-id(admin:get-configuration(), $oldname), $newname ) return admin:save-configuration($config); I converted it to rest-api like this: $ cat ernest.xqy xquery version "1.0-ml"; module namespace ernest = "http://marklogic.com/rest-api/resource/ernest"; import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; declare variable $oldname := "oldname"; declare variable $newname := "newname"; declare function ernest:put( $context as map:map, $params as map:map, $input as document-node()* ) as document-node()? { let $oldname := map:get($params, $oldname) let $newname := map:get($params, $newname) let $config := admin:get-configuration() let $config := admin:forest-rename($config, admin:forest-get-id(admin:get-configuration(), $oldname), $newname ) return admin:save-configuration($config) }; Installed it but then execution with curl invoking PUT returns: * Empty reply from server * Connection #0 to host localhost left intact curl: (52) Empty reply from server and based on your answer, this is happening because forest-rename is not supported in rest-api in version below 8.0-4, correct? Is that true? I thought that every function that is available in selected release can be converted to rest-api. Is that wrong assumption? I'm testing this in ML7 (7.0-5). Thank you
  • You can rename a forest with the PUT method on the properties endpoint. 1. Create a forest named OldName 2. Create this payload: {"forest-name": "NewName"} 3. PUT that payload to /manage/v2/forests/OldName/properties That'll rename the forest.
  • Is there an equivalent REST API call to this?
Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy