Class: Gretl::K8sClient

Inherits:
Object
  • Object
show all
Defined in:
lib/gretl.rb

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ K8sClient

Returns a new instance of K8sClient.



161
162
163
# File 'lib/gretl.rb', line 161

def initialize(token)
  @token = token
end

Instance Method Details

#auto_sleep(workload_id) ⇒ Object



200
201
202
# File 'lib/gretl.rb', line 200

def auto_sleep(workload_id)
  _cloud_get("/k8s/workloads/#{workload_id}/auto-sleep")
end

#clustersObject



165
166
167
# File 'lib/gretl.rb', line 165

def clusters
  _cloud_get("/k8s/clusters")
end

#detach(tether_id) ⇒ Object



192
193
194
# File 'lib/gretl.rb', line 192

def detach(tether_id)
  _cloud_post("/k8s/tethers/#{tether_id}/deactivate")
end

#set_auto_sleep(workload_id, enabled:, idle_timeout_minutes:) ⇒ Object



204
205
206
207
# File 'lib/gretl.rb', line 204

def set_auto_sleep(workload_id, enabled:, idle_timeout_minutes:)
  _cloud_put("/k8s/workloads/#{workload_id}/auto-sleep",
             { auto_sleep_enabled: enabled, idle_timeout_minutes: idle_timeout_minutes })
end

#sleep(workload_id) ⇒ Object



178
179
180
# File 'lib/gretl.rb', line 178

def sleep(workload_id)
  _cloud_post("/k8s/workloads/#{workload_id}/sleep")
end

#sync(cluster_id) ⇒ Object



174
175
176
# File 'lib/gretl.rb', line 174

def sync(cluster_id)
  _cloud_post("/k8s/clusters/#{cluster_id}/sync")
end

#tether(workload_id, container_port:, label: nil) ⇒ Object



186
187
188
189
190
# File 'lib/gretl.rb', line 186

def tether(workload_id, container_port:, label: nil)
  body = { container_port: container_port }
  body[:label] = label if label
  _cloud_post("/k8s/workloads/#{workload_id}/tether", body)
end

#tethersObject



196
197
198
# File 'lib/gretl.rb', line 196

def tethers
  _cloud_get("/k8s/tethers")
end

#wake(workload_id) ⇒ Object



182
183
184
# File 'lib/gretl.rb', line 182

def wake(workload_id)
  _cloud_post("/k8s/workloads/#{workload_id}/wake")
end

#workloads(cluster_id: nil) ⇒ Object



169
170
171
172
# File 'lib/gretl.rb', line 169

def workloads(cluster_id: nil)
  path = cluster_id ? "/k8s/clusters/#{cluster_id}/workloads" : "/k8s/workloads"
  _cloud_get(path)
end