def update_exchange(api_client, exchange, is_phase_updated=False): data = entity_to_dict(exchange) exchange_id = data['id'] if is_phase_updated: data = filter_dict(data, remove_fields=[ 'id', 'parentTemplateId', 'actions', 'securityLevel', 'type', 'pvpEnabled', 'htmlViewEnabled', 'location' ]) else: data = filter_dict(data, remove_fields=[ 'id', 'parentTemplateId', 'phase', 'actions', 'securityLevel', 'type', 'pvpEnabled', 'htmlViewEnabled', 'location' ]) data['name'] = data.pop('workspaceName') response = api_client.update('/v2/workspaces/{}'.format(exchange_id), data=json.dumps(data), headers={'Content-Type': 'application/json'}, api_version=2) response.check(202, 'application/json') data = response.data() return data
def update_group(api_client, exchange_id, group, remove_group_members=None, add_group_members=None): group_data = entity_to_dict(group) group_id = group_data['id'] group_data = filter_dict(group_data, remove_fields={ 'id', 'groupMemberCount', 'lastModifiedOn', 'lastModifiedBy', 'createdOn', 'createdBy' }) response = api_client.update('/v2/workspaces/{}/groups/{}'.format( exchange_id, group_id), data=json.dumps(group_data), headers={'Content-Type': 'application/json'}, api_version=2) response.check(202, 'application/json') data = response.data() return get_node_as_item(data, 'groupPartials')
def update_exchange_member(api_client, exchange_id, exchange_member): exchange_member_data = entity_to_dict(exchange_member) user_data = entity_to_dict(exchange_member_data.pop('user', dict())) exchange_member_data.update(user_data) exchange_member_data = filter_dict(exchange_member_data, remove_fields={ 'userId', 'emailId', 'firstName', 'lastName', 'title', 'organization', 'officePhone', 'languagePref' }) # Fix because the V2 API does not return 'unauthenticatedDocumentAccess' as a boolean if 'unauthenticatedDocumentAccess' in exchange_member_data and exchange_member_data[ 'unauthenticatedDocumentAccess'] in {'T', 'F'}: exchange_member_data[ 'unauthenticatedDocumentAccess'] = exchange_member_data[ 'unauthenticatedDocumentAccess'] == 'T' response = api_client.update('/v2/workspaces/{}/users'.format(exchange_id), data=json.dumps( {'users': [exchange_member_data]}), headers={'Content-Type': 'application/json'}, api_version=2) response.check(202, 'application/json') data = response.data() return get_node_as_item(data, ['userPartials'])
def update_folder(api_client, exchange_id, folder): folder_data = entity_to_dict(folder) folder_data = filter_dict(folder_data, remove_fields={'isEmailin', 'versionNumber', 'isFavorite', 'lastModifiedBy', 'lastModifiedOn', 'createdBy', 'createdOn', 'hasChildFolders', 'orderNumber', 'indexNumber'}) response = api_client.update( '/v2/workspaces/{}/folders'.format(exchange_id), data=json.dumps({'folders':[folder_data]}), headers={'Content-Type':'application/json'}, api_version=2 ) response.check(202, 'application/json') data = response.data() result = get_node_as_item(data, 'folderPartial') if 'hasNote' in result and result['hasNote'] in {'T', 'F'}: result['hasNote'] = result['hasNote'] == 'T' return result
def create_exchange_member(api_client, exchange_id, exchange_member=None, alert=None): exchange_member_data = entity_to_dict(exchange_member) user_data = entity_to_dict(exchange_member_data.pop('user', dict())) exchange_member_data.update(user_data) exchange_member_data = filter_dict( exchange_member_data, remove_fields={'languagePref', 'unauthenticatedDocumentAccess'}) exchange_member_data['sendAlert'] = alert is not None if alert is None: exchange_member_data['sendAlert'] = False else: exchange_member_data['sendAlert'] = True alert_data = entity_to_dict(alert) alert_data['saveAlertSettings'] = True exchange_member_data['welcomeAlertDetails'] = alert_data response = api_client.create('/v2/workspaces/{}/users'.format(exchange_id), data=json.dumps( {'users': [exchange_member_data]}), headers={'Content-Type': 'application/json'}, api_version=2) response.check(201, 'application/json') data = response.data() return get_node_as_item(data, ['userPartials'])