direct_admin 0.1.0 → 0.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 +4 -4
- data/lib/direct_admin/client.rb +2 -2
- data/lib/direct_admin/commands.rb +48 -0
- data/lib/direct_admin/request.rb +2 -1
- data/lib/direct_admin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12f43b220e83ac9062e827edbb28139e108f8fff
|
4
|
+
data.tar.gz: 9fd7c435c917f1355b4cc04b5084eca341662582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8fae7329e435a5956d2753fb17605cb2b1979b8fddf6349e0a65f2b5b59ca4c4c680cf335e43401dd6cce2b1af06bc4c21aba208d93404342f12d0314ebcad8
|
7
|
+
data.tar.gz: 6062501f699e5d59eb8781f039c8c376bdd98589f79171d3c56adefbfa25535c371a0cc6698fa0ab3910968e52c95ed00afd0421371b0892587f368a1103f6ce
|
data/lib/direct_admin/client.rb
CHANGED
@@ -31,8 +31,8 @@ module DirectAdmin
|
|
31
31
|
@password = password
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
Request.new(self, method, endpoint, params)
|
34
|
+
def request(method, endpoint, params) # :nodoc:
|
35
|
+
Request.new(self, method, endpoint, params).call
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -47,5 +47,53 @@ module DirectAdmin
|
|
47
47
|
|
48
48
|
request(:post, "/CMD_API_LOGIN_KEYS", params)
|
49
49
|
end
|
50
|
+
|
51
|
+
# Verify the username and password of a user
|
52
|
+
#
|
53
|
+
# client.verify_password("admin", "secret")
|
54
|
+
def verify_password(username, password)
|
55
|
+
params = {
|
56
|
+
"user" => username,
|
57
|
+
"passwd" => password
|
58
|
+
}
|
59
|
+
|
60
|
+
response = request(:post, "/CMD_API_VERIFY_PASSWORD", params)
|
61
|
+
|
62
|
+
if response.has_key?("valid")
|
63
|
+
Integer(response["valid"]) == 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Authenticate email account. Must be logged in as domain owner for command
|
68
|
+
# to be successful.
|
69
|
+
#
|
70
|
+
# client.email_auth("user@domain.com", "secret")
|
71
|
+
def email_auth(email, password)
|
72
|
+
params = {
|
73
|
+
"email" => email,
|
74
|
+
"passwd" => password
|
75
|
+
}
|
76
|
+
|
77
|
+
response = request(:post, "/CMD_API_EMAIL_AUTH", params)
|
78
|
+
|
79
|
+
if response.has_key?("error")
|
80
|
+
Integer(response["error"]) == 0
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Owner of domain
|
85
|
+
#
|
86
|
+
# client.domain_owner("domain.com")
|
87
|
+
def domain_owner(domain)
|
88
|
+
params = {
|
89
|
+
"domain" => domain
|
90
|
+
}
|
91
|
+
|
92
|
+
response = request(:post, "/CMD_API_DOMAIN_OWNERS", params)
|
93
|
+
|
94
|
+
if response.has_key?(domain)
|
95
|
+
response[domain]
|
96
|
+
end
|
97
|
+
end
|
50
98
|
end
|
51
99
|
end
|
data/lib/direct_admin/request.rb
CHANGED
@@ -5,9 +5,10 @@ require "http"
|
|
5
5
|
|
6
6
|
module DirectAdmin
|
7
7
|
class Request
|
8
|
-
attr_reader :method, :endpont, :params, :url
|
8
|
+
attr_reader :client, :method, :endpont, :params, :url
|
9
9
|
|
10
10
|
def initialize(client, method, endpoint, params)
|
11
|
+
@client = client
|
11
12
|
@method = method
|
12
13
|
@endpoint = endpoint
|
13
14
|
@params = params
|
data/lib/direct_admin/version.rb
CHANGED