Files
ubicloud/serializers/load_balancer.rb
Jeremy Evans e56335c678 Make cli lb list command include location
This requires changes to the api/serializer so that location is
included for load balancers by default.

I think the reason this wasn't included for load balancer but was
included for private subnets is that load balancer does not have
a location column, it gets the location through the private_subnet
it is associated with.
2025-02-21 15:19:20 -08:00

34 lines
824 B
Ruby

# frozen_string_literal: true
class Serializers::LoadBalancer < Serializers::Base
def self.serialize_internal(lb, options = {})
base = {
id: lb.ubid,
name: lb.name,
location: lb.private_subnet.display_location,
hostname: lb.hostname,
algorithm: lb.algorithm,
stack: lb.stack,
health_check_endpoint: lb.health_check_endpoint,
health_check_protocol: lb.health_check_protocol,
src_port: lb.src_port,
dst_port: lb.dst_port
}
if options[:include_path]
base[:path] = lb.path
end
if options[:detailed]
base[:subnet] = lb.private_subnet.name
base[:vms] = lb.vms.map { _1.ubid } || []
end
if options[:vms_serialized]
base[:vms] = Serializers::Vm.serialize(lb.vms, {load_balancer: true})
end
base
end
end