Documentation
¶
Overview ¶
Package serverapi contains GO types corresponding to Kopia server API.
Index ¶
- Constants
- type APIErrorCode
- type Client
- func (c *Client) CancelUpload(ctx context.Context, match *snapshot.SourceInfo) (*MultipleSourceActionResponse, error)
- func (c *Client) ConnectToRepository(ctx context.Context, req *ConnectRepositoryRequest) error
- func (c *Client) CreateRepository(ctx context.Context, req *CreateRepositoryRequest) error
- func (c *Client) CreateSnapshotSource(ctx context.Context, req *CreateSnapshotSourceRequest) (*CreateSnapshotSourceResponse, error)
- func (c *Client) DisconnectFromRepository(ctx context.Context) error
- func (c *Client) Get(ctx context.Context, path string, respPayload interface{}) error
- func (c *Client) GetObject(ctx context.Context, objectID string) ([]byte, error)
- func (c *Client) ListPolicies(ctx context.Context, match *snapshot.SourceInfo) (*PoliciesResponse, error)
- func (c *Client) ListSnapshots(ctx context.Context, match *snapshot.SourceInfo) (*SnapshotsResponse, error)
- func (c *Client) ListSources(ctx context.Context, match *snapshot.SourceInfo) (*SourcesResponse, error)
- func (c *Client) Post(ctx context.Context, path string, reqPayload, respPayload interface{}) error
- func (c *Client) Shutdown(ctx context.Context)
- func (c *Client) Status(ctx context.Context) (*StatusResponse, error)
- func (c *Client) UploadSnapshots(ctx context.Context, match *snapshot.SourceInfo) (*MultipleSourceActionResponse, error)
- type ClientOptions
- type ConnectRepositoryRequest
- type CreateRepositoryRequest
- type CreateSnapshotSourceRequest
- type CreateSnapshotSourceResponse
- type Empty
- type ErrorResponse
- type MultipleSourceActionResponse
- type PoliciesResponse
- type PolicyListEntry
- type Snapshot
- type SnapshotsResponse
- type SourceActionResponse
- type SourceStatus
- type SourcesResponse
- type StatusResponse
- type SupportedAlgorithmsResponse
Constants ¶
const DefaultUsername = "kopia"
DefaultUsername is the default username for Kopia server.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIErrorCode ¶ added in v0.5.2
type APIErrorCode string
APIErrorCode indicates machine-readable error code returned in API responses.
const ( ErrorInternal APIErrorCode = "INTERNAL" ErrorAlreadyConnected APIErrorCode = "ALREADY_CONNECTED" ErrorAlreadyInitialized APIErrorCode = "ALREADY_INITIALIZED" ErrorInvalidPassword APIErrorCode = "INVALID_PASSWORD" ErrorInvalidToken APIErrorCode = "INVALID_TOKEN" ErrorMalformedRequest APIErrorCode = "MALFORMED_REQUEST" ErrorNotConnected APIErrorCode = "NOT_CONNECTED" ErrorNotFound APIErrorCode = "NOT_FOUND" ErrorNotInitialized APIErrorCode = "NOT_INITIALIZED" ErrorPathNotFound APIErrorCode = "PATH_NOT_FOUND" ErrorStorageConnection APIErrorCode = "STORAGE_CONNECTION" )
Supported error codes.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides helper methods for communicating with Kopia API serevr.
func NewClient ¶
func NewClient(options ClientOptions) (*Client, error)
NewClient creates a options.HTTPClient for connecting to Kopia HTTP API. nolint:gocritic
func (*Client) CancelUpload ¶ added in v0.5.2
func (c *Client) CancelUpload(ctx context.Context, match *snapshot.SourceInfo) (*MultipleSourceActionResponse, error)
CancelUpload cancels snapshot upload on matching snapshots.
func (*Client) ConnectToRepository ¶ added in v0.5.2
func (c *Client) ConnectToRepository(ctx context.Context, req *ConnectRepositoryRequest) error
ConnectToRepository invokes the 'repo/connect' API.
func (*Client) CreateRepository ¶ added in v0.5.2
func (c *Client) CreateRepository(ctx context.Context, req *CreateRepositoryRequest) error
CreateRepository invokes the 'repo/create' API.
func (*Client) CreateSnapshotSource ¶ added in v0.5.2
func (c *Client) CreateSnapshotSource(ctx context.Context, req *CreateSnapshotSourceRequest) (*CreateSnapshotSourceResponse, error)
CreateSnapshotSource creates snapshot source with a given path.
func (*Client) DisconnectFromRepository ¶ added in v0.5.2
DisconnectFromRepository invokes the 'repo/disconnect' API.
func (*Client) Get ¶
Get sends HTTP GET request and decodes the JSON response into the provided payload structure.
func (*Client) ListPolicies ¶ added in v0.5.2
func (c *Client) ListPolicies(ctx context.Context, match *snapshot.SourceInfo) (*PoliciesResponse, error)
ListPolicies lists the policies managed by the server for a given target filter.
func (*Client) ListSnapshots ¶ added in v0.5.2
func (c *Client) ListSnapshots(ctx context.Context, match *snapshot.SourceInfo) (*SnapshotsResponse, error)
ListSnapshots lists the snapshots managed by the server for a given source filter.
func (*Client) ListSources ¶ added in v0.5.2
func (c *Client) ListSources(ctx context.Context, match *snapshot.SourceInfo) (*SourcesResponse, error)
ListSources lists the snapshot sources managed by the server.
func (*Client) Post ¶
Post sends HTTP post request with given JSON payload structure and decodes the JSON response into another payload structure.
func (*Client) Status ¶ added in v0.5.2
func (c *Client) Status(ctx context.Context) (*StatusResponse, error)
Status invokes the 'repo/status' API.
func (*Client) UploadSnapshots ¶ added in v0.5.2
func (c *Client) UploadSnapshots(ctx context.Context, match *snapshot.SourceInfo) (*MultipleSourceActionResponse, error)
UploadSnapshots triggers snapshot upload on matching snapshots.
type ClientOptions ¶ added in v0.5.2
type ClientOptions struct {
BaseURL string
HTTPClient *http.Client
Username string
Password string
TrustedServerCertificateFingerprint string
RootCAs *x509.CertPool
LogRequests bool
}
ClientOptions encapsulates all optional API options.HTTPClient options.
type ConnectRepositoryRequest ¶ added in v0.5.2
type ConnectRepositoryRequest struct {
Storage blob.ConnectionInfo `json:"storage"`
Password string `json:"password"`
Token string `json:"token"` // when set, overrides Storage and Password
}
ConnectRepositoryRequest contains request to connect to a repository.
type CreateRepositoryRequest ¶ added in v0.5.2
type CreateRepositoryRequest struct {
ConnectRepositoryRequest
NewRepositoryOptions repo.NewRepositoryOptions `json:"options"`
}
CreateRepositoryRequest contains request to create a repository in a given storage
type CreateSnapshotSourceRequest ¶ added in v0.5.2
type CreateSnapshotSourceRequest struct {
Path string `json:"path"`
CreateSnapshot bool `json:"createSnapshot"`
InitialPolicy policy.Policy `json:"initialPolicy"` // policy to set on the source when first created, ignored if already exists
}
CreateSnapshotSourceRequest contains request to create snapshot source and optionally create first snapshot.
type CreateSnapshotSourceResponse ¶ added in v0.5.2
type CreateSnapshotSourceResponse struct {
Created bool `json:"created"` // whether the source was created (false==previously existed)
SnapshotStarted bool `json:"snapshotted"` // whether snapshotting has been started
}
CreateSnapshotSourceResponse contains response of creating snapshot source.
type ErrorResponse ¶ added in v0.5.2
type ErrorResponse struct {
Code APIErrorCode `json:"code"`
Error string `json:"error"`
}
ErrorResponse represents error response.
type MultipleSourceActionResponse ¶
type MultipleSourceActionResponse struct {
Sources map[string]SourceActionResponse `json:"sources"`
}
MultipleSourceActionResponse contains per-source responses for all sources targeted by API command.
type PoliciesResponse ¶
type PoliciesResponse struct {
Policies []*PolicyListEntry `json:"policies"`
}
PoliciesResponse is the response of 'policies' HTTP API command.
type PolicyListEntry ¶
type PolicyListEntry struct {
ID string `json:"id"`
Target snapshot.SourceInfo `json:"target"`
Policy *policy.Policy `json:"policy"`
}
PolicyListEntry describes single policy.
type Snapshot ¶ added in v0.5.2
type Snapshot struct {
ID manifest.ID `json:"id"`
Source snapshot.SourceInfo `json:"source"`
Description string `json:"description"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
IncompleteReason string `json:"incomplete,omitempty"`
Summary *fs.DirectorySummary `json:"summary"`
RootEntry string `json:"rootID"`
RetentionReasons []string `json:"retention"`
}
Snapshot describes single snapshot entry.
type SnapshotsResponse ¶ added in v0.5.2
type SnapshotsResponse struct {
Snapshots []*Snapshot `json:"snapshots"`
}
SnapshotsResponse contains a list of snapshots.
type SourceActionResponse ¶
type SourceActionResponse struct {
Success bool `json:"success"`
}
SourceActionResponse is a per-source response.
type SourceStatus ¶
type SourceStatus struct {
Source snapshot.SourceInfo `json:"source"`
Status string `json:"status"`
SchedulingPolicy policy.SchedulingPolicy `json:"schedule"`
LastSnapshotSize *int64 `json:"lastSnapshotSize,omitempty"`
LastSnapshotTime *time.Time `json:"lastSnapshotTime,omitempty"`
NextSnapshotTime *time.Time `json:"nextSnapshotTime,omitempty"`
UploadCounters *snapshotfs.UploadCounters `json:"upload,omitempty"`
}
SourceStatus describes the status of a single source.
type SourcesResponse ¶
type SourcesResponse struct {
LocalUsername string `json:"localUsername"`
LocalHost string `json:"localHost"`
Sources []*SourceStatus `json:"sources"`
}
SourcesResponse is the response of 'sources' HTTP API command.
type StatusResponse ¶
type StatusResponse struct {
Connected bool `json:"connected"`
ConfigFile string `json:"configFile,omitempty"`
CacheDir string `json:"cacheDir,omitempty"`
Hash string `json:"hash,omitempty"`
Encryption string `json:"encryption,omitempty"`
Splitter string `json:"splitter,omitempty"`
MaxPackSize int `json:"maxPackSize,omitempty"`
Storage string `json:"storage,omitempty"`
}
StatusResponse is the response of 'status' HTTP API command.
type SupportedAlgorithmsResponse ¶ added in v0.5.2
type SupportedAlgorithmsResponse struct {
DefaultHashAlgorithm string `json:"defaultHash"`
DefaultEncryptionAlgorithm string `json:"defaultEncryption"`
DefaultSplitterAlgorithm string `json:"defaultSplitter"`
HashAlgorithms []string `json:"hash"`
EncryptionAlgorithms []string `json:"encryption"`
SplitterAlgorithms []string `json:"splitter"`
CompressionAlgorithms []string `json:"compression"`
}
SupportedAlgorithmsResponse returns the list of supported algorithms for repository creation.