Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update_group_by_id(self, gid, group):
"""Update a group, defined by an id
:param gid: the target group id
:type gid: str
:param group: the data to update the target group
:type group: UserGroup
:rtype: UserGroup
"""
response = ApiClient.put_path(self, '/{0}'.format(gid), group)
return Utils.deserialize(response.text, UserGroup)
"""Get a list of Events
:param limit: maximum number of events to return
:type limit: int or None
:param filter_string: string to filter events
:type filter_string: str or None
:rtype: list of Event
"""
params = {
'limit': limit,
'startDate': start_date,
'filter': filter_string
}
response = ApiClient.get_path(self, '/', params=params)
return Utils.deserialize(response.text, Event)
:param limit: maximum number of users to return
:type limit: int or None
:param query: string to search users' first names, last names, and emails
:type query: str or None
:param filter_string: string to filter users
:type filter_string: str or None
:rtype: list of User
"""
params = {
'limit': limit,
'q': query,
'filter': filter_string
}
response = ApiClient.get_path(self, '/', params=params)
return Utils.deserialize(response.text, User)
"""Create a session
:param username: the user's username
:type username: str
:param password: the user's password
:type password: str
:param additional_fields: additional fields that will be included in the response
:type additional_fields: str
:rtype: Session
"""
creds = Credentials()
creds.username = username
creds.password = password
params = {'additionalFields': additional_fields}
response = ApiClient.post_path(self, '/', creds, params=params)
return Utils.deserialize(response.text, Session)
def get_group_users(self, gid):
"""Get the users of a group
:param gid: the group id
:type gid: str
:rtype: User
"""
response = ApiClient.get_path(self, '/{0}/users'.format(gid))
return Utils.deserialize(response.text, User)
setattr(o, a, v)
json_dump = {}
if from_data is None or len(from_data) == 0:
json_dump = {}
elif isinstance(from_data, six.text_type) or isinstance(from_data, six.string_types):
json_dump = json.loads(from_data)
else:
json_dump = from_data
list_type = types.ListType if six.PY2 else list
if isinstance(json_dump, list_type):
obj_list = list()
for obj in json_dump:
obj_list.append(Utils.deserialize(obj, to_class))
return obj_list
else:
obj = to_class()
# Loop through each type of object in types
if hasattr(to_class, 'types'):
for attr, attr_type in six.iteritems(to_class.types):
if attr in json_dump:
val = json_dump[attr]
if not val:
continue
if attr_type == datetime:
def remove_nulls(d):
built = {}
for k, v in six.iteritems(d):
if v is None:
continue
if isinstance(v, dict):
built[k] = Utils.remove_nulls(v)
if isinstance(v, object) and hasattr(v, '__dict__'):
built[k] = Utils.remove_nulls(v.__dict__)
else:
built[k] = v
return built
def get_factors_catalog(self, user_id):
"""Get available factors for a user
:param user_id: target user id
:type user_id: str
:rtype: list of FactorCatalogEntry
"""
response = ApiClient.get_path(self, '/{0}/factors/catalog'.format(user_id))
return Utils.deserialize(response.text, FactorCatalogEntry)
def create_session_by_session_token(self, session_token, additional_fields=None):
"""Create a session using a session token
:param session_token: a token that can be exchanged for a session
:type session_token: str
:param additional_fields: additional fields that will be included in the response
:type additional_fields: str
:rtype: Session
"""
data = {'sessionToken': session_token}
params = {'additionalFields': additional_fields}
response = ApiClient.post_path(self, '/', data, params=params)
return Utils.deserialize(response.text, Session)
def default(self, obj):
if isinstance(obj, datetime):
return obj.strftime('dt(%Y-%m-%dT%H:%M:%SZ)')
elif isinstance(obj, object):
no_nulls = Utils.remove_nulls(obj.__dict__)
formatted = Utils.replace_alt_names(obj, no_nulls)
return formatted
else:
return JSONEncoder.default(self, obj)