A java based Synology DSM Webapi client.
Latest stable release is 1.0.0-M1. It allows all basic files operation.
Roadmap :
- 1.0.0-M2: extract Spring configuration in a separate project and allow to use the framework without Spring at all.
- 1.0.0-FINAL: missing FileStation APIs (Favorites, thumbnail, MD5, compress / uncompress).
- 2.0.0-FINAL: DownloadStation APIs.
Simply run: mvn clean install
Tests requires an actual Synology DSM server running with some existing account, share and folder structure.
Note that integration tests are not run by default. Running the tests requires it
profile to be activated: mvn clean install -Pit
The following Maven properties are used by the integration tests, and can be overriden in Maven settings.xml
:
Property | Default value |
---|---|
test.dsm.webapi.scheme |
http |
test.dsm.webapi.host |
diskstation.local |
test.dsm.webapi.port |
5000 |
test.dsm.webapi.username |
dsm-webapi-it |
test.dsm.webapi.password |
dsm-webapi-it |
test.dsm.webapi.session |
filestation |
test.dsm.webapi.timeZone |
Europe/Brussels |
Add the dsm-webapi-client-filestation
as a Maven dependency :
<dependency>
<groupId>com.github.gauthierj.dsm-webapi-client</groupId>
<artifactId>dsm-webapi-client-filestation</artifactId>
<version>1.0.0-M1</version>
</dependency>
The project is available in the following public repository:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-gauthierj-maven</id>
<name>bintray</name>
<url>http://dl.bintray.com/gauthierj/maven</url>
</repository>
This is a Spring based library. It is supposed to be used within Spring based applications.
- Import class
DsmWebapiClientConfig
in the application configuration - Provide implementations of follwing interfaces in the application context
DsmUrlProvider
: provides the URL of Synology DSM server.
Existing implementation: PropertiesDsmUrlProvider
This implementation retrieves the URL based on the following properties:
dsm.webapi.scheme
dsm.webapi.host
dsm.webapi.port
AuthenticationProvider
: provides login and password
Existing implementation: PropertiesAuthenticationProvider
This implementation retrieves connection information based on the following properties:
dsm.webapi.username
dsm.webapi.password
dsm.webapi.session
Existing implementation: ConsoleAuthenticationProvider
This implentation asks credentials in the console.
TimeZoneProvider
: provides time zone
Existing implementation: PropertiesTimeZoneProvider
Retrieves time zone form the following property:
dsm.webapi.timeZone
Existing implementation: DefaultTimeZoneProvider
Retrieves system default time zone.
PropertySourcesPlaceholderConfigurer
if any PropertiesXXXProvider
is used.
Example configuration
@Configuration
@Import(DsmWebapiClientConfig.class)
public class MyAppConfig {
@Bean
public AuthenticationProvider authenticationProvider() {
return new PropertiesAuthenticationProvider();
}
@Bean
public DsmUrlProvider urlProvider() {
return new PropertiesDsmUrlProvider();
}
@Bean
public TimeZoneProvider timeZoneProvider() {
return new PropertiesTimeZoneProvider();
}
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
// ...
// My app's own beans
// ...
}
Finally, inject services needed in application classes: search for interfaces XXXService
corresponding to implemented APIs.
public class MyApplicationSerivce {
@Autowired
FileListService fileListService;
// ...
public void doStuff() throws Exception {
// ...
List<File> list = fileListService.list("/my-share");
// ...
}
// ...
}
Integration tests are a good place to look for samples.
Contains all base code required to easily call DSM webapi.
It also implements the following APIs:
- SYNO.API.Info:
ApiInfoService
- SYNO.API.Auth:
AuthenticationService
Implements FileStation APIs:
- SYNO.FileStation.List:
FileListService
andShareListService
- SYNO.FileStation.Info:
FileStationInformationService
- SYNO.FileStation.Search:
SearchService
- SYNO.FileStation.Download:
DownloadService
- SYNO.FileStation.Upload:
UploadService
- SYNO.FileStation.CreateFolder:
CreateFolderService
- SYNO.FileStation.CopyMove:
CopyMoveService
- SYNO.FileStation.Delete:
DeleteService
- SYNO.FileStation.DirSize:
DirSizeService
- SYNO.FileStation.Rename:
RenameService
Future development :
- Missing FileStation APIs
- DownloadStation APIs