From cdba8fc554f8d5bacfe0ff3736f47603cfcd8f8a Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Wed, 23 Sep 2020 15:04:42 +0000 Subject: [PATCH] API.pm: update to version 1.2.0 git-svn-id: https://svn.fhem.de/fhem/trunk@22832 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/lib/FHEM/SynoModules/API.pm | 49 +++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/fhem/lib/FHEM/SynoModules/API.pm b/fhem/lib/FHEM/SynoModules/API.pm index 66a87fc20..a139f03bf 100644 --- a/fhem/lib/FHEM/SynoModules/API.pm +++ b/fhem/lib/FHEM/SynoModules/API.pm @@ -32,16 +32,17 @@ use warnings; use utf8; use Carp qw(croak carp); -use version; our $VERSION = version->declare('1.0.1'); +use version; our $VERSION = version->declare('1.2.0'); use Exporter ('import'); our @EXPORT_OK = qw(apistatic); our %EXPORT_TAGS = (all => [@EXPORT_OK]); my %hspecs = ( # Hash der verfügbaren API-Specs - surveillance => {fn => "_staticSurveillance" }, - chat => {fn => "_staticChat" }, - calendar => {fn => "_staticCalendar" }, + surveillance => {fn => \&_staticSurveillance }, + chat => {fn => \&_staticChat }, + calendar => {fn => \&_staticCalendar }, + file => {fn => \&_staticFile }, ); ######################################################################## @@ -50,8 +51,7 @@ my %hspecs = ( # Hash ######################################################################## sub apistatic { my $spec = shift // carp "got no API specification !" && return; - - no strict "refs"; ## no critic 'NoStrict' + if($hspecs{$spec} && defined &{$hspecs{$spec}{fn}}) { my $h = q{}; $h = &{$hspecs{$spec}{fn}}; @@ -61,7 +61,6 @@ sub apistatic { return $h; } - use strict "refs"; carp qq{API specification "$spec" not found !}; @@ -72,7 +71,7 @@ return; ######################################################################## # Liefert die statischen Informationen der Surveillance API ######################################################################## -sub _staticSurveillance { ## no critic "not used" +sub _staticSurveillance { my %hapi = ( INFO => { NAME => "SYNO.API.Info" }, # Info-Seite für alle API's, einzige statische Seite ! AUTH => { NAME => "SYNO.API.Auth" }, # API used to perform session login and logout @@ -100,7 +99,7 @@ return \%hapi; ######################################################################## # Liefert die statischen Informationen der Chat API ######################################################################## -sub _staticChat { ## no critic "not used" +sub _staticChat { my %hapi = ( INFO => { NAME => "SYNO.API.Info" }, EXTERNAL => { NAME => "SYNO.Chat.External" }, @@ -112,7 +111,7 @@ return \%hapi; ######################################################################## # Liefert die statischen Informationen der Calendar API ######################################################################## -sub _staticCalendar { ## no critic "not used" +sub _staticCalendar { my %hapi = ( INFO => { NAME => "SYNO.API.Info" }, AUTH => { NAME => "SYNO.API.Auth" }, # API used to perform session login and logout @@ -120,7 +119,37 @@ sub _staticCalendar { ## no critic "not used" EVENT => { NAME => "SYNO.Cal.Event" }, # Provide methods to manipulate events in the specific calendar SHARE => { NAME => "SYNO.Cal.Sharing" }, # Get/set sharing setting of calendar TODO => { NAME => "SYNO.Cal.Todo" }, # Provide methods to manipulate events in the specific calendar + ); +return \%hapi; +} + +######################################################################## +# Liefert die statischen Informationen der File Station API +######################################################################## +sub _staticFile { + my %hapi = ( + INFO => { NAME => "SYNO.API.Info" }, + AUTH => { NAME => "SYNO.API.Auth" }, # Perform login and logout + FSINFO => { NAME => "SYNO.FileStation.Info" }, # Provide File Station info + LIST => { NAME => "SYNO.FileStation.List" }, # List all shared folders, enumerate files in a shared folder, and get detailed file information + SEARCH => { NAME => "SYNO.FileStation.Search" }, # Search files on given criteria + LVFOLDER => { NAME => "SYNO.FileStation.VirtualFolder" }, # List all mount point folders of virtual file system, ex: CIFS or ISO + FAVORITE => { NAME => "SYNO.FileStation.Favorite" }, # Add a folder to user’s favorites or do operations on user’s favorites + THUMB => { NAME => "SYNO.FileStation.Thumb" }, # Get a thumbnail of a file + DIRSIZE => { NAME => "SYNO.FileStation.DirSize" }, # Get the total size of files/folders within folder(s) + MD5 => { NAME => "SYNO.FileStation.MD5" }, # Get MD5 of a file + CHECKPERM => { NAME => "SYNO.FileStation.CheckPermission" }, # Check if the file/folder has a permission of a file/folder or not + UPLOAD => { NAME => "SYNO.FileStation.Upload" }, # Upload a file + DOWNLOAD => { NAME => "SYNO.FileStation.Download" }, # Download files/folders + SHARING => { NAME => "SYNO.FileStation.Sharing" }, # Generate a sharing link to share files/folders with other people and perform operations on sharing links + CFOLDER => { NAME => "SYNO.FileStation.CreateFolder" }, # Create folder(s) + RENAME => { NAME => "SYNO.FileStation.Rename" }, # Rename a file/folder + COPYMOVE => { NAME => "SYNO.FileStation.CopyMove" }, # Copy/Move files/folders + DELETE => { NAME => "SYNO.FileStation.Delete" }, # Delete files/folders + EXTRACT => { NAME => "SYNO.FileStation.Extract" }, # Extract an archive and do operations on an archive + COMPRESS => { NAME => "SYNO.FileStation.Compress" }, # Compress files/folders + BGTASK => { NAME => "SYNO.FileStation.BackgroundTask" }, # Get information regarding tasks of file operations which are run as the background process including copy, move, delete, compress and extract tasks or perform operations on these background tasks ); return \%hapi;