hetznercloud 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -6
- data/LICENSE.md +1 -1
- data/README.md +2 -0
- data/config/inflections.rb +3 -0
- data/lib/hcloud/concerns/creatable.rb +2 -0
- data/lib/hcloud/concerns/deletable.rb +2 -0
- data/lib/hcloud/concerns/updatable.rb +5 -1
- data/lib/hcloud/errors.rb +8 -0
- data/lib/hcloud/resource_type.rb +1 -0
- data/lib/hcloud/resources/primary_ip.rb +148 -0
- data/lib/hcloud/version.rb +2 -2
- data/lib/hcloud.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1b9b0de15d2fe2aecdbfa6b00b46df9ec658855ebdafcabebe72f371dd98d50
|
4
|
+
data.tar.gz: 6c39c3ee93d35767d355e522408d1285ce3777fc841753968ae9c33d0916cc6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9971d0195c839594b88759d828dc04f98e36d37eab7880d27f4299f8266d2e37676eea3b60399440bed9240e6d39190dba0af75f2d32bfe78c5e42bb160cd5
|
7
|
+
data.tar.gz: bbecc7998329638d8499d0a33c877cdc5857b2a94c80633672a874f6828cc69f29e67d8e3a618b21db5cd84d87cf66cecd2e2ee3ddcfa16db00f841394f0ea85
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## HCloud v1.
|
3
|
+
## HCloud v1.4.0 (2023-01-22)
|
4
4
|
|
5
|
-
-
|
5
|
+
- Implemented Primary IPs
|
6
|
+
- Implemented Primary IP Actions
|
7
|
+
- Allow calling `#update` with additional attributes to be updated
|
8
|
+
- Return the resource when calling `#create`, `#update` or `#delete`
|
9
|
+
- Add additional primary IP mismatch errors:
|
10
|
+
- `PrimaryIPAssigned`
|
11
|
+
- `PrimaryIPDatacenterMismatch`
|
12
|
+
- `PrimaryIPVersionMismatch`
|
6
13
|
|
7
|
-
## HCloud v1.3.
|
14
|
+
## HCloud v1.3.1 (2022-02-06)
|
15
|
+
|
16
|
+
- Add missing `Server#user_data`
|
17
|
+
|
18
|
+
## HCloud v1.3.0 (2022-02-04)
|
8
19
|
|
9
20
|
- Implemented Load Balancers
|
10
21
|
- Implemented Load Balancer Types
|
11
22
|
|
12
|
-
## HCloud v1.2.0
|
23
|
+
## HCloud v1.2.0 (2022-02-01)
|
13
24
|
|
14
25
|
- Implemented Networks
|
15
26
|
- Implemented Network Actions
|
@@ -17,10 +28,10 @@
|
|
17
28
|
- Implemented Certificates
|
18
29
|
- Implemented Certificate Actions
|
19
30
|
|
20
|
-
## HCloud v1.1.0
|
31
|
+
## HCloud v1.1.0 (2022-01-30)
|
21
32
|
|
22
33
|
- Implemented Firewall Actions
|
23
34
|
|
24
|
-
## HCloud v1.0.0
|
35
|
+
## HCloud v1.0.0 (2022-01-16)
|
25
36
|
|
26
37
|
Initial release
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2023 Florian Dejonckheere
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -88,6 +88,8 @@ Not all Hetzner Cloud API endpoints have been implemented yet.
|
|
88
88
|
| Load Balancer Actions | Not implemented |
|
89
89
|
| Load Balancer Types | Implemented |
|
90
90
|
| Locations | Implemented |
|
91
|
+
| Primary IPs | Implemented |
|
92
|
+
| Primary IP Actions | Implemented |
|
91
93
|
| Networks | Implemented |
|
92
94
|
| Network Actions | Implemented |
|
93
95
|
| Placement Groups | Implemented |
|
data/config/inflections.rb
CHANGED
@@ -14,6 +14,7 @@ HCloud.loader.inflector.inflect(
|
|
14
14
|
"ipv6" => "IPv6",
|
15
15
|
"iso" => "ISO",
|
16
16
|
"iso_type" => "ISOType",
|
17
|
+
"primary_ip" => "PrimaryIP",
|
17
18
|
"service_http" => "ServiceHTTP",
|
18
19
|
"ssh_key" => "SSHKey",
|
19
20
|
"target_ip" => "TargetIP",
|
@@ -23,6 +24,8 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
23
24
|
inflect.acronym "DNS"
|
24
25
|
inflect.acronym "HTTP"
|
25
26
|
inflect.acronym "IP"
|
27
|
+
inflect.acronym "IPv4"
|
28
|
+
inflect.acronym "IPv6"
|
26
29
|
inflect.acronym "ISO"
|
27
30
|
inflect.acronym "JSON"
|
28
31
|
end
|
@@ -5,12 +5,16 @@ module HCloud
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
def update
|
8
|
+
def update(**attributes)
|
9
9
|
raise Errors::MissingIDError unless id
|
10
10
|
|
11
|
+
assign_attributes attributes
|
12
|
+
|
11
13
|
assign_attributes client
|
12
14
|
.put("/#{resource_name.pluralize}/#{id}", updatable_params)
|
13
15
|
.fetch(resource_name.to_sym)
|
16
|
+
|
17
|
+
self
|
14
18
|
end
|
15
19
|
|
16
20
|
def updatable_attributes
|
data/lib/hcloud/errors.rb
CHANGED
@@ -43,6 +43,10 @@ module HCloud
|
|
43
43
|
class NotFound < Error; end
|
44
44
|
class PlacementError < Error; end
|
45
45
|
class PlacementError < Error; end
|
46
|
+
class PrimaryIPAssigned < Error; end
|
47
|
+
class PrimaryIPAlreadyAssigned < Error; end
|
48
|
+
class PrimaryIPDatacenterMismatch < Error; end
|
49
|
+
class PrimaryIPVersionMismatch < Error; end
|
46
50
|
class Protected < Error; end
|
47
51
|
class RateLimitExceeded < Error; end
|
48
52
|
class ResourceInUse < Error; end
|
@@ -52,7 +56,11 @@ module HCloud
|
|
52
56
|
class ServerAlreadyAdded < Error; end
|
53
57
|
class ServerAlreadyAttached < Error; end
|
54
58
|
class ServerError < Error; end
|
59
|
+
class ServerHasIPv4 < Error; end
|
60
|
+
class ServerHasIPv6 < Error; end
|
61
|
+
class ServerIsLoadBalancerTarget < Error; end
|
55
62
|
class ServerNotAttachedToNetwork < Error; end
|
63
|
+
class ServerNotStopped < Error; end
|
56
64
|
class ServiceError < Error; end
|
57
65
|
class SourcePortAlreadyUsed < Error; end
|
58
66
|
class TargetAlreadyDefined < Error; end
|
data/lib/hcloud/resource_type.rb
CHANGED
@@ -90,6 +90,7 @@ ActiveModel::Type.register(:network, HCloud::ResourceType.Type("HCloud::Network"
|
|
90
90
|
ActiveModel::Type.register(:placement_group, HCloud::ResourceType.Type("HCloud::PlacementGroup"))
|
91
91
|
ActiveModel::Type.register(:price, HCloud::ResourceType.Type("HCloud::Price"))
|
92
92
|
ActiveModel::Type.register(:pricing, HCloud::ResourceType.Type("HCloud::Pricing"))
|
93
|
+
ActiveModel::Type.register(:primary_ip, HCloud::ResourceType.Type("HCloud::PrimaryIP"))
|
93
94
|
ActiveModel::Type.register(:private_net, HCloud::ResourceType.Type("HCloud::PrivateNet"))
|
94
95
|
ActiveModel::Type.register(:protection, HCloud::ResourceType.Type("HCloud::Protection"))
|
95
96
|
ActiveModel::Type.register(:public_net, HCloud::ResourceType.Type("HCloud::PublicNet"))
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents a primary IP
|
6
|
+
#
|
7
|
+
# == List all primary IPs
|
8
|
+
#
|
9
|
+
# HCloud::PrimaryIP.all
|
10
|
+
# # => [#<HCloud::PrimaryIP id: 1, ...>, ...]
|
11
|
+
#
|
12
|
+
# == Sort primary IPs
|
13
|
+
#
|
14
|
+
# HCloud::PrimaryIP.all.sort(id: :asc)
|
15
|
+
# # => [#<HCloud::PrimaryIP id: 1, ...>, ...]
|
16
|
+
#
|
17
|
+
# HCloud::PrimaryIP.all.sort(:id, created: :asc)
|
18
|
+
# # => [#<HCloud::PrimaryIP id: 1, ...>, ...]
|
19
|
+
#
|
20
|
+
# == Search primary IPs
|
21
|
+
#
|
22
|
+
# HCloud::PrimaryIP.all.where(name: "my_primary_ip")
|
23
|
+
# # => #<HCloud::PrimaryIP id: 1, ...>
|
24
|
+
#
|
25
|
+
# HCloud::PrimaryIP.all.where(ip: "1.2.3.4")
|
26
|
+
# # => #<HCloud::PrimaryIP id: 1, ...>
|
27
|
+
#
|
28
|
+
# == Find primary IP by ID
|
29
|
+
#
|
30
|
+
# HCloud::PrimaryIP.find(1)
|
31
|
+
# # => #<HCloud::PrimaryIP id: 1, ...>
|
32
|
+
#
|
33
|
+
# == Create primary IP
|
34
|
+
#
|
35
|
+
# primary IP = HCloud::PrimaryIP.new(name: "my_primary_ip", type: "ipv4", datacenter: "fsn1-dc8")
|
36
|
+
# primary IP.create
|
37
|
+
# primary IP.created?
|
38
|
+
# # => true
|
39
|
+
#
|
40
|
+
# firewall = HCloud::PrimaryIP.create(name: "my_primary_ip")
|
41
|
+
# # => #<HCloud::PrimaryIP id: 1, ...>
|
42
|
+
#
|
43
|
+
# == Update primary IP
|
44
|
+
#
|
45
|
+
# primary IP = HCloud::PrimaryIP.find(1)
|
46
|
+
# primary IP.name = "another_primary_ip"
|
47
|
+
# primary IP.update
|
48
|
+
#
|
49
|
+
# == Delete primary IP
|
50
|
+
#
|
51
|
+
# primary IP = HCloud::PrimaryIP.find(1)
|
52
|
+
# primary IP.delete
|
53
|
+
# primary IP.deleted?
|
54
|
+
# # => true
|
55
|
+
#
|
56
|
+
# = Actions
|
57
|
+
# == List actions
|
58
|
+
#
|
59
|
+
# actions = HCloud::PrimaryIP.find(1).actions
|
60
|
+
# # => [#<HCloud::Action id: 1, ...>, ...]
|
61
|
+
#
|
62
|
+
# == Sort actions
|
63
|
+
#
|
64
|
+
# HCloud::PrimaryIP.find(1).actions.sort(finished: :desc)
|
65
|
+
# # => [#<HCloud::Action id: 1, ...>, ...]
|
66
|
+
#
|
67
|
+
# HCloud::PrimaryIP.find(1).actions.sort(:command, finished: :asc)
|
68
|
+
# # => [#<HCloud::Actions id: 1, ...>, ...]
|
69
|
+
#
|
70
|
+
# == Search actions
|
71
|
+
#
|
72
|
+
# HCloud::PrimaryIP.find(1).actions.where(command: "assign_primary_ip")
|
73
|
+
# # => #<HCloud::Action id: 1, ...>
|
74
|
+
#
|
75
|
+
# HCloud::PrimaryIP.find(1).actions.where(status: "success")
|
76
|
+
# # => #<HCloud::Action id: 1, ...>
|
77
|
+
#
|
78
|
+
# == Find action by ID
|
79
|
+
#
|
80
|
+
# HCloud::PrimaryIP.find(1).actions.find(1)
|
81
|
+
# # => #<HCloud::Action id: 1, ...>
|
82
|
+
#
|
83
|
+
# = Resource-specific actions
|
84
|
+
# == Assign a primary IP to a server
|
85
|
+
#
|
86
|
+
# HCloud::PrimaryIP.find(1).assign(assignee_id: 1, assignee_type: "server")
|
87
|
+
# # => #<HCloud::Action id: 1, ...>
|
88
|
+
#
|
89
|
+
# == Unassign a primary IP from a server
|
90
|
+
#
|
91
|
+
# HCloud::PrimaryIP.find(1).unassign
|
92
|
+
# # => #<HCloud::Action id: 1, ...>
|
93
|
+
#
|
94
|
+
# == Change reverse DNS entry
|
95
|
+
#
|
96
|
+
# HCloud::PrimaryIP.find(1).change_dns_ptr(dns_ptr: "server.example.com", ip: "1.2.3.4")
|
97
|
+
# # => #<HCloud::Action id: 1, ...>
|
98
|
+
#
|
99
|
+
# == Change protection
|
100
|
+
#
|
101
|
+
# HCloud::PrimaryIP.find(1).change_protection(delete: true)
|
102
|
+
# # => #<HCloud::Action id: 1, ...>
|
103
|
+
#
|
104
|
+
class PrimaryIP < Resource
|
105
|
+
actionable
|
106
|
+
queryable
|
107
|
+
creatable
|
108
|
+
updatable
|
109
|
+
deletable
|
110
|
+
|
111
|
+
attribute :id, :integer
|
112
|
+
attribute :name
|
113
|
+
|
114
|
+
attribute :type
|
115
|
+
attribute :ip
|
116
|
+
attribute :dns_ptr, :dns_pointer, array: true, default: -> { [] }
|
117
|
+
|
118
|
+
attribute :assignee_id
|
119
|
+
attribute :assignee_type, default: "server"
|
120
|
+
|
121
|
+
attribute :auto_delete, :boolean
|
122
|
+
attribute :blocked, :boolean
|
123
|
+
|
124
|
+
attribute :datacenter, :datacenter
|
125
|
+
|
126
|
+
attribute :protection, :protection
|
127
|
+
|
128
|
+
attribute :labels, default: -> { {} }
|
129
|
+
|
130
|
+
alias auto_delete? auto_delete
|
131
|
+
alias blocked? blocked
|
132
|
+
|
133
|
+
action :assign
|
134
|
+
action :unassign
|
135
|
+
|
136
|
+
action :change_dns_ptr
|
137
|
+
|
138
|
+
action :change_protection
|
139
|
+
|
140
|
+
def creatable_attributes
|
141
|
+
[:name, :type, :assignee_id, :assignee_type, :auto_delete, :labels, datacenter: [:id, :name]]
|
142
|
+
end
|
143
|
+
|
144
|
+
def updatable_attributes
|
145
|
+
[:name, :auto_delete, :labels]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/lib/hcloud/version.rb
CHANGED
data/lib/hcloud.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hetznercloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- lib/hcloud/resources/network.rb
|
276
276
|
- lib/hcloud/resources/placement_group.rb
|
277
277
|
- lib/hcloud/resources/pricing.rb
|
278
|
+
- lib/hcloud/resources/primary_ip.rb
|
278
279
|
- lib/hcloud/resources/server.rb
|
279
280
|
- lib/hcloud/resources/server_type.rb
|
280
281
|
- lib/hcloud/resources/ssh_key.rb
|
@@ -301,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
302
|
- !ruby/object:Gem::Version
|
302
303
|
version: '0'
|
303
304
|
requirements: []
|
304
|
-
rubygems_version: 3.
|
305
|
+
rubygems_version: 3.3.5
|
305
306
|
signing_key:
|
306
307
|
specification_version: 4
|
307
308
|
summary: Ruby library wrapping the Hetzner Cloud API
|