Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add admin web api methods #305

Merged
merged 2 commits into from Dec 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
### 0.14.6 (Next)

* [#305](https://github.com/slack-ruby/slack-ruby-client/pull/305): Added `admin.inviteRequests.approve`, `admin.inviteRequests.deny`, `admin.inviteRequests.list`, `admin.inviteRequests.approved.list`, `admin.inviteRequests.denied.list`, `admin.teams.create`, `admin.teams.list`, `admin.teams.admins.list`, `admin.teams.owners.list`, `admin.teams.settings`, `admin.teams.settings.setIcon`, `admin.teams.settings.setName`, `admin.teams.settings.setDescription`, `admin.users.assign`, `admin.users.invite`, `admin.users.remove`, `admin.users.setAdmin`, `admin.users.setOwner` and `admin.users.setRegular` endpoints - [@manuelmeurer](https://github.com/manuelmeurer).
* Your contribution here.

### 0.14.5 (2019/12/23)

* [#293](https://github.com/slack-ruby/slack-ruby-client/pull/293): Rubocop auto-correct and comprehensive todo - [@jcraigk](https://github.com/jcraigk).
* [#297](https://github.com/slack-ruby/slack-ruby-client/pull/297): Various Rubocop fixes - [@jcraigk](https://github.com/jcraigk).
* [#298](https://github.com/slack-ruby/slack-ruby-client/pull/298): Add `admin.apps`, `admin.app.requests` and `views` endpoints - [@jmanian](https://github.com/jmanian).
* [#302](https://github.com/slack-ruby/slack-ruby-client/pull/302): Add `oauth.v2.access` and `views.published` endpoints - [@jwright](https://github.com/jwright).
* [#298](https://github.com/slack-ruby/slack-ruby-client/pull/298): Added `admin.apps`, `admin.app.requests` and `views` endpoints - [@jmanian](https://github.com/jmanian).
* [#303](https://github.com/slack-ruby/slack-ruby-client/pull/303): Added `oauth.v2.access` and `views.publish` endpoints - [@jwright](https://github.com/jwright).
* [#309](https://github.com/slack-ruby/slack-ruby-client/pull/309): Stop ping on `inactive_account` and `invalid_auth` - [@dblock](https://github.com/dblock).

### 0.14.4 (2019/7/28)
Expand Down Expand Up @@ -171,8 +172,8 @@
### 0.7.1 (2016/5/2)

* [#82](https://github.com/slack-ruby/slack-ruby-client/pull/82): Fix `usergroups.users.{list,update}` and `files.comments.{add,edit,delete}` APIs - [@masatomo](https://github.com/masatomo).
* [#73](https://github.com/slack-ruby/slack-ruby-client/issues/73): Add a `closed` event - [@rkadyb](https://github.com/rkadyb).
* [#69](https://github.com/slack-ruby/slack-ruby-client/issues/69): Add attachments support for `Slack::Web::Api::Endpoints::Chat.chat_update` - [@nicka](https://github.com/nicka).
* [#73](https://github.com/slack-ruby/slack-ruby-client/issues/73): Added a `closed` event - [@rkadyb](https://github.com/rkadyb).
* [#69](https://github.com/slack-ruby/slack-ruby-client/issues/69): Added attachments support for `Slack::Web::Api::Endpoints::Chat.chat_update` - [@nicka](https://github.com/nicka).
* [#85](https://github.com/slack-ruby/slack-ruby-client/issues/85): Compatibility with WebMock 2.0 - [@dblock](https://github.com/dblock).
* Added `as_user` to `chat_delete` Web API - [@dblock](https://github.com/dblock).
* Added `reminders_add`, `reminders_complete`, `reminders_delete`, `reminders_info` and `reminders_list` to Web API - [@dblock](https://github.com/dblock).
Expand Down
8 changes: 8 additions & 0 deletions bin/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

require 'commands/admin_apps'
require 'commands/admin_apps_requests'
require 'commands/admin_inviteRequests'
require 'commands/admin_inviteRequests_approved'
require 'commands/admin_inviteRequests_denied'
require 'commands/admin_teams'
require 'commands/admin_teams_admins'
require 'commands/admin_teams_owners'
require 'commands/admin_teams_settings'
require 'commands/admin_users'
require 'commands/admin_users_session'
require 'commands/api'
require 'commands/apps'
Expand Down
36 changes: 36 additions & 0 deletions bin/commands/admin_inviteRequests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminInviterequests methods.'
command 'admin_inviteRequests' do |g|
g.desc 'Approve a workspace invite request.'
g.long_desc %( Approve a workspace invite request. )
g.command 'approve' do |c|
c.flag 'invite_request_id', desc: 'ID of the request to invite.'
c.flag 'team_id', desc: 'ID for the workspace where the invite request was made.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_inviteRequests_approve(options))
end
end

g.desc 'Deny a workspace invite request.'
g.long_desc %( Deny a workspace invite request. )
g.command 'deny' do |c|
c.flag 'invite_request_id', desc: 'ID of the request to invite.'
c.flag 'team_id', desc: 'ID for the workspace where the invite request was made.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_inviteRequests_deny(options))
end
end

g.desc 'List all pending workspace invite requests.'
g.long_desc %( List all pending workspace invite requests. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Value of the next_cursor field sent as part of the previous API response.'
c.flag 'limit', desc: 'The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive.'
c.flag 'team_id', desc: 'ID for the workspace where the invite requests were made.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_inviteRequests_list(options))
end
end
end
16 changes: 16 additions & 0 deletions bin/commands/admin_inviteRequests_approved.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 'AdminInviterequestsApproved methods.'
command 'admin_inviteRequests_approved' do |g|
g.desc 'List all approved workspace invite requests.'
g.long_desc %( List all approved workspace invite requests. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Value of the next_cursor field sent as part of the previous API response.'
c.flag 'limit', desc: 'The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive.'
c.flag 'team_id', desc: 'ID for the workspace where the invite requests were made.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_inviteRequests_approved_list(options))
end
end
end
16 changes: 16 additions & 0 deletions bin/commands/admin_inviteRequests_denied.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 'AdminInviterequestsDenied methods.'
command 'admin_inviteRequests_denied' do |g|
g.desc 'List all denied workspace invite requests.'
g.long_desc %( List all denied workspace invite requests. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Value of the next_cursor field sent as part of the previous api response.'
c.flag 'limit', desc: 'The number of results that will be returned by the API on each invocation. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: 'ID for the workspace where the invite requests were made.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_inviteRequests_denied_list(options))
end
end
end
27 changes: 27 additions & 0 deletions bin/commands/admin_teams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminTeams methods.'
command 'admin_teams' do |g|
g.desc 'Create an Enterprise team.'
g.long_desc %( Create an Enterprise team. )
g.command 'create' do |c|
c.flag 'team_domain', desc: 'Team domain (for example, slacksoftballteam).'
c.flag 'team_name', desc: 'Team name (for example, Slack Softball Team).'
c.flag 'team_description', desc: 'Description for the team.'
c.flag 'team_discoverability', desc: "Who can join the team. A team's discoverability can be open, closed, invite_only, or unlisted."
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_teams_create(options))
end
end

g.desc 'List all teams on an Enterprise organization'
g.long_desc %( List all teams on an Enterprise organization )
g.command 'list' 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: 'The maximum number of items to return. Must be between 1 - 100 both inclusive.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_teams_list(options))
end
end
end
16 changes: 16 additions & 0 deletions bin/commands/admin_teams_admins.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 'AdminTeamsAdmins methods.'
command 'admin_teams_admins' do |g|
g.desc 'List all of the admins on a given workspace.'
g.long_desc %( List all of the admins on a given workspace. )
g.command 'list' do |c|
c.flag 'team_id', desc: '.'
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.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_teams_admins_list(options))
end
end
end
16 changes: 16 additions & 0 deletions bin/commands/admin_teams_owners.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 'AdminTeamsOwners methods.'
command 'admin_teams_owners' do |g|
g.desc 'List all of the owners on a given workspace.'
g.long_desc %( List all of the owners on a given workspace. )
g.command 'list' do |c|
c.flag 'team_id', desc: '.'
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_teams_owners_list(options))
end
end
end
35 changes: 35 additions & 0 deletions bin/commands/admin_teams_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminTeamsSettings methods.'
command 'admin_teams_settings' do |g|
g.desc 'Set the description of a given workspace.'
g.long_desc %( Set the description of a given workspace. )
g.command 'setDescription' do |c|
c.flag 'description', desc: '.'
c.flag 'team_id', desc: 'ID for the workspace to set the description for.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_teams_settings_setDescription(options))
end
end

g.desc 'Sets the icon of a workspace.'
g.long_desc %( Sets the icon of a workspace. )
g.command 'setIcon' do |c|
c.flag 'image_url', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'team_id', desc: 'ID for the workspace to set the icon for.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_teams_settings_setIcon(options))
end
end

g.desc 'Set the name of a given workspace.'
g.long_desc %( Set the name of a given workspace. )
g.command 'setName' do |c|
c.flag 'name', desc: '.'
c.flag 'team_id', desc: 'ID for the workspace to set the name for.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_teams_settings_setName(options))
end
end
end
74 changes: 74 additions & 0 deletions bin/commands/admin_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminUsers methods.'
command 'admin_users' do |g|
g.desc 'Add an Enterprise user to a workspace.'
g.long_desc %( Add an Enterprise user to a workspace. )
g.command 'assign' do |c|
c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
c.flag 'user_id', desc: 'The ID of the user to add to the workspace.'
c.flag 'is_restricted', desc: 'True if user should be added to the workspace as a guest.'
c.flag 'is_ultra_restricted', desc: 'True if user should be added to the workspace as a single-channel guest.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_assign(options))
end
end

g.desc 'Invite a user to a workspace.'
g.long_desc %( Invite a user to a workspace. )
g.command 'invite' do |c|
c.flag 'channel_ids', desc: 'A comma-separated list of channel_ids for this user to join. At least one channel is required.'
c.flag 'email', desc: 'The email address of the person to invite.'
c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
c.flag 'custom_message', desc: 'An optional message to send to the user in the invite email.'
c.flag 'guest_expiration_ts', desc: 'Timestamp when guest account should be disabled. Only include this timestamp if you are inviting a guest user and you want their account to expire on a certain date.'
c.flag 'is_restricted', desc: 'Is this user a multi-channel guest user? (default: false).'
c.flag 'is_ultra_restricted', desc: 'Is this user a single channel guest user? (default: false).'
c.flag 'real_name', desc: 'Full name of the user.'
c.flag 'resend', desc: 'Allow this invite to be resent in the future if a user has not signed up yet. (default: false).'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_invite(options))
end
end

g.desc 'Remove a user from a workspace.'
g.long_desc %( Remove a user from a workspace. )
g.command 'remove' do |c|
c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
c.flag 'user_id', desc: 'The ID of the user to remove.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_remove(options))
end
end

g.desc 'Set an existing guest, regular user, or owner to be an admin user.'
g.long_desc %( Set an existing guest, regular user, or owner to be an admin user. )
g.command 'setAdmin' do |c|
c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
c.flag 'user_id', desc: 'The ID of the user to designate as an admin.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_setAdmin(options))
end
end

g.desc 'Set an existing guest, regular user, or admin user to be a workspace owner.'
g.long_desc %( Set an existing guest, regular user, or admin user to be a workspace owner. )
g.command 'setOwner' do |c|
c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
c.flag 'user_id', desc: 'Id of the user to promote to owner.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_setOwner(options))
end
end

g.desc 'Set an existing guest user, admin user, or owner to be a regular user.'
g.long_desc %( Set an existing guest user, admin user, or owner to be a regular user. )
g.command 'setRegular' do |c|
c.flag 'team_id', desc: 'The ID (T1234) of the workspace.'
c.flag 'user_id', desc: 'The ID of the user to designate as a regular user.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_users_setRegular(options))
end
end
end
2 changes: 1 addition & 1 deletion bin/commands/conversations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
g.long_desc %( Invites users to a channel. )
g.command 'invite' do |c|
c.flag 'channel', desc: 'The ID of the public or private channel to invite user(s) to.'
c.flag 'users', desc: 'A comma separated list of user IDs. Up to 30 users may be listed.'
c.flag 'users', desc: 'A comma separated list of user IDs. Up to 1000 users may be listed.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.conversations_invite(options))
end
Expand Down
16 changes: 16 additions & 0 deletions lib/slack/web/api/endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

require_relative 'endpoints/admin_apps'
require_relative 'endpoints/admin_apps_requests'
require_relative 'endpoints/admin_inviteRequests'
require_relative 'endpoints/admin_inviteRequests_approved'
require_relative 'endpoints/admin_inviteRequests_denied'
require_relative 'endpoints/admin_teams'
require_relative 'endpoints/admin_teams_admins'
require_relative 'endpoints/admin_teams_owners'
require_relative 'endpoints/admin_teams_settings'
require_relative 'endpoints/admin_users'
require_relative 'endpoints/admin_users_session'
require_relative 'endpoints/api'
require_relative 'endpoints/apps'
Expand Down Expand Up @@ -54,6 +62,14 @@ module Endpoints

include AdminApps
include AdminAppsRequests
include AdminInviterequests
include AdminInviterequestsApproved
include AdminInviterequestsDenied
include AdminTeams
include AdminTeamsAdmins
include AdminTeamsOwners
include AdminTeamsSettings
include AdminUsers
include AdminUsersSession
include Api
include Apps
Expand Down
61 changes: 61 additions & 0 deletions lib/slack/web/api/endpoints/admin_inviteRequests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

module Slack
module Web
module Api
module Endpoints
module AdminInviterequests
#
# Approve a workspace invite request.
#
# @option options [Object] :invite_request_id
# ID of the request to invite.
# @option options [Object] :team_id
# ID for the workspace where the invite request was made.
# @see https://api.slack.com/methods/admin.inviteRequests.approve
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.inviteRequests/admin.inviteRequests.approve.json
def admin_inviteRequests_approve(options = {})
throw ArgumentError.new('Required arguments :invite_request_id missing') if options[:invite_request_id].nil?
post('admin.inviteRequests.approve', options)
end

#
# Deny a workspace invite request.
#
# @option options [Object] :invite_request_id
# ID of the request to invite.
# @option options [Object] :team_id
# ID for the workspace where the invite request was made.
# @see https://api.slack.com/methods/admin.inviteRequests.deny
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.inviteRequests/admin.inviteRequests.deny.json
def admin_inviteRequests_deny(options = {})
throw ArgumentError.new('Required arguments :invite_request_id missing') if options[:invite_request_id].nil?
post('admin.inviteRequests.deny', options)
end

#
# List all pending workspace invite requests.
#
# @option options [Object] :cursor
# Value of the next_cursor field sent as part of the previous API response.
# @option options [Object] :limit
# The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive.
# @option options [Object] :team_id
# ID for the workspace where the invite requests were made.
# @see https://api.slack.com/methods/admin.inviteRequests.list
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/admin.inviteRequests/admin.inviteRequests.list.json
def admin_inviteRequests_list(options = {})
if block_given?
Pagination::Cursor.new(self, :admin_inviteRequests_list, options).each do |page|
yield page
end
else
post('admin.inviteRequests.list', options)
end
end
end
end
end
end
end
Loading