Skip to content

Commit

Permalink
lib: add name to floating IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Koch committed Jun 22, 2023
1 parent 30c037b commit a025edc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/hcloud/floating_ip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FloatingIP
)

protectable :delete
updatable :description
updatable :name, :description
destructible

has_actions
Expand Down
2 changes: 1 addition & 1 deletion lib/hcloud/floating_ip_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def [](arg)
end
end

def create(type:, server: nil, home_location: nil, description: nil, labels: {})
def create(type:, name: nil, server: nil, home_location: nil, description: nil, labels: {})
raise Hcloud::Error::InvalidInput, 'no type given' if type.blank?
if server.nil? && home_location.nil?
raise Hcloud::Error::InvalidInput, 'either server or home_location must be given'
Expand Down
5 changes: 3 additions & 2 deletions spec/hcloud/floating_ip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
it 'works' do
params = {
type: 'ipv4',
name: 'moo',
home_location: 'fsn1',
labels: { 'key' => 'value', 'novalue' => '' }
}
response_params = {
type: params[:type],
name: params[:name],
home_location: floating_ip[:home_location],
labels: params[:labels]
}
Expand All @@ -64,14 +66,13 @@
expect(key.id).to be_a Integer
expect(key.name).to be_a String
expect(key.type).to eq('ipv4')
expect(key.name).to eq('moo')
expect(key.home_location).to be_a Hcloud::Location
expect(key.created).to be_a Time
expect(key.labels).to eq(params[:labels])
end

it 'validates uniq name' do
pending 'Implementation of floating IP does not support name, yet'

stub_error(:floating_ips, :post, 'uniqueness_error', 409)

expect do
Expand Down

0 comments on commit a025edc

Please sign in to comment.