Class: Cloudfoundry::Copilot::Client
- Inherits:
-
Object
- Object
- Cloudfoundry::Copilot::Client
- Defined in:
- lib/cf-copilot.rb
Defined Under Namespace
Classes: PilotError
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:, capi_diego_process_associations:) ⇒ Object
- #delete_capi_diego_process_association(capi_process_guid:) ⇒ Object
- #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:, route_guid:, route_weight:) ⇒ Object
- #unmap_route(capi_process_guid:, route_guid:, route_weight:) ⇒ Object
- #upsert_capi_diego_process_association(capi_process_guid:, diego_process_guids:) ⇒ Object
- #upsert_route(guid:, host:, path: '') ⇒ Object
Constructor Details
#initialize(host:, port:, client_ca_file:, client_key_file:, client_chain_file:, timeout: 5) ⇒ Client
13 14 15 16 17 18 19 20 21 |
# File 'lib/cf-copilot.rb', line 13 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.
11 12 13 |
# File 'lib/cf-copilot.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/cf-copilot.rb', line 11 def port @port end |
Instance Method Details
#bulk_sync(routes:, route_mappings:, capi_diego_process_associations:) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cf-copilot.rb', line 81 def bulk_sync(routes:, route_mappings:, capi_diego_process_associations:) request = Api::BulkSyncRequest.new( routes: routes, route_mappings: route_mappings, capi_diego_process_associations: capi_diego_process_associations ) service.bulk_sync(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |
#delete_capi_diego_process_association(capi_process_guid:) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/cf-copilot.rb', line 72 def delete_capi_diego_process_association(capi_process_guid:) request = Api::DeleteCapiDiegoProcessAssociationRequest.new( capi_process_guid: capi_process_guid ) service.delete_capi_diego_process_association(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |
#delete_route(guid:) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/cf-copilot.rb', line 36 def delete_route(guid:) request = Api::DeleteRouteRequest.new(guid: guid) service.delete_route(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |
#health ⇒ Object
23 24 25 26 |
# File 'lib/cf-copilot.rb', line 23 def health request = Api::HealthRequest.new service.health(request) end |
#map_route(capi_process_guid:, route_guid:, route_weight:) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/cf-copilot.rb', line 43 def map_route(capi_process_guid:, route_guid:, route_weight:) route_mapping = Api::RouteMapping.new(capi_process_guid: capi_process_guid, route_guid: route_guid, route_weight: route_weight) request = Api::MapRouteRequest.new(route_mapping: route_mapping) service.map_route(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |
#unmap_route(capi_process_guid:, route_guid:, route_weight:) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/cf-copilot.rb', line 51 def unmap_route(capi_process_guid:, route_guid:, route_weight:) route_mapping = Api::RouteMapping.new(capi_process_guid: capi_process_guid, route_guid: route_guid, route_weight: route_weight) request = Api::UnmapRouteRequest.new(route_mapping: route_mapping) service.unmap_route(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |
#upsert_capi_diego_process_association(capi_process_guid:, diego_process_guids:) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cf-copilot.rb', line 59 def upsert_capi_diego_process_association(capi_process_guid:, diego_process_guids:) request = Api::UpsertCapiDiegoProcessAssociationRequest.new( capi_diego_process_association: { capi_process_guid: capi_process_guid, diego_process_guids: diego_process_guids } ) service.upsert_capi_diego_process_association(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |
#upsert_route(guid:, host:, path: '') ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/cf-copilot.rb', line 28 def upsert_route(guid:, host:, path: '') route = Api::Route.new(guid: guid, host: host, path: path) request = Api::UpsertRouteRequest.new(route: route) service.upsert_route(request) rescue GRPC::BadStatus => e raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.}" end |