Compare commits
2 Commits
3f512bf9cf
...
71a283513c
Author | SHA1 | Date |
---|---|---|
David Vargas | 71a283513c | |
David Vargas | 69d79262d9 |
|
@ -3,3 +3,9 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem "colorize"
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "dotenv"
|
||||
gem "nextcloud"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
.env
|
||||
private*
|
||||
*.lock
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
require "dotenv"
|
||||
|
||||
settings = Dotenv.load
|
||||
puts settings
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env ruby
|
||||
require "debug"
|
||||
require "dotenv"
|
||||
require "nextcloud"
|
||||
|
||||
settings = Dotenv.load
|
||||
|
||||
nextcloud = Nextcloud.new(
|
||||
url: settings["URL"],
|
||||
username: settings["USERNAME"],
|
||||
password: settings["PASSWORD"]
|
||||
)
|
||||
|
||||
ocs = nextcloud.ocs
|
||||
puts "* ocs.webdav.directory: #{ocs.webdav.directory}"
|
||||
webdav = nextcloud.webdav
|
||||
puts "* webdav.directory(@path): #{webdav.directory.instance_variable_get(:@path)}"
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env ruby
|
||||
require "debug"
|
||||
require "dotenv"
|
||||
require "nextcloud"
|
||||
|
||||
settings = Dotenv.load
|
||||
|
||||
nextcloud = Nextcloud.new(
|
||||
url: settings["URL"],
|
||||
username: settings["USERNAME"],
|
||||
password: settings["PASSWORD"]
|
||||
)
|
||||
|
||||
ocs = nextcloud.ocs
|
||||
user = ocs.user.find("dvarrui")
|
||||
|
||||
tags = %i(enabled id quota email displayname phone address website twitter groups language meta)
|
||||
|
||||
tags.each do |tag|
|
||||
label = "user.#{tag}"
|
||||
puts "#{label.rjust(16)} = #{user.send(tag)}"
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env ruby
|
||||
require_relative "lib"
|
||||
|
||||
nextcloud = get_nextcloud_object()
|
||||
ocs = nextcloud.ocs
|
||||
user = ocs.user.find("dvarrui")
|
||||
|
||||
tags = %i(enabled id quota email displayname phone address website twitter groups language meta)
|
||||
|
||||
puts "User:"
|
||||
tags.each do |tag|
|
||||
value = user.send(tag)
|
||||
puts "#{tag.to_s.rjust(12)} = #{value.to_s}"
|
||||
end
|
||||
|
||||
puts "\nAdmin:"
|
||||
groups = ocs.group.all
|
||||
puts " groups : #{groups}"
|
||||
# => ["admin", "group1", "group2"]
|
||||
meta = groups.meta
|
||||
puts " meta : #{meta}"
|
||||
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env ruby
|
||||
require_relative "lib"
|
||||
|
||||
fs = get_filesharing_object()
|
||||
|
||||
puts "Retrieve all shares of an (authenticated) user"
|
||||
all_shares = fs.all
|
||||
meta = all_shares.meta
|
||||
|
||||
puts all_shares
|
||||
puts meta
|
||||
|
||||
puts "Retrieve a single share"
|
||||
share = fs.find(11)
|
||||
meta = share.meta
|
||||
|
||||
puts share
|
||||
puts meta
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env ruby
|
||||
require_relative "lib"
|
||||
|
||||
nextcloud = get_nextcloud_object()
|
||||
webdav = nextcloud.webdav
|
||||
|
||||
ocs = nextcloud.ocs
|
||||
puts "* ocs.webdav.directory: #{ocs.webdav.directory}"
|
||||
webdav = nextcloud.webdav
|
||||
path = webdav.directory.instance_variable_get(:@path)
|
||||
puts "* webdav.directory(@path): #{path}"
|
||||
|
||||
dir = "files_from_git"
|
||||
result = webdav.directory.create(dir)
|
||||
puts result
|
||||
|
||||
dir = webdav.directory.find
|
||||
puts dir.contents
|
|
@ -0,0 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "dotenv"
|
||||
gem "nextcloud"
|
|
@ -0,0 +1,22 @@
|
|||
require "dotenv"
|
||||
require "nextcloud"
|
||||
|
||||
def get_nextcloud_object
|
||||
settings = Dotenv.load
|
||||
nextcloud = Nextcloud.new(
|
||||
url: settings["URL"],
|
||||
username: settings["USERNAME"],
|
||||
password: settings["PASSWORD"]
|
||||
)
|
||||
return nextcloud
|
||||
end
|
||||
|
||||
def get_filesharing_object
|
||||
settings = Dotenv.load
|
||||
fs = Nextcloud::Ocs::FileSharingApi.new(
|
||||
url: settings["URL"],
|
||||
username: settings["USERNAME"],
|
||||
password: settings["PASSWORD"]
|
||||
)
|
||||
return fs
|
||||
end
|
Loading…
Reference in New Issue