Documentation
¶
Index ¶
- Constants
- Variables
- type AdminClient
- func (ac *AdminClient) ActivateMaintenance(slug string, opts map[string]interface{}) error
- func (ac *AdminClient) CleanSessions(domain string) error
- func (ac *AdminClient) CountInstances() (int, error)
- func (ac *AdminClient) CreateInstance(opts *InstanceOptions) (*Instance, error)
- func (ac *AdminClient) DeactivateMaintenance(slug string) error
- func (ac *AdminClient) DestroyInstance(domain string) error
- func (ac *AdminClient) DisableDebug(domain string) error
- func (ac *AdminClient) DiskUsage(domain string, includeTrash bool) (map[string]interface{}, error)
- func (ac *AdminClient) EnableDebug(domain string, ttl time.Duration) error
- func (ac *AdminClient) Export(opts *ExportOptions) error
- func (ac *AdminClient) GetDebug(domain string) (bool, error)
- func (ac *AdminClient) GetInstance(domain string) (*Instance, error)
- func (ac *AdminClient) GetToken(opts *TokenOptions) (string, error)
- func (ac *AdminClient) Import(domain string, opts *ImportOptions) error
- func (ac *AdminClient) ListInstances() ([]*Instance, error)
- func (ac *AdminClient) ListMaintenances(context string) ([]interface{}, error)
- func (ac *AdminClient) ModifyInstance(opts *InstanceOptions) (*Instance, error)
- func (ac *AdminClient) NewInstanceClient(domain string, scopes ...string) (*Client, error)
- func (ac *AdminClient) ProfileHeap() (io.ReadCloser, error)
- func (ac *AdminClient) RebuildRedis() error
- func (ac *AdminClient) RegisterOAuthClient(opts *OAuthClientOptions) (map[string]interface{}, error)
- type AppManifest
- type AppOptions
- type Client
- func (c *Client) Authenticate() (request.Authorizer, error)
- func (c *Client) DownloadByID(id string) (io.ReadCloser, error)
- func (c *Client) DownloadByPath(name string) (io.ReadCloser, error)
- func (c *Client) GetApp(opts *AppOptions) (*AppManifest, error)
- func (c *Client) GetDirByID(id string) (*Dir, error)
- func (c *Client) GetDirByPath(name string) (*Dir, error)
- func (c *Client) GetDirOrFileByPath(name string) (*DirOrFile, error)
- func (c *Client) GetFileByID(id string) (*File, error)
- func (c *Client) GetFileByPath(name string) (*File, error)
- func (c *Client) GetTrigger(triggerID string) (*Trigger, error)
- func (c *Client) GetTriggers(worker string) ([]*Trigger, error)
- func (c *Client) InstallApp(opts *AppOptions) (*AppManifest, error)
- func (c *Client) JobPush(r *JobOptions) (*Job, error)
- func (c *Client) ListApps(appType string) ([]*AppManifest, error)
- func (c *Client) ListChildrenByDirID(id string) ([]*DirOrFile, error)
- func (c *Client) ListTriggers() ([]*Trigger, error)
- func (c *Client) Mkdir(name string) (*Dir, error)
- func (c *Client) Mkdirall(name string) (*Dir, error)
- func (c *Client) Move(from, to string) error
- func (c *Client) PermanentDeleteByID(id string) error
- func (c *Client) PermanentDeleteByPath(name string) error
- func (c *Client) RealtimeClient(opts RealtimeOptions) (*RealtimeChannel, error)
- func (c *Client) Req(opts *request.Options) (*http.Response, error)
- func (c *Client) RestoreByID(id string) error
- func (c *Client) RestoreByPath(name string) error
- func (c *Client) TrashByID(id string) error
- func (c *Client) TrashByPath(name string) error
- func (c *Client) TriggerLaunch(triggerID string) (*Job, error)
- func (c *Client) UninstallApp(opts *AppOptions) (*AppManifest, error)
- func (c *Client) UpdateApp(opts *AppOptions, safe bool) (*AppManifest, error)
- func (c *Client) UpdateAttrsByID(id string, patch *FilePatch) (*DirOrFile, error)
- func (c *Client) UpdateAttrsByPath(name string, patch *FilePatch) (*DirOrFile, error)
- func (c *Client) Upload(u *Upload) (*File, error)
- func (c *Client) WalkByPath(root string, walkFn WalkFn) error
- type Dir
- type DirOrFile
- type ExportOptions
- type File
- type FilePatch
- type FilePatchAttrs
- type ImportOptions
- type Instance
- type InstanceOptions
- type Job
- type JobLog
- type JobOptions
- type OAuthClientOptions
- type RealtimeChannel
- type RealtimeClientMessage
- type RealtimeOptions
- type RealtimeServerMessage
- type RealtimeServerPayload
- type TokenOptions
- type Trigger
- type Upload
- type WalkFn
Constants ¶
const ( // DirType is the directory type name DirType = "directory" // FileType is the file type name FileType = "file" )
Variables ¶
var ErrWrongPassphrase = errors.New("Unauthorized: wrong passphrase")
ErrWrongPassphrase is used when the passphrase is wrong
var ListChildrenPageSize = "100"
ListChildrenPageSize controls the number of items fetched per request when listing directory children. Tests can override this to force pagination.
Functions ¶
This section is empty.
Types ¶
type AdminClient ¶
type AdminClient struct {
Client
}
func (*AdminClient) ActivateMaintenance ¶
func (ac *AdminClient) ActivateMaintenance(slug string, opts map[string]interface{}) error
ActivateMaintenance is used to activate the maintenance for a konnector
func (*AdminClient) CleanSessions ¶
func (ac *AdminClient) CleanSessions(domain string) error
CleanSessions delete the databases for io.cozy.sessions and io.cozy.sessions.logins
func (*AdminClient) CountInstances ¶
func (ac *AdminClient) CountInstances() (int, error)
CountInstances returns the number of instances.
func (*AdminClient) CreateInstance ¶
func (ac *AdminClient) CreateInstance(opts *InstanceOptions) (*Instance, error)
CreateInstance is used to create a new cozy instance of the specified domain and locale.
func (*AdminClient) DeactivateMaintenance ¶
func (ac *AdminClient) DeactivateMaintenance(slug string) error
DeactivateMaintenance is used to deactivate the maintenance for a konnector
func (*AdminClient) DestroyInstance ¶
func (ac *AdminClient) DestroyInstance(domain string) error
DestroyInstance is used to delete an instance and all its data.
func (*AdminClient) DisableDebug ¶
func (ac *AdminClient) DisableDebug(domain string) error
DisableDebug disables the debug mode for the logger of an instance.
func (*AdminClient) DiskUsage ¶
func (ac *AdminClient) DiskUsage(domain string, includeTrash bool) (map[string]interface{}, error)
DiskUsage returns the information about disk usage and quota
func (*AdminClient) EnableDebug ¶
func (ac *AdminClient) EnableDebug(domain string, ttl time.Duration) error
EnableDebug sets the logger of an instance in debug mode.
func (*AdminClient) Export ¶
func (ac *AdminClient) Export(opts *ExportOptions) error
Export launch the creation of a tarball to export data from an instance.
func (*AdminClient) GetDebug ¶
func (ac *AdminClient) GetDebug(domain string) (bool, error)
GetDebug is used to known if an instance has its logger in debug mode.
func (*AdminClient) GetInstance ¶
func (ac *AdminClient) GetInstance(domain string) (*Instance, error)
GetInstance returns the instance associated with the specified domain.
func (*AdminClient) GetToken ¶
func (ac *AdminClient) GetToken(opts *TokenOptions) (string, error)
GetToken is used to generate a token with the specified options.
func (*AdminClient) Import ¶
func (ac *AdminClient) Import(domain string, opts *ImportOptions) error
Import launch the import of a tarball with data to put in an instance.
func (*AdminClient) ListInstances ¶
func (ac *AdminClient) ListInstances() ([]*Instance, error)
ListInstances returns the list of instances recorded on the stack.
func (*AdminClient) ListMaintenances ¶
func (ac *AdminClient) ListMaintenances(context string) ([]interface{}, error)
ListMaintenances returns a list of konnectors in maintenance
func (*AdminClient) ModifyInstance ¶
func (ac *AdminClient) ModifyInstance(opts *InstanceOptions) (*Instance, error)
ModifyInstance is used to update an instance.
func (*AdminClient) NewInstanceClient ¶
func (ac *AdminClient) NewInstanceClient(domain string, scopes ...string) (*Client, error)
func (*AdminClient) ProfileHeap ¶
func (ac *AdminClient) ProfileHeap() (io.ReadCloser, error)
ProfileHeap returns a sampling of memory allocations as pprof format.
func (*AdminClient) RebuildRedis ¶
func (ac *AdminClient) RebuildRedis() error
RebuildRedis puts the triggers in redis.
func (*AdminClient) RegisterOAuthClient ¶
func (ac *AdminClient) RegisterOAuthClient(opts *OAuthClientOptions) (map[string]interface{}, error)
RegisterOAuthClient register a new OAuth client associated to the specified instance.
type AppManifest ¶
type AppManifest struct {
ID string `json:"id"`
Rev string `json:"rev"`
Attrs struct {
Name string `json:"name"`
NamePrefix string `json:"name_prefix,omitempty"`
Editor string `json:"editor"`
Icon string `json:"icon"`
Type string `json:"type,omitempty"`
License string `json:"license,omitempty"`
Language string `json:"language,omitempty"`
Category string `json:"category,omitempty"`
VendorLink interface{} `json:"vendor_link"` // can be a string or []string
Locales *json.RawMessage `json:"locales,omitempty"`
Langs *json.RawMessage `json:"langs,omitempty"`
Platforms *json.RawMessage `json:"platforms,omitempty"`
Categories *json.RawMessage `json:"categories,omitempty"`
Developer *json.RawMessage `json:"developer,omitempty"`
Screenshots *json.RawMessage `json:"screenshots,omitempty"`
Tags *json.RawMessage `json:"tags,omitempty"`
Frequency string `json:"frequency,omitempty"`
DataTypes *json.RawMessage `json:"data_types,omitempty"`
Doctypes *json.RawMessage `json:"doctypes,omitempty"`
Fields *json.RawMessage `json:"fields,omitempty"`
Folders *json.RawMessage `json:"folders,omitempty"`
Messages *json.RawMessage `json:"messages,omitempty"`
OAuth *json.RawMessage `json:"oauth,omitempty"`
TimeInterval *json.RawMessage `json:"time_interval,omitempty"`
ClientSide bool `json:"clientSide,omitempty"`
Slug string `json:"slug"`
State string `json:"state"`
Source string `json:"source"`
Version string `json:"version"`
Permissions *map[string]struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Verbs []string `json:"verbs,omitempty"`
Selector string `json:"selector,omitempty"`
Values []string `json:"values,omitempty"`
} `json:"permissions"`
AvailableVersion string `json:"available_version,omitempty"`
Parameters json.RawMessage `json:"parameters,omitempty"`
Intents []struct {
Action string `json:"action"`
Types []string `json:"type"`
Href string `json:"href"`
} `json:"intents"`
Routes *map[string]struct {
Folder string `json:"folder"`
Index string `json:"index"`
Public bool `json:"public"`
} `json:"routes,omitempty"`
Services *map[string]struct {
Type string `json:"type"`
File string `json:"file"`
Debounce string `json:"debounce"`
TriggerOptions string `json:"trigger"`
TriggerID string `json:"trigger_id"`
} `json:"services"`
Notifications map[string]struct {
Description string `json:"description,omitempty"`
Collapsible bool `json:"collapsible,omitempty"`
Multiple bool `json:"multiple,omitempty"`
Stateful bool `json:"stateful,omitempty"`
DefaultPriority string `json:"default_priority,omitempty"`
TimeToLive time.Duration `json:"time_to_live,omitempty"`
Templates map[string]string `json:"templates,omitempty"`
MinInterval time.Duration `json:"min_interval,omitempty"`
} `json:"notifications,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Error string `json:"error,omitempty"`
} `json:"attributes,omitempty"`
}
AppManifest holds the JSON-API representation of an application.
type AppOptions ¶
type AppOptions struct {
AppType string
Slug string
SourceURL string
Deactivated bool
OverridenParameters *json.RawMessage
}
AppOptions holds the options to install an application.
type Client ¶
type Client struct {
Addr string
Domain string
Scheme string
Client *http.Client
AuthClient *auth.Client
AuthScopes []string
AuthAccept auth.UserAcceptFunc
AuthStorage auth.Storage
Authorizer request.Authorizer
UserAgent string
Retries int
Transport http.RoundTripper
// contains filtered or unexported fields
}
Client encapsulates the element representing a typical connection to the HTTP api of the cozy-stack.
It holds the elements to authenticate a user, as well as the transport layer used for all the calls to the stack.
func (*Client) Authenticate ¶
func (c *Client) Authenticate() (request.Authorizer, error)
Authenticate is used to authenticate a client via OAuth.
func (*Client) DownloadByID ¶
func (c *Client) DownloadByID(id string) (io.ReadCloser, error)
DownloadByID is used to download a file's content given its ID. It returns a io.ReadCloser that you can read from.
func (*Client) DownloadByPath ¶
func (c *Client) DownloadByPath(name string) (io.ReadCloser, error)
DownloadByPath is used to download a file's content given its path. It returns a io.ReadCloser that you can read from.
func (*Client) GetApp ¶
func (c *Client) GetApp(opts *AppOptions) (*AppManifest, error)
GetApp is used to fetch an application manifest with specified slug
func (*Client) GetDirByID ¶
GetDirByID returns a Dir given the specified ID
func (*Client) GetDirByPath ¶
GetDirByPath returns a Dir given the specified path
func (*Client) GetDirOrFileByPath ¶
GetDirOrFileByPath returns a DirOrFile given the specified path
func (*Client) GetFileByID ¶
GetFileByID returns a File given the specified ID
func (*Client) GetFileByPath ¶
GetFileByPath returns a File given the specified path
func (*Client) GetTrigger ¶
GetTrigger return the trigger with the specified ID.
func (*Client) GetTriggers ¶
GetTriggers returns the list of all triggers with the specified worker type.
func (*Client) InstallApp ¶
func (c *Client) InstallApp(opts *AppOptions) (*AppManifest, error)
InstallApp is used to install an application.
func (*Client) JobPush ¶
func (c *Client) JobPush(r *JobOptions) (*Job, error)
JobPush is used to push a new job into the job queue.
func (*Client) ListApps ¶
func (c *Client) ListApps(appType string) ([]*AppManifest, error)
ListApps is used to get the list of all installed applications.
func (*Client) ListChildrenByDirID ¶
ListChildrenByDirID returns all direct child items (files and directories) of the directory identified by its ID. It transparently follows pagination and returns the complete list.
func (*Client) ListTriggers ¶
ListTriggers returns the list of all triggers for an instance.
func (*Client) Mkdir ¶
Mkdir creates a directory with the specified path. If the directory's parent does not exist, an error is returned.
func (*Client) Mkdirall ¶
Mkdirall creates a directory with the specified path. If the directory's parent does not exist, all intermediary parents are created.
func (*Client) Move ¶
Move is used to move a file or directory from a given path to the other given path
func (*Client) PermanentDeleteByID ¶
PermanentDeleteByID is used to delete a file or directory specified by its ID, not just putting it in the trash
func (*Client) PermanentDeleteByPath ¶
PermanentDeleteByPath is used to delete a file or directory specified by its path, not just putting it in the trash
func (*Client) RealtimeClient ¶
func (c *Client) RealtimeClient(opts RealtimeOptions) (*RealtimeChannel, error)
RealtimeClient returns a new RealtimeChannel that instantiate a realtime connection with the client server.
func (*Client) RestoreByID ¶
RestoreByID is used to restore a file or directory from the trash given its ID
func (*Client) RestoreByPath ¶
RestoreByPath is used to restore a file or directory from the trash given its path
func (*Client) TrashByID ¶
TrashByID is used to move a file or directory specified by its ID to the trash
func (*Client) TrashByPath ¶
TrashByPath is used to move a file or directory specified by its path to the trash
func (*Client) TriggerLaunch ¶
TriggerLaunch launches manually the trigger with the specified ID.
func (*Client) UninstallApp ¶
func (c *Client) UninstallApp(opts *AppOptions) (*AppManifest, error)
UninstallApp is used to uninstall an application.
func (*Client) UpdateApp ¶
func (c *Client) UpdateApp(opts *AppOptions, safe bool) (*AppManifest, error)
UpdateApp is used to update an application.
func (*Client) UpdateAttrsByID ¶
UpdateAttrsByID is used to update the attributes of a file or directory of the specified ID
func (*Client) UpdateAttrsByPath ¶
UpdateAttrsByPath is used to update the attributes of a file or directory of the specified path
type Dir ¶
type Dir struct {
ID string `json:"id"`
Rev string `json:"rev"`
Attrs struct {
Type string `json:"type"`
Name string `json:"name"`
DirID string `json:"dir_id"`
Fullpath string `json:"path"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Tags []string `json:"tags"`
Metadata map[string]interface{} `json:"metadata"`
} `json:"attributes"`
}
Dir is the JSON-API directory structure
type DirOrFile ¶
type DirOrFile File
DirOrFile is the JSON-API file structure used to encapsulate a file or directory
type ExportOptions ¶
type File ¶
type File struct {
ID string `json:"id"`
Rev string `json:"rev"`
Attrs struct {
Type string `json:"type"`
Name string `json:"name"`
DirID string `json:"dir_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Size int64 `json:"size,string"`
MD5Sum []byte `json:"md5sum"`
Mime string `json:"mime"`
Class string `json:"class"`
Executable bool `json:"executable"`
Encrypted bool `json:"encrypted"`
Tags []string `json:"tags"`
Metadata map[string]interface{} `json:"metadata"`
} `json:"attributes"`
}
File is the JSON-API file structure
type FilePatch ¶
type FilePatch struct {
Rev string `json:"-"`
Attrs FilePatchAttrs `json:"attributes"`
}
FilePatch is the structure used to modify file or directory metadata
type FilePatchAttrs ¶
type FilePatchAttrs struct {
Name string `json:"name,omitempty"`
DirID string `json:"dir_id,omitempty"`
Tags []string `json:"tags,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Executable bool `json:"executable,omitempty"`
Class string `json:"class,omitempty"`
}
FilePatchAttrs is the attributes in the JSON-API structure for modifying the metadata of a file or directory
type ImportOptions ¶
type ImportOptions struct {
ManifestURL string
}
ImportOptions is a struct with the options for importing a tarball.
type Instance ¶
type Instance struct {
ID string `json:"id"`
Meta struct {
Rev string `json:"rev"`
} `json:"meta"`
Attrs struct {
Domain string `json:"domain"`
DomainAliases []string `json:"domain_aliases,omitempty"`
OldDomain string `json:"old_domain,omitempty"`
Prefix string `json:"prefix,omitempty"`
Locale string `json:"locale"`
UUID string `json:"uuid,omitempty"`
OIDCID string `json:"oidc_id,omitempty"`
ContextName string `json:"context,omitempty"`
Sponsorships []string `json:"sponsorships,omitempty"`
FeatureSets []string `json:"feature_sets,omitempty"`
TOSSigned string `json:"tos,omitempty"`
TOSLatest string `json:"tos_latest,omitempty"`
AuthMode int `json:"auth_mode,omitempty"`
NoAutoUpdate bool `json:"no_auto_update,omitempty"`
Blocked bool `json:"blocked,omitempty"`
OnboardingFinished bool `json:"onboarding_finished"`
PasswordDefined *bool `json:"password_defined"`
MagicLink bool `json:"magic_link,omitempty"`
BytesDiskQuota int64 `json:"disk_quota,string,omitempty"`
IndexViewsVersion int `json:"indexes_version"`
CouchCluster int `json:"couch_cluster,omitempty"`
SwiftLayout int `json:"swift_cluster,omitempty"`
PassphraseResetToken []byte `json:"passphrase_reset_token"`
PassphraseResetTime time.Time `json:"passphrase_reset_time"`
RegisterToken []byte `json:"register_token,omitempty"`
} `json:"attributes"`
}
Instance is a struct holding the representation of an instance on the API.
type InstanceOptions ¶
type InstanceOptions struct {
Domain string
DomainAliases []string
OldDomain string
Locale string
UUID string
OIDCID string
FranceConnectID string
TOSSigned string
TOSLatest string
Timezone string
ContextName string
Sponsorships []string
Email string
PublicName string
Phone string
Settings string
BlockingReason string
SwiftLayout int
CouchCluster int
DiskQuota int64
Apps []string
Passphrase string
KdfIterations int
MagicLink *bool
Debug *bool
Blocked *bool
Deleting *bool
OnboardingFinished *bool
Trace *bool
}
InstanceOptions contains the options passed on instance creation.
type Job ¶
type Job struct {
ID string `json:"id"`
Rev string `json:"rev"`
Attrs struct {
Domain string `json:"domain"`
TriggerID string `json:"trigger_id"`
Message json.RawMessage `json:"message"`
Debounced bool `json:"debounced"`
Event struct {
Domain string `json:"domain"`
Verb string `json:"verb"`
Doc json.RawMessage `json:"doc"`
OldDoc json.RawMessage `json:"old,omitempty"`
} `json:"event"`
Options *jobOptions `json:"options"`
QueuedAt time.Time `json:"queued_at"`
StartedAt time.Time `json:"started_at"`
State string `json:"state"`
Worker string `json:"worker"`
} `json:"attributes"`
}
Job is a struct representing a job
type JobLog ¶
type JobLog struct {
Time time.Time `json:"time"`
Message string `json:"message"`
Level string `json:"level"`
Data map[string]interface{} `json:"data"`
}
JobLog is a log being outputted by the running job.
type JobOptions ¶
type JobOptions struct {
Worker string
Arguments interface{}
MaxExecCount int
Timeout *time.Duration
Logs chan *JobLog
}
JobOptions is the options to run a job.
type OAuthClientOptions ¶
type OAuthClientOptions struct {
Domain string
RedirectURI string
ClientName string
SoftwareID string
AllowLoginScope bool
OnboardingSecret string
OnboardingApp string
OnboardingPermissions string
OnboardingState string
}
OAuthClientOptions is a struct holding all the options to generate an OAuth client associated to an instance.
type RealtimeChannel ¶
type RealtimeChannel struct {
// contains filtered or unexported fields
}
RealtimeChannel is used to create a realtime connection with the server. The Channel method can be used to retrieve a channel on which the realtime events can be received.
func (*RealtimeChannel) Channel ¶
func (r *RealtimeChannel) Channel() <-chan *RealtimeServerMessage
Channel returns the channel of realtime server messages received by the client from the server.
func (*RealtimeChannel) Close ¶
func (r *RealtimeChannel) Close() error
Close will close the underlying connection of the realtime channel and close the channel of messages.
type RealtimeClientMessage ¶
type RealtimeClientMessage struct {
Method string `json:"method"`
Payload interface{} `json:"payload"`
}
RealtimeClientMessage is a struct containing the structure of the client messages sent to the server.
type RealtimeOptions ¶
type RealtimeOptions struct {
DocTypes []string
}
RealtimeOptions contains the options to create the realtime subscription channel.
type RealtimeServerMessage ¶
type RealtimeServerMessage struct {
Event string `json:"event"`
Payload RealtimeServerPayload `json:"payload"`
}
RealtimeServerMessage is a struct containing the structure of the server messages received by the client.
type RealtimeServerPayload ¶
type RealtimeServerPayload struct {
// Response payload
Type string `json:"type"`
ID string `json:"id"`
Doc json.RawMessage `json:"doc"`
// Error payload
Status string `json:"status"`
Code string `json:"code"`
Title string `json:"title"`
}
RealtimeServerPayload is the payload content of the RealtimeServerMessage.
type TokenOptions ¶
type TokenOptions struct {
Domain string
Subject string
Audience string
Scope []string
Expire *time.Duration
}
TokenOptions is a struct holding all the options to generate a token.
type Trigger ¶
type Trigger struct {
ID string `json:"id"`
Rev string `json:"rev"`
Attrs struct {
Domain string `json:"domain"`
Type string `json:"type"`
WorkerType string `json:"worker"`
Arguments string `json:"arguments"`
Debounce string `json:"debounce"`
Message json.RawMessage `json:"message"`
Options *struct {
MaxExecCount int `json:"max_exec_count"`
Timeout time.Duration `json:"timeout"`
} `json:"options"`
} `json:"attributes"`
}
Trigger is a struct representing a trigger