|
|
package:add-appserver(
|
|
$pkg as element(pkg:package),
|
|
$groupname as xs:string,
|
|
$appname as xs:string
|
| ) as element(pkg:package) |
|
 |
Summary:
Add the configuration settings for an App Server to a package.
|
Parameters:
$pkg
:
The package to which to add App Server configuration settings.
|
$groupname
:
The name of the Group containing the target App Server.
|
$appname
:
The name of the App Server whose settings should be added to the
package. The App Server must be in the Group identified by
$groupname.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/manage
|
Usage Notes:
If the named App Server is already in the package, this function
has no effect.
If the App Server described by the $groupname and
$appname does not exist, an exception is raised.
The security role manage-user grants
http://marklogic.com/xdmp/privileges/manage.
|
Example:
xquery version "1.0-ml";
import module namespace package = "http://marklogic.com/package/package"
at "/MarkLogic/package/package.xqy";
let $my-package := package:create()
return package:add-appserver($my-package, "Default", "sample-server")
=> A package containing the configuration settings for
the App Server "sample-server" in the "Default" group.
|
|
|
|
package:add-database(
|
|
$pkg as element(pkg:package),
|
|
$dbname as xs:string
|
| ) as element(pkg:package) |
|
 |
Summary:
Add the configuration settings for a database to a package.
|
Parameters:
$pkg
:
The package to which to add database configuration settings.
|
$dbname
:
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/manage
|
Usage Notes:
If the database is already in the package, this function
has no effect.
If the database does not exist, an exception is raised.
The pre-defined security role manage-user grants
http://marklogic.com/xdmp/privileges/manage.
|
Example:
xquery version "1.0-ml";
import module namespace package = "http://marklogic.com/package/package"
at "/MarkLogic/package/package.xqy";
let $my-package := package:create()
return package:add-database($my-package, "sample-db")
=> A package containing the configuration settings for
the database "sample-db".
|
|
|
|
package:compare(
|
|
$source-pkg as node(),
|
|
$target-pkg as node()
|
| ) as element(pkg:package-diff) |
|
 |
Summary:
Compare two configuration packages previously created using the
packaging API, and return the differences as a
pkg:package-diff.
|
Parameters:
$source-pkg
:
The "updated" package to diff against the baseline. The node must
be element(pkg:package) or a document node rooted at
pkg:package.
|
$target-pkg
:
The "original" package to diff against. Differences are reported
as changes from this baseline. The node must be a
element(pkg:package) or a document node rooted at
pkg:package.
|
|
Usage Notes:
The returned pkg:package-diff contains the entire
configuration, with differences called out in pkg:delta
elements.
The differences between the two input packages are reported as changes
that transform from-pkg into to-pkg.
|
Example:
xquery version "1.0-ml";
(: package the original database configuration and save as a document :)
import module namespace package = "http://marklogic.com/package/package"
at "/MarkLogic/package/package.xqy";
let $from-package := package:create()
let $from-doc :=
xdmp:document-insert("/package/from",
package:add-database($from-package, "samples"))
return "saved from-package";
(: modify the database configuration by flipping word positions setting :)
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $db-id := xdmp:database("samples")
let $config := admin:get-configuration()
return admin:save-configuration(
admin:database-set-word-positions(
$config, $db-id,
fn:not(admin:database-get-word-positions($config,$db-id))
));
(: package the modified database configuration and save as a document :)
import module namespace package = "http://marklogic.com/package/package"
at "/MarkLogic/package/package.xqy";
let $to-package := package:create()
let $to-doc :=
xdmp:document-insert("/package/to",
package:add-database($to-package, "samples"))
return "saved to-package";
(: compare the original and modified configurations :)
import module namespace package = "http://marklogic.com/package/package"
at "/MarkLogic/package/package.xqy";
declare namespace pkg = "http://marklogic.com/package";
let $deltas :=
package:compare(fn:doc("/package/to"), fn:doc("/package/from"))//pkg:delta
for $delta in ($deltas)
return $delta/..
=> The package differences, showing word positions changed
from false to true:
saved from-package
saved to-package
<db:timestamp xmlns:pkg="http://marklogic.com/package"
xmlns:db="http://marklogic.com/package/databases">
<pkg:delta>
<pkg:del>2011-09-26T12:19:55.237658-07:00</pkg:del>
<pkg:add>2011-09-26T12:19:55.732692-07:00</pkg:add>
</pkg:delta>
</db:timestamp>
<word-positions xmlns:pkg="http://marklogic.com/package"
xmlns:db="http://marklogic.com/package/databases"
xmlns="http://marklogic.com/package/databases">
<pkg:delta>
<pkg:del>false</pkg:del>
<pkg:add>true</pkg:add>
</pkg:delta>
</word-positions>
|
|
|
|
package:install(
|
|
$pkg as node()
|
| ) as element(pkg:result) |
|
 |
Summary:
Apply the configuration settings in a package to a MarkLogic
Server instance.
|
Parameters:
$pkg
:
The packaged configuration to install. The node must be either
an element(pkg:package), or a document node rooted
at element(pkg:package).
|
|
Usage Notes:
Only users in the admin role may install packages.
Installing a package creates a ticket. The ticket number is provided
in the returned pkg:result. Use info:ticket
to check the status of the ticket.
Modifying some settings requires a server restart. If package
installation requires a server restart to complete, the returned
result directs you to restart.
The returned pkg:result reports success or failure in
the pkg:result-status child element. If the installation
fails, the live configuration is unchanged; errors are reported in
the pkg:configuration-errors child element.
Attempting to install two or more packages concurrently may leave your
configuration in an indeterminate state.
|
Example:
(: install a package previously saved as a document :)
import module namespace package = "http://marklogic.com/package/package"
at "/MarkLogic/package/package.xqy";
package:install(fn:doc("/package/to"))
=> The settings in /package/to are applied and a pkg:result is
returned, indicating success or failure. For example:
<pkg:result xmlns:pkg="http://marklogic.com/package">
<pkg:ticket-id>/tickets/ticket/2438123874498566113</pkg:ticket-id>
<pkg:result-status>COMPLETED</pkg:result-status>
<pkg:result-event>PACKAGE_WRITTEN</pkg:result-event>
</pkg:result>
|
|
|