cpanel_ruby 0.1.3 → 0.1.4

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: d40dbe8679e2ea82cdacfe3e4c01d98947ccf00e
4
- data.tar.gz: aaa63503c1b7252385371a76e64d2117736dd044
3
+ metadata.gz: 7a023c0d54614e47bc4fb0732586948d66b8052e
4
+ data.tar.gz: 8403721ab1414075abeac26c5eb74ec662c3b4e5
5
5
  SHA512:
6
- metadata.gz: 6e608fb4447135d2d62c3c346644399d91a6ca5e2fb0df3b33388222a3efcf7fa011dcb2ad1e25d1f31e001dcf36b135ad5661b6648dea1e4ab966d34c78702c
7
- data.tar.gz: 8ddc7159cf01b4a414d120c742251618f393de00695946c4b841aab0b77a17ee5ad84c11f03f19bc6d0f537ba408f48a4352f34d300d97f6d39ff163b6e7e85c
6
+ metadata.gz: 23b6330f7113c314a804422989ebb0c92c85a639ed79efb2f54e2fb83d9dbfb1adf5e8ef9245a51048b6457d4b24977f0ce585011162030ccd513fb5377f70e2
7
+ data.tar.gz: '08731c28f6dab1a9b471c8f3939e84f8984cf6d6a7c2e0dc7c0b059a93bc98997200eb08ee843504d8feef59b66d81bfa7effdb025f666a4f78efc9cb38226c9'
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # CpanelRuby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cpanel_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cpanel_ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cpanel_ruby
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cpanel_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kloxo.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ exec "irb -r mygem -I ./lib"
10
+ end
@@ -0,0 +1,27 @@
1
+ module CpanelRuby
2
+ # Your code goes here...
3
+ require "cpanel_ruby/version"
4
+ require "cpanel_ruby/api/request"
5
+ require "cpanel_ruby/api/response"
6
+ require "cpanel_ruby/api/service"
7
+
8
+ require "cpanel_ruby/api/account/account_summary"
9
+ require "cpanel_ruby/api/account/change_password"
10
+ require "cpanel_ruby/api/account/create_account"
11
+ require "cpanel_ruby/api/account/limit_bw"
12
+ require "cpanel_ruby/api/account/list_account"
13
+ require "cpanel_ruby/api/account/remove_account"
14
+ require "cpanel_ruby/api/account/show_bw"
15
+ require "cpanel_ruby/api/account/suspend_account"
16
+ require "cpanel_ruby/api/account/unsuspend_account"
17
+
18
+ require "cpanel_ruby/api/account/account_summary_response"
19
+ require "cpanel_ruby/api/account/change_password_response"
20
+ require "cpanel_ruby/api/account/create_account_response"
21
+ require "cpanel_ruby/api/account/limit_bw_response"
22
+ require "cpanel_ruby/api/account/list_account_response"
23
+ require "cpanel_ruby/api/account/remove_account_response"
24
+ require "cpanel_ruby/api/account/show_bw_response"
25
+ require "cpanel_ruby/api/account/suspend_account_response"
26
+ require "cpanel_ruby/api/account/unsuspend_account_response"
27
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class AccountSummary < CpanelRuby::API::Request
5
+ attr_accessor :user, :domain
6
+
7
+ def initialize params = {}
8
+ self.user = params[:user]
9
+ self.domain = params[:domain]
10
+ end
11
+
12
+ def param
13
+ {
14
+ user: self.user,
15
+ domain: self.domain
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class AccountSummaryResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class ChangePassword < CpanelRuby::API::Request
5
+ attr_accessor :user, :password
6
+
7
+ def initialize params = {}
8
+ self.user = params[:user]
9
+ self.password = params[:password]
10
+ end
11
+
12
+ def param
13
+ {
14
+ user: self.user,
15
+ password: self.password
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class ChangePasswordResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,103 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class CreateAccount < CpanelRuby::API::Request
5
+ attr_accessor :username, :domain, :plan, :pkgname, :savepkg, :featurelist, :quota,
6
+ :password, :ip, :cgi, :spamassassin, :frontpage, :hasshell, :contactemail, :cpmod,
7
+ :maxftp, :maxsql, :maxpop, :maxlst, :maxsub, :maxpark, :maxaddon, :bwlimit, :customip,
8
+ :language, :useregns, :hasuseregns, :reseller, :forcedns, :mailbox_format, :mxcheck,
9
+ :max_email_per_hour, :max_emailacct_quota, :max_defer_fail_percentage, :uid, :gid,
10
+ :homedir, :dkim, :spf, :owner
11
+
12
+
13
+ def initialize params = {}
14
+ self.username = params[:username]
15
+ self.domain = params[:domain]
16
+ self.plan = params[:plan]
17
+ self.pkgname = params[:pkgname]
18
+ self.savepkg = params[:savepkg]
19
+ self.featurelist = params[:featurelist]
20
+ self.quota = params[:quota]
21
+ self.password = params[:password]
22
+ self.ip = params[:ip]
23
+ self.cgi = params[:cgi]
24
+ self.spamassassin = params[:spamassassin]
25
+ self.frontpage = params[:frontpage]
26
+ self.hasshell = params[:hasshell]
27
+ self.contactemail = params[:contactemail]
28
+ self.cpmod = params[:cpmod]
29
+ self.maxftp = params[:maxftp]
30
+ self.maxsql = params[:maxsql]
31
+ self.maxpop = params[:maxpop]
32
+ self.maxlst = params[:maxlst]
33
+ self.maxsub = params[:maxsub]
34
+ self.maxpark = params[:maxpark]
35
+ self.maxaddon = params[:maxaddon]
36
+ self.bwlimit = params[:bwlimit]
37
+ self.customip = params[:customip]
38
+ self.language = params[:language]
39
+ self.useregns = params[:useregns]
40
+ self.hasuseregns = params[:hasuseregns]
41
+ self.reseller = params[:reseller]
42
+ self.forcedns = params[:forcedns]
43
+ self.mailbox_format = params[:mailbox_format]
44
+ self.mxcheck = params[:mxcheck]
45
+ self.max_email_per_hour = params[:max_email_per_hour]
46
+ self.max_emailacct_quota = params[:max_emailacct_quota]
47
+ self.max_defer_fail_percentage = params[:max_defer_fail_percentage]
48
+ self.uid = params[:uid]
49
+ self.gid = params[:gid]
50
+ self.homedir = params[:homedir]
51
+ self.dkim = params[:dkim]
52
+ self.spf = params[:spf]
53
+ self.owner = params[:owner]
54
+ end
55
+
56
+ def param
57
+ {
58
+ username: self.username,
59
+ domain: self.domain,
60
+ plan: self.plan,
61
+ pkgname: self.pkgname,
62
+ savepkg: self.savepkg,
63
+ featurelist: self.featurelist,
64
+ quota: self.quota,
65
+ password: self.password,
66
+ ip: self.ip,
67
+ cgi: self.cgi,
68
+ spamassassin: self.spamassassin,
69
+ frontpage: self.frontpage,
70
+ hasshell: self.hasshell,
71
+ contactemail: self.contactemail,
72
+ cpmod: self.cpmod,
73
+ maxftp: self.maxftp,
74
+ maxsql: self.maxsql,
75
+ maxpop: self.maxpop,
76
+ maxlst: self.maxlst,
77
+ maxsub: self.maxsub,
78
+ maxpark: self.maxpark,
79
+ maxaddon: self.maxaddon,
80
+ bwlimit: self.bwlimit,
81
+ customip: self.customip,
82
+ language: self.language,
83
+ useregns: self.useregns,
84
+ hasuseregns: self.hasuseregns,
85
+ reseller: self.reseller,
86
+ forcedns: self.forcedns,
87
+ mailbox_format: self.mailbox_format,
88
+ mxcheck: self.mxcheck,
89
+ max_email_per_hour: self.max_email_per_hour,
90
+ max_emailacct_quota: self.max_emailacct_quota,
91
+ max_defer_fail_percentage: self.max_defer_fail_percentage,
92
+ uid: self.uid,
93
+ gid: self.gid,
94
+ homedir: self.homedir,
95
+ dkim: self.dkim,
96
+ spf: self.spf,
97
+ owner: self.owner
98
+ }
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class CreateAccountResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class LimitBw < CpanelRuby::API::Request
5
+ attr_accessor :bwlimit, :user
6
+
7
+ def initialize params = {}
8
+ self.bwlimit = params[:bwlimit]
9
+ self.user = params[:user]
10
+ end
11
+
12
+ def param
13
+ {
14
+ bwlimit: self.bwlimit,
15
+ user: self.user
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class LimitBwResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class ListAccount < CpanelRuby::API::Request
5
+ def initialize params = {}
6
+ end
7
+
8
+ def params
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class ListAccountResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class RemoveAccount < CpanelRuby::API::Request
5
+ attr_accessor :user, :keepdns
6
+
7
+ def initialize params = {}
8
+ self.user = params[:user]
9
+ self.keepdns = params[:keepdns]
10
+ end
11
+
12
+ def param
13
+ {
14
+ user: self.user,
15
+ keepdns: self.keepdns
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class RemoveAccountResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class ShowBw < CpanelRuby::API::Request
5
+ attr_accessor :month, :year
6
+
7
+ def initialize params = {}
8
+ self.month = params[:month]
9
+ self.year = params[:year]
10
+ end
11
+
12
+ def param
13
+ {
14
+ month: self.month,
15
+ year: self.year
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class ShowBwResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class SuspendAccount < CpanelRuby::API::Request
5
+ attr_accessor :user, :reason
6
+
7
+ def initialize params = {}
8
+ self.user = params[:user]
9
+ self.reason = params[:reason]
10
+ end
11
+
12
+ def param
13
+ {
14
+ user: self.user,
15
+ reason: self.reason
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class SuspendAccountResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class UnsuspendAccount < CpanelRuby::API::Request
5
+ attr_accessor :user
6
+
7
+ def initialize params = {}
8
+ self.user = params[:user]
9
+ end
10
+
11
+ def param
12
+ {
13
+ user: self.user
14
+ }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ module CpanelRuby
2
+ module API
3
+ module Account
4
+ class UnsuspendAccountResponse < CpanelRuby::API::Response
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext/hash'
3
+
4
+ module CpanelRuby
5
+ module API
6
+ class Request
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ module CpanelRuby
2
+ module API
3
+ class Response
4
+ def initialize response
5
+ @response = response
6
+ end
7
+
8
+ def response
9
+ @response
10
+ end
11
+
12
+ def body
13
+ @response.body
14
+ end
15
+
16
+ def code
17
+ @response.code
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,97 @@
1
+ require 'httparty'
2
+
3
+ module CpanelRuby
4
+ module API
5
+ class Service
6
+ attr_accessor :address, :port, :username, :token, :query, :request
7
+
8
+ def initialize params = {}
9
+ self.address = params[:address]
10
+ self.port = params[:port]
11
+ self.username = params[:username]
12
+ self.token = params[:token]
13
+
14
+ HTTParty::Basement.default_options.update(verify: false)
15
+ end
16
+
17
+ def headers
18
+ {
19
+ 'Authorization' => "whm #{self.username}:#{self.token}",
20
+ 'Content-Type' => 'application/json',
21
+ 'Accept' => 'application/json'
22
+ }
23
+ end
24
+
25
+ def url
26
+ "#{self.address}:#{self.port}/json-api/#{self.request}?api.version=1"
27
+ end
28
+
29
+ def account_summary params
30
+ set_request("accountsummary")
31
+
32
+ response = HTTParty.get self.url, query: params, headers: self.headers
33
+ CpanelRuby::API::Account::AccountSummaryResponse.new response
34
+ end
35
+
36
+ def change_password params
37
+ set_request("passwd")
38
+
39
+ response = HTTParty.post self.url, query: params, headers: self.headers
40
+ CpanelRuby::API::Account::ChangePasswordResponse.new response
41
+ end
42
+
43
+ def create_account params
44
+ set_request("createacct")
45
+
46
+ response = HTTParty.post self.url, query: params, headers: self.headers
47
+ CpanelRuby::API::Account::CreateAccountResponse.new response
48
+ end
49
+
50
+ def limit_bw params
51
+ set_request("limitbw")
52
+
53
+ response = HTTParty.post self.url, query: params, headers: self.headers
54
+ CpanelRuby::API::Account::LimitBwResponse.new response
55
+ end
56
+
57
+ def list_account
58
+ set_request("listaccts")
59
+
60
+ response = HTTParty.get self.url, query: {}, headers: self.headers
61
+ CpanelRuby::API::Account::ListAccountResponse.new response
62
+ end
63
+
64
+ def remove_account params
65
+ set_request("removeacct")
66
+
67
+ response = HTTParty.delete self.url, query: params, headers: self.headers
68
+ CpanelRuby::API::Account::RemoveAccountResponse.new response
69
+ end
70
+
71
+ def show_bw params
72
+ set_request("showbw")
73
+
74
+ response = HTTParty.get self.url, query: params, headers: self.headers
75
+ CpanelRuby::API::Account::ShowBwResponse.new response
76
+ end
77
+
78
+ def suspend_account params
79
+ set_request("suspendacct")
80
+
81
+ response = HTTParty.post self.url, query: params, headers: self.headers
82
+ CpanelRuby::API::Account::SuspendAccountResponse.new response
83
+ end
84
+
85
+ def unsuspend_account params
86
+ set_request("unsuspendacct")
87
+
88
+ response = HTTParty.get self.url, query: params, headers: self.headers
89
+ CpanelRuby::API::Account::UnsuspendAccountResponse.new response
90
+ end
91
+
92
+ def set_request request
93
+ self.request = request
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,3 @@
1
+ module CpanelRuby
2
+ VERSION = "0.1.4"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpanel_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Galamay
@@ -86,10 +86,34 @@ email:
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
- files: []
90
- homepage:
91
- licenses:
92
- - MIT
89
+ files:
90
+ - README.md
91
+ - Rakefile
92
+ - lib/cpanel_ruby.rb
93
+ - lib/cpanel_ruby/api/account/account_summary.rb
94
+ - lib/cpanel_ruby/api/account/account_summary_response.rb
95
+ - lib/cpanel_ruby/api/account/change_password.rb
96
+ - lib/cpanel_ruby/api/account/change_password_response.rb
97
+ - lib/cpanel_ruby/api/account/create_account.rb
98
+ - lib/cpanel_ruby/api/account/create_account_response.rb
99
+ - lib/cpanel_ruby/api/account/limit_bw.rb
100
+ - lib/cpanel_ruby/api/account/limit_bw_response.rb
101
+ - lib/cpanel_ruby/api/account/list_account.rb
102
+ - lib/cpanel_ruby/api/account/list_account_response.rb
103
+ - lib/cpanel_ruby/api/account/remove_account.rb
104
+ - lib/cpanel_ruby/api/account/remove_account_response.rb
105
+ - lib/cpanel_ruby/api/account/show_bw.rb
106
+ - lib/cpanel_ruby/api/account/show_bw_response.rb
107
+ - lib/cpanel_ruby/api/account/suspend_account.rb
108
+ - lib/cpanel_ruby/api/account/suspend_account_response.rb
109
+ - lib/cpanel_ruby/api/account/unsuspend_account.rb
110
+ - lib/cpanel_ruby/api/account/unsuspend_account_response.rb
111
+ - lib/cpanel_ruby/api/request.rb
112
+ - lib/cpanel_ruby/api/response.rb
113
+ - lib/cpanel_ruby/api/service.rb
114
+ - lib/cpanel_ruby/version.rb
115
+ homepage: https://github.com/dotph/cpanel_ruby
116
+ licenses: []
93
117
  metadata:
94
118
  allowed_push_host: https://rubygems.org
95
119
  post_install_message: