Class: OutlineVpnApi::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/outline_vpn_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_url) ⇒ Client

Returns a new instance of Client.



12
13
14
# File 'lib/outline_vpn_api/client.rb', line 12

def initialize(api_url)
  self.class.base_uri(api_url)
end

Instance Method Details

#create_keyObject



24
25
26
# File 'lib/outline_vpn_api/client.rb', line 24

def create_key
  post("/access-keys")
end

#delete_key(key_id) ⇒ Object



38
39
40
41
# File 'lib/outline_vpn_api/client.rb', line 38

def delete_key(key_id)
  response = self.class.delete("/access-keys/#{key_id}")
  handle_response(response, "key_id: #{key_id}, deleted")
end

#keys_listObject



16
17
18
# File 'lib/outline_vpn_api/client.rb', line 16

def keys_list
  get("/access-keys")["accessKeys"]
end

#rename_key(key_id, name) ⇒ Object



33
34
35
36
# File 'lib/outline_vpn_api/client.rb', line 33

def rename_key(key_id, name)
  body = { name: }.to_json
  put("/access-keys/#{key_id}/name", body, "key_id: #{key_id}, renamed to #{name}")
end

#set_limit(key_id, limit) ⇒ Object



28
29
30
31
# File 'lib/outline_vpn_api/client.rb', line 28

def set_limit(key_id, limit)
  body = { limit: { bytes: limit } }.to_json
  put("/access-keys/#{key_id}/data-limit", body, "Limit for key_id: #{key_id} is #{limit} bytes")
end

#transferred_data_by_idObject



20
21
22
# File 'lib/outline_vpn_api/client.rb', line 20

def transferred_data_by_id
  get("/metrics/transfer")
end