Class: Zillabyte::API::Keys

Inherits:
Base
  • Object
show all
Defined in:
lib/zillabyte/api/keys.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Zillabyte::API::Base

Instance Method Details

#add(name, key) ⇒ Object

PUT /keys/:name



13
14
15
16
17
18
19
20
21
22
# File 'lib/zillabyte/api/keys.rb', line 13

def add(name, key)
  response = request(
    body:     key,
    expects:  200,
    method:   :put,
    path:     "/keys/#{CGI.escape(name)}",
  )
  body = response.body
  body["body"]
end

#clear ⇒ Object

DELETE /keys



61
62
63
64
65
66
67
68
69
# File 'lib/zillabyte/api/keys.rb', line 61

def clear()
  response = request(
    expects:  200,
    method:   :delete,
    path:     "/keys",
  )
  body = response.body
  body["body"]
end

#list ⇒ Object

GET /keys



50
51
52
53
54
55
56
57
58
# File 'lib/zillabyte/api/keys.rb', line 50

def list()
  response = request(
    expects:  200,
    method:   :get,
    path:     "/keys",
  )
  body = response.body
  body
end

#remove(name, key_data) ⇒ Object

DELETE /keys/:name



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zillabyte/api/keys.rb', line 36

def remove(name, key_data)
  response = request(
    expects:  200,
    method:   :delete,
    path: "/keys/#{CGI.escape(name)}",
    query: {
      key_data: key_data,
    },
  )
  body = response.body
  body["body"]
end

#show(name) ⇒ Object

GET /keys/:name



25
26
27
28
29
30
31
32
33
# File 'lib/zillabyte/api/keys.rb', line 25

def show(name)
  response = request(
    expects:  200,
    method:   :get,
    path:     "/keys/#{CGI.escape(name)}",
  )
  body = response.body
  body["body"]
end