Skip to content

Commit

Permalink
Added admin_users_session_reset to Web API.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jul 20, 2019
1 parent 30450bc commit ae5a62c
Show file tree
Hide file tree
Showing 20 changed files with 112 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.14.3 (Next)

* [#279](https://github.com/slack-ruby/slack-ruby-client/pull/279): Prevent ping worker from dying on unexpected errors - [@dblock](https://github.com/dblock).
* [#281](https://github.com/slack-ruby/slack-ruby-client/pull/281): Added `admin_users_session_reset` to Web API - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.14.2 (2019/4/12)
Expand Down
1 change: 1 addition & 0 deletions bin/commands.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was auto-generated by lib/tasks/web.rake

require 'commands/admin_users_session'
require 'commands/api'
require 'commands/apps'
require 'commands/apps_permissions'
Expand Down
15 changes: 15 additions & 0 deletions bin/commands/admin_users_session.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminUsersSession methods.'
command 'admin_users_session' do |g|
g.desc 'This method wipes a user session, leaving the user unauthenticated. The user’s Slack client will reset its local cache.'
g.long_desc %( This method wipes a user session, leaving the user unauthenticated. The user’s Slack client will reset its local cache. )
g.command 'reset' do |c|
c.flag 'user_id', desc: 'The ID of the user to wipe sessions for.'
c.flag 'mobile_only', desc: 'Only expire mobile sessions (default: false).'
c.flag 'web_only', desc: 'Only expire web sessions (default: false).'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_session_reset(options))
end
end
end
4 changes: 2 additions & 2 deletions bin/commands/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

desc 'Apps methods.'
command 'apps' do |g|
g.desc 'This method uninstalls a workspace app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of a workspace app.'
g.long_desc %( This method uninstalls a workspace app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of a workspace app. )
g.desc 'This method uninstalls an app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of an app.'
g.long_desc %( This method uninstalls an app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of an app. )
g.command 'uninstall' do |c|
c.flag 'client_id', desc: 'Issued when you created your application.'
c.flag 'client_secret', desc: 'Issued when you created your application.'
Expand Down
5 changes: 4 additions & 1 deletion bin/commands/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,18 @@
g.desc 'This method posts an ephemeral message, which is visible only to the assigned user in a specific public channel, private channel, or private conversation.'
g.long_desc %( This method posts an ephemeral message, which is visible only to the assigned user in a specific public channel, private channel, or private conversation. )
g.command 'postEphemeral' do |c|
c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
c.flag 'channel', desc: 'Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.'
c.flag 'text', desc: "Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead."
c.flag 'user', desc: 'id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument.'
c.flag 'as_user', desc: 'Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.'
c.flag 'attachments', desc: 'A JSON-based array of structured attachments, presented as a URL-encoded string.'
c.flag 'blocks', desc: 'A JSON-based array of structured blocks, presented as a URL-encoded string.'
c.flag 'icon_emoji', desc: 'Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
c.flag 'icon_url', desc: 'URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.'
c.flag 'link_names', desc: 'Find and link channel names and usernames.'
c.flag 'parse', desc: 'Change how messages are treated. Defaults to none. See below.'
c.flag 'thread_ts', desc: "Provide another message's ts value to post this message in a thread. Avoid using a reply's ts value; use its parent's value instead. Ephemeral messages in threads are only shown if there is already an active thread."
c.flag 'username', desc: "Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below."
c.action do |_global_options, options, _args|
puts JSON.dump($client.chat_postEphemeral(options))
end
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/pins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

desc 'Pins methods.'
command 'pins' do |g|
g.desc 'This method pins an item (file, file comment, channel message, or group message) to a particular channel.'
g.long_desc %( This method pins an item (file, file comment, channel message, or group message) to a particular channel. The channel argument is required and one of file, file_comment, or timestamp must also be specified. )
g.desc ''
g.long_desc %( We are phasing out support for pinning files and file comments only. This method will no longer accept the file and file_comment parameters beginning August 22, 2019. )
g.command 'add' do |c|
c.flag 'channel', desc: 'Channel to pin the item in.'
c.flag 'file', desc: 'File to pin.'
Expand Down
1 change: 1 addition & 0 deletions bin/commands/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
g.desc 'This method provides information about your team.'
g.long_desc %( This method provides information about your team. )
g.command 'info' do |c|
c.flag 'team', desc: 'Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.team_info(options))
end
Expand Down
10 changes: 10 additions & 0 deletions lib/slack/real_time/stores/starter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ def initialize(attrs)

### RealTime Events

# An enterprise grid migration has started on an external workspace..
# @see https://api.slack.com/events/external_org_migration_started
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_started.json
# on :external_org_migration_started do |data|

# An enterprise grid migration has finished on an external workspace..
# @see https://api.slack.com/events/external_org_migration_finished
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_finished.json
# on :external_org_migration_finished do |data|

# A private channel was deleted.
# @see https://api.slack.com/events/group_deleted
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_deleted.json
Expand Down
10 changes: 10 additions & 0 deletions lib/slack/real_time/stores/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ def initialize(attrs)

### RealTime Events

# An enterprise grid migration has started on an external workspace..
# @see https://api.slack.com/events/external_org_migration_started
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_started.json
# on :external_org_migration_started do |data|

# An enterprise grid migration has finished on an external workspace..
# @see https://api.slack.com/events/external_org_migration_finished
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_finished.json
# on :external_org_migration_finished do |data|

# A private channel was deleted.
# @see https://api.slack.com/events/group_deleted
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_deleted.json
Expand Down
2 changes: 2 additions & 0 deletions lib/slack/web/api/endpoints.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was auto-generated by lib/tasks/web.rake

require_relative 'endpoints/admin_users_session'
require_relative 'endpoints/api'
require_relative 'endpoints/apps'
require_relative 'endpoints/apps_permissions'
Expand Down Expand Up @@ -45,6 +46,7 @@ module Endpoints
include Slack::Web::Api::Mixins::Users
include Slack::Web::Api::Mixins::Groups

include AdminUsersSession
include Api
include Apps
include AppsPermissions
Expand Down
27 changes: 27 additions & 0 deletions lib/slack/web/api/endpoints/admin_users_session.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file was auto-generated by lib/tasks/web.rake

module Slack
module Web
module Api
module Endpoints
module AdminUsersSession
#
# This method wipes a user session, leaving the user unauthenticated. The user’s Slack client will reset its local cache.
#
# @option options [Object] :user_id
# The ID of the user to wipe sessions for.
# @option options [Object] :mobile_only
# Only expire mobile sessions (default: false).
# @option options [Object] :web_only
# Only expire web sessions (default: false).
# @see https://api.slack.com/methods/admin.users.session.reset
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.users.session/admin.users.session.reset.json
def admin_users_session_reset(options = {})
throw ArgumentError.new('Required arguments :user_id missing') if options[:user_id].nil?
post('admin.users.session.reset', options)
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/slack/web/api/endpoints/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Api
module Endpoints
module Apps
#
# This method uninstalls a workspace app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of a workspace app.
# This method uninstalls an app. Unlike auth.revoke, which revokes a single token, this method revokes all tokens associated with a single installation of an app.
#
# @option options [Object] :client_id
# Issued when you created your application.
Expand Down
10 changes: 8 additions & 2 deletions lib/slack/web/api/endpoints/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def chat_meMessage(options = {})
#
# This method posts an ephemeral message, which is visible only to the assigned user in a specific public channel, private channel, or private conversation.
#
# @option options [Object] :attachments
# A JSON-based array of structured attachments, presented as a URL-encoded string.
# @option options [channel] :channel
# Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.
# @option options [Object] :text
Expand All @@ -101,16 +103,20 @@ def chat_meMessage(options = {})
# id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument.
# @option options [Object] :as_user
# Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.
# @option options [Object] :attachments
# A JSON-based array of structured attachments, presented as a URL-encoded string.
# @option options [Object] :blocks
# A JSON-based array of structured blocks, presented as a URL-encoded string.
# @option options [Object] :icon_emoji
# Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
# @option options [Object] :icon_url
# URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
# @option options [Object] :link_names
# Find and link channel names and usernames.
# @option options [Object] :parse
# Change how messages are treated. Defaults to none. See below.
# @option options [Object] :thread_ts
# Provide another message's ts value to post this message in a thread. Avoid using a reply's ts value; use its parent's value instead. Ephemeral messages in threads are only shown if there is already an active thread.
# @option options [Object] :username
# Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
# @see https://api.slack.com/methods/chat.postEphemeral
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json
def chat_postEphemeral(options = {})
Expand Down
1 change: 1 addition & 0 deletions lib/slack/web/api/endpoints/dnd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def dnd_setSnooze(options = {})
# @see https://api.slack.com/methods/dnd.teamInfo
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/dnd/dnd.teamInfo.json
def dnd_teamInfo(options = {})
throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
post('dnd.teamInfo', options)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/slack/web/api/endpoints/pins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Api
module Endpoints
module Pins
#
# This method pins an item (file, file comment, channel message, or group message) to a particular channel.
# The channel argument is required and one of file, file_comment, or timestamp must also be specified.
#
# We are phasing out support for pinning files and file comments only. This method will no longer accept the file and file_comment parameters beginning August 22, 2019.
#
# @option options [channel] :channel
# Channel to pin the item in.
Expand Down
2 changes: 2 additions & 0 deletions lib/slack/web/api/endpoints/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def team_billableInfo(options = {})
#
# This method provides information about your team.
#
# @option options [Object] :team
# Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels.
# @see https://api.slack.com/methods/team.info
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/team/team.info.json
def team_info(options = {})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
diff --git a/slack-ruby-client/lib/slack/web/api/endpoints/chat.rb b/slack-ruby-client-original/lib/slack/web/api/endpoints/chat.rb
index 194419e..2ef5c65 100644
diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
index e1c409d..3b24fea 100644
--- a/lib/slack/web/api/endpoints/chat.rb
+++ b/lib/slack/web/api/endpoints/chat.rb
@@ -93,7 +93,7 @@ module Slack
@@ -120,9 +120,8 @@ module Slack
# @see https://api.slack.com/methods/chat.postEphemeral
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json
def chat_postEphemeral(options = {})
- throw ArgumentError.new('Required arguments :attachments missing') if options[:attachments].nil?
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
- throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/api/slack-api-ref
Submodule slack-api-ref updated 104 files
12 changes: 12 additions & 0 deletions spec/slack/web/api/endpoints/admin_users_session_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was auto-generated by lib/tasks/web.rake

require 'spec_helper'

RSpec.describe Slack::Web::Api::Endpoints::AdminUsersSession do
let(:client) { Slack::Web::Client.new }
context 'admin.users.session_reset' do
it 'requires user_id' do
expect { client.admin_users_session_reset }.to raise_error ArgumentError, /Required arguments :user_id missing/
end
end
end
5 changes: 5 additions & 0 deletions spec/slack/web/api/endpoints/dnd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@
expect { client.dnd_setSnooze }.to raise_error ArgumentError, /Required arguments :num_minutes missing/
end
end
context 'dnd_teamInfo' do
it 'requires users' do
expect { client.dnd_teamInfo }.to raise_error ArgumentError, /Required arguments :users missing/
end
end
end

0 comments on commit ae5a62c

Please sign in to comment.