Documentation
¶
Index ¶
- Constants
- Variables
- type API
- type CTime
- type CertUploadResult
- type Certificate
- type Client
- func (cl *Client) APIVersion(ctx context.Context, apiName string) (API, error)
- func (cl *Client) DeleteCertByID(ctx context.Context, id string) (*ServerStatus, error)
- func (cl *Client) DownloadStation() *DownloadStation
- func (cl *Client) ListCerts(ctx context.Context) ([]Certificate, error)
- func (cl *Client) Login(ctx context.Context) error
- func (cl *Client) UploadCert(ctx context.Context, draft NewCertificate) (*CertUploadResult, error)
- func (cl *Client) WithClient(client HTTPClient) *Client
- type Config
- type DownloadStation
- type DownloadTask
- type DownloadTasks
- type FileType
- type HTTPClient
- type HTTPClientFunc
- type Issuer
- type NewCertificate
- type RemoteError
- type ScheduledTask
- type ServerStatus
- type Service
- type Subject
Constants ¶
const ( EnvURL = "SYNOLOGY_URL" EnvUser = "SYNOLOGY_USER" EnvPass = "SYNOLOGY_PASSWORD" //nolint:gosec )
const DefaultTimeout = 30 * time.Second
Variables ¶
var ErrBadStatus = errors.New("bad response status")
var ErrInvalidFileType = errors.New("not a valid FileType")
var ErrUnknownFileType = errors.New("unknown file type")
Functions ¶
This section is empty.
Types ¶
type CertUploadResult ¶
type CertUploadResult struct {
CertificateID string `json:"id"`
ServerStatus
}
type Certificate ¶
type Certificate struct {
ID string `json:"id"`
Description string `json:"desc"`
IsBroken bool `json:"is_broken"`
IsDefault bool `json:"is_default"`
Issuer Issuer `json:"issuer"`
KeyTypes string `json:"key_types"`
Renewable bool `json:"renewable"`
Services []Service `json:"services"`
SignatureAlgorithm string `json:"signature_algorithm"`
Subject Subject `json:"subject"`
UserDeletable bool `json:"user_deletable"`
ValidFrom CTime `json:"valid_from"`
ValidTill CTime `json:"valid_till"`
}
func (*Certificate) Expired ¶
func (ct *Certificate) Expired() bool
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) APIVersion ¶
APIVersion returns max version for specific API. It queries Synology for all APIs and caches result.
func (*Client) DeleteCertByID ¶
DeleteCertByID deletes certificate by known ID (not name).
func (*Client) DownloadStation ¶ added in v0.1.3
func (cl *Client) DownloadStation() *DownloadStation
DownloadStation API
func (*Client) Login ¶
Login to Synology and get token. Token will be cached. If token already obtained, API call will not be executed.
func (*Client) UploadCert ¶
func (cl *Client) UploadCert(ctx context.Context, draft NewCertificate) (*CertUploadResult, error)
UploadCert uploads certificate to Synology. Replaces if name (used field description) already exists.
func (*Client) WithClient ¶
func (cl *Client) WithClient(client HTTPClient) *Client
WithClient returns copy of Synology client with custom HTTP client.
type Config ¶
type Config struct {
Client HTTPClient // HTTP client to perform requests, default is new HTTP client. Client MUST support cookies. Keep it nil for most cases is a good idea.
User string // User name
Password string // User password
URL string // Synology url, default is http://localhost:5000
}
type DownloadStation ¶ added in v0.1.3
type DownloadStation struct {
// contains filtered or unexported fields
}
DownloadStation API. Enhanced by some undocumented API from JS.
func (*DownloadStation) Create ¶ added in v0.1.3
func (ds *DownloadStation) Create(ctx context.Context, task DownloadTask) error
Create download task in DownloadStation based on configuration.
func (*DownloadStation) Download ¶ added in v0.1.3
Download remote data from HTTP/FTP/magnet/ED2K links or the file path starting with a shared folder. This is simplified version of Create.
func (*DownloadStation) List ¶ added in v0.1.3
func (ds *DownloadStation) List(ctx context.Context, offset, limit int) (*DownloadTasks, error)
List all download tasks in NAS. Implies 'detail' feature. Limit -1 means all.
type DownloadTask ¶ added in v0.1.3
type DownloadTask struct {
URL []string // HTTP/FTP/magnet/ED2K links or the file path starting with a shared folder.
File io.Reader // Optional. File (ex: torrent) uploading from client
FileType FileType // Optional. Type of File. If not set, it will try automatically detect (which may fail, so better set it).
Username string // Optional. Login username for remote resource (not NAS!)
Password string // Optional. Login password for remote resource (not NAS!)
UnzipPassword string // Optional. Password for unzipping download tasks
Destination string // Optional. Download destination path starting with a shared folder
}
type DownloadTasks ¶ added in v0.1.3
type DownloadTasks struct {
Total int64 `json:"total"`
Offset int64 `json:"offset"`
Tasks []ScheduledTask `json:"tasks"`
}
type FileType ¶ added in v0.2.0
type FileType string
FileType defines content type. Extracted from 'allowfilters' in JS (download.js) ENUM(unknown = "", auto, torrent, nzb, txt)
const ( // FileTypeUnknown is a FileType of type unknown. FileTypeUnknown FileType = "" // FileTypeAuto is a FileType of type auto. FileTypeAuto FileType = "auto" // FileTypeTorrent is a FileType of type torrent. FileTypeTorrent FileType = "torrent" // FileTypeNzb is a FileType of type nzb. FileTypeNzb FileType = "nzb" // FileTypeTxt is a FileType of type txt. FileTypeTxt FileType = "txt" )
func FileTypeValues ¶ added in v0.2.0
func FileTypeValues() []FileType
FileTypeValues returns a list of the values for FileType
func ParseFileType ¶ added in v0.2.0
ParseFileType attempts to convert a string to a FileType.
func (FileType) IsValid ¶ added in v0.2.0
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (*FileType) UnmarshalFlag ¶ added in v0.2.0
UnmarshalFlag is an adapter for go-flags.
type HTTPClientFunc ¶
type NewCertificate ¶
type RemoteError ¶
type RemoteError struct {
Code int64 `json:"code"`
}
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
type ScheduledTask ¶ added in v0.2.0
type ScheduledTask struct {
ID string `json:"id"`
Type string `json:"type"`
Username string `json:"username"`
Title string `json:"title"`
Size int64 `json:"size"`
Status string `json:"status"`
Additional struct {
Detail struct {
CreateTime int64 `json:"create_time"`
Destination string `json:"destination"`
Priority string `json:"priority"`
URI string `json:"uri"`
} `json:"detail"`
} `json:"additional"`
}
type ServerStatus ¶
type ServerStatus struct {
ServerRestarted bool `json:"restart_httpd"`
}
type Service ¶
type Service struct {
DisplayName string `json:"display_name"`
DisplayNameI18N string `json:"display_name_i18n,omitempty"`
IsPkg bool `json:"isPkg"`
Owner string `json:"owner"`
Service string `json:"service"`
Subscriber string `json:"subscriber"`
MultipleCert bool `json:"multiple_cert,omitempty"`
UserSetable bool `json:"user_setable,omitempty"`
}