mattermost-api4-ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +39 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/mattermost.rb +8 -0
  12. data/lib/mattermost/client.rb +44 -0
  13. data/lib/mattermost/endpoint.rb +51 -0
  14. data/lib/mattermost/endpoint/brand.rb +27 -0
  15. data/lib/mattermost/endpoint/channels.rb +118 -0
  16. data/lib/mattermost/endpoint/cluster.rb +12 -0
  17. data/lib/mattermost/endpoint/commands.rb +39 -0
  18. data/lib/mattermost/endpoint/compliance.rb +33 -0
  19. data/lib/mattermost/endpoint/data_retention.rb +12 -0
  20. data/lib/mattermost/endpoint/elasticsearch.rb +16 -0
  21. data/lib/mattermost/endpoint/emoji.rb +38 -0
  22. data/lib/mattermost/endpoint/files.rb +60 -0
  23. data/lib/mattermost/endpoint/jobs.rb +28 -0
  24. data/lib/mattermost/endpoint/ldap.rb +17 -0
  25. data/lib/mattermost/endpoint/oauth.rb +40 -0
  26. data/lib/mattermost/endpoint/open_graph.rb +9 -0
  27. data/lib/mattermost/endpoint/plugins.rb +33 -0
  28. data/lib/mattermost/endpoint/posts.rb +62 -0
  29. data/lib/mattermost/endpoint/preferences.rb +28 -0
  30. data/lib/mattermost/endpoint/reactions.rb +9 -0
  31. data/lib/mattermost/endpoint/saml.rb +43 -0
  32. data/lib/mattermost/endpoint/status.rb +20 -0
  33. data/lib/mattermost/endpoint/system.rb +80 -0
  34. data/lib/mattermost/endpoint/teams.rb +113 -0
  35. data/lib/mattermost/endpoint/users.rb +9 -0
  36. data/lib/mattermost/endpoint/webhooks.rb +60 -0
  37. data/lib/mattermost/request.rb +7 -0
  38. data/mattermost-api4-ruby.gemspec +26 -0
  39. metadata +137 -0
@@ -0,0 +1,12 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module DataRetention
6
+
7
+ def get_data_retention_policy_details
8
+ get("/data_retention/policy")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Elasticsearch
6
+
7
+ def test_elasticsearch_configuration
8
+ post("/elasticsearch/test")
9
+ end
10
+
11
+ def purge_elasticsearch_indexes
12
+ post("/elasticsearch/purge_indexes")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Emoji
6
+
7
+ def create_custom_emoji(image_file, emoji)
8
+ #post("/emoji", emoji.to_json)
9
+ raise NotImplementedError
10
+ end
11
+
12
+ def get_custom_emoji_list(max = 60)
13
+ get("/emoji?per_page=#{max}")
14
+ end
15
+
16
+ def get_custom_emoji(emoji_id)
17
+ get("/emoji/#{emoji_id}")
18
+ end
19
+
20
+ def delete_custom_emoji(emoji_id)
21
+ delete("/emoji/#{emoji_id}")
22
+ end
23
+
24
+ def get_custom_emoji_image(emoji_id, file_name)
25
+ File.open(file_name, "w") do |file|
26
+ file.binmode
27
+ get(get_custom_emoji_image_url(emoji_id), stream_body: true) do |fragment|
28
+ file.write(fragment)
29
+ end
30
+ end
31
+ end
32
+
33
+ def get_custom_emoji_image_url(emoji_id)
34
+ "/emoji/#{emoji_id}/image"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,60 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Files
6
+
7
+ def upload_file(file, channel_id)
8
+ #post("/files, file)
9
+ raise NotImplementedError
10
+ end
11
+
12
+ def get_file(file_id, file_name)
13
+ File.open(file_name, "w") do |file|
14
+ file.binmode
15
+ get(get_file_url(file_id), stream_body: true) do |fragment|
16
+ file.write(fragment)
17
+ end
18
+ end
19
+ end
20
+
21
+ def get_file_url(file_id)
22
+ "/files/#{file_id}"
23
+ end
24
+
25
+ def get_file_thumbnail(file_id, file_name)
26
+ File.open(file_name, "w") do |file|
27
+ file.binmode
28
+ get(get_file_thumbnail_url(file_id), stream_body: true) do |fragment|
29
+ file.write(fragment)
30
+ end
31
+ end
32
+ end
33
+
34
+ def get_file_thumbnail_url(file_id)
35
+ "/files/#{file_id}/thumbnail"
36
+ end
37
+
38
+ def get_file_preview(file_id, file_name)
39
+ File.open(file_name, "w") do |file|
40
+ file.binmode
41
+ get(get_file_preview_url(file_id), stream_body: true) do |fragment|
42
+ file.write(fragment)
43
+ end
44
+ end
45
+ end
46
+
47
+ def get_file_preview_url(file_id)
48
+ "/files/#{file_id}/preview"
49
+ end
50
+
51
+ def get_public_file_link(file_id)
52
+ get("/files/#{file_id}/link")
53
+ end
54
+
55
+ def get_metadata_for_file(file_id)
56
+ get("/files/#{file_id}/info")
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Jobs
6
+
7
+ def get_jobs(max = 60)
8
+ get("/jobs?per_page=#{max}")
9
+ end
10
+
11
+ def create_job(job)
12
+ post("/jobs", :body => job.to_json)
13
+ end
14
+
15
+ def get_job(job_id)
16
+ get("/jobs/#{job_id}")
17
+ end
18
+
19
+ def cancel_job(job_id)
20
+ post("/jobs/#{job_id}/cancel")
21
+ end
22
+
23
+ def get_jobs_of_type(type, max = 60)
24
+ get("/jobs/type/#{type}?per_page=#{max}")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module LDAP
6
+
7
+ def sync_with_ldap
8
+ post("/ldap/sync")
9
+ end
10
+
11
+ def test_ldap_configuration
12
+ post("/ldap/test")
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module OAuth
6
+
7
+ def register_oauth_app(app)
8
+ post("/oauth/apps", :body => app.to_json)
9
+ end
10
+
11
+ def get_oauth_apps(max = 60)
12
+ get("/oauth/apps?per_page=#{max}")
13
+ end
14
+
15
+ def get_oauth_app(app_id)
16
+ get("/oauth/apps/#{app_id}")
17
+ end
18
+
19
+ def update_oauth_app(app_id, app)
20
+ put("/oauth/apps/#{app_id}", :body => app.to_json)
21
+ end
22
+
23
+ def delete_oauth_app(app_id)
24
+ delete("/oauth/apps/#{app_id}")
25
+ end
26
+
27
+ def regenerate_oauth_app_secret(app_id)
28
+ post("/oauth/apps/#{app_id}/regen_secret")
29
+ end
30
+
31
+ def get_oauth_app_info(app_id)
32
+ get("/oauth/apps/#{app_id}/info")
33
+ end
34
+
35
+ def get_authorized_oauth_apps(user_id, max = 60)
36
+ get("/users/#{user_id}/oauth/apps/authorized?per_page=#{max}")
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,9 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module OpenGraph
6
+ #empty
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Plugins
6
+
7
+ def upload_plugin(plugin)
8
+ #post("/pkugins", plugin)
9
+ raise NotImplementedError
10
+ end
11
+
12
+ def get_plugins
13
+ get("/plugins")
14
+ end
15
+
16
+ def remove_plugin(plugin_id)
17
+ delete("/plugins/#{plugin_id}")
18
+ end
19
+
20
+ def activate_plugin(plugin_id)
21
+ post("/plugins/#{plugin_id}/activate")
22
+ end
23
+
24
+ def deactivate_plugin(plugin_id)
25
+ post("/plugins/#{plugin_id}/deactivate")
26
+ end
27
+
28
+ def get_webapp_plugins
29
+ get("/plugins/webapp")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,62 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Posts
6
+ def create_post(post)
7
+ post("/posts", :body => post.to_json)
8
+ end
9
+
10
+ def get_post(post_id)
11
+ get("/posts/#{post_id}")
12
+ end
13
+
14
+ def delete_post(post_id)
15
+ delete("/posts/#{post_id}")
16
+ end
17
+
18
+ def update_post(post_id, post)
19
+ put("/posts/#{post_id}", :body => post.to_json)
20
+ end
21
+
22
+ def patch_post(post_id, patch)
23
+ put("/posts/#{post_id}", :body => patch.to_json)
24
+ end
25
+
26
+ def get_thread(post_id)
27
+ get("/posts/#{post_id}/thread")
28
+ end
29
+
30
+ def get_flagged_posts(user_id)
31
+ get("/posts/#{user_id}/posts/flagged")
32
+ end
33
+
34
+ def get_file_info_for_post(post_id)
35
+ get("/posts/#{post_id}/files/info")
36
+ end
37
+
38
+ def get_posts_for_channel(channel_id)
39
+ get("/channels/#{channel_id}/posts")
40
+ end
41
+
42
+ def search_team_posts(team_id, terms, is_or_search = false)
43
+ post("/teams/#{team_id}/posts/search", :body => {
44
+ :terms => terms,
45
+ :is_or_search => is_or_search
46
+ }.to_json)
47
+ end
48
+
49
+ def pin_post(post_id)
50
+ post("/posts/#{post_id}/pin")
51
+ end
52
+
53
+ def unpin_post(post_id)
54
+ post("/posts/#{post_id}/unpin")
55
+ end
56
+
57
+ def perform_post_action(post_id, action_id)
58
+ post("/posts/#{post_id}/actions/#{action_id}")
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Preferences
6
+
7
+ def get_user_preferences(user_id)
8
+ get("/users/#{user_id}/preferences")
9
+ end
10
+
11
+ def save_user_perferences(user_id, preferences = [])
12
+ put("/users/#{user_id}/preferences", :body => JSON.generate(preferences))
13
+ end
14
+
15
+ def delete_user_preferences(user_id, preferences = [])
16
+ post("/users/#{user_id}/preferences/delete", :body => JSON.generate(preferences))
17
+ end
18
+
19
+ def list_user_preferences_by_category(user_id, category)
20
+ get("/users/#{user_id}/preferences/#{category}")
21
+ end
22
+
23
+ def get_user_preference(user_id, category, preference_name)
24
+ get("/users/#{user_id}/preferences/#{category}/name/#{preference_name}")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Reactions
6
+ # empty
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,43 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module SAML
6
+
7
+ def get_saml_metadata
8
+ get("/saml/metadata")
9
+ end
10
+
11
+ def upload_idp_certificate(certificate)
12
+ #post("saml/certifiate/idp", certificate)
13
+ raise NotImplementedError
14
+ end
15
+
16
+ def remove_idp_certificate
17
+ delete("/saml/certificate/idp")
18
+ end
19
+
20
+ def upload_public_certificate(certificate)
21
+ #post("/saml/certificate/public", certificate)
22
+ raise NotImplementedError
23
+ end
24
+
25
+ def remove_public_certificate
26
+ delete("/saml/certificate/public")
27
+ end
28
+
29
+ def upload_private_key(key)
30
+ #post("/saml/certificate/private", key)
31
+ raise NotImplementedError
32
+ end
33
+
34
+ def remove_private_key
35
+ delete("/saml/certificate/private")
36
+ end
37
+
38
+ def get_certificate_status
39
+ get("/saml/certificate/status")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Status
6
+
7
+ def get_user_status(user_id)
8
+ get("/users/#{user_id}/status")
9
+ end
10
+
11
+ def update_user_status(user_id, status)
12
+ put("/users/#{user_id}/status", :body => {:status => status}.to_json)
13
+ end
14
+
15
+ def get_user_statuses_by_id()
16
+ get("/users/status/ids")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,80 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module System
6
+
7
+ def ping
8
+ get("/system/ping")
9
+ end
10
+
11
+ def recycle_database_connections
12
+ post("/database/recycle")
13
+ end
14
+
15
+ def send_test_email
16
+ post("/email/test")
17
+ end
18
+
19
+ def get_configuration
20
+ get("/config")
21
+ end
22
+
23
+ def update_configuration(config)
24
+ put("/config", :body => config.to_json)
25
+ end
26
+
27
+ def reload_configuration
28
+ post("/config/reload")
29
+ end
30
+
31
+ def get_client_configuration
32
+ get("/config/client?format=old")
33
+ end
34
+
35
+ def upload_license_file(file_name)
36
+ #post("/license", license)
37
+ raise NotImplementedError
38
+ end
39
+
40
+ def remove_license_file
41
+ delete("/license")
42
+ end
43
+
44
+ def get_client_license
45
+ get("/license/client?format=old")
46
+ end
47
+
48
+ def get_audits(max = 60)
49
+ get("/audits?per_page=#{max}")
50
+ end
51
+
52
+ def invalidate_server_caches
53
+ post("/caches/invalidate")
54
+ end
55
+
56
+ def get_logs(max = 60)
57
+ get("/logs?per_page=#{max}")
58
+ end
59
+
60
+ def add_log_message(level, message)
61
+ post("/logs", :body => {
62
+ :level => level,
63
+ :message => message
64
+ }.to_json)
65
+ end
66
+
67
+ def get_webrtc_token
68
+ get("/webrtc/token")
69
+ end
70
+
71
+ def get_analytics(team_id, name = 'standard')
72
+ url = "/analytics/old?name=#{name}"
73
+ if team_id != nil
74
+ url = "#{url}&team_id=#{team_id}"
75
+ end
76
+ get(url)
77
+ end
78
+ end
79
+ end
80
+ end