outline_vpn_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a705549d6c1f842aeee03e7a6f6ded562020fc7eb946493e2eda44b0f307e95b
4
+ data.tar.gz: 5ed19a71d4b574e2b4acd6e851a44d556aabc047479ef053cb3dfedb41b662a3
5
+ SHA512:
6
+ metadata.gz: bb864456a7a6293a966406268dd66e82e364f1f3f3cc3842a54b1463f108cb0eb3f449a547ad896e2824a3ac217ba620d7297ff543151e88709cccde60221c8f
7
+ data.tar.gz: 495ee1dad45c93f6173e1a444af102526ae0a22056832bc98c5bc997067327bc745f50fea20606f31ee82985e5b74e4b088a4282ced952d3afc2e3c865713235
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.2
6
+ NewCops: enable
7
+ SuggestExtensions: false
8
+
9
+ Style/Documentation:
10
+ Enabled: false
11
+
12
+ Style/StringLiterals:
13
+ Enabled: true
14
+ EnforcedStyle: double_quotes
15
+
16
+ Style/StringLiteralsInInterpolation:
17
+ Enabled: true
18
+ EnforcedStyle: double_quotes
19
+
20
+ Layout/LineLength:
21
+ Max: 125
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at pavel.vlasikhin@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Pavel Vlasikhin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # outline_vpn_api
2
+
3
+ Ruby API wrapper for Outline VPN Server https://getoutline.org/
4
+ It provides a simple interface to manage and retrieve information about VPN keys, metrics, and other related functionalities.
5
+
6
+ ## Installation
7
+
8
+ Ensure you have the required gems installed:
9
+
10
+ ```bash
11
+ gem install outline_vpn_api
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### Initialization
17
+
18
+ To start using the client, initialize it with the API URL:
19
+
20
+ ```ruby
21
+ client = OutlineVpnApi.new('YOUR_API_URL')
22
+ ```
23
+
24
+ ### Methods
25
+
26
+ #### `keys_list`
27
+
28
+ Fetches a list of all keys:
29
+
30
+ ```ruby
31
+ keys = client.keys_list
32
+ ```
33
+
34
+ #### `transfered_data_by_id`
35
+
36
+ Fetches the transferred data metrics:
37
+
38
+ ```ruby
39
+ data = client.transfered_data_by_id
40
+ ```
41
+
42
+ #### `create_key`
43
+
44
+ Creates a new key:
45
+
46
+ ```ruby
47
+ new_key = client.create_key
48
+ ```
49
+
50
+ #### `set_limit(key_id, limit)`
51
+
52
+ Sets a data limit for a specific key:
53
+
54
+ ```ruby
55
+ client.set_limit('KEY_ID', LIMIT_IN_BYTES)
56
+ ```
57
+
58
+ #### `rename_key(key_id, name)`
59
+
60
+ Renames a specific key:
61
+
62
+ ```ruby
63
+ client.rename_key('KEY_ID', 'NEW_NAME')
64
+ ```
65
+
66
+ #### `delete_key(key_id)`
67
+
68
+ Deletes a specific key:
69
+
70
+ ```ruby
71
+ client.delete_key('KEY_ID')
72
+ ```
73
+
74
+ ## Dependencies
75
+
76
+ - `httparty`: Used for making HTTP requests.
77
+ - `json`: Used for parsing JSON responses.
78
+
79
+ ## Contributing
80
+
81
+ If you'd like to contribute to this project, please submit a pull request with your changes.
82
+
83
+ ## License
84
+
85
+ This project is licensed under the MIT License. See the LICENSE file for details.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec/core/rake_task"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: %i[rubocop spec]
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+ require "json"
5
+
6
+ module OutlineVpnApi
7
+ class Client
8
+ include HTTParty
9
+ base_uri ""
10
+ default_options.update(verify: false)
11
+ headers "Content-Type" => "application/json"
12
+
13
+ def initialize(api_url)
14
+ self.class.base_uri(api_url)
15
+ end
16
+
17
+ attr_reader :api_url
18
+
19
+ def keys_list
20
+ parse_response(self.class.get("/access-keys"))["accessKeys"]
21
+ end
22
+
23
+ def transfered_data_by_id
24
+ parse_response(self.class.get("/metrics/transfer"))
25
+ end
26
+
27
+ def create_key
28
+ parse_response(self.class.post("/access-keys"))
29
+ end
30
+
31
+ def set_limit(key_id, limit)
32
+ response = self.class.put("/access-keys/#{key_id}/data-limit", body: { limit: { bytes: limit } }.to_json)
33
+ handle_response(response, "Limit for key_id:#{key_id} is #{limit} bytes")
34
+ end
35
+
36
+ def rename_key(key_id, name)
37
+ response = self.class.put("/access-keys/#{key_id}/name", body: { name: }.to_json)
38
+ handle_response(response, "key_id:#{key_id}, renamed to #{name}")
39
+ end
40
+
41
+ def delete_key(key_id)
42
+ response = self.class.delete("/access-keys/#{key_id}")
43
+ handle_response(response, "key_id:#{key_id}, deleted")
44
+ end
45
+
46
+ private
47
+
48
+ def parse_response(response)
49
+ JSON.parse(response.body)
50
+ end
51
+
52
+ def handle_response(response, success_message)
53
+ response.code.to_i == 204 ? puts(success_message) : parse_response(response)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OutlineVpnApi
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+ require "json"
5
+
6
+ require_relative "outline_vpn_api/version"
7
+ require_relative "outline_vpn_api/client"
8
+
9
+ module OutlineVpnApi
10
+ def self.new(api_url)
11
+ OutlineVpnApi::Client.new(api_url)
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/outline_vpn_api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "outline_vpn_api"
7
+ spec.version = OutlineVpnApi::VERSION
8
+ spec.authors = ["Pavel Vlasikhin"]
9
+ spec.email = ["pavel.vlasikhin@gmail.com"]
10
+
11
+ spec.summary = "Ruby API wrapper for Outline VPN Server"
12
+ spec.description = "Ruby API wrapper for Outline VPN Server https://getoutline.org/"
13
+ spec.homepage = "https://github.com/vlasikhin/outline_vpn_api"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ spec.files = Dir.chdir(__dir__) do
21
+ `git ls-files -z`.split("\x0").reject do |f|
22
+ (File.expand_path(f) == __FILE__) || f.start_with?(
23
+ *%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile]
24
+ )
25
+ end
26
+ end
27
+
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency("httparty")
33
+ spec.metadata["rubygems_mfa_required"] = "true"
34
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: outline_vpn_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Vlasikhin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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
+ description: Ruby API wrapper for Outline VPN Server https://getoutline.org/
28
+ email:
29
+ - pavel.vlasikhin@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - CODE_OF_CONDUCT.md
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - lib/outline_vpn_api.rb
41
+ - lib/outline_vpn_api/client.rb
42
+ - lib/outline_vpn_api/version.rb
43
+ - outline_vpn_api.gemspec
44
+ homepage: https://github.com/vlasikhin/outline_vpn_api
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/vlasikhin/outline_vpn_api
49
+ source_code_uri: https://github.com/vlasikhin/outline_vpn_api
50
+ rubygems_mfa_required: 'true'
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 3.2.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.4.14
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Ruby API wrapper for Outline VPN Server
70
+ test_files: []