/
clientAPI.go
98 lines (80 loc) · 2.81 KB
/
clientAPI.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package gomarklogicgo
import (
"github.com/ryanjdew/go-marklogic-go/alert"
clients "github.com/ryanjdew/go-marklogic-go/clients"
"github.com/ryanjdew/go-marklogic-go/config"
datamovement "github.com/ryanjdew/go-marklogic-go/datamovement"
"github.com/ryanjdew/go-marklogic-go/dataservices"
"github.com/ryanjdew/go-marklogic-go/documents"
rowsManagement "github.com/ryanjdew/go-marklogic-go/rows-management"
search "github.com/ryanjdew/go-marklogic-go/search"
"github.com/ryanjdew/go-marklogic-go/semantics"
"github.com/ryanjdew/go-marklogic-go/util"
)
// Authentication options
const (
BasicAuth = clients.BasicAuth
DigestAuth = clients.DigestAuth
None = clients.None
)
// Client is used for connecting to the MarkLogic REST API.
type Client clients.Client
// Connection is used for defining the connection to the MarkLogic REST API.
type Connection clients.Connection
// NewClient creates the Client struct used for searching, etc.
func NewClient(host string, port int64, username string, password string, authType int) (*Client, error) {
return New(&Connection{Host: host, Port: port, Username: username, Password: password, AuthenticationType: authType})
}
// New creates the Client struct used for searching, etc.
func New(config *Connection) (*Client, error) {
client, err := clients.NewClient(convertToSubConnection(config))
return convertToClient(client), err
}
// Alerting service
func (c *Client) Alerting() *alert.Service {
return alert.NewService(convertToSubClient(c))
}
// Config service
func (c *Client) Config() *config.Service {
return config.NewService(convertToSubClient(c))
}
// DataMovement service
func (c *Client) DataMovement() *datamovement.Service {
return datamovement.NewService(convertToSubClient(c))
}
// DataServices service
func (c *Client) DataServices() *dataservices.Service {
return dataservices.NewService(convertToSubClient(c))
}
// Documents service
func (c *Client) Documents() *documents.Service {
return documents.NewService(convertToSubClient(c))
}
// RowsManagement service
func (c *Client) RowsManagement() *rowsManagement.Service {
return rowsManagement.NewService(convertToSubClient(c))
}
// Search service
func (c *Client) Search() *search.Service {
return search.NewService(convertToSubClient(c))
}
// Semantics service
func (c *Client) Semantics() *semantics.Service {
return semantics.NewService(convertToSubClient(c))
}
// NewTransaction returns a new transaction struct
func (c *Client) NewTransaction() *util.Transaction {
return &util.Transaction{}
}
func convertToSubClient(c *Client) *clients.Client {
converted := clients.Client(*c)
return &converted
}
func convertToClient(c *clients.Client) *Client {
converted := Client(*c)
return &converted
}
func convertToSubConnection(c *Connection) *clients.Connection {
converted := clients.Connection(*c)
return &converted
}