Loading TOC...

MarkLogic 9 Product Documentation
flexrep.configurationTargetSetHttpOptions

flexrep.configurationTargetSetHttpOptions(
   cfg as element(flexrep.configuration),
   target-id as (Number|String),
   val as element(flexrep.httpOptions)
) as element(flexrep.configuration)

Summary

This function sets the HTTP options on the specified replication target.

Parameters
cfg The replication configuration.
target-id The ID of the replication target.
val The HTTP options in XML format.

Example

// Execute against the Master database. ??
const flexrep = require('/MarkLogic/flexrep');

  declareUpdate();
  // Obtain the domain ID from the database used by the Master to enable CPF.
  const domain = xdmp.eval(
    'const dom = require("/MarkLogic/cpf/domains");' +
      'fn.data(dom.get("Default Master").xpath("//dom:domain-id"));',
       null,
         {
          'database' : xdmp.database('Triggers')
         });

  const config = flexrep.configurationGet(domain, true);

  const targetId = flexrep.configurationTargetGetId(config, "Replica");

  const httpOptions = fn.head(xdmp.unquote(
    '<flexrep:http-options xmlns:flexrep="http://marklogic.com/xdmp/flexible-replication">' +
      '<http:authentication xmlns:http="xdmp:http">' +
        '<http:username>replicator</http:username>' +
        '<http:password>admin</http:password>' +
      '</http:authentication>' +
    '</flexrep:http-options>')).root;

  const cfg = 
      flexrep.configurationTargetSetHttpOptions(config, targetId, httpOptions);

  flexrep.configurationInsert(cfg); 

  // Resets the username and password used to access the Replica App Server.
   

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.