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.
admin:save-configuration
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.
admin
binary
xml
text
xquery version "1.0-ml"; import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; admin:mimetype("application/foo","foo,bar","binary") (: returns the mimetype specification :)
admin:mimetype
xquery version "1.0-ml"; import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; let $config := admin:get-configuration() let $mimetype := admin:mimetype("application/foo","foo,bar","binary") return admin:mimetypes-add($config, $mimetype) (: 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. :)
xquery version "1.0-ml"; import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; let $config := admin:get-configuration() let $mimetype := admin:mimetype("application/foo","foo,bar","binary") return admin:mimetypes-delete($config, $mimetype) (: 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. :)
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:mimetypes-get($config) (: returns the mimetypes specifications for the cluster :)