pritunl_api_client 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -3
- data/lib/pritunl_api_client.rb +2 -3
- data/lib/pritunl_api_client/key.rb +15 -3
- data/lib/pritunl_api_client/version.rb +1 -1
- data/pritunl_api_client.gemspec +2 -1
- metadata +17 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8893ac808d0c01beb6358428c5b63d8527463d55
|
4
|
+
data.tar.gz: 626352f2e452a8d8eb162da04258d6866204acc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
|
data/lib/pritunl_api_client.rb
CHANGED
@@ -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
|
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
|
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
|
|
data/pritunl_api_client.gemspec
CHANGED
@@ -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
|
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
|
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-
|
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
|
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:
|