Class: SeafileApi::Connect

Inherits:
Object
  • Object
show all
Defined in:
lib/seafile-api.rb,
lib/seafile-api/file.rb,
lib/seafile-api/group.rb,
lib/seafile-api/share.rb,
lib/seafile-api/account.rb,
lib/seafile-api/library.rb,
lib/seafile-api/message.rb,
lib/seafile-api/starred.rb,
lib/seafile-api/directory.rb,
lib/seafile-api/group/group.rb,
lib/seafile-api/shared/share.rb,
lib/seafile-api/file/dry_methods.rb,
lib/seafile-api/group/group_member.rb,
lib/seafile-api/file/get_operations.rb,
lib/seafile-api/group/group_message.rb,
lib/seafile-api/library/del_library.rb,
lib/seafile-api/library/get_library.rb,
lib/seafile-api/shared/shared_files.rb,
lib/seafile-api/file/file_operations.rb,
lib/seafile-api/file/post_operations.rb,
lib/seafile-api/library/post_library.rb,
lib/seafile-api/shared/shared_libraries.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_name, password, host, repo) ⇒ Connect

Returns a new instance of Connect.



13
14
15
16
17
18
19
# File 'lib/seafile-api.rb', line 13

def initialize(user_name ,password,host,repo)
  self.user_name  = user_name
  self.password   = password
  self.host       = host
  self.repo       = repo
  self.token      = self.get_token
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



9
10
11
# File 'lib/seafile-api.rb', line 9

def host
  @host
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/seafile-api.rb', line 8

def password
  @password
end

#repoObject

Returns the value of attribute repo.



10
11
12
# File 'lib/seafile-api.rb', line 10

def repo
  @repo
end

#tokenObject

Returns the value of attribute token.



11
12
13
# File 'lib/seafile-api.rb', line 11

def token
  @token
end

#user_nameObject

Returns the value of attribute user_name.



7
8
9
# File 'lib/seafile-api.rb', line 7

def user_name
  @user_name
end

Instance Method Details

#account_infoObject



13
14
15
# File 'lib/seafile-api/account.rb', line 13

def 
  get_acc_info
end

#add_group(group_name) ⇒ Object



6
7
8
# File 'lib/seafile-api/group.rb', line 6

def add_group(group_name)
  put_new_group(group_name)
end

#add_group_member(user_email, group_id) ⇒ Object

group member



29
30
31
# File 'lib/seafile-api/group.rb', line 29

def add_group_member(user_email,group_id)
  put_new_meber_to_group(user_email,group_id)
end


22
23
24
# File 'lib/seafile-api/file.rb', line 22

def block_link(repo=self.repo)
  get_block(repo)
end

#copy_file(filename, dst_dir = '/', dst_repo = self.repo, src_repo = self.repo) ⇒ Object

TODO: missing arguments at 3,0,3 , at 3.0.0 all wark



42
43
44
# File 'lib/seafile-api/file.rb', line 42

def copy_file(filename,dst_dir='/',dst_repo=self.repo,src_repo=self.repo)
  post_copy(src_repo,{"file_names"=>filename, "dst_repo" => dst_repo, "dst_dir"=>dst_dir})
end

#create_accounts(email, pass) ⇒ Object



7
8
9
# File 'lib/seafile-api/account.rb', line 7

def create_accounts(email,pass)
  put_create_acc(email,pass)
end

#create_default_libraryObject



41
42
43
# File 'lib/seafile-api/library.rb', line 41

def create_default_library
  post_default_lib
end

#create_dir(path, repo = self.repo) ⇒ Object



7
8
9
# File 'lib/seafile-api/directory.rb', line 7

def create_dir(path,repo=self.repo)
  post_create_dir(path,repo)
end

#create_file(filename, repo = self.repo) ⇒ Object



33
34
35
# File 'lib/seafile-api/file.rb', line 33

def create_file(filename,repo=self.repo)
  post_file(filename,repo)
end


8
9
10
# File 'lib/seafile-api/share.rb', line 8

def create_file_share_link(file,repo_id=self.repo)
  create_share_link(file,repo_id)
end

#create_library(name, desc = "new repo", pwd = nil) ⇒ Object

post libraries



38
39
40
# File 'lib/seafile-api/library.rb', line 38

def create_library(name,desc="new repo",pwd=nil)
  post_lib({"name" =>name,"desc" =>desc,"passwd" => pwd})
end

#create_public_library(repo_id) ⇒ Object



44
45
46
# File 'lib/seafile-api/library.rb', line 44

def create_public_library(repo_id)
  post_public_lib(repo_id)
end

#create_sub_library(repo_id, name, p = '/') ⇒ Object



8
9
10
# File 'lib/seafile-api/library.rb', line 8

def create_sub_library(repo_id,name,p='/')
  get_create_sub_lib(repo_id,p,name)
end

#decrypt_library(repo_id, password) ⇒ Object



48
49
50
# File 'lib/seafile-api/library.rb', line 48

def decrypt_library(repo_id,password)
  post_lib_pass(repo_id,{'password' => password })
end

#default_libraryObject

get libraries



5
6
7
# File 'lib/seafile-api/library.rb', line 5

def default_library
  get_default_lib
end

#del_account(email) ⇒ Object



16
17
18
# File 'lib/seafile-api/account.rb', line 16

def (email)
  delete_acc(email)
end

#del_dir(path, repo = self.repo) ⇒ Object

You do not have permission to perform this action



12
13
14
# File 'lib/seafile-api/directory.rb', line 12

def del_dir(path,repo=self.repo)
  delete_directory(path,repo)
end

#del_file(filename, repo = self.repo) ⇒ Object



50
51
52
# File 'lib/seafile-api/file.rb', line 50

def del_file(filename,repo=self.repo)
  delete_file(filename,repo)
end


11
12
13
# File 'lib/seafile-api/share.rb', line 11

def del_file_share_link(shared_t)
  delete_share_link(shared_t)
end

#del_group_member(user_email, group_id) ⇒ Object



33
34
35
# File 'lib/seafile-api/group.rb', line 33

def del_group_member(user_email,group_id)
  delete_group_member(user_email,group_id)
end

#del_library(repo_id) ⇒ Object

del libraries



53
54
55
# File 'lib/seafile-api/library.rb', line 53

def del_library(repo_id)
  delete_lib(repo_id)
end

#download_dir(path, repo = self.repo) ⇒ Object



15
16
17
# File 'lib/seafile-api/directory.rb', line 15

def download_dir(path,repo=self.repo)
  get_download_dir(path,repo)
end

#download_private_shared_file(file_t) ⇒ Object

‘TODO need know what is private shared file -> need test“error_msg": "Token not found"}



29
30
31
# File 'lib/seafile-api/share.rb', line 29

def download_private_shared_file(file_t)
  get_private_shared_file_link(file_t)
end

#fetch_library_info(repo_id) ⇒ Object



33
34
35
# File 'lib/seafile-api/library.rb', line 33

def fetch_library_info(repo_id)
  get_lib_download_info(repo_id)
end

#file_detail(filename, repo = self.repo) ⇒ Object



11
12
13
# File 'lib/seafile-api/file.rb', line 11

def file_detail(filename,repo=self.repo)
  get_description(filename,repo)
end

#file_history(filename, repo = self.repo) ⇒ Object



18
19
20
# File 'lib/seafile-api/file.rb', line 18

def file_history(filename,repo=self.repo)
  get_history(filename,repo)
end


5
6
7
# File 'lib/seafile-api/file.rb', line 5

def file_link(filename,repo=self.repo)
  get_file_link(filename,repo)
end

#get_tokenObject



8
9
10
# File 'lib/seafile-api/file.rb', line 8

def get_token
  get_sf_token
end

#group_message_detail(group_id, msg_id) ⇒ Object



13
14
15
# File 'lib/seafile-api/group.rb', line 13

def group_message_detail(group_id,msg_id)
  get_group_message_detail(group_id,msg_id)
end

#group_messages(group_id) ⇒ Object

group_message



10
11
12
# File 'lib/seafile-api/group.rb', line 10

def group_messages(group_id)
  get_group_messages(group_id)
end

#group_messages_repliesObject



16
17
18
# File 'lib/seafile-api/group.rb', line 16

def group_messages_replies
  get_group_messages_replies
end

#library_history(repo_id) ⇒ Object



30
31
32
# File 'lib/seafile-api/library.rb', line 30

def library_history(repo_id)
  get_lib_history(repo_id)
end

#library_info(repo_id) ⇒ Object



22
23
24
# File 'lib/seafile-api/library.rb', line 22

def library_info(repo_id)
  get_lib_info(repo_id)
end

#library_owner(repo_id) ⇒ Object



26
27
28
# File 'lib/seafile-api/library.rb', line 26

def library_owner(repo_id)
  get_lib_owner(repo_id)
end


14
15
16
# File 'lib/seafile-api/file.rb', line 14

def link_revision(filename,commit_id,repo=self.repo)
  get_link_file_revision(filename,commit_id,repo)
end

#list_accountsObject



4
5
6
# File 'lib/seafile-api/account.rb', line 4

def list_accounts
  get_list_acc
end

#list_beshared_librariesObject

TODO: need know what it do



42
43
44
# File 'lib/seafile-api/share.rb', line 42

def list_beshared_libraries
  get_list_beshared_libraries
end

#list_dir_entry(path = '/', repo = self.repo) ⇒ Object



4
5
6
# File 'lib/seafile-api/directory.rb', line 4

def list_dir_entry(path='/',repo=self.repo)
  get_list_dir_entry(repo,path)
end

share



4
5
6
# File 'lib/seafile-api/share.rb', line 4

def list_file_share_link
  get_list_shared_files_link
end

#list_groupsObject



3
4
5
# File 'lib/seafile-api/group.rb', line 3

def list_groups
  get_list_groups
end

#list_librariesObject



15
16
17
# File 'lib/seafile-api/library.rb', line 15

def list_libraries
  get_list_lib
end

#list_shared_filesObject

shared_files



16
17
18
# File 'lib/seafile-api/share.rb', line 16

def list_shared_files
  get_list_shared_files
end

#list_shared_librariesObject

shared_libraries



38
39
40
# File 'lib/seafile-api/share.rb', line 38

def list_shared_libraries
  get_list_shared_libraries
end

#list_starredObject



3
4
5
# File 'lib/seafile-api/starred.rb', line 3

def list_starred
  get_list_starred_files
end

#list_user_message(to_email) ⇒ Object



3
4
5
# File 'lib/seafile-api/message.rb', line 3

def list_user_message(to_email)
  get_list_message(to_email)
end

#list_virtual_librariesObject



19
20
21
# File 'lib/seafile-api/library.rb', line 19

def list_virtual_libraries
  get_list_virtual_lib
end

#move_file(filename, dst_dir = '/', dest_repo = self.repo, src_repo = self.repo) ⇒ Object



46
47
48
# File 'lib/seafile-api/file.rb', line 46

def move_file(filename,dst_dir='/',dest_repo=self.repo,src_repo=self.repo)
  post_move(filename,src_repo,{"operation"=>"move", "dst_repo" => dest_repo, "dst_dir"=>dst_dir})
end

#private_shared_file_detail(file_t) ⇒ Object

TODO need know what is private shared file -> need test“error_msg": "Token not found"}



33
34
35
# File 'lib/seafile-api/share.rb', line 33

def private_shared_file_detail(file_t)
  get_private_shared_file_detail(file_t)
end

#remove_public_library(repo_id) ⇒ Object



56
57
58
# File 'lib/seafile-api/library.rb', line 56

def remove_public_library(repo_id)
  delete_public_lib(repo_id)
end

#rename_file(old_name, new_name, repo = self.repo) ⇒ Object



37
38
39
# File 'lib/seafile-api/file.rb', line 37

def rename_file(old_name,new_name,repo=self.repo)
  post_rename(old_name,repo,{"operation"=>"rename", "newname" => new_name})
end

#reply_group_message(group_id, message, msg_id) ⇒ Object



24
25
26
# File 'lib/seafile-api/group.rb', line 24

def reply_group_message(group_id,message,msg_id)
  post_reply_message_to_group(group_id,msg_id,{"message" => message})
end

#reply_user_message(to_email, message) ⇒ Object



9
10
11
# File 'lib/seafile-api/message.rb', line 9

def reply_user_message(to_email,message)
  post_reply_message(to_email,{"message" => message})
end

#revert_file(filename, commit_id, repo = self.repo) ⇒ Object

TODO: need test on new server version not working seafile server version 3.0.3 , curl to not working



56
57
58
# File 'lib/seafile-api/file.rb', line 56

def revert_file(filename,commit_id,repo=self.repo)
  post_revert("#{filename}",commit_id,repo)
end

#search_libraries(keyword) ⇒ Object

search not supported



12
13
14
# File 'lib/seafile-api/library.rb', line 12

def search_libraries(keyword)
  get_searched_lib(keyword)
end

#send_group_message(group_id, message, repo_id = self.repo, path = "/") ⇒ Object



20
21
22
# File 'lib/seafile-api/group.rb', line 20

def send_group_message(group_id,message,repo_id=self.repo,path="/")
  post_message_to_group(group_id,{"message"=> message,"repo_id"=> repo_id,"path"=> path})
end

#share_dir(email, path, perm = "r", repo = self.repo, s_type = "d") ⇒ Object

You do not have permission to perform this action



19
20
21
# File 'lib/seafile-api/directory.rb', line 19

def share_dir(email,path,perm="r",repo=self.repo,s_type="d")
  post_share_dir(repo,{"email"=> email, "path"=> path,"s_type"=> s_type,"perm"=> perm})
end

#share_library(repo_id, user, group_id, permission = "rw", share_type = "group") ⇒ Object

TODO need test not working !!



46
47
48
# File 'lib/seafile-api/share.rb', line 46

def share_library(repo_id,user,group_id,permission="rw",share_type="group")
  put_share_library(repo_id,share_type,user,group_id,permission)
end

#shared_file_detail(file_t) ⇒ Object



23
24
25
# File 'lib/seafile-api/share.rb', line 23

def shared_file_detail(file_t)
  get_share_file_detail(file_t)
end


20
21
22
# File 'lib/seafile-api/share.rb', line 20

def shared_file_link(file_t)
  get_shared_file_link(file_t)
end

#star_a_file(file, repo_id = self.repo) ⇒ Object



6
7
8
# File 'lib/seafile-api/starred.rb', line 6

def star_a_file(file,repo_id=self.repo)
  post_star_file({"repo_id" => repo_id, "p" => file})
end

#unread_messageObject



6
7
8
# File 'lib/seafile-api/message.rb', line 6

def unread_message
  get_count_unread_message
end

#unshare_library(repo_id, share_type, user, group_id) ⇒ Object

TODO need test not working wrong user error



50
51
52
# File 'lib/seafile-api/share.rb', line 50

def unshare_library(repo_id,share_type,user,group_id)
  delete_unshare_library(repo_id,share_type,user,group_id)
end

#unstar_a_file(file, repo_id = self.repo) ⇒ Object



9
10
11
# File 'lib/seafile-api/starred.rb', line 9

def unstar_a_file(file,repo_id=self.repo)
  delete_unstar_file(repo_id,file)
end

#update_account(email, pass) ⇒ Object



10
11
12
# File 'lib/seafile-api/account.rb', line 10

def (email,pass)
  put_update_acc(email,pass)
end

#update_file(file, target_file = nil, repo = self.repo) ⇒ Object



29
30
31
# File 'lib/seafile-api/file.rb', line 29

def update_file(file,target_file=nil,repo=self.repo)
  post_update(repo,{"file" => file, "filename" =>File.basename(file), "target_file"=> target_file ||File.basename(file)})
end

#upload_file(file, path = '/', repo = self.repo) ⇒ Object



26
27
28
# File 'lib/seafile-api/file.rb', line 26

def upload_file(file,path='/',repo=self.repo)
  post_upload(repo,{"file"=> file,"filename"=> File.basename(file),"parent_dir"=> "#{path}"})
end