integra365 0.1.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 286286718c5dbb03cc8f7c42fa96f2bb7aa8ab491f244a278b402f87b211c51c
4
- data.tar.gz: 24796e4d267be6b3af273949b97b67a764d7621a7a63981c7a67c81e5f291fd7
3
+ metadata.gz: 9b872e0f6b5f05ab04116db74078c1c70bacecfd596c8a268c93e0dce47df35a
4
+ data.tar.gz: 7522cac01bff0f2f86d11b962ff62baa0223707187698b5760056a3027718fb6
5
5
  SHA512:
6
- metadata.gz: cc34a938bb662acaebecd42dde3a51a600bdc99a1cc55a7330d5b91e8f663872d3129080dc580dfdc9a6ec001ac7ffe0e5c59658a24c739859741735b30720d0
7
- data.tar.gz: 732d6708e095fd297082a411fba15b0ceae055f7810436e0a899eab23d5ca805d82dc8d7fbd741594c5fcf27a74aad10bff03191fdeb09d4d8042813dd4c268d
6
+ metadata.gz: feb5d102d898512bb2aa05f5001c952f26817379a69e5370c3aee76d2a27e5248ae60dcad54e1632a29414dd0ddc35bd5241061d6a57afc9b2a50234e1a0f73c
7
+ data.tar.gz: 5c6c963dee2b09c51bbab1dae62b76d2ad9eb9a30307a1560e167f607166641806add2a0ae8f2add89d25814a4eb105cd22844f364a05c48140a238b6536756e
data/CHANGELOG.md CHANGED
@@ -1,8 +1,23 @@
1
- ## [Unreleased]
1
+ # Changelog
2
2
 
3
3
  ## [0.1.0] - 2024-02-05
4
+
4
5
  - Initial release
5
6
 
6
7
  ## [0.1.1] - 2024-02-09
8
+
7
9
  - new wrapi dependency for paging
8
10
 
11
+ ## [0.2.0] - 2024-02-20
12
+
13
+ - Exception harmonization
14
+
15
+ ## [0.3.0] - 2025-03-20
16
+
17
+ - Add backup job api
18
+ - fix issues with http error codes bad request vs unauthorized
19
+
20
+ ## [0.4.0] - 2025-09-08
21
+
22
+ - Add backup job sessions api
23
+ - Add constants for list type and last backup state
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
9
9
  gem 'rubocop', '~> 1.7'
10
- gem 'wrapi'
10
+ gem 'simplecov', require: false, group: :test
11
+ gem 'wrapi'
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # Integra Office365 backup API
2
2
 
3
- This is a wrapper for the Integra Office365 backup API. You can see the API endpoints here https://api.integra-bcs.nl/swagger/index.html
3
+ [![Version](https://img.shields.io/gem/v/integra365.svg)](https://rubygems.org/gems/integra365)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/41dec06ba5200b40b44e/maintainability)](https://codeclimate.com/github/jancotanis/integra365/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/41dec06ba5200b40b44e/test_coverage)](https://codeclimate.com/github/jancotanis/integra365/test_coverage)
4
6
 
5
- Currently only the GET requests to get a list of tenants and backup job reports are implemented.
7
+ This is a wrapper for the Integra Office365 backup API.
8
+ You can see the [API endpoints](https://api.integra-bcs.nl/swagger/index.html).
9
+
10
+ Currently only the GET requests to get a list of tenants and backup job reports
11
+ are implemented.
6
12
 
7
13
  ## Installation
8
14
 
@@ -14,17 +20,22 @@ gem 'integra365'
14
20
 
15
21
  And then execute:
16
22
 
17
- $ bundle install
23
+ ```console
24
+ > bundle install
25
+ ```
18
26
 
19
27
  Or install it yourself as:
20
28
 
21
- $ gem install integra365
29
+ ```console
30
+ > gem install integra365
31
+ ```
22
32
 
23
33
  ## Usage
24
34
 
25
- Before you start making the requests to API provide the client id and client secret and email/password using the configuration wrapping.
35
+ Before you start making the requests to API provide the client id and client secret and
36
+ email/password using the configuration wrapping.
26
37
 
27
- ```
38
+ ```ruby
28
39
  require 'integra365'
29
40
 
30
41
  Integra365.configure do |config|
@@ -42,20 +53,25 @@ end
42
53
  ```
43
54
 
44
55
  ## Resources
56
+
45
57
  ### Authentication
46
- ```
58
+
59
+ ```ruby
47
60
  # setup configuration
48
61
  #
49
62
  client.login
50
63
  ```
64
+
51
65
  |Resource|API endpoint|Description|
52
66
  |:--|:--|:--|
53
- |.token or .login|/Api/V1/Token portal user|
67
+ |.token or .login|/Api/V1/Token|portal user|
54
68
  |.token_refresh|/Api/V1/Token/Refresh|Refresh authentication token|
55
69
 
56
70
  ### Tenant
57
- Endpoint for tenant related requests
58
- ```
71
+
72
+ Endpoint for tenant related requests
73
+
74
+ ```ruby
59
75
  licenses = client.tenant_licenses
60
76
  ```
61
77
 
@@ -66,9 +82,22 @@ licenses = client.tenant_licenses
66
82
  |.tenant_licenses(id) |/Api/V1/Tenants/{id}/Licenses|
67
83
  |.tenant_storage(id)|/Api/V1/Tenants/{id}/Storage|
68
84
 
85
+ ### BackupJobs
86
+
87
+ Get list of backup jobs or by id and state
88
+
89
+ |Resource|API endpoint|
90
+ |:--|:--|
91
+ |.backup_jobs|/Api/V1/BackupJobs|
92
+ |.backup_job(id) .tenant(id)|/Api/V1/BackupJobs/{id}|
93
+ |.backup_job_state(id)|/Api/V1/BackupJobs/{id}/State|
94
+ |.backup_job_sessions(id)|/Api/V1/BackupJobs/{id}/Sessions|
95
+
69
96
  ### BackupJobReporting
97
+
70
98
  BackupJobReporting for status of backup jobs
71
- ```
99
+
100
+ ```ruby
72
101
  job_statuses = client.backup_job_reporting
73
102
 
74
103
  ```
@@ -79,7 +108,7 @@ job_statuses = client.backup_job_reporting
79
108
 
80
109
  ## Contributing
81
110
 
82
- Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/integra365.
111
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/jancotanis/integra365).
83
112
 
84
113
  ## License
85
114
 
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'
Binary file
data/integra365.gemspec CHANGED
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
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
@@ -1,4 +1,6 @@
1
- require "wrapi"
1
+ # frozen_string_literal: true
2
+
3
+ require 'wrapi'
2
4
  require File.expand_path('authentication', __dir__)
3
5
 
4
6
  module Integra365
@@ -1,17 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('error', __dir__)
1
4
 
2
5
  module Integra365
3
6
  # Deals with authentication flow and stores it within global configuration
4
7
  module Authentication
5
8
  # Authorize to the Integra365 portal and return access_token
6
9
  def token(options = {})
7
- api_auth("Token", options)
10
+ raise ConfigurationError.new 'Client id and/or secret not configured' unless self.username && self.password
11
+
12
+ api_auth('Token', options)
13
+ rescue Faraday::BadRequestError, Faraday::UnauthorizedError => e
14
+ raise AuthenticationError.new 'Unauthorized; response ' + e.to_s
8
15
  end
9
16
  alias login token
10
17
 
11
18
  # Return an access token from authorization
12
19
  # token currrent token
13
20
  def token_refresh(token)
14
- api_refresh("Token/Refresh", token)
21
+ api_refresh('Token/Refresh', token)
22
+ rescue Faraday::BadRequestError, Faraday::UnauthorizedError => e
23
+ raise AuthenticationError.new 'Unauthorized; response #{e}'
15
24
  end
16
25
  end
17
26
  end
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Integra365
2
4
  class Client
3
-
4
5
  # Defines methods related to backup job reporting
5
6
  # @see https://api.integra-bcs.nl/swagger/index.html
6
7
  module BackupJobReporting
7
8
  # Get all backupjob reports
8
9
  def backup_job_reporting
9
- get("BackupJobReporting")
10
+ get('BackupJobReporting')
10
11
  end
11
12
  end
12
13
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integra365
4
+ class Client
5
+ # Defines methods related to backup job reporting
6
+ # @see https://api.integra-bcs.nl/swagger/index.html
7
+ module BackupJobs
8
+ # Get all backupjobs
9
+ def backup_jobs
10
+ get('BackupJobs')
11
+ end
12
+
13
+ # Get backupjob by id
14
+ def backup_job(id)
15
+ get("BackupJobs/#{id}")
16
+ end
17
+
18
+ # Get backupjob state as string
19
+ def backup_job_state(id)
20
+ get("BackupJobs/#{id}/State")
21
+ end
22
+
23
+ # Get backupjob sessions
24
+ def backup_job_sessions(id)
25
+ get("BackupJobs/#{id}/Sessions")
26
+ end
27
+
28
+ # Get backupjob session
29
+ def backup_job_session(id, session_id)
30
+ get("BackupJobs/#{id}/Sessions/#{session_id}")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Integra365
2
4
  class Client
3
-
4
5
  # Defines methods related to tenants
5
6
  # @see https://api.integra-bcs.nl/swagger/index.html
6
7
  module Tenants
@@ -9,9 +10,11 @@ module Integra365
9
10
  if id
10
11
  get("Tenants/#{id}")
11
12
  else
12
- get("Tenants")
13
+ get('Tenants')
13
14
  end
14
15
  end
16
+
17
+ # Get tenant by id
15
18
  def tenant(id)
16
19
  tenants(id)
17
20
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('const', __dir__)
4
+
1
5
  module Integra365
2
6
  # Wrapper for the Integra365 REST API
3
7
  #
@@ -7,6 +11,7 @@ module Integra365
7
11
  Dir[File.expand_path('client/*.rb', __dir__)].each { |f| require f }
8
12
 
9
13
  include Integra365::Client::Tenants
14
+ include Integra365::Client::BackupJobs
10
15
  include Integra365::Client::BackupJobReporting
11
16
  end
12
17
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integra365
4
+ class Enum
5
+ def self.enum(array, proc=:to_s)
6
+ array.each do |c|
7
+ const_set c.upcase,c
8
+ end
9
+ end
10
+ end
11
+
12
+ # Represents different session line types
13
+ class BackupJobStatus < Enum
14
+ enum %w[Success Warning Error Running]
15
+ end
16
+
17
+ # Represents different session line types
18
+ class SessionListTypes
19
+ # Session is
20
+ RUNNING = 0
21
+ # Warning description
22
+ WARNING = 1
23
+ # Error description
24
+ ERROR = 2
25
+ # Succes line
26
+ SUCCESS = 3
27
+ # Session stopped
28
+ STOP = 4
29
+ end
30
+ end
31
+
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integra365
4
+ # Generic error to be able to rescue all Integra365 errors
5
+ class Integra365Error < StandardError; end
6
+
7
+ # Raised when Integra365 not configured correctly
8
+ class ConfigurationError < Integra365Error; end
9
+
10
+ # Error when authentication fails
11
+ class AuthenticationError < Integra365Error; end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Integra365
4
- VERSION = '0.1.1'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/integra365.rb CHANGED
@@ -1,4 +1,6 @@
1
- require "wrapi"
1
+ # frozen_string_literal: true
2
+
3
+ require 'wrapi'
2
4
  require File.expand_path('integra365/api', __dir__)
3
5
  require File.expand_path('integra365/client', __dir__)
4
6
  require File.expand_path('integra365/version', __dir__)
@@ -7,8 +9,8 @@ module Integra365
7
9
  extend WrAPI::Configuration
8
10
  extend WrAPI::RespondTo
9
11
 
10
- DEFAULT_ENDPOINT = 'https://api.integra-bcs.nl/Api/V1/'.freeze
11
- DEFAULT_UA = "Integra365 Ruby API wrapper #{Integra365::VERSION}".freeze
12
+ DEFAULT_ENDPOINT = 'https://api.integra-bcs.nl/Api/V1/'
13
+ DEFAULT_UA = "Integra365 Ruby API wrapper #{Integra365::VERSION}"
12
14
 
13
15
  # Alias for Integra365::Client.new
14
16
  #
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integra365
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janco Tanis
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-02-09 00:00:00.000000000 Z
10
+ date: 2025-09-08 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -80,7 +79,20 @@ dependencies:
80
79
  - - ">="
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
- description:
82
+ - !ruby/object:Gem::Dependency
83
+ name: simplecov
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
84
96
  email: gems@jancology.com
85
97
  executables: []
86
98
  extensions: []
@@ -92,13 +104,17 @@ files:
92
104
  - Gemfile
93
105
  - README.md
94
106
  - Rakefile
107
+ - bin/cc-test-reporter.exe
95
108
  - integra365.gemspec
96
109
  - lib/integra365.rb
97
110
  - lib/integra365/api.rb
98
111
  - lib/integra365/authentication.rb
99
112
  - lib/integra365/client.rb
100
113
  - lib/integra365/client/backup_job_reporting.rb
114
+ - lib/integra365/client/backup_jobs.rb
101
115
  - lib/integra365/client/tenants.rb
116
+ - lib/integra365/const.rb
117
+ - lib/integra365/error.rb
102
118
  - lib/integra365/version.rb
103
119
  homepage: https://rubygems.org/gems/integra365
104
120
  licenses:
@@ -106,7 +122,6 @@ licenses:
106
122
  metadata:
107
123
  homepage_uri: https://rubygems.org/gems/integra365
108
124
  source_code_uri: https://github.com/jancotanis/integra365
109
- post_install_message:
110
125
  rdoc_options: []
111
126
  require_paths:
112
127
  - lib
@@ -121,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
136
  - !ruby/object:Gem::Version
122
137
  version: '0'
123
138
  requirements: []
124
- rubygems_version: 3.2.12
125
- signing_key:
139
+ rubygems_version: 3.6.2
126
140
  specification_version: 4
127
141
  summary: A Ruby wrapper for the Integra36 backup Portal REST APIs (readonly)
128
142
  test_files: []