pritunl_api_client 1.0.1 → 1.2.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
  SHA1:
3
- metadata.gz: 3534d42cc32ee0ed36d274fe44bbcfd6f52dc3b1
4
- data.tar.gz: ba4d158c8eb83dadb67efd9d1528ab036259044b
3
+ metadata.gz: 8893ac808d0c01beb6358428c5b63d8527463d55
4
+ data.tar.gz: 626352f2e452a8d8eb162da04258d6866204acc2
5
5
  SHA512:
6
- metadata.gz: 83ccc8f360c7934d73a30e834aa485bd2d4608b84b42a436dbd0731a08f41573e280f3c0665aba1ae3a4e18f0fff0d2d3cd9e6ba6f513107d2ec280e56ee199f
7
- data.tar.gz: 124eeac5e68aa17483f1f84df78adadfde48eb45ecaf73c3821a958f615b29fa31148aa70c332e9250dbb407bc322a597246ce5fb9aa2e0fe3da326e4b0c654f
6
+ metadata.gz: 3d2cd77747daec9516ef5994738461a89ce87988d66616115f3b3f40a3fb626c855e569dfae3e158d356b755a667a3a7fc3a8682d91d5c5393736382d5bba4d3
7
+ data.tar.gz: 989fc53e24ddd513854465ca42cbe318e87e5f62dd4131126e8e4f3df5b9c7d765d20232c10a05f83fb7e9b6cdac94e4119cfab19095f11c233e919035f2dbd5
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Pritunl API Client
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/pritunl_api_client.svg)](https://badge.fury.io/rb/pritunl_api_client)
4
+
3
5
  API client for Pritunl written in Ruby.
4
6
 
5
7
  [Pritunl](https://github.com/pritunl/pritunl) is a distributed enterprise
6
8
  vpn server built using the OpenVPN protocol. See the official Pritunl API
7
9
  documentation here: https://pritunl.com/api.html. I am not affiliated with
8
- Pritunl at all, but couldn't find a Ruby client for their API. So I scratched
9
- my own itch and created it myself.
10
+ Pritunl.
10
11
 
11
12
  ## Installation
12
13
 
@@ -511,7 +512,61 @@ require 'pritunl_api_client'
511
512
 
512
513
  ## Contributing
513
514
 
514
- Bug reports and pull requests are welcome on GitHub at https://github.com/eterry1388/pritunl_api_client.
515
+ Bug reports and pull requests are welcome on GitHub at https://github.com/eterry1388/pritunl_api_client. Please make sure
516
+ all tests pass before making a pull request. The tests are system tests (not unit tests), so please have a live Pritunl
517
+ server up and running when executing the tests.
518
+
519
+ ### How to run system tests
520
+
521
+ ```bash
522
+ BASE_URL='https://your-ip-address:9700' API_TOKEN='your-api-token' API_SECRET='your-api-secret' rspec
523
+ ```
524
+
525
+ The output should look something like this:
526
+
527
+ ```
528
+ PritunlApiClient
529
+ Ping server
530
+ Get server status
531
+ Get logs
532
+ Get events
533
+ PritunlApiClient::Organization
534
+ Create organization
535
+ Find organization
536
+ Update organization
537
+ Get all organizations
538
+ Delete organization
539
+ PritunlApiClient::User
540
+ Create user
541
+ Find user
542
+ Update user
543
+ Get all users
544
+ Generate two-step auth for user
545
+ Delete user
546
+ PritunlApiClient::Key
547
+ Get tar key
548
+ Get zip key
549
+ Get key temporary url
550
+ PritunlApiClient::Server
551
+ Create server
552
+ Find server
553
+ Get all servers
554
+ Update server
555
+ Attach organization
556
+ Get all organizations on server
557
+ Remove organization
558
+ Start server
559
+ Restart server
560
+ Stop server
561
+ Get server output
562
+ Clear server output
563
+ PritunlApiClient::Settings
564
+ Get all settings
565
+ Update settings
566
+
567
+ Finished in 1 minute 14.14 seconds (files took 0.12978 seconds to load)
568
+ 32 examples, 0 failures
569
+ ```
515
570
 
516
571
  ## License
517
572
 
@@ -7,12 +7,11 @@ require_relative 'pritunl_api_client/server'
7
7
 
8
8
  # API client for Pritunl. Pritunl is a distributed enterprise vpn server built
9
9
  # using the OpenVPN protocol. See the official Pritunl API documentation here:
10
- # https://pritunl.com/api.html. I am not affiliated with Pritunl at all, but
11
- # couldn't find a Ruby client for their API. So I scratched my own itch and
12
- # created it myself.
10
+ # https://pritunl.com/api.html. I am not affiliated with Pritunl.
13
11
  #
14
12
  # @author {mailto:eterry1388@aol.com Eric Terry}
15
13
  # @see https://github.com/eterry1388/pritunl_api_client
14
+ # @note Tested with Pritunl server version 1.11.813.26
16
15
  module PritunlApiClient
17
16
 
18
17
  # Main interface to the Pritunl api
@@ -16,19 +16,31 @@ module PritunlApiClient
16
16
  # @return [String] Local path to downloaded file
17
17
  def download_tar( organization_id:, user_id:, path: )
18
18
  data = @api.get( "/key/#{organization_id}/#{user_id}.tar" )
19
- File.write( path, data )
19
+ File.write( path, data.force_encoding( 'utf-8' ) )
20
20
  path
21
21
  end
22
22
 
23
- # Download a users onc key zip archive
23
+ # Download a users key zip archive
24
24
  #
25
25
  # @param organization_id [String]
26
26
  # @param user_id [String]
27
27
  # @param path [String] Local path to save downloaded file
28
28
  # @return [String] Local path to downloaded file
29
29
  def download_zip( organization_id:, user_id:, path: )
30
+ data = @api.get( "/key/#{organization_id}/#{user_id}.zip" )
31
+ File.write( path, data.force_encoding( 'utf-8' ) )
32
+ path
33
+ end
34
+
35
+ # Download a users onc key (Chromebook profile) as a zip archive
36
+ #
37
+ # @param organization_id [String]
38
+ # @param user_id [String]
39
+ # @param path [String] Local path to save downloaded file
40
+ # @return [String] Local path to downloaded file
41
+ def download_chromebook_profile( organization_id:, user_id:, path: )
30
42
  data = @api.get( "/key_onc/#{organization_id}/#{user_id}.zip" )
31
- File.write( path, data )
43
+ File.write( path, data.force_encoding( 'utf-8' ) )
32
44
  path
33
45
  end
34
46
 
@@ -1,3 +1,3 @@
1
1
  module PritunlApiClient
2
- VERSION = '1.0.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['eterry1388@aol.com']
11
11
 
12
12
  spec.summary = 'Pritunl Ruby API Client'
13
- spec.description = "API client for Pritunl written in Ruby. Pritunl is a distributed enterprise vpn server built using the OpenVPN protocol. See the official Pritunl API documentation here: https://pritunl.com/api.html. I am not affiliated with Pritunl at all, but couldn't find a Ruby client for their API. So I scratched my own itch and created it myself."
13
+ spec.description = "API client for Pritunl written in Ruby. Pritunl is a distributed enterprise vpn server built using the OpenVPN protocol. See the official Pritunl API documentation here: https://pritunl.com/api.html. I am not affiliated with Pritunl."
14
14
  spec.homepage = 'http://eterry1388.github.io/pritunl_api_client'
15
15
  spec.license = 'MIT'
16
16
 
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'bundler', '~> 1.10'
26
26
  spec.add_development_dependency 'rake', '~> 10.0'
27
27
  spec.add_development_dependency 'rspec', '~> 3.3'
28
+ spec.add_development_dependency 'byebug'
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pritunl_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Terry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2015-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -66,11 +66,23 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
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'
69
83
  description: 'API client for Pritunl written in Ruby. Pritunl is a distributed enterprise
70
84
  vpn server built using the OpenVPN protocol. See the official Pritunl API documentation
71
- here: https://pritunl.com/api.html. I am not affiliated with Pritunl at all, but
72
- couldn''t find a Ruby client for their API. So I scratched my own itch and created
73
- it myself.'
85
+ here: https://pritunl.com/api.html. I am not affiliated with Pritunl.'
74
86
  email:
75
87
  - eterry1388@aol.com
76
88
  executables: