Class: Scaled::Client
- Inherits:
-
Object
- Object
- Scaled::Client
- Defined in:
- lib/scaled/client.rb
Overview
Main entry point for interacting with Tailscale API. Основна точка входу для взаємодії з Tailscale API.
Instance Attribute Summary collapse
-
#tailnet ⇒ Object
readonly
Returns the value of attribute tailnet.
Instance Method Summary collapse
- #acl ⇒ Scaled::Resources::Acl
-
#delete(path, query: nil) ⇒ Hash, ...
Parsed response body.
- #device_routes ⇒ Scaled::Resources::DeviceRoutes
- #devices ⇒ Scaled::Resources::Devices
-
#get(path, query: nil) ⇒ Hash, ...
Note: use this low-level method until resource-specific clients are introduced.
-
#initialize(api_token: nil, auth: nil, oauth: nil, tailnet: "-", **http_options) ⇒ void
constructor
Note: exactly one auth mode must be provided: ‘api_token`, `auth`, or `oauth`.
- #keys ⇒ Scaled::Resources::Keys
- #logs ⇒ Scaled::Resources::Logs
-
#patch(path, body: nil, query: nil) ⇒ Hash, ...
Parsed response body.
-
#post(path, body: nil, query: nil) ⇒ Hash, ...
Parsed response body.
-
#put(path, body: nil, query: nil) ⇒ Hash, ...
Parsed response body.
Constructor Details
#initialize(api_token: nil, auth: nil, oauth: nil, tailnet: "-", **http_options) ⇒ void
Note: exactly one auth mode must be provided: ‘api_token`, `auth`, or `oauth`. Нотатка: потрібно передати рівно один режим auth: `api_token`, `auth` або `oauth`.
26 27 28 29 30 |
# File 'lib/scaled/client.rb', line 26 def initialize(api_token: nil, auth: nil, oauth: nil, tailnet: "-", **) @tailnet = tailnet auth_strategy = resolve_auth(api_token: api_token, auth: auth, oauth: oauth) @http = HTTP.new(auth: auth_strategy, **) end |
Instance Attribute Details
#tailnet ⇒ Object (readonly)
Returns the value of attribute tailnet.
16 17 18 |
# File 'lib/scaled/client.rb', line 16 def tailnet @tailnet end |
Instance Method Details
#acl ⇒ Scaled::Resources::Acl
88 89 90 |
# File 'lib/scaled/client.rb', line 88 def acl @acl ||= Resources::Acl.new(self) end |
#delete(path, query: nil) ⇒ Hash, ...
Returns parsed response body.
68 69 70 |
# File 'lib/scaled/client.rb', line 68 def delete(path, query: nil) @http.request(method: :delete, path: path, query: query) end |
#device_routes ⇒ Scaled::Resources::DeviceRoutes
93 94 95 |
# File 'lib/scaled/client.rb', line 93 def device_routes @device_routes ||= Resources::DeviceRoutes.new(self) end |
#devices ⇒ Scaled::Resources::Devices
73 74 75 |
# File 'lib/scaled/client.rb', line 73 def devices @devices ||= Resources::Devices.new(self) end |
#get(path, query: nil) ⇒ Hash, ...
Note: use this low-level method until resource-specific clients are introduced. Нотатка: використовуйте цей low-level метод, доки не додані ресурсні клієнти.
37 38 39 |
# File 'lib/scaled/client.rb', line 37 def get(path, query: nil) @http.request(method: :get, path: path, query: query) end |
#keys ⇒ Scaled::Resources::Keys
78 79 80 |
# File 'lib/scaled/client.rb', line 78 def keys @keys ||= Resources::Keys.new(self) end |
#logs ⇒ Scaled::Resources::Logs
83 84 85 |
# File 'lib/scaled/client.rb', line 83 def logs @logs ||= Resources::Logs.new(self) end |
#patch(path, body: nil, query: nil) ⇒ Hash, ...
Returns parsed response body.
61 62 63 |
# File 'lib/scaled/client.rb', line 61 def patch(path, body: nil, query: nil) @http.request(method: :patch, path: path, body: body, query: query) end |
#post(path, body: nil, query: nil) ⇒ Hash, ...
Returns parsed response body.
45 46 47 |
# File 'lib/scaled/client.rb', line 45 def post(path, body: nil, query: nil) @http.request(method: :post, path: path, body: body, query: query) end |
#put(path, body: nil, query: nil) ⇒ Hash, ...
Returns parsed response body.
53 54 55 |
# File 'lib/scaled/client.rb', line 53 def put(path, body: nil, query: nil) @http.request(method: :put, path: path, body: body, query: query) end |