// SetQueryOptions shows all the installed REST extensions func setQueryOptions(c *clients.Client, optionsName string, options handle.Handle, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "PUT", "/config/query/"+optionsName, options) if err != nil { return err } return util.Execute(c, req, response) }
// StructuredSearch searches with a structured query func StructuredSearch(c *clients.Client, query handle.Handle, start int64, pageLength int64, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "POST", "/search?start="+strconv.FormatInt(start, 10)+"&pageLength="+strconv.FormatInt(pageLength, 10), query) if err != nil { return err } return util.Execute(c, req, response) }
// ResetProperties resets the REST API properties to their default func resetProperties(c *clients.Client, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "DELETE", "/config/properties", nil) if err != nil { return err } return util.Execute(c, req, response) }
// SetPropertyValue sets a property of the REST API func setPropertyValue(c *clients.Client, propertyName string, property handle.Handle, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "PUT", "/config/properties/"+propertyName, property) if err != nil { return err } return util.Execute(c, req, response) }
// SetNamespace shows the namespaces used in queries func setNamespace(c *clients.Client, namespace handle.Handle, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "PUT", "/config/namespaces", namespace) if err != nil { return err } return util.Execute(c, req, response) }
// GetQueryOptions returns the named REST query options func getQueryOptions(c *clients.Client, name string, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "GET", "/config/query/"+name, nil) if err != nil { return err } return util.Execute(c, req, response) }
// Initialize MarkLogic instance func initialize(ac *clients.AdminClient, license handle.Handle, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(ac, "POST", "/init", license) if err != nil { return err } return util.Execute(ac, req, response) }
// Search with text value func Search(c *clients.Client, text string, start int64, pageLength int64, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "GET", "/search?q="+text+"&start="+strconv.FormatInt(start, 10)+"&pageLength="+strconv.FormatInt(pageLength, 10), nil) if err != nil { return err } return util.Execute(c, req, response) }
// GetDatabaseProperties sets the database properties func GetDatabaseProperties(mc *clients.ManagementClient, databaseName string, propertiesHandle handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(mc, "GET", "/databases/"+databaseName+"/properties", nil) if err != nil { return err } return util.Execute(mc, req, propertiesHandle) }
// DeleteExtensions shows all the installed REST extensions func deleteExtensions(c *clients.Client, directory string) error { req, err := util.BuildRequestFromHandle(c, "DELETE", "/ext"+directory, nil) if err != nil { return err } return util.Execute(c, req, nil) }
// DeleteResource removes a REST service func deleteResource(c *clients.Client, name string, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "DELETE", "/config/resources/"+name, nil) if err != nil { return err } return util.Execute(c, req, response) }
// ListResources shows all the installed REST service extensions func listResources(c *clients.Client, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "GET", "/config/resources", nil) if err != nil { return err } return util.Execute(c, req, response) }
// DeleteAllQueryOptions removes all the installed REST query options func deleteAllQueryOptions(c *clients.Client, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "DELETE", "/config/query", nil) if err != nil { return err } return util.Execute(c, req, response) }
// ListExtensions shows all the installed REST extensions func listExtensions(c *clients.Client, directory string, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(c, "GET", "/ext"+directory, nil) if err != nil { return err } return util.Execute(c, req, response) }
// IndexesReport shows the status of indexes in query options func indexesReport(c *clients.Client, response handle.ResponseHandle) error { req, err := http.NewRequest("GET", c.Base()+"/config/indexes", nil) if err != nil { return err } return util.Execute(c, req, response) }
// Verify that MarkLogic Server is up and accepting requests. // https://docs.marklogic.com/REST/GET/admin/v1/timestamp func timestamp(ac *clients.AdminClient, response handle.ResponseHandle) error { req, err := util.BuildRequestFromHandle(ac, "GET", "/timestamp", nil) if err != nil { return err } return util.Execute(ac, req, response) }
func read(c *clients.Client, uris []string, categories []string, transform *util.Transform, response handle.ResponseHandle) error { params := buildParameters(uris, categories, nil, nil, nil, transform) req, err := http.NewRequest("GET", c.Base()+"/documents"+params, nil) if err != nil { return err } return util.Execute(c, req, response) }
// CreateResource installs a REST service func createResource(c *clients.Client, name string, resource io.Reader, extensionType string, options map[string]string, response handle.ResponseHandle) error { params := mapToParams(options) req, err := http.NewRequest("PUT", c.Base()+"/config/resources/"+name+params, resource) if err != nil { return err } req.Header.Add("Content-Type", "application/"+extensionType) return util.Execute(c, req, response) }
// GetServerProperties sets the database properties func GetServerProperties(mc *clients.ManagementClient, serverName string, groupID string, properties handle.ResponseHandle) error { if groupID == "" { groupID = "Default" } req, err := util.BuildRequestFromHandle(mc, "GET", "/servers/"+serverName+"/propertie?group-id="+groupID, nil) if err != nil { return err } return util.Execute(mc, req, properties) }
// Install the admin username and password, and initialize the security database and objects. func instanceAdmin(ac *clients.AdminClient, username string, password string, realm string, response handle.ResponseHandle) error { params := "?" params = util.RepeatingParameters(params, "admin-username", []string{username}) params = util.RepeatingParameters(params, "admin-password", []string{password}) params = util.RepeatingParameters(params, "realm", []string{realm}) req, err := util.BuildRequestFromHandle(ac, "POST", "/instance-admin"+params, nil) if err != nil { return err } return util.Execute(ac, req, response) }
// StructuredSuggestions suggests query text based off of a structured query func StructuredSuggestions(c *clients.Client, query handle.Handle, partialQ string, limit int64, options string, response handle.ResponseHandle) error { uri := "/suggest?limit=" + strconv.FormatInt(limit, 10) if options != "" { uri = uri + "&options=" + options } req, err := util.BuildRequestFromHandle(c, "POST", uri, query) if err != nil { return err } return util.Execute(c, req, response) }
func write(c *clients.Client, documents []DocumentDescription, transform *util.Transform, response handle.ResponseHandle) error { channel := make(chan error) var err error for _, doc := range documents { go func(doc DocumentDescription) { params := buildParameters([]string{doc.URI}, nil, doc.Collections, doc.Permissions, doc.Properties, transform) req, err := http.NewRequest("PUT", c.Base()+"/documents"+params, doc.Content) if err == nil { err = util.Execute(c, req, response) } channel <- err }(doc) } for _ = range documents { if err == nil { err = <-channel } else { <-channel } } return err }