Class: Cloudfoundry::Copilot::Client
- Inherits:
-
Object
- Object
- Cloudfoundry::Copilot::Client
show all
- Defined in:
- lib/cf-copilot.rb
Defined Under Namespace
Classes: BulkSyncEnum, PilotError
Constant Summary
collapse
- CHUNK_SIZE =
64 * 1024
Instance Attribute Summary collapse
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: '', internal: false, vip: nil) ⇒ Object
Constructor Details
#initialize(host:, port:, client_ca_file:, client_key_file:, client_chain_file:, timeout: 5) ⇒ Client
Returns a new instance of Client.
15
16
17
18
19
20
21
22
23
|
# File 'lib/cf-copilot.rb', line 15
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
Returns the value of attribute host.
13
14
15
|
# File 'lib/cf-copilot.rb', line 13
def host
@host
end
|
#port ⇒ Object
Returns the value of attribute port.
13
14
15
|
# File 'lib/cf-copilot.rb', line 13
def port
@port
end
|
Instance Method Details
#bulk_sync(routes:, route_mappings:, capi_diego_process_associations:) ⇒ Object
114
115
116
117
118
119
|
# File 'lib/cf-copilot.rb', line 114
def bulk_sync(routes:, route_mappings:, capi_diego_process_associations:)
bs_enum = BulkSyncEnum.new(routes, route_mappings, capi_diego_process_associations)
service.bulk_sync(bs_enum.each)
rescue GRPC::BadStatus => e
raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.metadata}"
end
|
#delete_capi_diego_process_association(capi_process_guid:) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/cf-copilot.rb', line 77
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.metadata}"
end
|
#delete_route(guid:) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/cf-copilot.rb', line 41
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.metadata}"
end
|
#health ⇒ Object
25
26
27
28
|
# File 'lib/cf-copilot.rb', line 25
def health
request = Api::HealthRequest.new
service.health(request)
end
|
#map_route(capi_process_guid:, route_guid:, route_weight:) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/cf-copilot.rb', line 48
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.metadata}"
end
|
#unmap_route(capi_process_guid:, route_guid:, route_weight:) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/cf-copilot.rb', line 56
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.metadata}"
end
|
#upsert_capi_diego_process_association(capi_process_guid:, diego_process_guids:) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/cf-copilot.rb', line 64
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.metadata}"
end
|
#upsert_route(guid:, host:, path: '', internal: false, vip: nil) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cf-copilot.rb', line 30
def upsert_route(guid:, host:, path: '', internal: false, vip: nil)
if internal && vip.nil?
raise Cloudfoundry::Copilot::Client::PilotError, "vip required for internal routes"
end
route = Api::Route.new(guid: guid, host: host, path: path, internal: internal, vip: vip)
request = Api::UpsertRouteRequest.new(route: route)
service.upsert_route(request)
rescue GRPC::BadStatus => e
raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.metadata}"
end
|