Class: UffizziCore::ControllerClient
- Inherits:
-
Object
- Object
- UffizziCore::ControllerClient
show all
- Defined in:
- app/clients/uffizzi_core/controller_client.rb
Defined Under Namespace
Classes: ConnectionError, RequestResult
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#apply_config_file(deployment_id:, config_file_id:, body:) ⇒ Object
-
#apply_credential(deployment_id:, body:) ⇒ Object
-
#create_cluster(namespace:, body:) ⇒ Object
-
#create_namespace(body:) ⇒ Object
-
#delete_credential(deployment_id:, credential_id:) ⇒ Object
-
#delete_namespace(namespace:) ⇒ Object
-
#deploy_containers(deployment_id:, body:) ⇒ Object
-
#deployment_container_logs(deployment_id:, container_name:, limit:, previous:) ⇒ Object
-
#deployment_containers(deployment_id:) ⇒ Object
-
#deployment_containers_events(deployment_id:) ⇒ Object
-
#deployment_containers_metrics(deployment_id:) ⇒ Object
-
#get_deployments_usage_metrics_containers(deployment_ids:, begin_at:, end_at:) ⇒ Object
-
#ingresses(namespace:) ⇒ Object
-
#initialize(connection_settings) ⇒ ControllerClient
constructor
A new instance of ControllerClient.
-
#namespace(namespace:) ⇒ Object
-
#nodes ⇒ Object
-
#patch_cluster(name:, namespace:, body:) ⇒ Object
-
#show_cluster(namespace:, name:) ⇒ Object
Constructor Details
#initialize(connection_settings) ⇒ ControllerClient
Returns a new instance of ControllerClient.
8
9
10
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 8
def initialize(connection_settings)
@connection = build_connection(connection_settings)
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6
7
8
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 6
def connection
@connection
end
|
Instance Method Details
#apply_config_file(deployment_id:, config_file_id:, body:) ⇒ Object
12
13
14
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 12
def apply_config_file(deployment_id:, config_file_id:, body:)
connection.post("/deployments/#{deployment_id}/config_files/#{config_file_id}", body)
end
|
#apply_credential(deployment_id:, body:) ⇒ Object
44
45
46
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 44
def apply_credential(deployment_id:, body:)
connection.post("/deployments/#{deployment_id}/credentials", body)
end
|
#create_cluster(namespace:, body:) ⇒ Object
73
74
75
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 73
def create_cluster(namespace:, body:)
post("/namespaces/#{namespace}/cluster", body)
end
|
#create_namespace(body:) ⇒ Object
61
62
63
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 61
def create_namespace(body:)
post('/namespaces', body)
end
|
#delete_credential(deployment_id:, credential_id:) ⇒ Object
48
49
50
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 48
def delete_credential(deployment_id:, credential_id:)
connection.delete("/deployments/#{deployment_id}/credentials/#{credential_id}")
end
|
#delete_namespace(namespace:) ⇒ Object
69
70
71
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 69
def delete_namespace(namespace:)
connection.delete("/namespaces/#{namespace}")
end
|
#deploy_containers(deployment_id:, body:) ⇒ Object
20
21
22
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 20
def deploy_containers(deployment_id:, body:)
connection.post("/deployments/#{deployment_id}/containers", body)
end
|
#deployment_container_logs(deployment_id:, container_name:, limit:, previous:) ⇒ Object
28
29
30
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 28
def deployment_container_logs(deployment_id:, container_name:, limit:, previous:)
get("/deployments/#{deployment_id}/containers/#{container_name}/logs?limit=#{limit}&previous=#{previous}")
end
|
#deployment_containers(deployment_id:) ⇒ Object
16
17
18
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 16
def deployment_containers(deployment_id:)
get("/deployments/#{deployment_id}/containers")
end
|
#deployment_containers_events(deployment_id:) ⇒ Object
32
33
34
35
36
37
38
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 32
def deployment_containers_events(deployment_id:)
events = get("/deployments/#{deployment_id}/containers/events").result.items
pods_events = events.select { |event| event.involved_object.kind == 'Pod' }
pods_events.map do |event|
{ first_timestamp: event.first_timestamp, last_timestamp: event.last_timestamp, reason: event.reason, message: event.message }
end
end
|
#deployment_containers_metrics(deployment_id:) ⇒ Object
24
25
26
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 24
def deployment_containers_metrics(deployment_id:)
get("/deployments/#{deployment_id}/containers/metrics")
end
|
#get_deployments_usage_metrics_containers(deployment_ids:, begin_at:, end_at:) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 52
def get_deployments_usage_metrics_containers(deployment_ids:, begin_at:, end_at:)
query_params = {
deployment_ids: deployment_ids,
begin_at: begin_at,
end_at: end_at,
}
get('/deployments/usage_metrics/containers', query_params)
end
|
#ingresses(namespace:) ⇒ Object
85
86
87
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 85
def ingresses(namespace:)
get("/namespaces/#{namespace}/ingresses")
end
|
#namespace(namespace:) ⇒ Object
65
66
67
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 65
def namespace(namespace:)
get("/namespaces/#{namespace}")
end
|
#nodes ⇒ Object
40
41
42
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 40
def nodes
get('/nodes')
end
|
#patch_cluster(name:, namespace:, body:) ⇒ Object
81
82
83
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 81
def patch_cluster(name:, namespace:, body:)
patch("/namespaces/#{namespace}/cluster/#{name}", body)
end
|
#show_cluster(namespace:, name:) ⇒ Object
77
78
79
|
# File 'app/clients/uffizzi_core/controller_client.rb', line 77
def show_cluster(namespace:, name:)
get("/namespaces/#{namespace}/cluster/#{name}")
end
|