nextcloud 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +172 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +87 -0
- data/LICENSE.txt +21 -0
- data/README.md +668 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/nextcloud.rb +47 -0
- data/lib/nextcloud/api.rb +51 -0
- data/lib/nextcloud/errors/nextcloud.rb +5 -0
- data/lib/nextcloud/helpers/nextcloud.rb +101 -0
- data/lib/nextcloud/helpers/properties.rb +73 -0
- data/lib/nextcloud/models/directory.rb +74 -0
- data/lib/nextcloud/models/user.rb +50 -0
- data/lib/nextcloud/ocs/app.rb +90 -0
- data/lib/nextcloud/ocs/file_sharing_api.rb +221 -0
- data/lib/nextcloud/ocs/group.rb +89 -0
- data/lib/nextcloud/ocs/user.rb +225 -0
- data/lib/nextcloud/ocs_api.rb +34 -0
- data/lib/nextcloud/version/nextcloud.rb +5 -0
- data/lib/nextcloud/webdav/directory.rb +174 -0
- data/lib/nextcloud/webdav_api.rb +21 -0
- data/nextcloud.gemspec +45 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53bda8e8c13b3595070f0895adb7a29cf4773d0f
|
4
|
+
data.tar.gz: a8c34ecb37ed8ea38d8468f310933ec8cd4ca134
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee9515e02c319536ddc9fd05c290a9bee3330a9a6aff0bca307fd522dacf8dfa41002a5cf719faf7d070a4e9b9f4148264773594514cce7a3c5f405b1857bf3f
|
7
|
+
data.tar.gz: 937566070385aaad0702f91585e15a60e0bcc01bb3de31eacb9e92415d209b280339c49ae98909ec46ab03cc61ba73c66c77c4f0ab516f248a0b2009136165fa
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
DisplayCopNames: true
|
4
|
+
DisabledByDefault: true
|
5
|
+
|
6
|
+
# Prefer &&/|| over and/or.
|
7
|
+
Style/AndOr:
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
# Do not use braces for hash literals when they are the last argument of a
|
11
|
+
# method call.
|
12
|
+
Style/BracesAroundHashParameters:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: context_dependent
|
15
|
+
|
16
|
+
# Align `when` with `case`.
|
17
|
+
Layout/CaseIndentation:
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
# Align comments with method definitions.
|
21
|
+
Layout/CommentIndentation:
|
22
|
+
Enabled: true
|
23
|
+
|
24
|
+
Layout/EmptyLineAfterMagicComment:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
# In a regular class definition, no empty lines around the body.
|
28
|
+
Layout/EmptyLinesAroundClassBody:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
# In a regular method definition, no empty lines around the body.
|
32
|
+
Layout/EmptyLinesAroundMethodBody:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
# In a regular module definition, no empty lines around the body.
|
36
|
+
Layout/EmptyLinesAroundModuleBody:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Layout/FirstParameterIndentation:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
43
|
+
Style/HashSyntax:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
47
|
+
# extra level of indentation.
|
48
|
+
Layout/IndentationConsistency:
|
49
|
+
Enabled: true
|
50
|
+
EnforcedStyle: normal
|
51
|
+
|
52
|
+
# Two spaces, no tabs (for indentation).
|
53
|
+
Layout/IndentationWidth:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Layout/SpaceAfterColon:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Layout/SpaceAfterComma:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Layout/SpaceAroundKeyword:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
Layout/SpaceAroundOperators:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Layout/SpaceBeforeFirstArg:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
# Defining a method with parameters needs parentheses.
|
75
|
+
Style/MethodDefParentheses:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
# VuDo: Enable this when confident about all test coverage
|
79
|
+
Style/FrozenStringLiteralComment:
|
80
|
+
Enabled: false
|
81
|
+
EnforcedStyle: always
|
82
|
+
|
83
|
+
# Use `foo {}` not `foo{}`.
|
84
|
+
Layout/SpaceBeforeBlockBraces:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
# Use `foo { bar }` not `foo {bar}`.
|
88
|
+
Layout/SpaceInsideBlockBraces:
|
89
|
+
Enabled: true
|
90
|
+
|
91
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
92
|
+
Layout/SpaceInsideHashLiteralBraces:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Layout/SpaceInsideParens:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
# Check quotes usage according to lint rule below.
|
99
|
+
Style/StringLiterals:
|
100
|
+
Enabled: true
|
101
|
+
EnforcedStyle: double_quotes
|
102
|
+
|
103
|
+
# Detect hard tabs, no hard tabs.
|
104
|
+
Layout/Tab:
|
105
|
+
Enabled: true
|
106
|
+
|
107
|
+
# Blank lines should not have any spaces.
|
108
|
+
Layout/TrailingBlankLines:
|
109
|
+
Enabled: true
|
110
|
+
|
111
|
+
# No trailing whitespace.
|
112
|
+
Layout/TrailingWhitespace:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
# Use quotes for string literals when they are enough.
|
116
|
+
Style/UnneededPercentQ:
|
117
|
+
Enabled: true
|
118
|
+
|
119
|
+
# Align `end` with the matching keyword or starting expression except for
|
120
|
+
# assignments, where it should be aligned with the LHS.
|
121
|
+
Lint/EndAlignment:
|
122
|
+
Enabled: true
|
123
|
+
EnforcedStyleAlignWith: variable
|
124
|
+
|
125
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
126
|
+
Lint/RequireParentheses:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
# CMG Rules
|
130
|
+
Rails:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
Bundler:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Security:
|
137
|
+
Enabled: true
|
138
|
+
|
139
|
+
Style/Documentation:
|
140
|
+
Description: 'Document classes and non-namespace modules.'
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
Style/MethodCalledOnDoEndBlock:
|
144
|
+
Enabled: true
|
145
|
+
|
146
|
+
Style/CollectionMethods:
|
147
|
+
Enabled: true
|
148
|
+
|
149
|
+
Style/SymbolArray:
|
150
|
+
Description: 'Use %i or %I for arrays of symbols.'
|
151
|
+
Enabled: true
|
152
|
+
|
153
|
+
Metrics/LineLength:
|
154
|
+
Description: 'Limit lines to 120 characters.'
|
155
|
+
Enabled: true
|
156
|
+
Max: 120
|
157
|
+
Exclude:
|
158
|
+
- 'spec/**/*.rb'
|
159
|
+
|
160
|
+
|
161
|
+
Lint/AmbiguousBlockAssociation:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
Lint/RescueWithoutErrorClass:
|
165
|
+
Enabled: false
|
166
|
+
|
167
|
+
Layout/AlignParameters:
|
168
|
+
Enabled: true
|
169
|
+
EnforcedStyle: with_fixed_indentation
|
170
|
+
SupportedStyles:
|
171
|
+
- with_first_parameter
|
172
|
+
- with_fixed_indentation
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dachinat@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
nextcloud (1.3.0)
|
5
|
+
activesupport (~> 5.1)
|
6
|
+
json (~> 2.1)
|
7
|
+
net-http-report (~> 0.1)
|
8
|
+
nokogiri (~> 1.8)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (5.1.4)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (~> 0.7)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
addressable (2.5.2)
|
19
|
+
public_suffix (>= 2.0.2, < 4.0)
|
20
|
+
ast (2.3.0)
|
21
|
+
concurrent-ruby (1.0.5)
|
22
|
+
crack (0.4.3)
|
23
|
+
safe_yaml (~> 1.0.0)
|
24
|
+
diff-lcs (1.3)
|
25
|
+
hashdiff (0.3.7)
|
26
|
+
i18n (0.9.1)
|
27
|
+
concurrent-ruby (~> 1.0)
|
28
|
+
json (2.1.0)
|
29
|
+
mini_portile2 (2.3.0)
|
30
|
+
minitest (5.10.3)
|
31
|
+
net-http-report (0.1.0)
|
32
|
+
nokogiri (1.8.1)
|
33
|
+
mini_portile2 (~> 2.3.0)
|
34
|
+
parallel (1.12.0)
|
35
|
+
parser (2.4.0.2)
|
36
|
+
ast (~> 2.3)
|
37
|
+
powerpack (0.1.1)
|
38
|
+
public_suffix (3.0.1)
|
39
|
+
rainbow (2.2.2)
|
40
|
+
rake
|
41
|
+
rake (10.5.0)
|
42
|
+
rspec (3.7.0)
|
43
|
+
rspec-core (~> 3.7.0)
|
44
|
+
rspec-expectations (~> 3.7.0)
|
45
|
+
rspec-mocks (~> 3.7.0)
|
46
|
+
rspec-core (3.7.0)
|
47
|
+
rspec-support (~> 3.7.0)
|
48
|
+
rspec-expectations (3.7.0)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.7.0)
|
51
|
+
rspec-mocks (3.7.0)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.7.0)
|
54
|
+
rspec-support (3.7.0)
|
55
|
+
rubocop (0.51.0)
|
56
|
+
parallel (~> 1.10)
|
57
|
+
parser (>= 2.3.3.1, < 3.0)
|
58
|
+
powerpack (~> 0.1)
|
59
|
+
rainbow (>= 2.2.2, < 3.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
62
|
+
ruby-progressbar (1.9.0)
|
63
|
+
safe_yaml (1.0.4)
|
64
|
+
thread_safe (0.3.6)
|
65
|
+
tzinfo (1.2.4)
|
66
|
+
thread_safe (~> 0.1)
|
67
|
+
unicode-display_width (1.3.0)
|
68
|
+
vcr (3.0.3)
|
69
|
+
webmock (3.1.1)
|
70
|
+
addressable (>= 2.3.6)
|
71
|
+
crack (>= 0.3.2)
|
72
|
+
hashdiff
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
bundler (~> 1.16)
|
79
|
+
nextcloud!
|
80
|
+
rake (~> 10.0)
|
81
|
+
rspec (~> 3.0)
|
82
|
+
rubocop (~> 0.51)
|
83
|
+
vcr (~> 3.0)
|
84
|
+
webmock (~> 3.1)
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dachi Natsvlishvili
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,668 @@
|
|
1
|
+
[](https://rubygems.org/gems/nextcloud)
|
2
|
+
|
3
|
+
# Nextcloud Ruby API
|
4
|
+
|
5
|
+
Wrapper gem for Ruby used for communicating with Nextcloud OCS and WebDAV API endpoints.
|
6
|
+
|
7
|
+
This gem provides features for User provisioning, Group and App management, control of Shares and Federated Cloud
|
8
|
+
Shares, WebDAV functions for File / Folder creation, removal and other operations.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem "nextcloud"
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install nextcloud
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
#### Initialize with endpoint bundles
|
29
|
+
|
30
|
+
To initialize an OCS client you can look at following example
|
31
|
+
|
32
|
+
```
|
33
|
+
ocs = Nextcloud.ocs(
|
34
|
+
url: "https://cloud.yourdomain.com",
|
35
|
+
username: "your_username",
|
36
|
+
password: "your_password"
|
37
|
+
)
|
38
|
+
```
|
39
|
+
|
40
|
+
An URL has to be a base of your Nextcloud instance. For API requests, it will be parsed to
|
41
|
+
`https://cloud.yourdomain.com/ocs/v2.php/cloud/` or similar.
|
42
|
+
|
43
|
+
Once `ocs` is available you can use following methods to initiate specific classes:
|
44
|
+
|
45
|
+
`ocs.user`, `ocs.app`, `ocs.group`, `ocs.file_sharing`
|
46
|
+
|
47
|
+
If you intent to work with WebDAV api you can initialize a client with `webdav`:
|
48
|
+
|
49
|
+
```
|
50
|
+
webdav = Nextcloud.webdav(
|
51
|
+
url: "https://cloud.yourdomain.com",
|
52
|
+
username: "your_username",
|
53
|
+
password: "your_password"
|
54
|
+
)
|
55
|
+
```
|
56
|
+
|
57
|
+
#### Initialize specific APIs
|
58
|
+
|
59
|
+
Previously described method is recommended, however you can initialize in a differt manner.
|
60
|
+
|
61
|
+
Initialize OCS Users API:
|
62
|
+
|
63
|
+
```
|
64
|
+
user = Nextcloud::Ocs::User.new(url: "...", username: "...", password: "...")
|
65
|
+
```
|
66
|
+
|
67
|
+
Initialize OCS Groups API:
|
68
|
+
|
69
|
+
```
|
70
|
+
group = Nextcloud::Ocs::Group.new(url: "...", username: "...", password: "...")
|
71
|
+
```
|
72
|
+
|
73
|
+
Initialize OCS Apps API:
|
74
|
+
|
75
|
+
```
|
76
|
+
app = Nextcloud::Ocs::App.new(url: "...", username: "...", password: "...")
|
77
|
+
```
|
78
|
+
|
79
|
+
Initialize OCS File Sharing API:
|
80
|
+
|
81
|
+
```
|
82
|
+
file_sharing = Nextcloud::Ocs::FileSharingApi.new(url: "...", username: "...", password: "...")
|
83
|
+
```
|
84
|
+
|
85
|
+
Initialize WebDAV Directory API:
|
86
|
+
|
87
|
+
```
|
88
|
+
directory = Nextcloud::WebDav::Directory.new(url: "...", username: "...", password: "...")
|
89
|
+
```
|
90
|
+
|
91
|
+
> When initializing this way, to work with certain objects some circumstances might force you use `set` method.
|
92
|
+
> For example if you wish to list members of group admin, using first way you could simply write
|
93
|
+
`ocs.group('admin').members`, in this case you will need to use `group.set('admin').members`. There is another way to
|
94
|
+
set object of intereset by putting it into initialize arguments, like so
|
95
|
+
`Nextcloud::Ocs::Group.new({...credentials}, groupid: "admin")` it can be then reset with
|
96
|
+
`set`. Corressponding parameter names for other classes are `userid` and `appid`.
|
97
|
+
|
98
|
+
### *OCS Api usage*
|
99
|
+
|
100
|
+
These examples assume you have `Nextcloud.ocs` instance or relevant instance of
|
101
|
+
`Nextcloud::Ocs::{CLASS_NAME}.new` stored in `ocs` variable.
|
102
|
+
|
103
|
+
### User actions
|
104
|
+
|
105
|
+
#### Get list of users
|
106
|
+
|
107
|
+
```
|
108
|
+
users = ocs.user.all
|
109
|
+
# => [#<Nextcloud::Models::User:0x00000104d253c0 @id="your_user_1">, #<Nextcloud::Models::User:0x00000104d1f858 @id="your_user_2">]
|
110
|
+
|
111
|
+
last_user = user.last
|
112
|
+
=> #<Nextcloud::Models::User:0x000001042a2ba0 @id="your_user_2">
|
113
|
+
|
114
|
+
response_meta = users.meta
|
115
|
+
{"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
116
|
+
```
|
117
|
+
|
118
|
+
#### Get a single user
|
119
|
+
|
120
|
+
```
|
121
|
+
user = ocs.user.find("your_user_1")
|
122
|
+
# => #<Nextcloud::Models::User:0x00000103964020 @enabled="true", @id="your_user_1", ..., @meta={"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}>
|
123
|
+
```
|
124
|
+
|
125
|
+
Having `user` variable you have access to following attributes:
|
126
|
+
|
127
|
+
* enabled
|
128
|
+
* id
|
129
|
+
* quota
|
130
|
+
* email
|
131
|
+
* displayname
|
132
|
+
* phone
|
133
|
+
* address
|
134
|
+
* website
|
135
|
+
* twitter
|
136
|
+
* groups
|
137
|
+
* language
|
138
|
+
* meta
|
139
|
+
|
140
|
+
|
141
|
+
Again, here you can use `user.meta` to get service response status, code and message.
|
142
|
+
|
143
|
+
#### Create an user
|
144
|
+
|
145
|
+
```
|
146
|
+
meta = ocs.user.create("user3", "userPassword1!").meta
|
147
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
148
|
+
```
|
149
|
+
|
150
|
+
#### Update an user
|
151
|
+
|
152
|
+
You can update an user attributes with key-value method.
|
153
|
+
|
154
|
+
Valid keys include:
|
155
|
+
|
156
|
+
* quota
|
157
|
+
* displayname
|
158
|
+
* phone
|
159
|
+
* address
|
160
|
+
* website
|
161
|
+
* twitter
|
162
|
+
* password
|
163
|
+
|
164
|
+
```
|
165
|
+
meta = ocs.user.update("user3", "email", "new-address@some-domain.com").meta
|
166
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
167
|
+
```
|
168
|
+
|
169
|
+
#### Disable user
|
170
|
+
|
171
|
+
```
|
172
|
+
meta = ocs.user.disable("user3").meta
|
173
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
174
|
+
```
|
175
|
+
|
176
|
+
#### Enable user
|
177
|
+
|
178
|
+
```
|
179
|
+
meta = ocs.user.enable("user3").meta
|
180
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
181
|
+
```
|
182
|
+
|
183
|
+
#### Delete user
|
184
|
+
|
185
|
+
```
|
186
|
+
meta = ocs.user.destroy("user3").meta
|
187
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
188
|
+
```
|
189
|
+
|
190
|
+
#### Resend welcome email message
|
191
|
+
|
192
|
+
```
|
193
|
+
meta = ocs.user.resend_welcome("user3").meta
|
194
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
195
|
+
```
|
196
|
+
|
197
|
+
### User group actions
|
198
|
+
|
199
|
+
#### Get user groups
|
200
|
+
|
201
|
+
```
|
202
|
+
groups = ocs.user("user1").groups
|
203
|
+
# => ["admin"]
|
204
|
+
meta = groups.meta
|
205
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
206
|
+
```
|
207
|
+
|
208
|
+
if you work with initialized User class
|
209
|
+
|
210
|
+
```
|
211
|
+
user.set("user1").groups
|
212
|
+
```
|
213
|
+
|
214
|
+
#### Add user to group
|
215
|
+
|
216
|
+
```
|
217
|
+
meta = ocs.user("user4").group.create("admin").meta
|
218
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
219
|
+
```
|
220
|
+
|
221
|
+
if you work with initialized User class
|
222
|
+
|
223
|
+
```
|
224
|
+
user.set("user4").group.create("admin")
|
225
|
+
```
|
226
|
+
|
227
|
+
#### Remove user from group
|
228
|
+
|
229
|
+
```
|
230
|
+
meta = ocs.user("user4").group.destroy("admin").meta
|
231
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
232
|
+
```
|
233
|
+
|
234
|
+
if you work with initialized User class
|
235
|
+
|
236
|
+
```
|
237
|
+
user.set("user4").group.destroy("admin")
|
238
|
+
```
|
239
|
+
|
240
|
+
#### Promote user to group subadmin
|
241
|
+
|
242
|
+
```
|
243
|
+
meta = ocs.user("user4").group("group1").promote.meta
|
244
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
245
|
+
```
|
246
|
+
|
247
|
+
if you work with initialized User class
|
248
|
+
|
249
|
+
```
|
250
|
+
user.set("user4").group("group1").promote
|
251
|
+
```
|
252
|
+
|
253
|
+
#### Demote user from group subadmin
|
254
|
+
|
255
|
+
```
|
256
|
+
meta = ocs.user("user4").group("group1").demote.meta
|
257
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
258
|
+
```
|
259
|
+
|
260
|
+
if you work with initialized User class
|
261
|
+
|
262
|
+
```
|
263
|
+
user.set("user4").group("group1").demote
|
264
|
+
```
|
265
|
+
|
266
|
+
#### Get user subadmin groups
|
267
|
+
|
268
|
+
```
|
269
|
+
subadmin_groups = ocs.user("user4").subadmin_groups
|
270
|
+
# => ["group1"]
|
271
|
+
meta = subadmin_groups.meta
|
272
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
273
|
+
```
|
274
|
+
|
275
|
+
if you work with initialized User class
|
276
|
+
|
277
|
+
```
|
278
|
+
user.set("user4").subadmin_groups
|
279
|
+
```
|
280
|
+
|
281
|
+
### Group actions
|
282
|
+
|
283
|
+
#### Get all groups
|
284
|
+
|
285
|
+
```
|
286
|
+
groups = ocs.group.all
|
287
|
+
# => ["admin", "group1", "group2"]
|
288
|
+
meta = groups.meta
|
289
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
290
|
+
```
|
291
|
+
|
292
|
+
#### Search for a group
|
293
|
+
|
294
|
+
```
|
295
|
+
groups = ocs.group.search("admin")
|
296
|
+
# => ["admin"]
|
297
|
+
meta = groups.meta
|
298
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
299
|
+
```
|
300
|
+
|
301
|
+
#### Create a new group
|
302
|
+
|
303
|
+
```
|
304
|
+
meta = ocs.group.create("group3").meta
|
305
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
306
|
+
```
|
307
|
+
|
308
|
+
#### Get group members
|
309
|
+
|
310
|
+
```
|
311
|
+
members = ocs.group("admin").members
|
312
|
+
# => ["user1", "user2"]
|
313
|
+
meta = members.meta
|
314
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
315
|
+
```
|
316
|
+
|
317
|
+
if you work with initialized Group class
|
318
|
+
|
319
|
+
```
|
320
|
+
group.set("admin").members
|
321
|
+
```
|
322
|
+
|
323
|
+
#### Get group subadmins
|
324
|
+
|
325
|
+
```
|
326
|
+
members = ocs.group("group1").subadmins
|
327
|
+
# => ["user1", "user2", "user3"]
|
328
|
+
meta = members.meta
|
329
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
330
|
+
```
|
331
|
+
|
332
|
+
if you work with initialized Group class
|
333
|
+
|
334
|
+
```
|
335
|
+
group.set("group1").subadmins
|
336
|
+
```
|
337
|
+
|
338
|
+
#### Delete a group
|
339
|
+
|
340
|
+
```
|
341
|
+
meta = ocs.group.destroy("group3").meta
|
342
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
343
|
+
```
|
344
|
+
|
345
|
+
### App actions
|
346
|
+
|
347
|
+
#### Get enabled applications
|
348
|
+
|
349
|
+
```
|
350
|
+
enabled = ocs.app.enabled
|
351
|
+
# => [...]
|
352
|
+
meta = enabled.meta
|
353
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
354
|
+
```
|
355
|
+
|
356
|
+
#### Get disabled applications
|
357
|
+
|
358
|
+
```
|
359
|
+
disabled = ocs.app.disabled
|
360
|
+
# => [...]
|
361
|
+
meta = disabled.meta
|
362
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
363
|
+
```
|
364
|
+
|
365
|
+
#### Get application information
|
366
|
+
|
367
|
+
```
|
368
|
+
app = ocs.app.find("appname")
|
369
|
+
# => {...}
|
370
|
+
meta = app.meta
|
371
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
372
|
+
```
|
373
|
+
|
374
|
+
#### Enable application
|
375
|
+
|
376
|
+
```
|
377
|
+
meta = ocs.app("appname").enable.meta
|
378
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
379
|
+
```
|
380
|
+
|
381
|
+
if you work with initialized App class
|
382
|
+
|
383
|
+
```
|
384
|
+
app.set("appname").enable
|
385
|
+
```
|
386
|
+
|
387
|
+
#### Disable application
|
388
|
+
|
389
|
+
```
|
390
|
+
meta = ocs.app("appname").disable.meta
|
391
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
392
|
+
```
|
393
|
+
|
394
|
+
if you work with initialized App class
|
395
|
+
|
396
|
+
```
|
397
|
+
app.set("appname").disable
|
398
|
+
```
|
399
|
+
|
400
|
+
### FileSharing API
|
401
|
+
|
402
|
+
#### Initialize with authentication information
|
403
|
+
|
404
|
+
First of all you need to initiate a class with authentication information of user
|
405
|
+
|
406
|
+
```
|
407
|
+
ocs_fs = Nextcloud::Ocs::FileSharingApi.new(
|
408
|
+
url: "https://cloud.yourdomain.com",
|
409
|
+
username: "your_username",
|
410
|
+
password: "your_password"
|
411
|
+
)
|
412
|
+
```
|
413
|
+
|
414
|
+
An URL has to be a base of your Nextcloud instance. For Sharing API requests, it will be parsed to
|
415
|
+
`https://cloud.yourdomain.com/ocs/v2.php/apps/files_sharing/api/v1/`
|
416
|
+
|
417
|
+
> You can also initialize with `Nextcloud.ocs(...credentials).file_sharing`
|
418
|
+
|
419
|
+
#### Retrieve all shares of an (authenticated) user
|
420
|
+
|
421
|
+
```
|
422
|
+
all_shares = ocs_fs.all
|
423
|
+
# => [{...}, {...}]
|
424
|
+
meta = all_shares.meta
|
425
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
426
|
+
```
|
427
|
+
|
428
|
+
#### Retrieve a single share
|
429
|
+
|
430
|
+
```
|
431
|
+
share = ocs_fs.find(11)
|
432
|
+
# => {"id" => "22", "shareType" => "0", ...}
|
433
|
+
meta = share.meta
|
434
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
435
|
+
```
|
436
|
+
|
437
|
+
#### Retrive shares from specific file or folder
|
438
|
+
|
439
|
+
Can be called with two optional paremeters
|
440
|
+
* reshares - boolean - shows all shares for a given file
|
441
|
+
* subfiles - boolean - shows all shares for subfiles in a directory
|
442
|
+
|
443
|
+
```
|
444
|
+
# shares from file.txt
|
445
|
+
file_shares = ocs_fs.specific("file.txt")
|
446
|
+
|
447
|
+
# shares from /dir1
|
448
|
+
dir_shares = ocs_fs.specific("/dir1")
|
449
|
+
|
450
|
+
# not only the shares from the current user but all shares from the given file
|
451
|
+
reshares = ocs_fs.specific("file1.txt", true)
|
452
|
+
|
453
|
+
# all shares within a folder, given that path defines a folder
|
454
|
+
subfiles = ocs_fs.specific("/dir1", ture, true)
|
455
|
+
|
456
|
+
# Attached variables will also have .meta method with server response information
|
457
|
+
```
|
458
|
+
|
459
|
+
#### Create a share
|
460
|
+
|
461
|
+
First argument is a `path` (required) to a file or a folder
|
462
|
+
|
463
|
+
`shareType` (required) has to be an integer
|
464
|
+
|
465
|
+
* 0 = user
|
466
|
+
* 1 = group
|
467
|
+
* 3 = public link
|
468
|
+
* 6 = federated cloud share
|
469
|
+
|
470
|
+
`shareWith` is only reqired if `shareType` is `0` or `1`, defines user or group file will be shared with
|
471
|
+
|
472
|
+
`publicUpload` is boolean, allows public uploads in a directory (Visitors will be able to upload to public directory
|
473
|
+
shared with link)
|
474
|
+
|
475
|
+
`password` to protect shared links with
|
476
|
+
|
477
|
+
`permissions` has to be an integer (default: 31, for public shares: 1)
|
478
|
+
|
479
|
+
* 1 = read
|
480
|
+
* 2 = update
|
481
|
+
* 4 = create
|
482
|
+
* 8 = delete
|
483
|
+
* 16 = share
|
484
|
+
* 31 = all
|
485
|
+
|
486
|
+
```
|
487
|
+
# share file.txt with user user1
|
488
|
+
ocs_fs.create("file.txt", 0, "user1").meta
|
489
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
490
|
+
|
491
|
+
# share file1.txt with public link and assign password to it
|
492
|
+
ocs_fs.create("file1.txt", 3, nil, nil, "password1P/")
|
493
|
+
```
|
494
|
+
|
495
|
+
#### Delete a share
|
496
|
+
|
497
|
+
```
|
498
|
+
delete = ocs_fs.destroy("21").meta
|
499
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
500
|
+
```
|
501
|
+
|
502
|
+
#### Update a share
|
503
|
+
|
504
|
+
For details about permissions see "Create a share" section
|
505
|
+
|
506
|
+
Expiration date should be in "YYYY-MM-DD" format
|
507
|
+
|
508
|
+
```
|
509
|
+
# makes a share read-only
|
510
|
+
ocs_fs.update_permissions(21, 1)
|
511
|
+
|
512
|
+
# updates password
|
513
|
+
ocs_fs.update_password(21, "newPassword!0")
|
514
|
+
|
515
|
+
# allows public uploads
|
516
|
+
ocs_fs.update_public_upload(21, true)
|
517
|
+
|
518
|
+
# change expiration date
|
519
|
+
ocs_fs.update_expire_date(21, "2017-11-22")
|
520
|
+
|
521
|
+
# These methods will also have .meta method with server response information
|
522
|
+
```
|
523
|
+
|
524
|
+
### Federated Cloud Shares
|
525
|
+
|
526
|
+
To create a federated cloud shares you can use `create` method on `FileSharingApi` (see previous section)
|
527
|
+
|
528
|
+
#### List accepted federated shares
|
529
|
+
|
530
|
+
```
|
531
|
+
accepted = ocs_fs.federated.accepted
|
532
|
+
# => [{...}, {...}]
|
533
|
+
meta = accepted.meta
|
534
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
535
|
+
```
|
536
|
+
|
537
|
+
#### List pending federated shares
|
538
|
+
|
539
|
+
```
|
540
|
+
pending = ocs_fs.federated.pending
|
541
|
+
# => [{...}, {...}]
|
542
|
+
meta = pending.meta
|
543
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
544
|
+
```
|
545
|
+
|
546
|
+
#### Info about federated share (accepted)
|
547
|
+
|
548
|
+
```
|
549
|
+
federated_share = ocs_fs.federated.find(12)
|
550
|
+
# => {"id"=>"12", "remote"=>"https://...", ...}
|
551
|
+
meta = federated_share.meta
|
552
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
553
|
+
```
|
554
|
+
|
555
|
+
#### Delete accepted federated share
|
556
|
+
|
557
|
+
```
|
558
|
+
meta = ocs_fs.federated.destroy(12)
|
559
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
560
|
+
```
|
561
|
+
|
562
|
+
#### Accept federated share
|
563
|
+
|
564
|
+
```
|
565
|
+
meta = ocs_fs.federated.accept(13)
|
566
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
567
|
+
```
|
568
|
+
|
569
|
+
#### Decline federated share
|
570
|
+
|
571
|
+
```
|
572
|
+
meta = ocs_fs.federated.decline(13)
|
573
|
+
# => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
|
574
|
+
```
|
575
|
+
|
576
|
+
#### *WebDAV Api usage*
|
577
|
+
|
578
|
+
In these examples `webdav` variable is assumed to be a valid instance of
|
579
|
+
`Nextcloud.webdav` or `Nextcloud::Webdav::{CLASS_NAME}.new`
|
580
|
+
|
581
|
+
#### File/Directory Operations
|
582
|
+
|
583
|
+
Let's assume
|
584
|
+
|
585
|
+
### Find files/directories in given path
|
586
|
+
|
587
|
+
```
|
588
|
+
directory = webdav.directory.find("dir1/")
|
589
|
+
```
|
590
|
+
|
591
|
+
Will return instance of `Directory` model with information about current directory, it's method `contents` will contain
|
592
|
+
array of resutls:
|
593
|
+
|
594
|
+
```
|
595
|
+
directory.contents
|
596
|
+
```
|
597
|
+
|
598
|
+
### Query information about file
|
599
|
+
|
600
|
+
```
|
601
|
+
file = webdav.directory.find("some_file.txt")
|
602
|
+
```
|
603
|
+
|
604
|
+
### Create a directory
|
605
|
+
|
606
|
+
```
|
607
|
+
webdav.directory.create("some_dir/new_dir")
|
608
|
+
```
|
609
|
+
|
610
|
+
### Delete a directory
|
611
|
+
|
612
|
+
```
|
613
|
+
webdav.directory.destroy("some_dir")
|
614
|
+
```
|
615
|
+
|
616
|
+
### Move a directory
|
617
|
+
|
618
|
+
```
|
619
|
+
webdav.directory.move("source_dir/", "destination_dir/")
|
620
|
+
```
|
621
|
+
|
622
|
+
### Copy a directory
|
623
|
+
|
624
|
+
```
|
625
|
+
webdav.directory.copy("source_dir/", "destination_dir/)
|
626
|
+
```
|
627
|
+
|
628
|
+
### Download a file
|
629
|
+
|
630
|
+
```
|
631
|
+
webdav.directory.download("some_file.txt")
|
632
|
+
```
|
633
|
+
|
634
|
+
### Upload a file
|
635
|
+
|
636
|
+
```
|
637
|
+
webdav.directory.upload("some_dir/new_file.txt", "CONTENTS")
|
638
|
+
```
|
639
|
+
|
640
|
+
### Make a file favorite
|
641
|
+
|
642
|
+
```
|
643
|
+
webdav.directory.favorite("some_file")
|
644
|
+
```
|
645
|
+
|
646
|
+
### Unfavorite a file
|
647
|
+
|
648
|
+
```
|
649
|
+
webdav.directory.unfavorite("some_file")
|
650
|
+
```
|
651
|
+
|
652
|
+
### Show favorite files in path
|
653
|
+
|
654
|
+
```
|
655
|
+
webdav.directory.favorites("/")
|
656
|
+
```
|
657
|
+
|
658
|
+
## Contributing
|
659
|
+
|
660
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dachinat/nextcloud. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
661
|
+
|
662
|
+
## License
|
663
|
+
|
664
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
665
|
+
|
666
|
+
## Code of Conduct
|
667
|
+
|
668
|
+
Everyone interacting in the Nextcloud gem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dachinat/nextcloud/blob/master/CODE_OF_CONDUCT.md).
|