porkbun 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +12 -6
- data/bin/porkbun +22 -0
- data/lib/porkbun/version.rb +1 -1
- data/lib/porkbun.rb +21 -6
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 183c27cc342e3e3c76f2c3ca1881db37026a6424ebce500460834c88351fccac
|
4
|
+
data.tar.gz: 9ffa3f822d9d41acaf1196e797fb229e06d571167b6e5fdae5f1798e20652d9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00a2f94d8ab1373ebba48f7c9d4b8e9bea6f706038b9b0b8fd3918c48d5a5620800f7ab00a069d02b58a86d927df7a7532378476875cd3d16bee223f87829ca8
|
7
|
+
data.tar.gz: 92ea76964e4cee12abd438c203bff55a6933ff5f6f27a56497d952ee2fea3384fcee9f752e60ae752da80caa70559c4b39051f68b522dbc7c508508941db7608
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Reference: https://porkbun.com/api/json/v3/documentation
|
4
4
|
|
5
|
+
This is currently only a partial implementation to suit my own needs. If you
|
6
|
+
need a specific call to be implemented, let me know, or submit a PR
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
`gem install porkbun`
|
@@ -20,7 +23,7 @@ record = Porkbun::DNS.create(name: 'test',
|
|
20
23
|
|
21
24
|
## API
|
22
25
|
|
23
|
-
### `Porkbun
|
26
|
+
### `Porkbun.ping`
|
24
27
|
|
25
28
|
Make sure your keys are good.
|
26
29
|
|
@@ -47,11 +50,14 @@ The gem also comes with a CLI
|
|
47
50
|
|
48
51
|
$ porkbun
|
49
52
|
Commands:
|
50
|
-
porkbun delete_all <domain>
|
51
|
-
porkbun
|
52
|
-
porkbun
|
53
|
-
porkbun
|
54
|
-
porkbun
|
53
|
+
porkbun delete_all <domain> # deletes all records for a domain. this is destructive. use with caution
|
54
|
+
porkbun dyndns <hostname.domain> [<ip>] # Update a dynamic dns record. example: porkbun dyndns home.example.com
|
55
|
+
porkbun help [COMMAND] # Describe available commands or one specific command
|
56
|
+
porkbun import <file> # Import BIND zone file
|
57
|
+
porkbun list # List all domains
|
58
|
+
porkbun retrieve <domain> [<id>] # List all records for a domain
|
59
|
+
|
60
|
+
|
55
61
|
|
56
62
|
## Development
|
57
63
|
|
data/bin/porkbun
CHANGED
@@ -47,6 +47,28 @@ class CLI < Thor
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
desc 'dyndns <hostname.domain> [<ip>]', 'Update a dynamic dns record. example: porkbun dyndns home.example.com'
|
51
|
+
long_desc 'If no IP is provided, the current public IP is used.'
|
52
|
+
def dyndns(hostname, ip = nil)
|
53
|
+
ip ||= HTTP.get('https://canhazip.com').to_s.chomp
|
54
|
+
domain = hostname.split('.')[-2..].join('.').chomp '.'
|
55
|
+
name = hostname.split('.')[0..-3].join('.')
|
56
|
+
records = get_all(domain)
|
57
|
+
record = records.find { |r| r.name == hostname }
|
58
|
+
if record
|
59
|
+
record.content = ip
|
60
|
+
record.name = name
|
61
|
+
puts "UPDATE #{record}"
|
62
|
+
record.save
|
63
|
+
puts record.message
|
64
|
+
else
|
65
|
+
print 'CREATE '
|
66
|
+
record = Porkbun::DNS.create(domain:, name:, type: 'A', content: ip)
|
67
|
+
puts record
|
68
|
+
puts record.message
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
50
72
|
desc 'retrieve <domain> [<id>]', 'List all records for a domain'
|
51
73
|
def retrieve(domain, id = '')
|
52
74
|
records = get_all(domain, id)
|
data/lib/porkbun/version.rb
CHANGED
data/lib/porkbun.rb
CHANGED
@@ -57,7 +57,16 @@ module Porkbun
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def edit
|
60
|
-
raise Error, '
|
60
|
+
raise Error, 'Need ID to id record' unless id
|
61
|
+
|
62
|
+
res = Porkbun.porkbun File.join('dns/edit', domain, id), get_options
|
63
|
+
parse_response res
|
64
|
+
@id = res[:id]
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
def save
|
69
|
+
edit
|
61
70
|
end
|
62
71
|
|
63
72
|
def self.retrieve(domain, id = nil)
|
@@ -94,17 +103,23 @@ module Porkbun
|
|
94
103
|
end
|
95
104
|
|
96
105
|
def create
|
106
|
+
res = Porkbun.porkbun File.join('dns/create', domain), get_options
|
107
|
+
parse_response res
|
108
|
+
@id = res[:id]
|
109
|
+
self
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def get_options
|
97
115
|
options = {
|
98
116
|
name:,
|
99
117
|
content:,
|
100
118
|
type:,
|
101
119
|
ttl:
|
102
120
|
}
|
103
|
-
options.merge!(prio:) if prio
|
104
|
-
|
105
|
-
parse_response res
|
106
|
-
@id = res[:id]
|
107
|
-
self
|
121
|
+
options.merge!(prio:) if prio and prio != '0'
|
122
|
+
options
|
108
123
|
end
|
109
124
|
end
|
110
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: porkbun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bretoi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
27
41
|
description: Porkbun API wrapper for Ruby.
|
28
42
|
email:
|
29
43
|
- daniel@otherware.org
|