Class: Etna::Clients::Janus
- Inherits:
-
BaseClient
show all
- Defined in:
- lib/etna/clients/janus/client.rb,
lib/etna/clients/janus/models.rb,
lib/etna/clients/janus/workflows/generate_token_workflow.rb
Defined Under Namespace
Classes: AddProjectRequest, AddUserRequest, GenerateTokenWorkflow, GetProjectRequest, GetProjectResponse, GetProjectsResponse, HtmlResponse, Project, RefreshTokenRequest, TokenResponse, UpdatePermissionRequest, ValidateTaskTokenRequest, ViewerTokenRequest
Instance Attribute Summary
Attributes inherited from BaseClient
#host, #ignore_ssl, #token
Instance Method Summary
collapse
Methods inherited from BaseClient
#initialize, #token_expired?, #token_will_expire?
Instance Method Details
#add_project(add_project_request = AddProjectRequest.new) ⇒ Object
29
30
31
32
33
|
# File 'lib/etna/clients/janus/client.rb', line 29
def add_project(add_project_request = AddProjectRequest.new)
@etna_client.post('/api/admin/add_project', add_project_request) do |res|
end
end
|
#add_user(add_user_request = AddUserRequest.new) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/etna/clients/janus/client.rb', line 35
def add_user(add_user_request = AddUserRequest.new)
@etna_client.post(
"/api/admin/#{add_user_request.project_name}/add_user",
add_user_request) do |res|
end
end
|
#generate_token(token_type, signed_nonce: nil, project_name: nil, read_only: false) ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/etna/clients/janus/client.rb', line 68
def generate_token(token_type, signed_nonce: nil, project_name: nil, read_only: false)
response = @etna_client.(
'Authorization' => signed_nonce ? "Signed-Nonce #{signed_nonce}" : nil
) do
post('/api/tokens/generate', token_type: token_type, project_name: project_name, read_only: read_only)
end
response.body
end
|
#get_nonce ⇒ Object
64
65
66
|
# File 'lib/etna/clients/janus/client.rb', line 64
def get_nonce
@etna_client.get('/api/tokens/nonce').body
end
|
#get_project(get_project_request = GetProjectRequest.new) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/etna/clients/janus/client.rb', line 10
def get_project(get_project_request = GetProjectRequest.new)
json = nil
@etna_client.get(
"/api/admin/#{get_project_request.project_name}/info") do |res|
json = JSON.parse(res.body, symbolize_names: true)
end
GetProjectResponse.new(json)
end
|
#get_projects ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/etna/clients/janus/client.rb', line 20
def get_projects()
json = nil
@etna_client.get('/api/user/projects') do |res|
json = JSON.parse(res.body, symbolize_names: true)
end
GetProjectsResponse.new(json)
end
|
#refresh_token(refresh_token_request = RefreshTokenRequest.new) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/etna/clients/janus/client.rb', line 51
def refresh_token(refresh_token_request = RefreshTokenRequest.new)
token = nil
@etna_client.post('/api/tokens/generate') do |res|
token = res.body
end
TokenResponse.new(token)
end
|
#update_permission(update_permission_request = UpdatePermissionRequest.new) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/etna/clients/janus/client.rb', line 43
def update_permission(update_permission_request = UpdatePermissionRequest.new)
@etna_client.post(
"/api/admin/#{update_permission_request.project_name}/update_permission",
update_permission_request) do |res|
end
end
|
#validate_task_token ⇒ Object
60
61
62
|
# File 'lib/etna/clients/janus/client.rb', line 60
def validate_task_token
@etna_client.post('/api/tokens/validate_task')
end
|