porkbun 0.3.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 183c27cc342e3e3c76f2c3ca1881db37026a6424ebce500460834c88351fccac
4
- data.tar.gz: 9ffa3f822d9d41acaf1196e797fb229e06d571167b6e5fdae5f1798e20652d9d
3
+ metadata.gz: 55966f08e27676143e86c9a7e8d20e93ab18f18072484a9212d4102706532d93
4
+ data.tar.gz: c75016c446c7e25d57be8c0faaf996df401494df87ac66b614a067e202a14fb8
5
5
  SHA512:
6
- metadata.gz: 00a2f94d8ab1373ebba48f7c9d4b8e9bea6f706038b9b0b8fd3918c48d5a5620800f7ab00a069d02b58a86d927df7a7532378476875cd3d16bee223f87829ca8
7
- data.tar.gz: 92ea76964e4cee12abd438c203bff55a6933ff5f6f27a56497d952ee2fea3384fcee9f752e60ae752da80caa70559c4b39051f68b522dbc7c508508941db7608
6
+ metadata.gz: 0a600d3705630e2062507e211dd6c3f000994463e60bdab46592aa6761d74d9704b1b3ca188fa5a76150948b36016442c3dda17189f9d2eb76781ca7b4b80556
7
+ data.tar.gz: f299259861ccb74e64f1d05d0eb8eecc9c22e9918ca7b243560604663e55ff06986cea57afc34d78530361b6cb73eabe3fac6e483e78b483db751b184a2a9d7a
data/Gemfile CHANGED
@@ -1,16 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in porkbun.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0", :group => :test
8
+ group :development do
9
+ # gem "rake", "~> 13.0", :group => :test
10
+ gem 'pry', '~> 0.14.2', group: :test
11
+ gem 'rspec', '~> 3.12', group: :test
12
+ gem 'webmock', '~> 3.19', group: :test
13
+ end
9
14
 
10
- gem "rspec", "~> 3.12", :group => :test
11
-
12
- gem "webmock", "~> 3.19", :group => :test
13
-
14
- gem "pry", "~> 0.14.2", :group => :test
15
-
16
- gem "thor", "~> 1.2"
15
+ gem 'thor', '~> 1.2'
data/README.md CHANGED
@@ -58,6 +58,10 @@ The gem also comes with a CLI
58
58
  porkbun retrieve <domain> [<id>] # List all records for a domain
59
59
 
60
60
 
61
+ be sure to set the environmental variables for it to work
62
+
63
+ export PORKBUN_API_KEY = YOUR_API_KEY
64
+ export PORKBUN_SECRET_API_KEY = YOUR_SECRET_API_KEY
61
65
 
62
66
  ## Development
63
67
 
data/bin/porkbun CHANGED
@@ -36,6 +36,12 @@ class CLI < Thor
36
36
  end
37
37
  end
38
38
 
39
+ desc 'env', 'Print environment variables'
40
+ def env
41
+ puts 'PORKBUN_API_KEY: ' + ENV['PORKBUN_API_KEY'].to_s
42
+ puts 'BUN_SECRET_API_KEY: ' + ENV['PORKBUN_SECRET_API_KEY'].to_s
43
+ end
44
+
39
45
  desc 'delete_all <domain>', 'deletes all records for a domain. this is destructive. use with caution'
40
46
  def delete_all(domain, id = '')
41
47
  records = get_all(domain, id)
@@ -47,6 +53,19 @@ class CLI < Thor
47
53
  end
48
54
  end
49
55
 
56
+ desc 'create', 'Create a new record'
57
+ option :type, required: true, desc: 'The record type: A, AAAA, CNAME, MX, TXT, SRV, NS, SOA'
58
+ option :domain, required: true, desc: 'The domain name: google.com'
59
+ option :name, required: true, desc: 'The hostname: www'
60
+ option :content, required: true, desc: 'The content: hostname, or IP address'
61
+ option :ttl, default: 600, type: :numeric, desc: 'The TTL in seconds'
62
+ option :prio, default: 0, type: :numeric, desc: 'The priority for MX records'
63
+ def create
64
+ record = Porkbun::DNS.create(options)
65
+ puts record
66
+ puts record.message
67
+ end
68
+
50
69
  desc 'dyndns <hostname.domain> [<ip>]', 'Update a dynamic dns record. example: porkbun dyndns home.example.com'
51
70
  long_desc 'If no IP is provided, the current public IP is used.'
52
71
  def dyndns(hostname, ip = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Porkbun
4
- VERSION = "0.3.1"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/porkbun.rb CHANGED
@@ -7,6 +7,10 @@ module Porkbun
7
7
  class Error < StandardError; end
8
8
 
9
9
  def self.porkbun(path, options = {})
10
+ pp options
11
+ if ENV.fetch('PORKBUN_API_KEY', nil).nil? || ENV.fetch('PORKBUN_SECRET_API_KEY', nil).nil?
12
+ abort 'PORKBUN_API_KEY and PORKBUN_SECRET_API_KEY must be set'
13
+ end
10
14
  res = HTTP.post File.join('https://porkbun.com/api/json/v3', path), json: {
11
15
  secretapikey: ENV.fetch('PORKBUN_SECRET_API_KEY', nil),
12
16
  apikey: ENV.fetch('PORKBUN_API_KEY', nil)
@@ -102,6 +106,18 @@ module Porkbun
102
106
  "#{name}. #{ttl} IN #{type} #{prio_str} #{content_str}".tr_s(' ', ' ')
103
107
  end
104
108
 
109
+ def to_h
110
+ {
111
+ name: name,
112
+ content: content,
113
+ type: type,
114
+ ttl: ttl,
115
+ prio: prio,
116
+ domain: domain,
117
+ id: id
118
+ }
119
+ end
120
+
105
121
  def create
106
122
  res = Porkbun.porkbun File.join('dns/create', domain), get_options
107
123
  parse_response res
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.3.1
4
+ version: 0.5.0
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-22 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.4.10
76
+ rubygems_version: 3.5.3
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Porkbun API wrapper for Ruby.