Exemplo n.º 1
0
// 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)
}
Exemplo n.º 2
0
// 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)
}
Exemplo n.º 3
0
// 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)
}
Exemplo n.º 4
0
// 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)
}
Exemplo n.º 5
0
// 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)
}
Exemplo n.º 6
0
// 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)
}
Exemplo n.º 7
0
// 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)
}
// 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)
}
Exemplo n.º 9
0
// 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)
}
Exemplo n.º 10
0
// 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)
}
Exemplo n.º 11
0
// 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)
}
Exemplo n.º 12
0
// 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)
}
Exemplo n.º 13
0
// 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)
}
Exemplo n.º 14
0
// 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)
}
Exemplo n.º 15
0
// 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)
}
Exemplo n.º 16
0
// 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)
}
Exemplo n.º 17
0
// 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)
}
Exemplo n.º 18
0
// 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)
}