-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
749 lines (684 loc) · 26.1 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
package connect
import "encoding/json"
// Entity - Available entities, entity prefix due to name collision
type Entity string
const (
EntityUser Entity = "EntityUser" // User Entity
EntityAlias Entity = "EntityAlias" // Alias Entity
EntityGroup Entity = "EntityGroup" // Group Entity
EntityMailingList Entity = "EntityMailingList" // Mailing List Entity
EntityResource Entity = "EntityResource" // Resource Scheduling Entity
EntityTimeRange Entity = "EntityTimeRange" // Time Range Entity
EntityTimeRangeGroup Entity = "EntityTimeRangeGroup" // Time Range Group Entity
EntityIpAddress Entity = "EntityIpAddress" // Ip Address Entity
EntityIpAddressGroup Entity = "EntityIpAddressGroup" // Ip Address Group Entity
EntityService Entity = "EntityService" // Service Entity
EntityDomain Entity = "EntityDomain"
)
// RestrictionTuple - Restriction Items
type RestrictionTuple struct {
Name ItemName `json:"name"`
Kind RestrictionKind `json:"kind"`
Values StringList `json:"values"`
}
// RestrictionTupleList - Restriction tuple for 1 entity
type RestrictionTupleList []RestrictionTuple
// Restriction - Entity name restriction definition
type Restriction struct {
EntityName Entity `json:"entityName"` // IDL entity name, eg. User
Tuples RestrictionTupleList `json:"tuples"` // Restriction tuples
}
// RestrictionList - List of restrictions
type RestrictionList []Restriction
// JavaScriptDate - JavaScript timestamp
type JavaScriptDate string
// SubscriptionInfo - Subscription information
type SubscriptionInfo struct {
IsUnlimited bool `json:"isUnlimited"` // is it a special license with expiration == never ?
ShowAlert bool `json:"showAlert"` // show subscription expiration alert
RemainingDays int `json:"remainingDays"` // days remaining to subscription expiration
SubscriptionDate JavaScriptDate `json:"subscriptionDate"` // last date of subscription
}
// AboutInfo - About information
type AboutInfo struct {
CurrentUsers int `json:"currentUsers"` // number of created users on domain
AllowedUsers MaximumUsers `json:"allowedUsers"` // number of allowed users, take stricter limit from max. number for domain, max. number by license
ServerSoftware string `json:"serverSoftware"` // product name and version string, same as SERVER_SOFTWARE
Subscription SubscriptionInfo `json:"subscription"` // information about subscription
Copyright string `json:"copyright"` // copyright string
ProductHomepage string `json:"productHomepage"` // url to homepage of product
}
type ServerVersion struct {
Product string `json:"product"` // name of product
Version string `json:"version"` // version in string consists of values of major, minor, revision, build a dot separated
Major int `json:"major"` // major version
Minor int `json:"minor"` // minor version
Revision int `json:"revision"` // revision number
Build int `json:"build"` // build number
}
// AlertName - Type of Alert
type AlertName string
const (
LicenseExpired AlertName = "LicenseExpired" // License has expired
LicenseInvalidMinVersion AlertName = "LicenseInvalidMinVersion" // Invalid minimal version of a product found
LicenseInvalidEdition AlertName = "LicenseInvalidEdition" // The license was not issued for this edition of the product
LicenseInvalidUser AlertName = "LicenseInvalidUser" // The license was not issued for this user
LicenseInvalidDomain AlertName = "LicenseInvalidDomain" // The license was not issued for this domain
LicenseInvalidOS AlertName = "LicenseInvalidOS" // The license was not issued for this operating system
LicenseCheckForwardingEnabled AlertName = "LicenseCheckForwardingEnabled" // The license was not alowed forward the message to another host
LicenseTooManyUsers AlertName = "LicenseTooManyUsers" // More users try login to their mailboxes then allowed License.
StorageSpaceLow AlertName = "StorageSpaceLow" // Low space in storage
SubscriptionExpired AlertName = "SubscriptionExpired" // Subscription has expired
SubscriptionSoonExpire AlertName = "SubscriptionSoonExpire" // Subscription soon expire
LicenseSoonExpire AlertName = "LicenseSoonExpire" // License soon expire
CoredumpFound AlertName = "CoredumpFound" // Some coredump was found after crash
MacOSServicesKeepsPorts AlertName = "MacOSServicesKeepsPorts" // Apache on Lion server keeps ports (Eg. port 443), which are assigned to our services. See Services.stopMacOSServices()
RemoteUpgradeFailed AlertName = "RemoteUpgradeFailed" // Remote server upgrade failed
RemoteUpgradeSucceeded AlertName = "RemoteUpgradeSucceeded" // Remote server upgrade succeeded
)
// TypeAlert - Type of Alert
type TypeAlert string
const (
Warning TypeAlert = "Warning"
Critical TypeAlert = "Critical"
Info TypeAlert = "Info"
)
// Alert - Alert
type Alert struct {
AlertName AlertName `json:"alertName"` // Alert Id
AlertType TypeAlert `json:"alertType"` // Alert type
CurrentValue string `json:"currentValue"` // Current Value
CriticalValue string `json:"criticalValue"` // Critical Value
}
type AlertList []Alert
// EntityDuplicate - Potential duplicate
type EntityDuplicate struct {
Kind Entity `json:"kind"` // which entity was found as first duplicate
Name string `json:"name"` // name of duplicate
CollisionAddress string `json:"collisionAddress"`
Win bool `json:"win"` // if entity is winner in this collision of mail address
IsPattern bool `json:"isPattern"` // is true if it is the pattern to check (self duplicity)
}
type EntityDuplicateList []EntityDuplicate
// EntityDetail - Detail about entity to be checked. Kind or id must be filled.
type EntityDetail struct {
Kind Entity `json:"kind"` // which entity is inserting
Id KId `json:"id"` // entity global identification of updated entity
}
type UserNameList []string
type FolderInfo struct {
FolderName string `json:"folderName"`
ReferenceCount int `json:"referenceCount"`
IndexLoaded bool `json:"indexLoaded"`
Users UserNameList `json:"users"`
}
type FolderInfoList []FolderInfo
type WebSession struct {
Id string `json:"id"`
UserName string `json:"userName"`
ClientAddress string `json:"clientAddress"` // IPv4 address
ExpirationTime string `json:"expirationTime"` // format dd.mm.yyyy hh:mm:ss
ComponentType WebComponent `json:"componentType"` // what about CalDav, WebDav, ActiveSync
IsSecure bool `json:"isSecure"` // is protocol secure
}
type WebSessionList []WebSession
type Protocol string
const (
protocolAdmin Protocol = "protocolAdmin"
protocolSmtp Protocol = "protocolSmtp"
protocolSmtps Protocol = "protocolSmtps"
protocolSubmission Protocol = "protocolSubmission"
protocolPop3 Protocol = "protocolPop3"
protocolPop3s Protocol = "protocolPop3s"
protocolImap Protocol = "protocolImap"
protocolImaps Protocol = "protocolImaps"
protocolNntp Protocol = "protocolNntp"
protocolNntps Protocol = "protocolNntps"
protocolLdap Protocol = "protocolLdap"
protocolLdaps Protocol = "protocolLdaps"
protocolHttp Protocol = "protocolHttp"
protocolHttps Protocol = "protocolHttps"
protocolXmpp Protocol = "protocolXmpp"
protocolXmpps Protocol = "protocolXmpps"
)
type HttpExtension string
const (
NoExtension HttpExtension = "NoExtension"
WebGeneric HttpExtension = "WebGeneric" // WebMail or WebMail Mini or WebAdmin
WebDav HttpExtension = "WebDav"
CalDav HttpExtension = "CalDav"
ActiveSync HttpExtension = "ActiveSync"
KocOffline HttpExtension = "KocOffline"
KBC HttpExtension = "KBC" // Kerio Connector for BlackBerry Enterprise Server
EWS HttpExtension = "EWS" // Exchange Web Services
)
type Connection struct {
Proto Protocol `json:"proto"`
Extension HttpExtension `json:"extension"`
IsSecure bool `json:"isSecure"`
Time string `json:"time"`
From string `json:"from"`
User string `json:"user"`
Description string `json:"description"`
}
type ConnectionList []Connection
// Administration - Note: isEnabled, isLimited and groupId fields must be assigned if any of them is used in set methods
type Administration struct {
IsEnabled bool `json:"isEnabled"` // administration from other that local machine is enabled/disabled
IsLimited bool `json:"isLimited"` // administration is limited
GroupId KId `json:"groupId"` // IP Address Group identifier on which is limit applied
GroupName string `json:"groupName"` // [READ-ONLY] IP Address Group name on which is limit applied
BuiltInAdminEnabled bool `json:"builtInAdminEnabled"` // if is enabled field builtInAdminPassword is required
BuiltInAdminUsername string `json:"builtInAdminUsername"` // [READ-ONLY] user name
BuiltInAdminPassword string `json:"builtInAdminPassword"` // password
BuiltInAdminPasswordIsEmpty bool `json:"builtInAdminPasswordIsEmpty"` // [READ-ONLY] password is empty
BuiltInAdminUsernameCollide bool `json:"builtInAdminUsernameCollide"` // [READ-ONLY] username colide with user in primary domain
}
// ServerTimeInfo - Server time information
type ServerTimeInfo struct {
TimezoneOffset int `json:"timezoneOffset"` // +/- offset in minutes
StartTime DateTimeStamp `json:"startTime"` // +/- start time of server
CurrentTime DateTimeStamp `json:"currentTime"` // +/- current time on server
}
// ServerCreatePath - Server creates an archive/backup path. If credentials aren't specified, values from current configuration of backup are used.
// Parameters
// path - new directory to create
// credentials - (optional) user name and password required to access network disk
// Return
// result - result of create action
func (c *ServerConnection) ServerCreatePath(path string, credentials Credentials) (*DirectoryAccessResult, error) {
params := struct {
Path string `json:"path"`
Credentials Credentials `json:"credentials"`
}{path, credentials}
data, err := c.CallRaw("Server.createPath", params)
if err != nil {
return nil, err
}
result := struct {
Result struct {
Result DirectoryAccessResult `json:"result"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &result)
return &result.Result.Result, err
}
// ServerFindEntityByEmail - caller must be authenticated; Note: creating duplicates is often allowed but may cause unwanted effects.
// Parameters
// addresses - list of email addresses (without domain) to be checked
// updatedEntity - identification of the current entity (to avoid self duplicity)
// domainId - domain identification
// Return
// entities - list of found entities with e-mail address duplicate 'updatedEntity' is included in list and marked, if none duplicate is found list is empty
func (c *ServerConnection) ServerFindEntityByEmail(addresses StringList, updatedEntity EntityDetail, domainId KId) (EntityDuplicateList, error) {
params := struct {
Addresses StringList `json:"addresses"`
UpdatedEntity EntityDetail `json:"updatedEntity"`
DomainId KId `json:"domainId"`
}{addresses, updatedEntity, domainId}
data, err := c.CallRaw("Server.findEntityByEmail", params)
if err != nil {
return nil, err
}
entities := struct {
Result struct {
Entities EntityDuplicateList `json:"entities"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &entities)
return entities.Result.Entities, err
}
// ServerGenerateSupportInfo - Generate a file with information for the support.
// Return
// fileDownload - description of output file
func (c *ServerConnection) ServerGenerateSupportInfo() (*Download, error) {
data, err := c.CallRaw("Server.generateSupportInfo", nil)
if err != nil {
return nil, err
}
fileDownload := struct {
Result struct {
FileDownload Download `json:"fileDownload"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &fileDownload)
return &fileDownload.Result.FileDownload, err
}
// ServerGetAboutInfo - Obtain information about server, caller must be authenticated.
// Return
// aboutInformation - information about server
func (c *ServerConnection) ServerGetAboutInfo() (*AboutInfo, error) {
data, err := c.CallRaw("Server.getAboutInfo", nil)
if err != nil {
return nil, err
}
aboutInformation := struct {
Result struct {
AboutInformation AboutInfo `json:"aboutInformation"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &aboutInformation)
return &aboutInformation.Result.AboutInformation, err
}
// ServerGetAlertList - Obtain a list of alerts.
// Return
// alerts - list of alerts
func (c *ServerConnection) ServerGetAlertList() (AlertList, error) {
data, err := c.CallRaw("Server.getAlertList", nil)
if err != nil {
return nil, err
}
alerts := struct {
Result struct {
Alerts AlertList `json:"alerts"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &alerts)
return alerts.Result.Alerts, err
}
// ServerGetBrowserLanguages - Returns a list of user-preferred languages set in browser.
// Return
// calculatedLanguage - a list of 2-character language codes
func (c *ServerConnection) ServerGetBrowserLanguages() (StringList, error) {
data, err := c.CallRaw("Server.getBrowserLanguages", nil)
if err != nil {
return nil, err
}
calculatedLanguage := struct {
Result struct {
CalculatedLanguage StringList `json:"calculatedLanguage"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &calculatedLanguage)
return calculatedLanguage.Result.CalculatedLanguage, err
}
// ServerGetClientStatistics - Obtain client statistics settings.
func (c *ServerConnection) ServerGetClientStatistics() (bool, error) {
data, err := c.CallRaw("Server.getClientStatistics", nil)
if err != nil {
return false, err
}
isEnabled := struct {
Result struct {
IsEnabled bool `json:"isEnabled"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &isEnabled)
return isEnabled.Result.IsEnabled, err
}
// ServerGetColumnList - Obtain a list of columns dependent on callee role.
// Parameters
// objectName - name of the API object
// methodName - name of the method of appropriate object
// Return
// columns - list of available columns
func (c *ServerConnection) ServerGetColumnList(objectName string, methodName string) (StringList, error) {
params := struct {
ObjectName string `json:"objectName"`
MethodName string `json:"methodName"`
}{objectName, methodName}
data, err := c.CallRaw("Server.getColumnList", params)
if err != nil {
return nil, err
}
columns := struct {
Result struct {
Columns StringList `json:"columns"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &columns)
return columns.Result.Columns, err
}
// ServerGetConnections - Obtain information about active connections.
// Parameters
// query - condition and fields have no effect for this method
// Return
// list - active connections
func (c *ServerConnection) ServerGetConnections(query SearchQuery) (ConnectionList, error) {
params := struct {
Query SearchQuery `json:"query"`
}{query}
data, err := c.CallRaw("Server.getConnections", params)
if err != nil {
return nil, err
}
list := struct {
Result struct {
List ConnectionList `json:"list"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &list)
return list.Result.List, err
}
// ServerGetDirs - Obtain a list of directories in a particular path.
// Parameters
// fullPath - directory for listing, if full path is empty logical drives will be listed
// Return
// dirList - List of directories
func (c *ServerConnection) ServerGetDirs(fullPath string) (DirectoryList, error) {
params := struct {
FullPath string `json:"fullPath"`
}{fullPath}
data, err := c.CallRaw("Server.getDirs", params)
if err != nil {
return nil, err
}
dirList := struct {
Result struct {
DirList DirectoryList `json:"dirList"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &dirList)
return dirList.Result.DirList, err
}
// ServerGetLicenseExtensionsList - Obtain list of license extensions, caller must be authenticated.
// Return
// extensions - list of license extensions
func (c *ServerConnection) ServerGetLicenseExtensionsList() (StringList, error) {
data, err := c.CallRaw("Server.getLicenseExtensionsList", nil)
if err != nil {
return nil, err
}
extensions := struct {
Result struct {
Extensions StringList `json:"extensions"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &extensions)
return extensions.Result.Extensions, err
}
// ServerGetNamedConstantList - Server side list of constants.
// Return
// constants - list of constants
func (c *ServerConnection) ServerGetNamedConstantList() (NamedConstantList, error) {
data, err := c.CallRaw("Server.getNamedConstantList", nil)
if err != nil {
return nil, err
}
constants := struct {
Result struct {
Constants NamedConstantList `json:"constants"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &constants)
return constants.Result.Constants, err
}
// ServerGetOpenedFoldersInfo - Obtain information about folders opened on server.
// Parameters
// query - condition and fields have no effect for this method
// Return
// list - opened folders with info
func (c *ServerConnection) ServerGetOpenedFoldersInfo(query SearchQuery) (FolderInfoList, error) {
params := struct {
Query SearchQuery `json:"query"`
}{query}
data, err := c.CallRaw("Server.getOpenedFoldersInfo", params)
if err != nil {
return nil, err
}
list := struct {
Result struct {
List FolderInfoList `json:"list"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &list)
return list.Result.List, err
}
// ServerGetProductInfo - Get basic information about product and its version.
// Return
// info - structure with basic information about product
func (c *ServerConnection) ServerGetProductInfo() (*ProductInfo, error) {
data, err := c.CallRaw("Server.getProductInfo", nil)
if err != nil {
return nil, err
}
info := struct {
Result struct {
Info ProductInfo `json:"info"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &info)
return &info.Result.Info, err
}
// ServerGetRemoteAdministration - Obtain information about remote administration settings.
// Return
// setting - current settings
func (c *ServerConnection) ServerGetRemoteAdministration() (*Administration, error) {
data, err := c.CallRaw("Server.getRemoteAdministration", nil)
if err != nil {
return nil, err
}
setting := struct {
Result struct {
Setting Administration `json:"setting"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &setting)
return &setting.Result.Setting, err
}
// ServerGetServerHash - Obtain a hash string created from product name, version, and installation time.
// Return
// serverHash - server hash
func (c *ServerConnection) ServerGetServerHash() (string, error) {
data, err := c.CallRaw("Server.getServerHash", nil)
if err != nil {
return "", err
}
serverHash := struct {
Result struct {
ServerHash string `json:"serverHash"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &serverHash)
return serverHash.Result.ServerHash, err
}
// ServerGetServerIpAddresses - List all server IP addresses.
// Return
// addresses - all IP addresses of the server
func (c *ServerConnection) ServerGetServerIpAddresses() (StringList, error) {
data, err := c.CallRaw("Server.getServerIpAddresses", nil)
if err != nil {
return nil, err
}
addresses := struct {
Result struct {
Addresses StringList `json:"addresses"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &addresses)
return addresses.Result.Addresses, err
}
// ServerGetServerTime - Get server time information.
// Return
// info - structure with time information
func (c *ServerConnection) ServerGetServerTime() (*ServerTimeInfo, error) {
data, err := c.CallRaw("Server.getServerTime", nil)
if err != nil {
return nil, err
}
info := struct {
Result struct {
Info ServerTimeInfo `json:"info"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &info)
return &info.Result.Info, err
}
// ServerGetVersion - Obtain information about server version.
// Return
// product - name of product
// version - version in string consists of values of major, minor, revision, build a dot separated
// major - major version
// minor - minor version
// revision - revision number
// build - build number
func (c *ServerConnection) ServerGetVersion() (*ServerVersion, error) {
data, err := c.CallRaw("Server.getVersion", nil)
if err != nil {
return nil, err
}
serverVersion := struct {
Result struct {
ServerVersion
} `json:"result"`
}{}
err = json.Unmarshal(data, &serverVersion)
return &serverVersion.Result.ServerVersion, err
}
// ServerGetWebSessions - Obtain information about web component sessions.
// Parameters
// query - condition and fields have no effect for this method
// Return
// list - web component sessions
func (c *ServerConnection) ServerGetWebSessions(query SearchQuery) (WebSessionList, error) {
params := struct {
Query SearchQuery `json:"query"`
}{query}
data, err := c.CallRaw("Server.getWebSessions", params)
if err != nil {
return nil, err
}
list := struct {
Result struct {
List WebSessionList `json:"list"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &list)
return list.Result.List, err
}
// ServerKillWebSessions - Terminate actual web sessions.
// Parameters
// ids - list of web sessions IDs to terminate
func (c *ServerConnection) ServerKillWebSessions(ids KIdList) error {
params := struct {
Ids KIdList `json:"ids"`
}{ids}
_, err := c.CallRaw("Server.killWebSessions", params)
return err
}
// ServerPathExists - Check if the selected path exists and is accessible from the server.
// Parameters
// path - directory name
// credentials - (optional) user name and password required to access network disk
// Return
// result - result of check
func (c *ServerConnection) ServerPathExists(path string, credentials Credentials) (DirectoryAccessResult, error) {
params := struct {
Path string `json:"path"`
Credentials Credentials `json:"credentials"`
}{path, credentials}
data, err := c.CallRaw("Server.pathExists", params)
if err != nil {
return "", err
}
result := struct {
Result struct {
Result DirectoryAccessResult `json:"result"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &result)
return result.Result.Result, err
}
// ServerReboot - Reboot the host system.
func (c *ServerConnection) ServerReboot() error {
_, err := c.CallRaw("Server.reboot", nil)
return err
}
// ServerRestart - Restart server. The server must run as service.
func (c *ServerConnection) ServerRestart() error {
_, err := c.CallRaw("Server.restart", nil)
return err
}
// ServerUpgrade - Upgrade server to the latest version. The server must run as service.
func (c *ServerConnection) ServerUpgrade() error {
_, err := c.CallRaw("Server.upgrade", nil)
return err
}
// ServerGetDownloadProgress - Get progress of installation package downloading
// Return
// progress - download progress in percents (0-100)
func (c *ServerConnection) ServerGetDownloadProgress() (int, error) {
data, err := c.CallRaw("Server.getDownloadProgress", nil)
if err != nil {
return 0, err
}
progress := struct {
Result struct {
Progress int `json:"progress"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &progress)
return progress.Result.Progress, err
}
// ServerSendBugReport - Send a bug report to Kerio.
// Parameters
// name - name of sender
// email - email of sender
// language - language of report
// subject - summary of report
// description - description of problem
func (c *ServerConnection) ServerSendBugReport(name string, email string, language string, subject string, description string) error {
params := struct {
Name string `json:"name"`
Email string `json:"email"`
Language string `json:"language"`
Subject string `json:"subject"`
Description string `json:"description"`
}{name, email, language, subject, description}
_, err := c.CallRaw("Server.sendBugReport", params)
return err
}
// ServerSetClientStatistics - Set client statistics settings.
func (c *ServerConnection) ServerSetClientStatistics(isEnabled bool) error {
params := struct {
IsEnabled bool `json:"isEnabled"`
}{isEnabled}
_, err := c.CallRaw("Server.setClientStatistics", params)
return err
}
// ServerSetRemoteAdministration - Set new remote administration parameters.
// Parameters
// setting - new settings
func (c *ServerConnection) ServerSetRemoteAdministration(setting Administration) error {
params := struct {
Setting Administration `json:"setting"`
}{setting}
_, err := c.CallRaw("Server.setRemoteAdministration", params)
return err
}
// ServerUploadLicense - Upload license manually from a file.
// Parameters
// fileId - ID of the uploaded file
func (c *ServerConnection) ServerUploadLicense(fileId string) error {
params := struct {
FileId string `json:"fileId"`
}{fileId}
_, err := c.CallRaw("Server.uploadLicense", params)
return err
}
// ServerValidateRemoteAdministration - Validate whether the administrator can cut off him/herself from the administration.
// Parameters
// setting - new setting
func (c *ServerConnection) ServerValidateRemoteAdministration(setting Administration) error {
params := struct {
Setting Administration `json:"setting"`
}{setting}
_, err := c.CallRaw("Server.validateRemoteAdministration", params)
return err
}
// ServerIsBritishPreferred - Determine whether to use British or American flag for English.
// Return
// preferred - use British flag
func (c *ServerConnection) ServerIsBritishPreferred() (bool, error) {
data, err := c.CallRaw("Server.isBritishPreferred", nil)
if err != nil {
return false, err
}
preferred := struct {
Result struct {
Preferred bool `json:"preferred"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &preferred)
return preferred.Result.Preferred, err
}