Documentation
¶
Index ¶
Constants ¶
const ( TypeProfile = "profile" TypeSettings = "settings" TypeSingleSetting = "single-setting" )
Export Types.
const (
ExportTargetGlobal = "global"
)
Export IDs.
Variables ¶
var ( MsgNone = "" MsgValid = "Import is valid." MsgSuccess = "Import successful." MsgRequireRestart = "Import successful. Restart required for setting to take effect." )
Messages.
var ( ErrMismatch = api.ErrorWithStatus( errors.New("the supplied export cannot be imported here"), http.StatusPreconditionFailed, ) ErrSettingNotFound = api.ErrorWithStatus( errors.New("setting not found"), http.StatusPreconditionFailed, ) ErrTargetNotFound = api.ErrorWithStatus( errors.New("import/export target does not exist"), http.StatusGone, ) ErrUnchanged = api.ErrorWithStatus( errors.New("cannot export unchanged setting"), http.StatusGone, ) ErrNotSettablePerApp = api.ErrorWithStatus( errors.New("cannot be set per app"), http.StatusGone, ) ErrInvalidImportRequest = api.ErrorWithStatus( errors.New("invalid import request"), http.StatusUnprocessableEntity, ) ErrInvalidSettingValue = api.ErrorWithStatus( errors.New("invalid setting value"), http.StatusUnprocessableEntity, ) ErrInvalidProfileData = api.ErrorWithStatus( errors.New("invalid profile data"), http.StatusUnprocessableEntity, ) ErrImportFailed = api.ErrorWithStatus( errors.New("import failed"), http.StatusInternalServerError, ) ErrExportFailed = api.ErrorWithStatus( errors.New("export failed"), http.StatusInternalServerError, ) )
Errors.
Functions ¶
This section is empty.
Types ¶
type ExportRequest ¶
ExportRequest is a request for an export.
type ImportRequest ¶
type ImportRequest struct {
// Where the export should be import to.
Target string `json:"target"`
// Only validate, but do not actually change anything.
ValidateOnly bool `json:"validateOnly"`
RawExport string `json:"rawExport"`
RawMime string `json:"rawMime"`
}
ImportRequest is a request to import an export.
type ImportResult ¶
type ImportResult struct {
RestartRequired bool `json:"restartRequired"`
ReplacesExisting bool `json:"replacesExisting"`
ContainsUnknown bool `json:"containsUnknown"`
}
ImportResult is returned by successful import operations.
func ImportSettings ¶
func ImportSettings(r *SettingsImportRequest) (*ImportResult, error)
ImportSettings imports the global settings.
func ImportSingeSetting ¶
func ImportSingeSetting(r *SingleSettingImportRequest) (*ImportResult, error)
ImportSingeSetting imports a single setting.
type ProfileExport ¶
type ProfileExport struct {
Type Type
// Identification (sync or import as new only)
ID string
Source string
// Human Metadata
Name string
Description string
Homepage string
Icons []profile.Icon
PresentationPath string
UsePresentationPath bool
// Process matching
Fingerprints []profile.Fingerprint
// Settings
Config map[string]any
// Metadata (sync only)
LastEdited time.Time
Created time.Time
Internal bool
}
ProfileExport holds an export of a profile.
type ProfileImportRequest ¶
type ProfileImportRequest struct {
ImportRequest
// Reset all settings and fingerprints of target before import.
Reset bool
Export *ProfileExport
}
ProfileImportRequest is a request to import Profile.
type SettingsExport ¶
SettingsExport holds an export of settings.
func ExportSettings ¶
func ExportSettings(from string, keys []string) (*SettingsExport, error)
ExportSettings exports the global settings.
type SettingsImportRequest ¶
type SettingsImportRequest struct {
ImportRequest `json:",inline"`
// Reset all settings of target before import.
// The ImportResult also reacts to this flag and correctly reports whether
// any settings would be replaced or deleted.
Reset bool `json:"reset"`
// AllowUnknown allows the import of unknown settings.
// Otherwise, attempting to import an unknown setting will result in an error.
AllowUnknown bool `json:"allowUnknown"`
Export *SettingsExport `json:"export"`
}
SettingsImportRequest is a request to import settings.
type SingleSettingExport ¶
type SingleSettingExport struct {
Type Type `json:"type"` // Must be TypeSingleSetting
ID string `json:"id"` // Settings Key
Value any `json:"value"`
}
SingleSettingExport holds an export of a single setting.
func ExportSingleSetting ¶
func ExportSingleSetting(key, from string) (*SingleSettingExport, error)
ExportSingleSetting export a single setting.
type SingleSettingImportRequest ¶
type SingleSettingImportRequest struct {
ImportRequest `json:",inline"`
Export *SingleSettingExport `json:"export"`
}
SingleSettingImportRequest is a request to import a single setting.