示例#1
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)
}
示例#2
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)
}
示例#3
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)
}
示例#4
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)
}
示例#5
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)
}
示例#6
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)
}
示例#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)
}
示例#8
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)
}
// 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)
}
示例#10
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)
}
示例#11
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)
}
示例#12
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)
}
示例#13
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)
}
示例#14
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)
}
示例#15
0
// 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)
}
示例#16
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)
}
示例#17
0
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)
}
示例#18
0
// 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)
}
示例#20
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)
}
示例#21
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)
}
示例#22
0
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
}