Module: Keybase::Local::Team
- Defined in:
- lib/keybase/local/team.rb
Overview
Represents Keybase’s JSON team API.
Constant Summary collapse
- TEAM_EXEC_ARGS =
The initial arguments to pass when executing Keybase for team management.
%w[keybase team api].freeze
Class Method Summary collapse
-
.add_members(team, emails: [], users: []) ⇒ OpenStruct
Add members to a team.
-
.create_team(team) ⇒ OpenStruct
Create a new team.
-
.edit_member(team, user, role) ⇒ OpenStruct
Edit the role of a user on a team.
-
.envelope(meth, options: {}) ⇒ String
private
The JSON serialized envelope.
-
.leave_team(team, permanent: false) ⇒ OpenStruct
Leave a team.
-
.list_self_memberships ⇒ OpenStruct
(also: self_memberships)
List all team memberships for the current user.
-
.list_team_memberships(team) ⇒ OpenStruct
(also: team_memberships)
List all users in the given team.
-
.list_user_memberships(user) ⇒ OpenStruct
(also: user_memberships)
List teams for a user.
-
.remove_member(team, user) ⇒ OpenStruct
Remove a user from a team.
-
.rename_subteam(old_name, new_name) ⇒ OpenStruct
Rename a subteam.
-
.team_call(meth, options: {}) ⇒ OpenStruct
private
Makes team API calls.
-
.unwrap(struct) ⇒ OpenStruct
private
Cleans up the object returned by Team.team_call.
Class Method Details
.add_members(team, emails: [], users: []) ⇒ OpenStruct
Add members to a team.
106 107 108 109 110 111 112 |
# File 'lib/keybase/local/team.rb', line 106 def add_members(team, emails: [], users: []) team_call "add-members", options: { team: team, emails: emails, usernames: users, } end |
.create_team(team) ⇒ OpenStruct
Create a new team.
91 92 93 94 95 |
# File 'lib/keybase/local/team.rb', line 91 def create_team(team) team_call "create-team", options: { team: team, } end |
.edit_member(team, user, role) ⇒ OpenStruct
Edit the role of a user on a team.
122 123 124 125 126 127 128 |
# File 'lib/keybase/local/team.rb', line 122 def edit_member(team, user, role) team_call "edit-member", options: { team: team, username: user, role: role, } end |
.envelope(meth, options: {}) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the JSON serialized envelope.
19 20 21 22 23 24 25 26 |
# File 'lib/keybase/local/team.rb', line 19 def envelope(meth, options: {}) { method: meth, params: { options: , }, }.to_json end |
.leave_team(team, permanent: false) ⇒ OpenStruct
Leave a team.
161 162 163 164 165 166 |
# File 'lib/keybase/local/team.rb', line 161 def leave_team(team, permanent: false) team_call "leave-team", options: { team: team, permanent: permanent, } end |
.list_self_memberships ⇒ OpenStruct Also known as: self_memberships
List all team memberships for the current user.
57 58 59 |
# File 'lib/keybase/local/team.rb', line 57 def list_self_memberships team_call "list-self-memberships" end |
.list_team_memberships(team) ⇒ OpenStruct Also known as: team_memberships
List all users in the given team.
67 68 69 70 71 |
# File 'lib/keybase/local/team.rb', line 67 def list_team_memberships(team) team_call "list-team-memberships", options: { team: team, } end |
.list_user_memberships(user) ⇒ OpenStruct Also known as: user_memberships
List teams for a user.
79 80 81 82 83 |
# File 'lib/keybase/local/team.rb', line 79 def list_user_memberships(user) team_call "list-user-memberships", options: { username: user, } end |
.remove_member(team, user) ⇒ OpenStruct
Remove a user from a team.
135 136 137 138 139 140 |
# File 'lib/keybase/local/team.rb', line 135 def remove_member(team, user) team_call "remove-member", options: { team: team, username: user, } end |
.rename_subteam(old_name, new_name) ⇒ OpenStruct
Rename a subteam.
149 150 151 152 153 154 |
# File 'lib/keybase/local/team.rb', line 149 def rename_subteam(old_name, new_name) team_call "rename-subteam", options: { team: old_name, "new-team-name": new_name, } end |
.team_call(meth, options: {}) ⇒ OpenStruct
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Makes team API calls.
44 45 46 47 48 49 50 51 52 |
# File 'lib/keybase/local/team.rb', line 44 def team_call(meth, options: {}) response = Open3.popen3(*TEAM_EXEC_ARGS) do |stdin, stdout, _, _| stdin.write envelope meth, options: stdin.close stdout.read end unwrap JSON.parse response, object_class: OpenStruct end |
.unwrap(struct) ⇒ OpenStruct
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Cleans up the object returned by team_call.
33 34 35 36 37 |
# File 'lib/keybase/local/team.rb', line 33 def unwrap(struct) raise Exceptions::TeamError, struct.error. if struct.error struct.result end |