This page was generated
August  8,  2011
2:23  AM
XQuery Built-In and Modules Function Reference

Module: Admin Library - Host Functions

The Admin module is an XQuery library module that allows you to script administrative tasks that you otherwise would need the Admin Interface to perform. Most functions in this library perform adminstrative tasks and therefore require the user who runs the XQuery program to have the Admin role.

Many of these functions provide new configuration information. In most cases, you must save the configuration (with admin:save-configuration, for example) in the same statement that you use the functions in order for them to take effect.

To use the Admin module as part of your own XQuery module, include the following line in your XQuery prolog:

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

The library namespace prefix admin is not predefined in the server.

Function Summary
admin:get-host-ids This function returns all the host IDs from the configuration.
admin:host-get-group This function returns the group ID for the host with the specified ID.
admin:host-get-id This function return the ID for the specified host from the configuration.
admin:host-get-name This function returns the name for the host with the specified ID.
admin:host-get-port This function returns the bind port for the host with the specified ID.
admin:host-set-group This function changes the group to which an existing host belongs to the newly specified value.
admin:host-set-name This function changes the name of an existing host to the newly specified value.
admin:host-set-port This function changes the bind port value for the host to the newly specified value.
Function Detail
admin:get-host-ids(
$config as element(configuration)
)  as   xs:unsignedLong*
Summary:

This function returns all the host IDs from the configuration.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.

Example:
  xquery version "1.0-ml";

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

  let $config := admin:get-configuration()
  return
  admin:get-host-ids($config)
  (: returns the IDs of all the hosts :)
  

admin:host-get-group(
$config as element(configuration),
$host-id as xs:unsignedLong
)  as   xs:unsignedLong
Summary:

This function returns the group ID for the host with the specified ID.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-id : The host ID. Typically, the result of an admin:host-get-id call.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  return
  admin:host-get-group($config, admin:host-get-id($config, xdmp:host-name()))
  (: returns the group ID :)  

  

admin:host-get-id(
$config as element(configuration),
$host-name as xs:string
)  as   xs:unsignedLong
Summary:

This function return the ID for the specified host from the configuration.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-name : The name of the host. If the host is the current host, xdmp:host-name() returns the name.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  return
  admin:host-get-id($config, xdmp:host-name())
  (: returns the host ID :)  

  

admin:host-get-name(
$config as element(configuration),
$host-id as xs:unsignedLong
)  as   xs:string
Summary:

This function returns the name for the host with the specified ID.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-id : The host ID. Typically, the result of an admin:host-get-id call.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  return
  admin:host-get-name($config, admin:host-get-id($config, xdmp:host-name()))
  (: returns the host name :)  

  

admin:host-get-port(
$config as element(configuration),
$host-id as xs:unsignedLong
)  as   xs:unsignedInt
Summary:

This function returns the bind port for the host with the specified ID.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-id : The host ID. Typically, the result of an admin:host-get-id call.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  return
  admin:host-get-port($config, admin:host-get-id($config, xdmp:host-name()))
  (: returns the bind port for the host :)  

  

admin:host-set-group(
$config as element(configuration),
$host-id as xs:unsignedLong,
$group-id as xs:unsignedLong
)  as   element(configuration)
Summary:

This function changes the group to which an existing host belongs to the newly specified value.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-id : The host ID. Typically, the result of an admin:host-get-id call.
$group-id : The new group ID value (typically from a admin:group-get-id call.

Usage Notes:

Any group whose ID you pass into this function must exist when the transaction begins, otherwise an exception is thrown. If you need to create the group, do so in a separate transaction before using them in in this function.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  let $hostid := admin:host-get-id($config, xdmp:host-name())
  return
  admin:host-set-group($config, $hostid,  
      admin:group-get-id($config, "Default"))
  (: 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.  :)  

  

admin:host-set-name(
$config as element(configuration),
$host-id as xs:unsignedLong,
$value as xs:string
)  as   element(configuration)
Summary:

This function changes the name of an existing host to the newly specified value.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-id : The host ID. Typically, the result of an admin:host-get-id call.
$value : The new name of the host.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  let $hostid := admin:host-get-id($config, "myOldHostname")
  return
  admin:host-set-name($config, $hostid, "myNewHostName")
  (: 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.  :)  
 
  

admin:host-set-port(
$config as element(configuration),
$host-id as xs:unsignedLong,
$value as xs:unsignedInt
)  as   element(configuration)
Summary:

This function changes the bind port value for the host to the newly specified value.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$host-id : The host ID. Typically, the result of an admin:host-get-id call.
$value : The new bind port value.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  let $hostid := admin:host-get-id($config, xdmp:host-name())
  return
  admin:host-set-port($config, $hostid, 7999)
  (: 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.  :)