Class: Cloudfoundry::Copilot::Client
- Inherits:
-
Object
- Object
- Cloudfoundry::Copilot::Client
- Defined in:
- lib/cf-copilot.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#bulk_sync(routes:, route_mappings:) ⇒ Object
untested - this will change a lot and no one is using it yet.
- #delete_route(guid:) ⇒ Object
- #health ⇒ Object
-
#initialize(host:, port:, client_ca_file:, client_key_file:, client_chain_file:, timeout: 5) ⇒ Client
constructor
A new instance of Client.
- #map_route(capi_process_guid:, diego_process_guid:, route_guid:) ⇒ Object
- #unmap_route(capi_process_guid:, route_guid:) ⇒ Object
- #upsert_route(guid:, host:) ⇒ Object
Constructor Details
#initialize(host:, port:, client_ca_file:, client_key_file:, client_chain_file:, timeout: 5) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 |
# File 'lib/cf-copilot.rb', line 12 def initialize(host:, port:, client_ca_file:, client_key_file:, client_chain_file:, timeout: 5) @host = host @port = port @url = "#{host}:#{port}" @timeout = timeout @client_ca = File.open(client_ca_file).read @client_key = File.open(client_key_file).read @client_chain = File.open(client_chain_file).read end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/cf-copilot.rb', line 10 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/cf-copilot.rb', line 10 def port @port end |
Instance Method Details
#bulk_sync(routes:, route_mappings:) ⇒ Object
untested - this will change a lot and no one is using it yet
51 52 53 54 55 56 57 |
# File 'lib/cf-copilot.rb', line 51 def bulk_sync(routes:, route_mappings:) routes.map! { |route| Api::UpsertRouteRequest.new(route: route) } route_mappings.map! { |mapping| Api::MapRouteRequest.new(route_mapping: mapping) } request = Api::BulkSyncRequest.new(routes: routes, route_mappings: route_mappings) service.bulk_sync(request) end |
#delete_route(guid:) ⇒ Object
33 34 35 36 |
# File 'lib/cf-copilot.rb', line 33 def delete_route(guid:) request = Api::DeleteRouteRequest.new(guid: guid) service.delete_route(request) end |
#health ⇒ Object
22 23 24 25 |
# File 'lib/cf-copilot.rb', line 22 def health request = Api::HealthRequest.new service.health(request) end |
#map_route(capi_process_guid:, diego_process_guid:, route_guid:) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/cf-copilot.rb', line 38 def map_route(capi_process_guid:, diego_process_guid:, route_guid:) capi_process = Api::CapiProcess.new(guid: capi_process_guid, diego_process_guid: diego_process_guid) route_mapping = Api::RouteMapping.new(capi_process: capi_process, route_guid: route_guid) request = Api::MapRouteRequest.new(route_mapping: route_mapping) service.map_route(request) end |
#unmap_route(capi_process_guid:, route_guid:) ⇒ Object
45 46 47 48 |
# File 'lib/cf-copilot.rb', line 45 def unmap_route(capi_process_guid:, route_guid:) request = Api::UnmapRouteRequest.new(capi_process_guid: capi_process_guid, route_guid: route_guid) service.unmap_route(request) end |
#upsert_route(guid:, host:) ⇒ Object
27 28 29 30 31 |
# File 'lib/cf-copilot.rb', line 27 def upsert_route(guid:, host:) route = Api::Route.new(guid: guid, host: host) request = Api::UpsertRouteRequest.new(route: route) service.upsert_route(request) end |