skykick 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -1
- data/README.md +11 -7
- data/Rakefile +8 -0
- data/lib/skykick/authentication.rb +12 -7
- data/lib/skykick/client/alerts.rb +1 -1
- data/lib/skykick/error.rb +11 -0
- data/lib/skykick/pagination.rb +44 -0
- data/lib/skykick/version.rb +1 -1
- data/lib/skykick.rb +5 -2
- data/skykick.gemspec +2 -1
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3568006d852bb95fdf9bc05a9c2847f0735858d0b30b1db54f07af5b1e8c547e
|
4
|
+
data.tar.gz: e714cce3f3851c064abf1fcb314f460d4d2dd34fab2fb6caba2e3a794fae4e57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 023d97f414b04c76cdacc95857b1b2c1c956ddeed653022f79c4f5bcdf13764b32f9e8ac931de6fd0e7b03c566ac2410f1b356991c2975008668f9f602857baa
|
7
|
+
data.tar.gz: 0baba10c6e1b0db00d6390a3ef594b292e0f23c1f6ef99a71ec2d0d81163c24a23eb3d0c047b4201a7ddbe2f08c699b4e2ce92aeb05ba827f2454a4cb64da0c3
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# Skykick Office365 backup API
|
2
|
+
[![Version](https://img.shields.io/gem/v/skykick.svg)](https://rubygems.org/gems/skykick)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/a340908aaf944745eeda/maintainability)](https://codeclimate.com/github/jancotanis/skykick/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/a340908aaf944745eeda/test_coverage)](https://codeclimate.com/github/jancotanis/skykick/test_coverage)
|
2
5
|
|
3
6
|
This is a wrapper for the Skykick Office365 backup API. You can see the API endpoints here https://developers.skykick.com/apis
|
4
7
|
|
@@ -24,7 +27,7 @@ Or install it yourself as:
|
|
24
27
|
|
25
28
|
Before you start making the requests to API provide the client id and client secret and email/password using the configuration wrapping.
|
26
29
|
|
27
|
-
```
|
30
|
+
```ruby
|
28
31
|
require 'skykick'
|
29
32
|
|
30
33
|
Skykick.configure do |config|
|
@@ -43,7 +46,7 @@ end
|
|
43
46
|
|
44
47
|
## Resources
|
45
48
|
### Authentication
|
46
|
-
```
|
49
|
+
```ruby
|
47
50
|
# setup configuration
|
48
51
|
#
|
49
52
|
client.login
|
@@ -55,8 +58,8 @@ client.login
|
|
55
58
|
|
56
59
|
### Backup
|
57
60
|
Endpoint for backup related requests
|
58
|
-
```
|
59
|
-
|
61
|
+
```ruby
|
62
|
+
subscriptions = client.subscriptions
|
60
63
|
```
|
61
64
|
|
62
65
|
|Resource|API endpoint|
|
@@ -77,8 +80,9 @@ licenses = client.tenant_licenses
|
|
77
80
|
|
78
81
|
### Alerts
|
79
82
|
Returns Alerts for a provided Email Migration Order ID or Backup service ID.
|
80
|
-
```
|
81
|
-
|
83
|
+
```ruby
|
84
|
+
subscriptions = client.subscriptions
|
85
|
+
alerts = client.alerts(subscriptions.first.id)
|
82
86
|
|
83
87
|
```
|
84
88
|
|
@@ -88,7 +92,7 @@ alerts = client.alerts(subscription_id)
|
|
88
92
|
|
89
93
|
## Contributing
|
90
94
|
|
91
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/
|
95
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/skykick.
|
92
96
|
|
93
97
|
## License
|
94
98
|
|
data/Rakefile
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
|
+
require 'dotenv'
|
4
5
|
require 'rake/testtask'
|
5
6
|
|
7
|
+
Dotenv.load
|
8
|
+
|
9
|
+
system './bin/cc-test-reporter before-build'
|
10
|
+
|
6
11
|
Rake::TestTask.new(:test) do |t|
|
7
12
|
t.libs << 'test'
|
8
13
|
t.libs << 'lib'
|
9
14
|
t.test_files = FileList['test/**/*_test.rb']
|
15
|
+
at_exit do
|
16
|
+
system './bin/cc-test-reporter after-build'
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
require 'rubocop/rake_task'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require File.expand_path('error', __dir__)
|
2
2
|
require 'uri'
|
3
3
|
|
4
4
|
module Skykick
|
@@ -7,6 +7,8 @@ module Skykick
|
|
7
7
|
# Authorize to the Skykick portal and return access_token
|
8
8
|
# @see https://developers.skykick.com/Guides/Authentication
|
9
9
|
def auth_token(options = {})
|
10
|
+
raise ConfigurationError.new 'Client id and/or secret not configured' unless client_id && client_secret
|
11
|
+
|
10
12
|
c = connection
|
11
13
|
c.basic_auth(client_id, client_secret)
|
12
14
|
response = c.post('/auth/token') do |request|
|
@@ -15,6 +17,10 @@ module Skykick
|
|
15
17
|
end
|
16
18
|
|
17
19
|
api_process_token(response.body)
|
20
|
+
|
21
|
+
self.access_token
|
22
|
+
rescue Faraday::ForbiddenError => e
|
23
|
+
raise AuthenticationError.new 'Unauthorized; response ' + e.to_s
|
18
24
|
end
|
19
25
|
alias login auth_token
|
20
26
|
|
@@ -28,13 +34,12 @@ module Skykick
|
|
28
34
|
end
|
29
35
|
|
30
36
|
def api_process_token(response)
|
31
|
-
|
32
|
-
self.token_type
|
33
|
-
self.refresh_token
|
34
|
-
self.token_expires
|
35
|
-
raise StandardError.new 'Could not find valid access_token; response ' + response.to_s if at.nil? || at.empty?
|
37
|
+
self.access_token = response['access_token']
|
38
|
+
self.token_type = response['token_type']
|
39
|
+
self.refresh_token = response['refresh_token']
|
40
|
+
self.token_expires = response['expires_in']
|
36
41
|
|
37
|
-
|
42
|
+
raise AuthorizationError.new 'Could not find valid access_token; response ' + response.to_s if self.access_token.nil? || self.access_token.empty?
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Skykick
|
2
|
+
|
3
|
+
# Generic error to be able to rescue all Skykick errors
|
4
|
+
class SkykickError < StandardError; end
|
5
|
+
|
6
|
+
# Error when configuration not sufficient
|
7
|
+
class ConfigurationError < SkykickError; end
|
8
|
+
|
9
|
+
# Error when authentication fails
|
10
|
+
class AuthenticationError < SkykickError; end
|
11
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Skykick
|
5
|
+
# Defines HTTP request methods
|
6
|
+
# required attributes format
|
7
|
+
module RequestPagination
|
8
|
+
|
9
|
+
# Skykick uses Odata pagination but unfortunately does not support skipping pages.
|
10
|
+
# Using skip responds with "The query specified in the URI is not valid. Query option
|
11
|
+
# 'Skip' is not allowed. To allow it, set the 'AllowedQueryOptions' property on
|
12
|
+
# EnableQueryAttribute or QueryValidationSettings."
|
13
|
+
class ODataPagination
|
14
|
+
attr_reader :offset, :limit, :total
|
15
|
+
def initialize(page_size)
|
16
|
+
@offset = 0
|
17
|
+
@limit = page_size
|
18
|
+
# we always have a first page
|
19
|
+
@total = @limit
|
20
|
+
end
|
21
|
+
def page_options
|
22
|
+
{ '$top': @limit, '$skip': @offset }
|
23
|
+
{ '$top': @limit }
|
24
|
+
end
|
25
|
+
def next_page!(data)
|
26
|
+
# assume array
|
27
|
+
if data.count
|
28
|
+
@total = data.count
|
29
|
+
else
|
30
|
+
@total = 1
|
31
|
+
end
|
32
|
+
@offset += @limit
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.data(body)
|
36
|
+
body
|
37
|
+
end
|
38
|
+
# only single page available
|
39
|
+
def more_pages?
|
40
|
+
@offset == 0
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/skykick/version.rb
CHANGED
data/lib/skykick.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "wrapi"
|
2
2
|
require File.expand_path('skykick/api', __dir__)
|
3
3
|
require File.expand_path('skykick/client', __dir__)
|
4
|
+
require File.expand_path('skykick/pagination', __dir__)
|
4
5
|
require File.expand_path('skykick/version', __dir__)
|
5
6
|
|
6
7
|
module Skykick
|
@@ -9,14 +10,15 @@ module Skykick
|
|
9
10
|
|
10
11
|
DEFAULT_ENDPOINT = 'https://apis.skykick.com'.freeze
|
11
12
|
DEFAULT_UA = "Skykick Ruby API wrapper #{Skykick::VERSION}".freeze
|
13
|
+
DEFAULT_PAGINATION = Skykick::RequestPagination::ODataPagination
|
12
14
|
|
13
|
-
# Alias for Skykick::Client.new
|
14
15
|
#
|
15
16
|
# @return [Skykick::Client]
|
16
17
|
def self.client(options = {})
|
17
18
|
Skykick::Client.new({
|
18
19
|
endpoint: DEFAULT_ENDPOINT,
|
19
|
-
user_agent: DEFAULT_UA
|
20
|
+
user_agent: DEFAULT_UA,
|
21
|
+
pagination_class: DEFAULT_PAGINATION
|
20
22
|
}.merge(options))
|
21
23
|
end
|
22
24
|
|
@@ -24,5 +26,6 @@ module Skykick
|
|
24
26
|
super
|
25
27
|
self.endpoint = DEFAULT_ENDPOINT
|
26
28
|
self.user_agent = DEFAULT_UA
|
29
|
+
self.pagination_class = DEFAULT_PAGINATION
|
27
30
|
end
|
28
31
|
end
|
data/skykick.gemspec
CHANGED
@@ -29,8 +29,9 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
30
|
s.platform = Gem::Platform::RUBY
|
31
31
|
s.add_runtime_dependency 'faraday'
|
32
|
-
s.add_runtime_dependency 'wrapi', "
|
32
|
+
s.add_runtime_dependency 'wrapi', ">= 0.2.0"
|
33
33
|
s.add_development_dependency 'dotenv'
|
34
34
|
s.add_development_dependency 'minitest'
|
35
35
|
s.add_development_dependency 'rubocop'
|
36
|
+
s.add_development_dependency 'simplecov'
|
36
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skykick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janco Tanis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: wrapi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: dotenv
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description:
|
84
98
|
email: gems@jancology.com
|
85
99
|
executables: []
|
@@ -99,6 +113,8 @@ files:
|
|
99
113
|
- lib/skykick/client/alerts.rb
|
100
114
|
- lib/skykick/client/backup.rb
|
101
115
|
- lib/skykick/connection.rb
|
116
|
+
- lib/skykick/error.rb
|
117
|
+
- lib/skykick/pagination.rb
|
102
118
|
- lib/skykick/version.rb
|
103
119
|
- skykick.gemspec
|
104
120
|
homepage: https://rubygems.org/gems/skykick
|