-
Notifications
You must be signed in to change notification settings - Fork 2
/
image.cr
50 lines (50 loc) · 1.66 KB
/
image.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module OceanKit
module Resource
# Images in DigitalOcean may refer to one of a few different kinds of objects.
# An image may refer to a snapshot that has been taken of a Droplet instance.
# It may also mean an image representing an automatic backup of a Droplet.
# The third category that it can represent is a public Linux distribution or
# application image that is used as a base to create Droplets.
class Image < OceanKit::Resource::Base
def images
self
end
# To list all of the images available on your account
#
# The response will be a JSON object with a key called images. This
# will be set to an array of image objects, each of which will contain
# the standard image attributes:
def all
get("/images")
end
# Retrieve information about an image (public or private),
# The response will be a JSON object with a key called image.
# The value of this will be an image object containing the standard
# image attributes.
def find(id)
get("/images/#{id}")
end
# Delete an image
def delete(id)
destroy("/images/#{id}")
end
# Update an image
def update(id, name)
options = {"name" => name }
put("/images/#{id}", %(options}))
end
# Retrieve only distribution images
def all_distribution
get("/images?type=distribution")
end
# Retrieve only application images
def all_application
get("/images?type=application")
end
# To retrieve only the private images
def all_private
get("/images?private=true")
end
end
end
end