yandex360 1.1.2 → 1.1.4
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 +4 -4
- data/.github/changelog_config.json +47 -0
- data/.github/dependabot.yml +7 -5
- data/.github/markdown-link-check.json +38 -0
- data/.github/workflows/ci.yml +150 -43
- data/.github/workflows/codeql.yml +84 -0
- data/.github/workflows/dependency-updates.yml +72 -0
- data/.github/workflows/docs.yml +73 -0
- data/.github/workflows/health-check.yml +80 -0
- data/.github/workflows/release.yml +52 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +14 -2
- data/CHANGELOG.md +76 -0
- data/Gemfile.lock +65 -57
- data/README.md +49 -3
- data/Rakefile +4 -7
- data/lib/yandex360/client.rb +38 -3
- data/lib/yandex360/collection.rb +31 -3
- data/lib/yandex360/error.rb +18 -0
- data/lib/yandex360/object.rb +5 -3
- data/lib/yandex360/objects/types.rb +7 -0
- data/lib/yandex360/param_builder.rb +13 -0
- data/lib/yandex360/resource.rb +59 -16
- data/lib/yandex360/resources/antispam.rb +12 -3
- data/lib/yandex360/resources/audit.rb +17 -0
- data/lib/yandex360/resources/departments.rb +36 -24
- data/lib/yandex360/resources/dns.rb +30 -0
- data/lib/yandex360/resources/domains.rb +34 -0
- data/lib/yandex360/resources/groups.rb +27 -14
- data/lib/yandex360/resources/organizations.rb +15 -0
- data/lib/yandex360/resources/post_settings.rb +35 -0
- data/lib/yandex360/resources/two_fa.rb +31 -0
- data/lib/yandex360/resources/users.rb +31 -13
- data/lib/yandex360/version.rb +1 -4
- data/lib/yandex360.rb +23 -0
- data/yandex360.gemspec +8 -5
- metadata +76 -33
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -38,7 +38,6 @@ Style/OptionHash:
|
|
38
38
|
- options
|
39
39
|
- opts
|
40
40
|
- args
|
41
|
-
- paramsgit sttus
|
42
41
|
- parameters
|
43
42
|
|
44
43
|
# Mixing the styles looks just silly.
|
@@ -139,4 +138,17 @@ Lint/Debugger:
|
|
139
138
|
|
140
139
|
# Style preference
|
141
140
|
Style/MethodDefParentheses:
|
142
|
-
Enabled: false
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
# Allow longer blocks in specs and configuration files
|
144
|
+
Metrics/BlockLength:
|
145
|
+
Exclude:
|
146
|
+
- 'spec/**/*'
|
147
|
+
- 'test/**/*'
|
148
|
+
- 'Rakefile'
|
149
|
+
- '**/*.rake'
|
150
|
+
|
151
|
+
# Allow longer modules in test support files due to mock data
|
152
|
+
Metrics/ModuleLength:
|
153
|
+
Exclude:
|
154
|
+
- 'spec/support/**/*'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
## 🧹 Maintenance
|
2
|
+
|
3
|
+
- build(deps): update faraday requirement from ~> 1.7 to >= 1.7, < 3.0 by @dependabot[bot] in #8
|
4
|
+
- build(deps-dev): update simplecov-lcov requirement from ~> 0.7.0 to ~> 0.8.0 by @dependabot[bot] in #5
|
5
|
+
- build(deps-dev): bump rspec from 3.11.0 to 3.12.0 by @dependabot[bot] in #6
|
6
|
+
- build(deps-dev): update rake requirement from ~> 12.3.3 to ~> 13.0.6 by @dependabot[bot] in #3
|
7
|
+
- build(deps): bump coverallsapp/github-action from 1.1.3 to 2.1.0 by @dependabot[bot] in #7
|
8
|
+
- build(deps): bump coverallsapp/github-action from 2.1.0 to 2.1.2 by @dependabot[bot] in #12
|
9
|
+
- build(deps): bump faraday from 2.7.4 to 2.7.5 by @dependabot[bot] in #13
|
10
|
+
- build(deps): bump coverallsapp/github-action from 2.1.2 to 2.2.0 by @dependabot[bot] in #15
|
11
|
+
- build(deps): bump faraday from 2.7.5 to 2.7.7 by @dependabot[bot] in #16
|
12
|
+
- build(deps): bump faraday from 2.7.7 to 2.7.10 by @dependabot[bot] in #19
|
13
|
+
- build(deps): bump coverallsapp/github-action from 2.2.0 to 2.2.1 by @dependabot[bot] in #20
|
14
|
+
- build(deps): bump coverallsapp/github-action from 2.2.1 to 2.2.3 by @dependabot[bot] in #25
|
15
|
+
- build(deps): bump faraday from 2.7.10 to 2.7.11 by @dependabot[bot] in #26
|
16
|
+
- build(deps): bump actions/checkout from 3 to 4 by @dependabot[bot] in #24
|
17
|
+
- build(deps-dev): bump webmock from 3.18.1 to 3.19.1 by @dependabot[bot] in #22
|
18
|
+
- build(deps-dev): update rake requirement from ~> 13.0.6 to ~> 13.1.0 by @dependabot[bot] in #27
|
19
|
+
- build(deps): bump faraday from 2.7.11 to 2.7.12 by @dependabot[bot] in #28
|
20
|
+
- build(deps-dev): bump simplecov from 0.21.2 to 0.22.0 by @dependabot[bot] in #4
|
21
|
+
- build(deps): bump faraday from 2.7.12 to 2.8.1 by @dependabot[bot] in #30
|
22
|
+
- build(deps): bump ruby/setup-ruby from 1.165.1 to 1.175.1 by @dependabot[bot] in #42
|
23
|
+
- build(deps): bump ruby/setup-ruby from 1.175.1 to 1.176.0 by @dependabot[bot] in #43
|
24
|
+
- build(deps-dev): bump rspec from 3.12.0 to 3.13.0 by @dependabot[bot] in #34
|
25
|
+
- build(deps-dev): bump webmock from 3.19.1 to 3.23.0 by @dependabot[bot] in #38
|
26
|
+
- build(deps): bump coverallsapp/github-action from 2.2.3 to 2.3.0 by @dependabot[bot] in #45
|
27
|
+
- build(deps-dev): bump rexml from 3.2.6 to 3.2.8 by @dependabot[bot] in #46
|
28
|
+
- build(deps-dev): update rake requirement from ~> 13.1.0 to ~> 13.2.1 by @dependabot[bot] in #47
|
29
|
+
- build(deps): bump ruby/setup-ruby from 1.176.0 to 1.177.0 by @dependabot[bot] in #48
|
30
|
+
- build(deps-dev): bump webmock from 3.23.0 to 3.23.1 by @dependabot[bot] in #49
|
31
|
+
- build(deps): bump ruby/setup-ruby from 1.177.0 to 1.177.1 by @dependabot[bot] in #50
|
32
|
+
- build(deps): bump ruby/setup-ruby from 1.177.1 to 1.179.0 by @dependabot[bot] in #51
|
33
|
+
- build(deps): bump ruby/setup-ruby from 1.179.0 to 1.180.1 by @dependabot[bot] in #53
|
34
|
+
- build(deps): bump ruby/setup-ruby from 1.180.1 to 1.185.0 by @dependabot[bot] in #55
|
35
|
+
- build(deps): bump ruby/setup-ruby from 1.185.0 to 1.187.0 by @dependabot[bot] in #56
|
36
|
+
- build(deps): bump ruby/setup-ruby from 1.187.0 to 1.188.0 by @dependabot[bot] in #57
|
37
|
+
- build(deps-dev): bump rexml from 3.2.8 to 3.3.2 by @dependabot[bot] in #58
|
38
|
+
- build(deps): bump ruby/setup-ruby from 1.188.0 to 1.190.0 by @dependabot[bot] in #59
|
39
|
+
- build(deps-dev): bump rexml from 3.3.2 to 3.3.6 by @dependabot[bot] in #60
|
40
|
+
- build(deps): bump ruby/setup-ruby from 1.190.0 to 1.191.0 by @dependabot[bot] in #61
|
41
|
+
- build(deps): bump ruby/setup-ruby from 1.191.0 to 1.192.0 by @dependabot[bot] in #62
|
42
|
+
- build(deps): bump ruby/setup-ruby from 1.192.0 to 1.193.0 by @dependabot[bot] in #63
|
43
|
+
- build(deps): bump ruby/setup-ruby from 1.193.0 to 1.194.0 by @dependabot[bot] in #64
|
44
|
+
- build(deps): bump ruby/setup-ruby from 1.194.0 to 1.196.0 by @dependabot[bot] in #65
|
45
|
+
- build(deps): bump ruby/setup-ruby from 1.196.0 to 1.199.0 by @dependabot[bot] in #72
|
46
|
+
- build(deps-dev): bump webmock from 3.23.1 to 3.24.0 by @dependabot[bot] in #71
|
47
|
+
- build(deps-dev): bump rexml from 3.3.6 to 3.3.9 by @dependabot[bot] in #69
|
48
|
+
- build(deps): bump coverallsapp/github-action from 2.3.0 to 2.3.4 by @dependabot[bot] in #70
|
49
|
+
- build(deps): bump ruby/setup-ruby from 1.199.0 to 1.202.0 by @dependabot[bot] in #73
|
50
|
+
- build(deps): bump ruby/setup-ruby from 1.202.0 to 1.203.0 by @dependabot[bot] in #74
|
51
|
+
- build(deps): bump ruby/setup-ruby from 1.203.0 to 1.204.0 by @dependabot[bot] in #75
|
52
|
+
- build(deps): bump ruby/setup-ruby from 1.204.0 to 1.205.0 by @dependabot[bot] in #76
|
53
|
+
- build(deps): bump ruby/setup-ruby from 1.205.0 to 1.206.0 by @dependabot[bot] in #77
|
54
|
+
- build(deps): bump ruby/setup-ruby from 1.206.0 to 1.207.0 by @dependabot[bot] in #78
|
55
|
+
- build(deps): bump ruby/setup-ruby from 1.207.0 to 1.213.0 by @dependabot[bot] in #79
|
56
|
+
- build(deps): bump coverallsapp/github-action from 2.3.4 to 2.3.6 by @dependabot[bot] in #81
|
57
|
+
- build(deps): bump ruby/setup-ruby from 1.213.0 to 1.214.0 by @dependabot[bot] in #80
|
58
|
+
- build(deps): bump ruby/setup-ruby from 1.214.0 to 1.215.0 by @dependabot[bot] in #82
|
59
|
+
- build(deps): bump ruby/setup-ruby from 1.215.0 to 1.218.0 by @dependabot[bot] in #83
|
60
|
+
- build(deps): bump ruby/setup-ruby from 1.218.0 to 1.221.0 by @dependabot[bot] in #84
|
61
|
+
- build(deps): bump ruby/setup-ruby from 1.221.0 to 1.222.0 by @dependabot[bot] in #85
|
62
|
+
- build(deps): bump ruby/setup-ruby from 1.222.0 to 1.226.0 by @dependabot[bot] in #86
|
63
|
+
- build(deps): bump ruby/setup-ruby from 1.226.0 to 1.227.0 by @dependabot[bot] in #87
|
64
|
+
- build(deps): bump ruby/setup-ruby from 1.227.0 to 1.229.0 by @dependabot[bot] in #88
|
65
|
+
- build(deps): bump ruby/setup-ruby from 1.229.0 to 1.237.0 by @dependabot[bot] in #92
|
66
|
+
- build(deps): bump ruby/setup-ruby from 1.237.0 to 1.242.0 by @dependabot[bot] in #94
|
67
|
+
- build(deps): bump ruby/setup-ruby from 1.242.0 to 1.245.0 by @dependabot[bot] in #96
|
68
|
+
- build(deps): bump ruby/setup-ruby from 1.245.0 to 1.247.0 by @dependabot[bot] in #97
|
69
|
+
- build(deps): bump actions/checkout from 4 to 5 by @dependabot[bot] in #99
|
70
|
+
- build(deps): bump ruby/setup-ruby from 1.247.0 to 1.256.0 by @dependabot[bot] in #101
|
71
|
+
- build(deps): bump ruby/setup-ruby from 1.256.0 to 1.257.0 by @dependabot[bot] in #102
|
72
|
+
- build(deps-dev): update rake requirement from ~> 13.2.1 to ~> 13.3.0 by @dependabot[bot] in #107
|
73
|
+
- build(deps-dev): bump webmock from 3.24.0 to 3.25.1 by @dependabot[bot] in #106
|
74
|
+
- build(deps-dev): bump rspec from 3.13.0 to 3.13.1 by @dependabot[bot] in #105
|
75
|
+
- build(deps-dev): update simplecov-lcov requirement from ~> 0.8.0 to ~> 0.9.0 by @dependabot[bot] in #104
|
76
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,85 +1,93 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yandex360 (1.1.
|
5
|
-
faraday (
|
4
|
+
yandex360 (1.1.4)
|
5
|
+
faraday (>= 1.7, < 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
rexml
|
14
|
-
diff-lcs (1.5.0)
|
10
|
+
ast (2.4.3)
|
11
|
+
base64 (0.2.0)
|
12
|
+
diff-lcs (1.6.2)
|
15
13
|
docile (1.4.0)
|
16
|
-
faraday (
|
17
|
-
|
18
|
-
faraday-
|
19
|
-
faraday-excon (~> 1.1)
|
20
|
-
faraday-httpclient (~> 1.0)
|
21
|
-
faraday-multipart (~> 1.0)
|
22
|
-
faraday-net_http (~> 1.0)
|
23
|
-
faraday-net_http_persistent (~> 1.0)
|
24
|
-
faraday-patron (~> 1.0)
|
25
|
-
faraday-rack (~> 1.0)
|
26
|
-
faraday-retry (~> 1.0)
|
14
|
+
faraday (2.8.1)
|
15
|
+
base64
|
16
|
+
faraday-net_http (>= 2.0, < 3.1)
|
27
17
|
ruby2_keywords (>= 0.0.4)
|
28
|
-
faraday-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
rake (
|
43
|
-
|
44
|
-
rspec (3.
|
45
|
-
rspec-core (~> 3.
|
46
|
-
rspec-expectations (~> 3.
|
47
|
-
rspec-mocks (~> 3.
|
48
|
-
rspec-core (3.
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-expectations (3.
|
18
|
+
faraday-net_http (3.0.2)
|
19
|
+
fiddle (1.1.6)
|
20
|
+
json (2.14.1)
|
21
|
+
language_server-protocol (3.17.0.5)
|
22
|
+
lint_roller (1.1.0)
|
23
|
+
logger (1.6.4)
|
24
|
+
ostruct (0.6.1)
|
25
|
+
parallel (1.27.0)
|
26
|
+
parser (3.3.9.0)
|
27
|
+
ast (~> 2.4.1)
|
28
|
+
racc
|
29
|
+
prism (1.5.1)
|
30
|
+
racc (1.8.1)
|
31
|
+
rainbow (3.1.1)
|
32
|
+
rake (13.3.0)
|
33
|
+
regexp_parser (2.11.3)
|
34
|
+
rspec (3.13.1)
|
35
|
+
rspec-core (~> 3.13.0)
|
36
|
+
rspec-expectations (~> 3.13.0)
|
37
|
+
rspec-mocks (~> 3.13.0)
|
38
|
+
rspec-core (3.13.5)
|
39
|
+
rspec-support (~> 3.13.0)
|
40
|
+
rspec-expectations (3.13.5)
|
51
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.
|
53
|
-
rspec-mocks (3.
|
42
|
+
rspec-support (~> 3.13.0)
|
43
|
+
rspec-mocks (3.13.5)
|
54
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
-
rspec-support (~> 3.
|
56
|
-
rspec-support (3.
|
45
|
+
rspec-support (~> 3.13.0)
|
46
|
+
rspec-support (3.13.6)
|
47
|
+
rubocop (1.80.2)
|
48
|
+
json (~> 2.3)
|
49
|
+
language_server-protocol (~> 3.17.0.2)
|
50
|
+
lint_roller (~> 1.1.0)
|
51
|
+
parallel (~> 1.10)
|
52
|
+
parser (>= 3.3.0.2)
|
53
|
+
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
55
|
+
rubocop-ast (>= 1.46.0, < 2.0)
|
56
|
+
ruby-progressbar (~> 1.7)
|
57
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
58
|
+
rubocop-ast (1.46.0)
|
59
|
+
parser (>= 3.3.7.2)
|
60
|
+
prism (~> 1.4)
|
61
|
+
ruby-progressbar (1.13.0)
|
57
62
|
ruby2_keywords (0.0.5)
|
58
|
-
simplecov (0.
|
63
|
+
simplecov (0.22.0)
|
59
64
|
docile (~> 1.1)
|
60
65
|
simplecov-html (~> 0.11)
|
61
66
|
simplecov_json_formatter (~> 0.1)
|
62
67
|
simplecov-html (0.12.3)
|
63
|
-
simplecov-lcov (0.
|
68
|
+
simplecov-lcov (0.9.0)
|
64
69
|
simplecov_json_formatter (0.1.4)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
crack (>= 0.3.2)
|
69
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
70
|
+
unicode-display_width (3.2.0)
|
71
|
+
unicode-emoji (~> 4.1)
|
72
|
+
unicode-emoji (4.1.0)
|
70
73
|
|
71
74
|
PLATFORMS
|
75
|
+
arm64-darwin-23
|
76
|
+
x64-mingw-ucrt
|
72
77
|
x86_64-darwin-17
|
78
|
+
x86_64-linux
|
73
79
|
|
74
80
|
DEPENDENCIES
|
75
81
|
bundler
|
76
|
-
|
82
|
+
fiddle (~> 1.0)
|
83
|
+
logger (~> 1.4)
|
84
|
+
ostruct (~> 0.5)
|
85
|
+
rake (~> 13.3.0)
|
77
86
|
rspec (~> 3.0)
|
87
|
+
rubocop (~> 1.60)
|
78
88
|
simplecov (~> 0.9)
|
79
|
-
simplecov-lcov (~> 0.
|
80
|
-
vcr (~> 6.1)
|
81
|
-
webmock (~> 3.18, >= 3.18.1)
|
89
|
+
simplecov-lcov (~> 0.9.0)
|
82
90
|
yandex360!
|
83
91
|
|
84
92
|
BUNDLED WITH
|
85
|
-
2.
|
93
|
+
2.6.9
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
### Gemfile
|
12
12
|
|
13
13
|
```gemfile
|
14
|
-
gem 'yandex360', '~> 1.1', '>= 1.1.
|
14
|
+
gem 'yandex360', '~> 1.1', '>= 1.1.4'
|
15
15
|
```
|
16
16
|
|
17
17
|
### Install
|
@@ -25,14 +25,59 @@ gem install yandex360
|
|
25
25
|
```ruby
|
26
26
|
require "yandex360"
|
27
27
|
|
28
|
-
|
28
|
+
client = Yandex360::Client.new(token: "paste your access_token here")
|
29
29
|
|
30
|
-
|
30
|
+
# List organizations
|
31
|
+
organizations = client.organizations.list
|
32
|
+
|
33
|
+
# List users in an organization
|
34
|
+
users = client.users.list(org_id: 1234567)
|
35
|
+
|
36
|
+
# Get organization domains
|
37
|
+
domains = client.domains.list(org_id: 1234567)
|
38
|
+
|
39
|
+
# Check 2FA status for a user
|
40
|
+
two_fa_status = client.two_fa.status(org_id: 1234567, user_id: 987654321)
|
31
41
|
```
|
32
42
|
|
33
43
|
## Available methods
|
34
44
|
|
35
45
|
```ruby
|
46
|
+
# Organizations
|
47
|
+
organizations.list()
|
48
|
+
organizations.info(org_id:)
|
49
|
+
|
50
|
+
# Domains
|
51
|
+
domains.list(org_id:)
|
52
|
+
domains.add(org_id:, name:, **params)
|
53
|
+
domains.info(org_id:, domain:)
|
54
|
+
domains.delete(org_id:, domain:)
|
55
|
+
domains.verify(org_id:, domain:)
|
56
|
+
|
57
|
+
# DNS
|
58
|
+
dns.list(org_id:, domain:)
|
59
|
+
dns.create(org_id:, domain:, **params)
|
60
|
+
dns.update(org_id:, domain:, record_id:, **params)
|
61
|
+
dns.delete(org_id:, domain:, record_id:)
|
62
|
+
|
63
|
+
# Two-Factor Authentication
|
64
|
+
two_fa.enable(org_id:, user_id:)
|
65
|
+
two_fa.disable(org_id:, user_id:)
|
66
|
+
two_fa.status(org_id:, user_id:)
|
67
|
+
two_fa.domain_status(org_id:)
|
68
|
+
two_fa.configure_domain(org_id:, enabled:)
|
69
|
+
|
70
|
+
# Audit
|
71
|
+
audit.list(org_id:, page: 1, per_page: 100, **params)
|
72
|
+
audit.export(org_id:, **params)
|
73
|
+
|
74
|
+
# Post Settings
|
75
|
+
post_settings.list(org_id:, user_id:)
|
76
|
+
post_settings.update(org_id:, user_id:, **params)
|
77
|
+
post_settings.forwarding_list(org_id:, user_id:)
|
78
|
+
post_settings.add_forwarding(org_id:, user_id:, address:)
|
79
|
+
post_settings.delete_forwarding(org_id:, user_id:, address:)
|
80
|
+
|
36
81
|
# Antispam
|
37
82
|
antispam.list(org_id:)
|
38
83
|
antispam.create(org_id, *strings)
|
@@ -47,6 +92,7 @@ users.list(org_id:, page: 1, per_page: 10)
|
|
47
92
|
users.get2FA(org_id:, user_id:)
|
48
93
|
users.has2FA?(org_id:, user_id:)
|
49
94
|
users.delete_alias(org_id:, user_id:, user_alias:)
|
95
|
+
users.delete(org_id:, user_id:)
|
50
96
|
|
51
97
|
# Departments
|
52
98
|
departments.add_alias(org_id:, dep_id:, name:)
|
data/Rakefile
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
-
require "
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
|
6
|
-
|
7
|
-
t.libs << "test"
|
8
|
-
t.libs << "lib"
|
9
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
-
end
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
7
|
|
12
|
-
task default: :
|
8
|
+
task default: :spec
|
9
|
+
task test: :spec
|
13
10
|
|
14
11
|
task :console do
|
15
12
|
exec "irb -I lib -r yandex360.rb"
|
data/lib/yandex360/client.rb
CHANGED
@@ -6,11 +6,12 @@ module Yandex360
|
|
6
6
|
|
7
7
|
attr_reader :token, :adapter
|
8
8
|
|
9
|
-
# new client
|
10
9
|
def initialize(token:, adapter: Faraday.default_adapter, stubs: nil)
|
10
|
+
raise ArgumentError, "Token cannot be nil or empty" if token.nil? || token.to_s.strip.empty?
|
11
|
+
|
11
12
|
@token = token
|
12
13
|
@adapter = adapter
|
13
|
-
@stubs = stubs
|
14
|
+
@stubs = stubs
|
14
15
|
end
|
15
16
|
|
16
17
|
def antispam
|
@@ -29,8 +30,42 @@ module Yandex360
|
|
29
30
|
UsersResource.new(self)
|
30
31
|
end
|
31
32
|
|
33
|
+
def organizations
|
34
|
+
OrganizationsResource.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
def domains
|
38
|
+
DomainsResource.new(self)
|
39
|
+
end
|
40
|
+
|
41
|
+
def dns
|
42
|
+
DnsResource.new(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def two_fa
|
46
|
+
TwoFaResource.new(self)
|
47
|
+
end
|
48
|
+
|
49
|
+
def audit
|
50
|
+
AuditResource.new(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
def post_settings
|
54
|
+
PostSettingsResource.new(self)
|
55
|
+
end
|
56
|
+
|
32
57
|
def connection
|
33
|
-
@connection ||=
|
58
|
+
@connection ||= build_connection
|
59
|
+
end
|
60
|
+
|
61
|
+
def inspect
|
62
|
+
"#<#{self.class.name}:#{object_id} token=***>"
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def build_connection
|
68
|
+
Faraday.new(BASE_URL) do |conn|
|
34
69
|
conn.request :authorization, :OAuth, token
|
35
70
|
conn.request :json
|
36
71
|
conn.request :url_encoded
|
data/lib/yandex360/collection.rb
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
module Yandex360
|
4
4
|
class Collection
|
5
|
+
include Enumerable
|
6
|
+
|
5
7
|
attr_reader :data, :items, :total
|
6
8
|
|
7
9
|
def self.from_response(response, key:, type:)
|
8
10
|
body = response.body
|
9
11
|
new(
|
10
|
-
data: body[key]
|
11
|
-
items: body["items"],
|
12
|
-
total: body["total"]
|
12
|
+
data: body[key]&.map {|attrs| type.new(attrs) } || [],
|
13
|
+
items: body["items"] || 0,
|
14
|
+
total: body["total"] || 0
|
13
15
|
)
|
14
16
|
end
|
15
17
|
|
@@ -18,5 +20,31 @@ module Yandex360
|
|
18
20
|
@items = items
|
19
21
|
@total = total
|
20
22
|
end
|
23
|
+
|
24
|
+
def each(&block)
|
25
|
+
data.each(&block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def size
|
29
|
+
data.size
|
30
|
+
end
|
31
|
+
alias length size
|
32
|
+
alias count size
|
33
|
+
|
34
|
+
def empty?
|
35
|
+
data.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
def first(idx=nil)
|
39
|
+
n ? data.first(idx) : data.first
|
40
|
+
end
|
41
|
+
|
42
|
+
def last(idx=nil)
|
43
|
+
n ? data.last(idx) : data.last
|
44
|
+
end
|
45
|
+
|
46
|
+
def [](index)
|
47
|
+
data[index]
|
48
|
+
end
|
21
49
|
end
|
22
50
|
end
|
data/lib/yandex360/error.rb
CHANGED
@@ -3,4 +3,22 @@
|
|
3
3
|
module Yandex360
|
4
4
|
class Error < StandardError
|
5
5
|
end
|
6
|
+
|
7
|
+
class AuthenticationError < Error
|
8
|
+
end
|
9
|
+
|
10
|
+
class AuthorizationError < Error
|
11
|
+
end
|
12
|
+
|
13
|
+
class NotFoundError < Error
|
14
|
+
end
|
15
|
+
|
16
|
+
class ValidationError < Error
|
17
|
+
end
|
18
|
+
|
19
|
+
class RateLimitError < Error
|
20
|
+
end
|
21
|
+
|
22
|
+
class ServerError < Error
|
23
|
+
end
|
6
24
|
end
|
data/lib/yandex360/object.rb
CHANGED
@@ -12,11 +12,13 @@ module Yandex360
|
|
12
12
|
def to_ostruct(obj)
|
13
13
|
case obj
|
14
14
|
when Hash
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
return OpenStruct.new if obj.empty?
|
16
|
+
|
17
|
+
OpenStruct.new(obj.transform_values {|val| to_ostruct(val) })
|
18
18
|
when Array
|
19
19
|
obj.map {|o| to_ostruct(o) }
|
20
|
+
when nil
|
21
|
+
nil
|
20
22
|
else
|
21
23
|
obj
|
22
24
|
end
|
@@ -17,4 +17,11 @@ module Yandex360
|
|
17
17
|
class GroupList < Object; end
|
18
18
|
|
19
19
|
class Alias < Object; end
|
20
|
+
class UserAlias < Object; end
|
21
|
+
|
22
|
+
# New services
|
23
|
+
class Organization < Object; end
|
24
|
+
class Domain < Object; end
|
25
|
+
class DnsRecord < Object; end
|
26
|
+
class AuditEvent < Object; end
|
20
27
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yandex360
|
4
|
+
module ParamBuilder
|
5
|
+
private
|
6
|
+
|
7
|
+
def build_params(base_params, additional_params)
|
8
|
+
params = base_params.dup
|
9
|
+
additional_params.each {|param, value| params[param] = value }
|
10
|
+
params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/yandex360/resource.rb
CHANGED
@@ -10,6 +10,36 @@ module Yandex360
|
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
+
def validate_required_params(params, required_keys)
|
14
|
+
missing_keys = required_keys.reject {|key| valid_param?(params, key) }
|
15
|
+
raise ArgumentError, "Missing required parameters: #{missing_keys.join(', ')}" unless missing_keys.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid_param?(params, key)
|
19
|
+
return false unless params.key?(key)
|
20
|
+
|
21
|
+
value = params[key]
|
22
|
+
return false if value.nil?
|
23
|
+
|
24
|
+
valid_string?(value) || valid_array?(value) || valid_other_type?(value)
|
25
|
+
end
|
26
|
+
|
27
|
+
def valid_string?(value)
|
28
|
+
value.is_a?(String) && !value.strip.empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
def valid_array?(value)
|
32
|
+
value.is_a?(Array) && !value.empty?
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_other_type?(value)
|
36
|
+
!value.is_a?(String) && !value.is_a?(Array)
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_url(path_segments)
|
40
|
+
"/#{path_segments.compact.join('/')}"
|
41
|
+
end
|
42
|
+
|
13
43
|
def get(url, params: {}, headers: {})
|
14
44
|
handle_response client.connection.get(url, params, headers)
|
15
45
|
end
|
@@ -31,29 +61,42 @@ module Yandex360
|
|
31
61
|
end
|
32
62
|
alias delete_request delete
|
33
63
|
|
34
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
35
|
-
# rubocop:disable Metrics/AbcSize
|
36
64
|
def handle_response(response)
|
37
|
-
|
65
|
+
return response if successful_response?(response)
|
66
|
+
|
67
|
+
error_message = extract_error_message(response)
|
68
|
+
raise_appropriate_error(response.status, error_message)
|
69
|
+
end
|
70
|
+
|
71
|
+
def successful_response?(response)
|
72
|
+
response.status.between?(200, 299)
|
73
|
+
end
|
74
|
+
|
75
|
+
def raise_appropriate_error(status, error_message)
|
76
|
+
case status
|
38
77
|
when 400
|
39
|
-
raise
|
78
|
+
raise ValidationError, "Your request was malformed. #{error_message}"
|
40
79
|
when 401
|
41
|
-
raise
|
80
|
+
raise AuthenticationError, "You did not supply valid authentication credentials. #{error_message}"
|
42
81
|
when 403
|
43
|
-
raise
|
82
|
+
raise AuthorizationError, "You are not allowed to perform that action. #{error_message}"
|
44
83
|
when 404
|
45
|
-
raise
|
46
|
-
when 429
|
47
|
-
raise
|
48
|
-
when 500
|
49
|
-
raise
|
50
|
-
|
51
|
-
raise Error, "
|
84
|
+
raise NotFoundError, "No results were found for your request. #{error_message}"
|
85
|
+
when 429, 503
|
86
|
+
raise RateLimitError, "Your request exceeded the API rate limit. #{error_message}"
|
87
|
+
when 500..599
|
88
|
+
raise ServerError, "We were unable to perform the request due to server-side problems. #{error_message}"
|
89
|
+
else
|
90
|
+
raise Error, "Unexpected response status: #{status}. #{error_message}"
|
52
91
|
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def extract_error_message(response)
|
95
|
+
return "" unless response.body.is_a?(Hash)
|
53
96
|
|
54
|
-
response
|
97
|
+
response.body["error"] || response.body["message"] || ""
|
98
|
+
rescue StandardError
|
99
|
+
""
|
55
100
|
end
|
56
|
-
# rubocop:enable Metrics/AbcSize
|
57
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
58
101
|
end
|
59
102
|
end
|
@@ -3,16 +3,25 @@
|
|
3
3
|
module Yandex360
|
4
4
|
class AntispamResource < Resource
|
5
5
|
def list(org_id:)
|
6
|
+
validate_required_params({org_id: org_id}, [:org_id])
|
6
7
|
AllowList.new get("/admin/v1/org/#{org_id}/mail/antispam/allowlist/ips").body
|
7
8
|
end
|
8
9
|
|
9
10
|
def create(org_id, *strings)
|
10
|
-
|
11
|
-
|
11
|
+
validate_required_params({org_id: org_id}, [:org_id])
|
12
|
+
raise ArgumentError, "At least one IP address must be provided" if strings.empty?
|
13
|
+
|
14
|
+
# Filter out empty strings
|
15
|
+
valid_strings = strings.compact.reject {|s| s.to_s.strip.empty? }
|
16
|
+
raise ArgumentError, "At least one valid IP address must be provided" if valid_strings.empty?
|
17
|
+
|
18
|
+
body = {allowList: valid_strings}
|
19
|
+
AllowList.new post("/admin/v1/org/#{org_id}/mail/antispam/allowlist/ips", body: body).body
|
12
20
|
end
|
13
21
|
|
14
22
|
def delete(org_id:)
|
15
|
-
|
23
|
+
validate_required_params({org_id: org_id}, [:org_id])
|
24
|
+
delete_request("/admin/v1/org/#{org_id}/mail/antispam/allowlist/ips")
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|