class Chef::Knife::IonoscloudLanDelete
Attributes
description[R]
required_options[R]
Public Class Methods
new(args = [])
click to toggle source
Calls superclass method
# File lib/chef/knife/ionoscloud_lan_delete.rb, line 17 def initialize(args = []) super(args) @description = 'Deletes an existing LAN.' @required_options = [:datacenter_id, :ionoscloud_username, :ionoscloud_password] end
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/ionoscloud_lan_delete.rb, line 24 def run $stdout.sync = true handle_extra_config validate_required_params(@required_options, config) lan_api = Ionoscloud::LanApi.new(api_client) @name_args.each do |lan_id| begin lan = lan_api.datacenters_lans_find_by_id(config[:datacenter_id], lan_id) rescue Ionoscloud::ApiError => err raise err unless err.code == 404 ui.error("Lan ID #{lan_id} not found. Skipping.") next end msg_pair('ID', lan.id) msg_pair('Name', lan.properties.name) msg_pair('Public', lan.properties.public.to_s) begin confirm('Do you really want to delete this LAN') rescue SystemExit => exc next end _, _, headers = lan_api.datacenters_lans_delete_with_http_info(config[:datacenter_id], lan.id) ui.warn("Deleted Lan #{lan.id}. Request ID: #{get_request_id headers}") end end