Class: UffizziCore::ControllerClient

Inherits:
Object
  • Object
show all
Defined in:
app/clients/uffizzi_core/controller_client.rb

Defined Under Namespace

Classes: RequestResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeControllerClient

Returns a new instance of ControllerClient.



6
7
8
# File 'app/clients/uffizzi_core/controller_client.rb', line 6

def initialize
  @connection = build_connection
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'app/clients/uffizzi_core/controller_client.rb', line 4

def connection
  @connection
end

Instance Method Details

#apply_config_file(deployment_id:, config_file_id:, body:) ⇒ Object



10
11
12
# File 'app/clients/uffizzi_core/controller_client.rb', line 10

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



58
59
60
# File 'app/clients/uffizzi_core/controller_client.rb', line 58

def apply_credential(deployment_id:, body:)
  connection.post("/deployments/#{deployment_id}/credentials", body)
end

#create_deployment(deployment_id:, body:) ⇒ Object



18
19
20
# File 'app/clients/uffizzi_core/controller_client.rb', line 18

def create_deployment(deployment_id:, body:)
  connection.post("/deployments/#{deployment_id}", body)
end

#delete_credential(deployment_id:, credential_id:) ⇒ Object



62
63
64
# File 'app/clients/uffizzi_core/controller_client.rb', line 62

def delete_credential(deployment_id:, credential_id:)
  connection.delete("/deployments/#{deployment_id}/credentials/#{credential_id}")
end

#delete_deployment(deployment_id:) ⇒ Object



26
27
28
# File 'app/clients/uffizzi_core/controller_client.rb', line 26

def delete_deployment(deployment_id:)
  connection.delete("/deployments/#{deployment_id}")
end

#deploy_containers(deployment_id:, body:) ⇒ Object



34
35
36
# File 'app/clients/uffizzi_core/controller_client.rb', line 34

def deploy_containers(deployment_id:, body:)
  connection.post("/deployments/#{deployment_id}/containers", body)
end

#deployment(deployment_id:) ⇒ Object



14
15
16
# File 'app/clients/uffizzi_core/controller_client.rb', line 14

def deployment(deployment_id:)
  get("/deployments/#{deployment_id}")
end

#deployment_container_logs(deployment_id:, container_name:, limit:) ⇒ Object



42
43
44
# File 'app/clients/uffizzi_core/controller_client.rb', line 42

def deployment_container_logs(deployment_id:, container_name:, limit:)
  get("/deployments/#{deployment_id}/containers/#{container_name}/logs?limit=#{limit}")
end

#deployment_containers(deployment_id:) ⇒ Object



30
31
32
# File 'app/clients/uffizzi_core/controller_client.rb', line 30

def deployment_containers(deployment_id:)
  get("/deployments/#{deployment_id}/containers")
end

#deployment_containers_events(deployment_id:) ⇒ Object



46
47
48
49
50
51
52
# File 'app/clients/uffizzi_core/controller_client.rb', line 46

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



38
39
40
# File 'app/clients/uffizzi_core/controller_client.rb', line 38

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



66
67
68
69
70
71
72
73
# File 'app/clients/uffizzi_core/controller_client.rb', line 66

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

#nodesObject



54
55
56
# File 'app/clients/uffizzi_core/controller_client.rb', line 54

def nodes
  get('/nodes')
end

#update_deployment(deployment_id:, body:) ⇒ Object



22
23
24
# File 'app/clients/uffizzi_core/controller_client.rb', line 22

def update_deployment(deployment_id:, body:)
  connection.put("/deployments/#{deployment_id}", body)
end