Kabelwerk API
Users
- kabelwerk.api.create_user(*, key, name, hub=None)
Create a user with the given key and name.
All arguments are named arguments.
- Parameters:
key – Your unique ID for this user.
name – The user’s name.
hub – The slug identifying the hub in which to create the user. Only set this if you want to create a hub user.
- Returns:
Info about the newly created user if the backend accepts the request.
- Return type:
NamedTuple
- Raises:
ValidationError – If the request is rejected because of invalid input.
AuthenticationError – If the request is rejected because the authentication token is invalid.
ConnectionError – If there is a problem connecting to the Kabelwerk backend or if the request times out.
ServerError – If the Kabelwerk backend fails to handle the request or behaves in an unexpected way.
Examples
>>> create_user(key='kusanagi', name='Motoko') User(id=42, key='kusanagi', name='Motoko')
>>> create_user(name='Name Only') ValidationError
- kabelwerk.api.update_user(*, key, name)
Update the user with the given key.
All arguments are named arguments.
- Parameters:
key – Your unique ID for this user.
name – The user’s name.
- Returns:
Info about the updated user if the backend accepts the request.
- Return type:
NamedTuple
- Raises:
DoesNotExist – If there is no user on the Kabelwerk backend with the given key.
ValidationError – If the request is rejected because of invalid input.
AuthenticationError – If the request is rejected because the authentication token is invalid.
ConnectionError – If there is a problem connecting to the Kabelwerk backend or if the request times out.
ServerError – If the Kabelwerk backend fails to handle the request or behaves in an unexpected way.
Examples
>>> update_user(key='kusanagi', name='Motoko') User(id=42, key='kusanagi', name='Motoko')
>>> update_user(key='kusanagi', name='') ValidationError
- kabelwerk.api.delete_user(*, key)
Delete the user with the given key.
All arguments are named arguments.
- Parameters:
key – Your unique ID for this user.
- Return type:
None
- Raises:
DoesNotExist – If there is no user on the Kabelwerk backend with the given key.
AuthenticationError – If the request is rejected because the authentication token is invalid.
ConnectionError – If there is a problem connecting to the Kabelwerk backend or if the request times out.
ServerError – If the Kabelwerk backend fails to handle the request or behaves in an unexpected way.
Examples
>>> delete_user(key='kusanagi') None
>>> delete_user(key='kusanagi') DoesNotExist
Rooms
- kabelwerk.api.update_room(*, hub='_', room, **kwargs)
Update a chat room.
All arguments are named arguments.
- Parameters:
hub – The slug identifying the hub to which the room belongs. You can omit this argument if you only have one hub.
room – Your unique ID of the end user to which the room belongs.
archived – Whether to mark the room as archived. Optional.
attributes – The attributes to set on the room. Optional.
hub_user – Your unique ID of the hub user to assign the room to. Set to None if you want to unassign the room. Optional.
- Returns:
Info about the updated room if the backend accepts the request.
- Return type:
NamedTuple
- Raises:
DoesNotExist – If there is no chat room for the given end user and hub.
ValidationError – If the request is rejected because of invalid input.
AuthenticationError – If the request is rejected because the authentication token is invalid.
ConnectionError – If there is a problem connecting to the Kabelwerk backend or if the request times out.
ServerError – If the Kabelwerk backend fails to handle the request or behaves in an unexpected way.
Examples
Set the room’s attributes to an empty dict:
>>> update_room(hub='section9', room='kusanagi', attributes={}) Room(id=42, archived=False, attributes={}, hub_user=None)
Archive the room:
>>> update_room(hub='section9', room='kusanagi', archived=True) Room(id=42, archived=True, attributes={}, hub_user=None)
Unarchive the room:
>>> update_room(hub='section9', room='kusanagi', archived=False) Room(id=42, archived=False, attributes={}, hub_user=None)
Assign the room to a hub user:
>>> update_room(hub='section9', room='kusanagi', hub_user='batou') Room(id=42, archived=False, attributes={}, hub_user=User(key='batou'))
Unassign the room:
>>> update_room(hub='section9', room='kusanagi', hub_user=None) Room(id=42, archived=False, attributes={}, hub_user=None)
Messages
- kabelwerk.api.post_message(*, hub='_', room, user, text)
Post a message in a chat room.
All arguments are named arguments.
- Parameters:
hub – The slug identifying the hub to which the belongs the room where to post the message. You can omit this argument if you only have one hub.
room – Your unique ID of the end user to which belongs the room where to post the message.
text – The text of the message.
- Returns:
Info about the newly posted message if the backend accepts the request.
- Return type:
NamedTuple
- Raises:
DoesNotExist – If there is no chat room for the given end user and hub.
ValidationError – If the request is rejected because of invalid input.
AuthenticationError – If the request is rejected because the authentication token is invalid.
ConnectionError – If there is a problem connecting to the Kabelwerk backend or if the request times out.
ServerError – If the Kabelwerk backend fails to handle the request or behaves in an unexpected way.
Examples
>>> post_message(hub='section9', room='kusanagi', user='batou', text='?') Message(id=42, key='kusanagi', name='Motoko')
>>> post_message(hub='section9', room='kusanagi', user='batou', text='') ValidationError