clients

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package clients provides clients for working with MarkLogic.

Index

Constants

View Source
const (
	BasicAuth = iota
	DigestAuth
	None
)

Authentication options

Variables

This section is empty.

Functions

func ApplyAuth

func ApplyAuth(c RESTClient, req *http.Request)

ApplyAuth adds the neccessary headers for authentication

Types

type AdminClient

type AdminClient struct {
	*BasicClient
}

AdminClient is used for connecting to the MarkLogic Management API.

func NewAdminClient

func NewAdminClient(connection *Connection) (*AdminClient, error)

NewAdminClient creates the Client struct used for managing admin features, etc.

type BasicClient

type BasicClient struct {
	// contains filtered or unexported fields
}

BasicClient is the basic parts that compose both

func ClientBuilder

func ClientBuilder(connection *Connection, base string) (*BasicClient, error)

ClientBuilder is a factory for MarkLogic clients

func (*BasicClient) AuthType

func (bc *BasicClient) AuthType() int

AuthType returns the int that represents an authentication type (BasicAuth, DigestAuth)

func (*BasicClient) Base

func (bc *BasicClient) Base() string

Base provides the base of the REST calls that will be made

func (*BasicClient) ConnectionInfo

func (bc *BasicClient) ConnectionInfo() *Connection

ConnectionInfo returns the information on the connection

func (*BasicClient) Database

func (bc *BasicClient) Database() string

Database returns the database the client is targeting

func (*BasicClient) DigestHeaders

func (bc *BasicClient) DigestHeaders() *digestAuth.DigestHeaders

DigestHeaders returns the digest headers that need updated with each DigestAuth call

func (*BasicClient) Do

func (bc *BasicClient) Do(req *http.Request) (*http.Response, error)

Do makes request with HTTP Client

func (*BasicClient) HTTPClient

func (bc *BasicClient) HTTPClient() *http.Client

HTTPClient returns the *http.Client to use to make the REST calls

func (*BasicClient) SetBase

func (bc *BasicClient) SetBase(base string)

SetBase is to only be used for testing purposes. It is exported for subpackage test access.

func (*BasicClient) Userinfo

func (bc *BasicClient) Userinfo() *url.Userinfo

Userinfo returns the credentials for the RESTClient

type Client

type Client struct {
	*BasicClient
}

Client is used for connecting to the MarkLogic REST API.

func NewClient

func NewClient(connection *Connection) (*Client, error)

NewClient creates the Client struct used for searching, etc.

type Connection

type Connection struct {
	Host               string
	Port               int64
	Username           string
	Password           string
	AuthenticationType int
	Database           string
}

Connection contains the information needed for a proper MarkLogic connection

type ManagementClient

type ManagementClient struct {
	*BasicClient
}

ManagementClient is used for connecting to the MarkLogic Management API.

func NewManagementClient

func NewManagementClient(connection *Connection) (*ManagementClient, error)

NewManagementClient creates the Client struct used for managing databases, etc.

type RESTClient

type RESTClient interface {
	Base() string
	Userinfo() *url.Userinfo
	AuthType() int
	HTTPClient() *http.Client
	Do(*http.Request) (*http.Response, error)
	DigestHeaders() *digestAuth.DigestHeaders
}

RESTClient is an inteface the different REST Clients (Client and ManagementClient)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL