Class: DockerCloud::ContainerAPI

Inherits:
API
  • Object
show all
Defined in:
lib/docker_cloud/api/container_api.rb

Constant Summary collapse

TYPE =
'Container'.freeze

Constants inherited from API

API::API_VERSION, API::BASE_API_PATH

Instance Attribute Summary

Attributes inherited from API

#client, #headers, #type

Instance Method Summary collapse

Methods inherited from API

#get_from_uri, #http_delete, #http_get, #http_patch, #http_post, #initialize, #parse, #url

Constructor Details

This class inherits a constructor from DockerCloud::API

Instance Method Details

#all(params = {}) ⇒ Object



9
10
11
12
# File 'lib/docker_cloud/api/container_api.rb', line 9

def all(params = {})
  response = http_get(resource_url, params)
  format_object(response, TYPE)
end

#get(uuid) ⇒ Object



14
15
16
17
# File 'lib/docker_cloud/api/container_api.rb', line 14

def get(uuid)
  response = http_get(resource_url(uuid))
  format_object(response, TYPE)
end

#logs(uuid) ⇒ Object



31
32
33
34
35
# File 'lib/docker_cloud/api/container_api.rb', line 31

def logs(uuid)
  url = "#{uuid}/logs/"
  response = http_get(resource_url(url))
  format_object(response, TYPE)
end

#redeploy(uuid) ⇒ Object

NOTE: Container redeployment will make a destructive update.

redeploy will update the container UUID. 
But response is still the old UUID.


45
46
47
48
49
# File 'lib/docker_cloud/api/container_api.rb', line 45

def redeploy(uuid)
  url = "#{uuid}/redeploy/"
  response = http_post(resource_url(url))
  format_object(response, TYPE)
end

#resource_url(params = '') ⇒ Object



5
6
7
# File 'lib/docker_cloud/api/container_api.rb', line 5

def resource_url(params = '')
  "/container/#{params}"
end

#start(uuid) ⇒ Object



19
20
21
22
23
# File 'lib/docker_cloud/api/container_api.rb', line 19

def start(uuid)
  url = "#{uuid}/start/"
  response = http_post(resource_url(url))
  format_object(response, TYPE)
end

#stop(uuid) ⇒ Object



25
26
27
28
29
# File 'lib/docker_cloud/api/container_api.rb', line 25

def stop(uuid)
  url = "#{uuid}/stop/"
  response = http_post(resource_url(url))
  format_object(response, TYPE)
end

#terminate(uuid) ⇒ Object



37
38
39
40
# File 'lib/docker_cloud/api/container_api.rb', line 37

def terminate(uuid)
  response = http_delete(resource_url(uuid))
  format_object(response, TYPE)
end