Skip to content

Commit

Permalink
Update APIs (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabigeek authored Oct 7, 2020
1 parent f2f2b45 commit 401a2b4
Show file tree
Hide file tree
Showing 44 changed files with 879 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.15.2 (Next)

* [#348](https://github.com/slack-ruby/slack-ruby-client/pull/348): Added `admin_conversations_archive`, `admin_conversations_convertToPrivate`, `admin_conversations_create`, `admin_conversations_delete`, `admin_conversations_disconnectShared`, `admin_conversations_getConversationPrefs`, `admin_conversations_getTeams`, `admin_conversations_invite`, `admin_conversations_rename`, `admin_conversations_search`, `admin_conversations_setConversationPrefs`, `admin_conversations_unarchive`, `admin_conversations_ekm_listOriginalConnectedChannelInfo`, `admin_users_session_invalidate`, `apps_event_authorizations_list`, `conversations_mark`, `workflows_stepCompleted`, `workflows_stepFailed`, `workflows_updateStep` endpoints - [@wasabigeek](https://github.com/wasabigeek).
* Your contribution here.

### 0.15.1 (2020/9/3)
Expand Down
3 changes: 3 additions & 0 deletions bin/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'commands/admin_apps_requests'
require 'commands/admin_apps_restricted'
require 'commands/admin_conversations'
require 'commands/admin_conversations_ekm'
require 'commands/admin_conversations_restrictAccess'
require 'commands/admin_conversations_whitelist'
require 'commands/admin_emoji'
Expand All @@ -21,6 +22,7 @@
require 'commands/admin_users_session'
require 'commands/api'
require 'commands/apps'
require 'commands/apps_event_authorizations'
require 'commands/apps_permissions'
require 'commands/apps_permissions_resources'
require 'commands/apps_permissions_scopes'
Expand Down Expand Up @@ -60,3 +62,4 @@
require 'commands/users_prefs'
require 'commands/users_profile'
require 'commands/views'
require 'commands/workflows'
128 changes: 126 additions & 2 deletions bin/commands/admin_conversations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,123 @@

desc 'AdminConversations methods.'
command 'admin_conversations' do |g|
g.desc 'Set the workspaces in an Enterprise grid org that connect to a channel.'
g.long_desc %( Set the workspaces in an Enterprise grid org that connect to a channel. )
g.desc 'Archive a public or private channel.'
g.long_desc %( Archive a public or private channel. )
g.command 'archive' do |c|
c.flag 'channel_id', desc: 'The channel to archive.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_archive(options))
end
end

g.desc 'Convert a public channel to a private channel.'
g.long_desc %( Convert a public channel to a private channel. )
g.command 'convertToPrivate' do |c|
c.flag 'channel_id', desc: 'The channel to convert to private.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_convertToPrivate(options))
end
end

g.desc 'Create a public or private channel-based conversation.'
g.long_desc %( Create a public or private channel-based conversation. )
g.command 'create' do |c|
c.flag 'is_private', desc: 'When true, creates a private channel instead of a public channel.'
c.flag 'name', desc: 'Name of the public or private channel to create.'
c.flag 'description', desc: 'Description of the public or private channel to create.'
c.flag 'org_wide', desc: 'When true, the channel will be available org-wide. Note: if the channel is not org_wide=true, you must specify a team_id for this channel.'
c.flag 'team_id', desc: 'The workspace to create the channel in. Note: this argument is required unless you set org_wide=true.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_create(options))
end
end

g.desc 'Delete a public or private channel.'
g.long_desc %( Delete a public or private channel. )
g.command 'delete' do |c|
c.flag 'channel_id', desc: 'The channel to delete.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_delete(options))
end
end

g.desc 'Disconnect a connected channel from one or more workspaces.'
g.long_desc %( Disconnect a connected channel from one or more workspaces. )
g.command 'disconnectShared' do |c|
c.flag 'channel_id', desc: 'The channel to be disconnected from some workspaces.'
c.flag 'leaving_team_ids', desc: 'The team to be removed from the channel. Currently only a single team id can be specified.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_disconnectShared(options))
end
end

g.desc 'Get conversation preferences for a public or private channel.'
g.long_desc %( Get conversation preferences for a public or private channel. )
g.command 'getConversationPrefs' do |c|
c.flag 'channel_id', desc: 'The channel to get preferences for.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_getConversationPrefs(options))
end
end

g.desc 'Get all the workspaces a given public or private channel is connected to within this Enterprise org.'
g.long_desc %( Get all the workspaces a given public or private channel is connected to within this Enterprise org. )
g.command 'getTeams' do |c|
c.flag 'channel_id', desc: 'The channel to determine connected workspaces within the organization for.'
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_getTeams(options))
end
end

g.desc 'Invite a user to a public or private channel.'
g.long_desc %( Invite a user to a public or private channel. )
g.command 'invite' do |c|
c.flag 'channel_id', desc: 'The channel that the users will be invited to.'
c.flag 'user_ids', desc: 'The users to invite.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_invite(options))
end
end

g.desc 'Rename a public or private channel.'
g.long_desc %( Rename a public or private channel. )
g.command 'rename' do |c|
c.flag 'channel_id', desc: 'The channel to rename.'
c.flag 'name', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_rename(options))
end
end

g.desc 'Search for public or private channels in an Enterprise organization.'
g.long_desc %( Search for public or private channels in an Enterprise organization. )
g.command 'search' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'limit', desc: 'Maximum number of items to be returned. Must be between 1 - 20 both inclusive. Default is 10.'
c.flag 'query', desc: 'Name of the the channel to query by.'
c.flag 'search_channel_types', desc: 'The type of channel to include or exclude in the search. For example private will search private channels, while private_exclude will exclude them. For a full list of types, check the Types section.'
c.flag 'sort', desc: 'Possible values are relevant (search ranking based on what we think is closest), name (alphabetical), member_count (number of users in the channel), and created (date channel was created). You can optionally pair this with the sort_dir arg to change how it is sorted.'
c.flag 'sort_dir', desc: 'Sort direction. Possible values are asc for ascending order like (1, 2, 3) or (a, b, c), and desc for descending order like (3, 2, 1) or (c, b, a).'
c.flag 'team_ids', desc: 'Comma separated string of team IDs, signifying the workspaces to search through.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_search(options))
end
end

g.desc 'Set the posting permissions for a public or private channel.'
g.long_desc %( Set the posting permissions for a public or private channel. )
g.command 'setConversationPrefs' do |c|
c.flag 'channel_id', desc: 'The channel to set the prefs for.'
c.flag 'prefs', desc: 'The prefs for this channel in a stringified JSON format.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_setConversationPrefs(options))
end
end

g.desc 'Set the workspaces in an Enterprise grid org that connect to a public or private channel.'
g.long_desc %( Set the workspaces in an Enterprise grid org that connect to a public or private channel. )
g.command 'setTeams' do |c|
c.flag 'channel_id', desc: 'The encoded channel_id to add or remove to workspaces.'
c.flag 'org_channel', desc: 'True if channel has to be converted to an org channel.'
Expand All @@ -14,4 +129,13 @@
puts JSON.dump($client.admin_conversations_setTeams(options))
end
end

g.desc 'Unarchive a public or private channel.'
g.long_desc %( Unarchive a public or private channel. )
g.command 'unarchive' do |c|
c.flag 'channel_id', desc: 'The channel to unarchive.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_unarchive(options))
end
end
end
17 changes: 17 additions & 0 deletions bin/commands/admin_conversations_ekm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminConversationsEkm methods.'
command 'admin_conversations_ekm' do |g|
g.desc 'List all disconnected channels—i.e., channels that were once connected to other workspaces and then disconnected—and the corresponding original channel IDs for key revocation with EKM.'
g.long_desc %( List all disconnected channels—i.e., channels that were once connected to other workspaces and then disconnected—and the corresponding original channel IDs for key revocation with EKM. )
g.command 'listOriginalConnectedChannelInfo' do |c|
c.flag 'channel_ids', desc: 'A comma-separated list of channels to filter to.'
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_ids', desc: 'A comma-separated list of the workspaces to which the channels you would like returned belong.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_ekm_listOriginalConnectedChannelInfo(options))
end
end
end
6 changes: 3 additions & 3 deletions bin/commands/admin_conversations_restrictAccess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
g.command 'addGroup' do |c|
c.flag 'channel_id', desc: 'The channel to link this group to.'
c.flag 'group_id', desc: 'The IDP Group ID to be an allowlist for the private channel.'
c.flag 'team_id', desc: 'The workspace where the IDP Group and channel exist.'
c.flag 'team_id', desc: 'The workspace where the channel exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_restrictAccess_addGroup(options))
end
Expand All @@ -18,7 +18,7 @@
g.long_desc %( List all IDP Groups linked to a channel )
g.command 'listGroups' do |c|
c.flag 'channel_id', desc: '.'
c.flag 'team_id', desc: 'The workspace where the channele exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization.'
c.flag 'team_id', desc: 'The workspace where the channel exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_restrictAccess_listGroups(options))
end
Expand All @@ -29,7 +29,7 @@
g.command 'removeGroup' do |c|
c.flag 'channel_id', desc: 'The channel to remove the linked group from.'
c.flag 'group_id', desc: 'The IDP Group ID to remove from the private channel.'
c.flag 'team_id', desc: 'The workspace where the IDP Group and channel exist.'
c.flag 'team_id', desc: 'The workspace where the channel exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_conversations_restrictAccess_removeGroup(options))
end
Expand Down
10 changes: 10 additions & 0 deletions bin/commands/admin_users_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

desc 'AdminUsersSession methods.'
command 'admin_users_session' do |g|
g.desc 'Invalidate a single session for a user by session_id'
g.long_desc %( Invalidate a single session for a user by session_id )
g.command 'invalidate' do |c|
c.flag 'session_id', desc: '.'
c.flag 'team_id', desc: 'ID of the team that the session belongs to.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_session_invalidate(options))
end
end

g.desc 'Wipes all valid sessions on all devices for a given user'
g.long_desc %( Wipes all valid sessions on all devices for a given user )
g.command 'reset' do |c|
Expand Down
16 changes: 16 additions & 0 deletions bin/commands/apps_event_authorizations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AppsEventAuthorizations methods.'
command 'apps_event_authorizations' do |g|
g.desc 'Get a list of authorizations for the given event context. Each authorization represents an app installation that the event is visible to.'
g.long_desc %( Get a list of authorizations for the given event context. Each authorization represents an app installation that the event is visible to. )
g.command 'list' do |c|
c.flag 'event_context', desc: '.'
c.flag 'cursor', desc: '.'
c.flag 'limit', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.apps_event_authorizations_list(options))
end
end
end
12 changes: 11 additions & 1 deletion bin/commands/conversations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@
end
end

g.desc 'Sets the read cursor in a channel.'
g.long_desc %( Sets the read cursor in a channel. )
g.command 'mark' do |c|
c.flag 'channel', desc: 'Channel or conversation to set the read cursor for.'
c.flag 'ts', desc: 'Unique identifier of message you want marked as most recently seen in this conversation.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.conversations_mark(options))
end
end

g.desc 'Retrieve members of a conversation.'
g.long_desc %( Retrieve members of a conversation. )
g.command 'members' do |c|
Expand Down Expand Up @@ -142,7 +152,7 @@
g.long_desc %( Retrieve a thread of messages posted to a conversation )
g.command 'replies' do |c|
c.flag 'channel', desc: 'Conversation ID to fetch thread from.'
c.flag 'ts', desc: "Unique identifier of a thread's parent message."
c.flag 'ts', desc: "Unique identifier of a thread's parent message. ts must be the timestamp of an existing message with 0 or more replies. If there are no replies then just the single message referenced by ts will return - it is just an ordinary, unthreaded message."
c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail."
c.flag 'inclusive', desc: 'Include messages with latest or oldest timestamp in results only when either timestamp is specified.'
c.flag 'latest', desc: 'End of time range of messages to include in results.'
Expand Down
8 changes: 4 additions & 4 deletions bin/commands/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
end
end

g.desc 'Gets information about a team file.'
g.long_desc %( Gets information about a team file. )
g.desc 'Gets information about a file.'
g.long_desc %( Gets information about a file. )
g.command 'info' do |c|
c.flag 'file', desc: 'Specify a file by providing its ID.'
c.flag 'cursor', desc: "Parameter for pagination. File comments are paginated for a single file. Set cursor equal to the next_cursor attribute returned by the previous request's response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first 'page' of the collection of comments. See pagination for more details."
Expand All @@ -34,8 +34,8 @@
end
end

g.desc 'Lists & filters team files.'
g.long_desc %( Lists & filters team files. )
g.desc 'List for a team, in a channel, or from a user with applied filters.'
g.long_desc %( List for a team, in a channel, or from a user with applied filters. )
g.command 'list' do |c|
c.flag 'channel', desc: 'Filter files appearing in a specific channel, indicated by its ID.'
c.flag 'show_files_hidden_by_limit', desc: 'Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit.'
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/files_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
g.long_desc %( Share a remote file into a channel. )
g.command 'share' do |c|
c.flag 'channels', desc: 'Comma-separated list of channel IDs where the file will be shared.'
c.flag 'external_id', desc: 'Creator defined GUID for the file.'
c.flag 'file', desc: 'Specify a file by providing its ID.'
c.flag 'external_id', desc: 'The globally unique identifier (GUID) for the file, as set by the app registering the file with Slack. Either this field or file or both are required.'
c.flag 'file', desc: 'Specify a file registered with Slack by providing its ID. Either this field or external_id or both are required.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.files_remote_share(options))
end
Expand Down
1 change: 1 addition & 0 deletions bin/commands/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
g.long_desc %( For Enterprise Grid workspaces, map local user IDs to global user IDs )
g.command 'exchange' do |c|
c.flag 'users', desc: 'A comma-separated list of user ids, up to 400 per request.'
c.flag 'team_id', desc: 'Specify team_id starts with T in case of Org Token.'
c.flag 'to_old', desc: 'Specify true to convert W global user IDs to workspace-specific U IDs. Defaults to false.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.migration_exchange(options))
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
g.command 'list' do |c|
c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail."
c.flag 'include_locale', desc: 'Set this to true to receive the locale for users. Defaults to false.'
c.flag 'limit', desc: "The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached."
c.flag 'limit', desc: "The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. Providing no limit value will result in Slack attempting to deliver you the entire result set. If the collection is too large you may experience limit_required or HTTP 500 errors."
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_list(options))
end
Expand Down Expand Up @@ -100,10 +100,10 @@
g.desc 'Set the user profile photo'
g.long_desc %( Set the user profile photo )
g.command 'setPhoto' do |c|
c.flag 'image', desc: 'File contents via multipart/form-data.'
c.flag 'crop_w', desc: 'Width/height of crop box (always square).'
c.flag 'crop_x', desc: 'X coordinate of top-left corner of crop box.'
c.flag 'crop_y', desc: 'Y coordinate of top-left corner of crop box.'
c.flag 'image', desc: 'File contents via multipart/form-data.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_setPhoto(options))
end
Expand Down
Loading

2 comments on commit 401a2b4

@crazyoptimist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been so much impressed by your contribution @wasabigeek !!
Please keep doing good 👍 👍 🥇

@wasabigeek
Copy link
Contributor Author

@wasabigeek wasabigeek commented on 401a2b4 Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crazyoptimist oh hey thanks, actually most of the credit for this goes to the infra that @dblock and other maintainers setup, I literally run a rake task that does all of this :D

Feel free to try it yourself! https://github.com/slack-ruby/slack-ruby-client/blob/master/CONTRIBUTING.md#update-slack-web-api, I saw there are already new methods that can be added

Please sign in to comment.