class Symgate::Auth::Client

client for the Symgate authentication system

Public Instance Methods

add_group_language(group, language) click to toggle source

Adds a language to the specified group

This enables users within the group to use the Symboliser in that language.

Attributes

  • group - The ID of the group to add the language to (String)

  • language - The cml language to enable (String)

Returns

Returns 'OK' if successful or 'Exists' if the language is already assigned to the account (String)

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 278
def add_group_language(group, language)
  savon_request(:add_group_language) do |soap|
    soap.message(groupid: group, language: language)
  end.body[:add_group_language_response]
end
authenticate(user_to_impersonate = nil) click to toggle source

Authenticates a user and returns a token

This optionally provides a token which allows you to 'impersonate' a user (i.e. use the API as if you were logged on as that user)

Raises a Symgate::Error on error (e.g. authentication fails)

Attributes

  • user_to_impersonate (optional) - The ID (String) of the user to impersonate

Returns

A token, used for further calls to the client (String)

  • account/key (requires user_to_impersonate)

  • user (cannot use user_to_impersonate)

# File lib/symgate/auth/client.rb, line 253
def authenticate(user_to_impersonate = nil)
  r = savon_request(:authenticate) do |soap|
    soap.message(userid: user_to_impersonate) if user_to_impersonate
  end.body[:authenticate_response]

  r ? r[:authtoken] : nil
end
create_group(group_id) click to toggle source

Creates a new group.

Raises a Symgate::Error on failure

Attributes

  • group_id - The ID of the new group to create (String)

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 35
def create_group(group_id)
  savon_request(:create_group, returns_error_string: true) do |soap|
    soap.message(groupid: group_id)
  end
end
create_user(user, password) click to toggle source

Creates a new user

Raises a Symgate::Error on failure (e.g. the user is invalid, or the group specified in the User object does not exist)

Attributes

  • user - A Symgate::Auth::User describing the new user

  • password - The password for the new user (String)

Supported authentication types

  • account/key

  • user (with is_group_admin)

# File lib/symgate/auth/client.rb, line 119
def create_user(user, password)
  savon_request(:create_user, returns_error_string: true) do |soap|
    soap.message(password: password)
    user.to_soap(soap[:message])
  end
end
destroy_group(group_id) click to toggle source

Destroys an existing group

IMPORTANT: This will permanently delete the group, along with all associated users, wordlists and metadata. Can't be undone.

Raises a Symgate::Error on failure

Attributes

  • group_id - The ID of the new group to create (String)

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 55
def destroy_group(group_id)
  savon_request(:destroy_group, returns_error_string: true) do |soap|
    soap.message(groupid: group_id)
  end
end
destroy_user(user_id) click to toggle source

Destroys a user

IMPORTANT: This will irreversibly destroy all wordlists and metadata belonging to the user

Attributes

  • user_id - The ID of the user for whom the password is to be changed

Supported authentication types

  • account/key

  • user (with is_group_admin)

# File lib/symgate/auth/client.rb, line 230
def destroy_user(user_id)
  savon_request(:destroy_user, returns_error_string: true) do |soap|
    soap.message(userid: user_id)
  end
end
enumerate_group_languages(group_id) click to toggle source

Lists the allowed languages for the specified group

Attributes

  • group_id - The ID of the group (String)

Returns

Returns an array of cml languages as strings

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 320
def enumerate_group_languages(group_id)
  resp = savon_request(:enumerate_group_languages) { |soap| soap.message(groupid: group_id) }

  Symgate::Client.savon_array(
    resp.body[:enumerate_group_languages_response],
    :language
  )
end
enumerate_groups() click to toggle source

Returns a list of groups for the current symgate account

Returns

An array of group ids, as strings

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 17
def enumerate_groups
  Symgate::Client.savon_array(
    savon_request(:enumerate_groups).body[:enumerate_groups_response],
    :groupid
  )
end
enumerate_languages() click to toggle source

Lists the allowed languages for the currently authenticated user

Returns

Returns an array of cml languages as strings

Supported authentication types

  • user

# File lib/symgate/auth/client.rb, line 358
def enumerate_languages
  resp = savon_request(:enumerate_languages)

  Symgate::Client.savon_array(
    resp.body[:enumerate_languages_response],
    :language
  )
end
enumerate_users(group_id) click to toggle source

Returns a list of users for the specified group)

Attributes

  • group_id - The ID of the group (String)

Returns

An array of Symgate::Auth::User objects

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 95
def enumerate_users(group_id)
  resp = savon_request(:enumerate_users) { |soap| soap.message(groupid: group_id) }

  Symgate::Client.savon_array(
    resp.body[:enumerate_users_response],
    :user,
    Symgate::Auth::User
  )
end
move_user(old_user_id, new_user_id) click to toggle source

Moves a user between groups

Moves a user from one group to another. The group part of the user ID should be changed.

Raises a Symgate::Error on failure (e.g. the new_user_id is already taken or the user with old_user_id does not exist)

Attributes

  • old_user_id - The ID of the user to move, in 'group_id/username' format (String)

  • new_user_id - The new ID of the renamed user (String)

Example

auth_client.move_user('group_1/username', 'group_2/username')

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 189
def move_user(old_user_id, new_user_id)
  savon_request(:move_user, returns_error_string: true) do |soap|
    soap.message(old_user_id: old_user_id, new_user_id: new_user_id)
  end
end
query_group_language(group_id, language) click to toggle source

Queries whether a language is assigned to a group

Attributes

  • group - The ID of the group (String)

  • language - The cml language to query (String)

Returns

Returns true if the user has the language assigned, otherwise false (Boolean)

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 343
def query_group_language(group_id, language)
  savon_request(:query_group_language) do |soap|
    soap.message(groupid: group_id, language: language)
  end.body[:query_group_language_response]
end
query_language(language) click to toggle source

Queries whether a language is assigned to the currently authenticated user

Attributes

  • language - The cml language to query (String)

Returns

Returns true if the user has the language assigned, otherwise false (Boolean)

Supported authentication types

  • user

# File lib/symgate/auth/client.rb, line 380
def query_language(language)
  savon_request(:query_language) { |soap| soap.message(language: language) }
    .body[:query_language_response]
end
remove_group_language(group, language) click to toggle source

Removes a language from the specified group

This prevents users within the group to use the Symboliser in that language.

Attributes

  • group - The ID of the group to remove the language from(String)

  • language - The cml language to disable (String)

Returns

Returns 'OK' if successful or 'NotExist' if the language is not assigned to the account (String)

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 301
def remove_group_language(group, language)
  savon_request(:remove_group_language) do |soap|
    soap.message(groupid: group, language: language)
  end.body[:remove_group_language_response]
end
rename_group(old_group_id, new_group_id) click to toggle source

Renames a group

This will require all users to use the new group_id as part of their login username in future.

Raises a Symgate::Error on failure (e.g. the new_group_id is invalid)

Attributes

  • old_group_id - The ID of the group to rename (String)

  • new_group_id - The new ID for the renamed group (String)

Supported authentication types

  • account/key

# File lib/symgate/auth/client.rb, line 76
def rename_group(old_group_id, new_group_id)
  savon_request(:rename_group, returns_error_string: true) do |soap|
    soap.message(old_groupid: old_group_id, new_groupid: new_group_id)
  end
end
rename_user(old_user_id, new_user_id) click to toggle source

Renames a user

The user cannot be renamed from one group to another - the group part of the user id should remain the same.

Raises a Symgate::Error on failure (e.g. the new_user_id is already taken or the user with old_user_id does not exist)

Attributes

  • old_user_id - The ID of the user to rename, in 'group_id/username' format (String)

  • new_user_id - The new ID of the renamed user (String)

Supported authentication types

  • account/key

  • user (with is_group_admin)

# File lib/symgate/auth/client.rb, line 163
def rename_user(old_user_id, new_user_id)
  savon_request(:rename_user, returns_error_string: true) do |soap|
    soap.message(old_user_id: old_user_id, new_user_id: new_user_id)
  end
end
set_user_password(user_id, password) click to toggle source

Sets the password for a user

Note that when authenticating as a user without the is_group_admin permission you can only change the password for yourself.

Raises a Symgate::Error on failure (e.g. the user identified by user_id does not exist, or you do not have sufficient permissions to update the password.)

Attributes

  • user_id - The ID of the user for whom the password is to be changed

Supported authentication types

  • account/key

  • user

# File lib/symgate/auth/client.rb, line 211
def set_user_password(user_id, password)
  savon_request(:set_user_password, returns_error_string: true) do |soap|
    soap.message(userid: user_id, password: password)
  end
end
update_user(user) click to toggle source

Updates a user

Currently this can only be used to set the is_group_admin member of the user object

Attributes

Supported authentication types

  • account/key

  • user (with is_group_admin)

# File lib/symgate/auth/client.rb, line 139
def update_user(user)
  savon_request(:update_user, returns_error_string: true) do |soap|
    soap.message({})
    user.to_soap(soap[:message])
  end
end