integra365 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2446f113b5f0bb83e671601702793a41c37aa97cd5d5e79de5bd91eb4933d085
4
+ data.tar.gz: c12c1bfd326ee06b34760c1da8b1dee0d89b88a7a7638f10930b149251380418
5
+ SHA512:
6
+ metadata.gz: 5dd0575779cec82d17aa8ab9a6a9800dee64468ec7c1a18aeb83817ee9003ce75f91f6b4014c17ac136ddbf9047a8e014901c9c594b701a73e183f696c75475c
7
+ data.tar.gz: 57e8a3a3f67af0c94b77276e9dbfd03a013c1060b8b63b1886ca4fdb950d6641bed68a39cfcffc95d04c4468fe5a171fef15532c727b272640a25bafa4d99c06
data/.env.template ADDED
@@ -0,0 +1,2 @@
1
+ INTEGRA365_USER=<username/mail>
2
+ INTEGRA365_PASSWORD=<password>
data/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+ /data/
13
+ *.log
14
+ *.txt
15
+ *.json
16
+ *.yml
17
+
18
+ # Used by dotenv library to load environment variables.
19
+ .env
20
+
21
+
22
+ ## Documentation cache and generated files:
23
+ /.yardoc/
24
+ /_yardoc/
25
+ /doc/
26
+ /rdoc/
27
+
28
+ ## Environment normalization:
29
+ /.bundle/
30
+ /vendor/bundle
31
+ /lib/bundler/man/
32
+
33
+ # for a library or gem, you might want to ignore these files since the code is
34
+ # intended to run in multiple environments; otherwise, check them in:
35
+ # Gemfile.lock
36
+ # .ruby-version
37
+ # .ruby-gemset
38
+
39
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
40
+ .rvmrc
41
+
42
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
43
+ # .rubocop-https?--*
44
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-02-05
4
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in cloudally.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rubocop', '~> 1.7'
10
+ gem 'wrapi'
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Integra Office365 backup API
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
4
+
5
+ Currently only the GET requests to get a list of tenants and backup job reports are implemented.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'integra365'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install integra365
22
+
23
+ ## Usage
24
+
25
+ Before you start making the requests to API provide the client id and client secret and email/password using the configuration wrapping.
26
+
27
+ ```
28
+ require 'integra365'
29
+
30
+ Integra365.configure do |config|
31
+ config.username = ENV["INTEGRA365_USER"]
32
+ config.password = ENV["INTEGRA365_PASSWORD"]
33
+ end
34
+
35
+ client = Integra365.client
36
+ client.login
37
+
38
+ tenants = client.tenants
39
+ tenants.each do |t|
40
+ puts "#{t.friendlyName} - #{t.tenantName}"
41
+ end
42
+ ```
43
+
44
+ ## Resources
45
+ ### Authentication
46
+ ```
47
+ # setup configuration
48
+ #
49
+ client.login
50
+ ```
51
+ |Resource|API endpoint|Description|
52
+ |:--|:--|:--|
53
+ |.token or .login|/Api/V1/Token portal user|
54
+ |.token_refresh|/Api/V1/Token/Refresh|Refresh authentication token|
55
+
56
+ ### Tenant
57
+ Endpoint for tenant related requests
58
+ ```
59
+ licenses = client.tenant_licenses
60
+ ```
61
+
62
+ |Resource|API endpoint|
63
+ |:--|:--|
64
+ |.tenants|/Api/V1/Tenants/{id}|
65
+ |.get_tenant_by_id(id) .tenant(id)|/Api/V1/Tenants/{id}|
66
+ |.tenant_licenses(id) |/Api/V1/Tenants/{id}/Licenses|
67
+ |.tenant_storage(id)|/Api/V1/Tenants/{id}/Storage|
68
+
69
+ ### BackupJobReporting
70
+ BackupJobReporting for status of backup jobs
71
+ ```
72
+ job_statuses = client.backup_job_reporting
73
+
74
+ ```
75
+
76
+ |Resource|API endpoint|
77
+ |:--|:--|
78
+ |.backup_job_reporting|/Api/V1/BackupJobReporting|
79
+
80
+ ## Contributing
81
+
82
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/integra365.
83
+
84
+ ## License
85
+
86
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ require 'rubocop/rake_task'
13
+ RuboCop::RakeTask.new
14
+ task default: %i[test rubocop]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/integra365/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'integra365'
7
+ s.version = Integra365::VERSION
8
+ s.authors = ['Janco Tanis']
9
+ s.email = 'gems@jancology.com'
10
+ s.license = 'MIT'
11
+
12
+ s.summary = 'A Ruby wrapper for the Integra36 backup Portal REST APIs (readonly)'
13
+ s.homepage = 'https://rubygems.org/gems/integra365'
14
+
15
+ s.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
16
+
17
+ s.metadata['homepage_uri'] = s.homepage
18
+ s.metadata['source_code_uri'] = 'https://github.com/jancotanis/integra365'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ s.bindir = 'exe'
26
+ s.executables = s.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ s.require_paths = ['lib']
28
+
29
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
+ s.platform = Gem::Platform::RUBY
31
+ s.add_runtime_dependency 'faraday'
32
+ s.add_runtime_dependency 'wrapi', "~> 0.1.2"
33
+ s.add_development_dependency 'dotenv'
34
+ s.add_development_dependency 'minitest'
35
+ s.add_development_dependency 'rubocop'
36
+ end
@@ -0,0 +1,31 @@
1
+ require "wrapi"
2
+ require File.expand_path('authentication', __dir__)
3
+
4
+ module Integra365
5
+ # @private
6
+ class API
7
+ # @private
8
+ attr_accessor *WrAPI::Configuration::VALID_OPTIONS_KEYS
9
+
10
+ # Creates a new API and copies settings from singleton
11
+ def initialize(options = {})
12
+ options = Integra365.options.merge(options)
13
+ WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key|
14
+ send("#{key}=", options[key])
15
+ end
16
+ end
17
+
18
+ def config
19
+ conf = {}
20
+ WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key|
21
+ conf[key] = send key
22
+ end
23
+ conf
24
+ end
25
+
26
+ include WrAPI::Connection
27
+ include WrAPI::Request
28
+ include WrAPI::Authentication
29
+ include Authentication
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+
2
+ module Integra365
3
+ # Deals with authentication flow and stores it within global configuration
4
+ module Authentication
5
+ # Authorize to the Integra365 portal and return access_token
6
+ def token(options = {})
7
+ api_auth("Token", options)
8
+ end
9
+ alias login token
10
+
11
+ # Return an access token from authorization
12
+ # token currrent token
13
+ def token_refresh(token)
14
+ api_refresh("Token/Refresh", token)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module Integra365
2
+ class Client
3
+
4
+ # Defines methods related to backup job reporting
5
+ # @see https://api.integra-bcs.nl/swagger/index.html
6
+ module BackupJobReporting
7
+ # Get all backupjob reports
8
+ def backup_job_reporting
9
+ get("BackupJobReporting")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ module Integra365
2
+ class Client
3
+
4
+ # Defines methods related to tenants
5
+ # @see https://api.integra-bcs.nl/swagger/index.html
6
+ module Tenants
7
+ # Get all tenants
8
+ def tenants(id = nil)
9
+ if id
10
+ get("Tenants/#{id}")
11
+ else
12
+ get("Tenants")
13
+ end
14
+ end
15
+ def tenant(id)
16
+ tenants(id)
17
+ end
18
+ alias get_tenant_by_id tenant
19
+
20
+ # Get license consumption history for a tenant
21
+ #
22
+ # @see https://api.integra-bcs.nl/swagger/index.html#operations-Tenants-get_Api_V1_Tenants__id__Licenses
23
+ def tenant_licenses(id)
24
+ get("Tenants/#{id}/Licenses")
25
+ end
26
+
27
+ # Get storage consumption history for a tenant
28
+ #
29
+ # @see https://api.integra-bcs.nl/swagger/index.html
30
+ def tenant_storage(id)
31
+ get("Tenants/#{id}/Storage")
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ module Integra365
2
+ # Wrapper for the Integra365 REST API
3
+ #
4
+ # @note All methods have been separated into modules and follow the same grouping used in api docs
5
+ # @see https://api.integra-bcs.nl/swagger/index.html
6
+ class Client < API
7
+ Dir[File.expand_path('client/*.rb', __dir__)].each { |f| require f }
8
+
9
+ include Integra365::Client::Tenants
10
+ include Integra365::Client::BackupJobReporting
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integra365
4
+ VERSION = '0.1.0'
5
+ end
data/lib/integra365.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "wrapi"
2
+ require File.expand_path('integra365/api', __dir__)
3
+ require File.expand_path('integra365/client', __dir__)
4
+ require File.expand_path('integra365/version', __dir__)
5
+
6
+ module Integra365
7
+ extend WrAPI::Configuration
8
+ extend WrAPI::RespondTo
9
+
10
+ # Alias for Integra365::Client.new
11
+ #
12
+ # @return [Integra365::Client]
13
+ def self.client(options = {})
14
+ Integra365::Client.new({
15
+ endpoint: 'https://api.integra-bcs.nl/Api/V1/'.freeze,
16
+ user_agent: "Integra365 Ruby API wrapper #{Integra365::VERSION}".freeze
17
+ }.merge(options))
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: integra365
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Janco Tanis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: wrapi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email: gems@jancology.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".env.template"
90
+ - ".gitignore"
91
+ - CHANGELOG.md
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
95
+ - integra365.gemspec
96
+ - lib/integra365.rb
97
+ - lib/integra365/api.rb
98
+ - lib/integra365/authentication.rb
99
+ - lib/integra365/client.rb
100
+ - lib/integra365/client/backup_job_reporting.rb
101
+ - lib/integra365/client/tenants.rb
102
+ - lib/integra365/version.rb
103
+ homepage: https://rubygems.org/gems/integra365
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ homepage_uri: https://rubygems.org/gems/integra365
108
+ source_code_uri: https://github.com/jancotanis/integra365
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.4.0
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.2.12
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A Ruby wrapper for the Integra36 backup Portal REST APIs (readonly)
128
+ test_files: []