Import API

This part of the documentation covers the different classes and methods available in limeclient.

LimeClient

class limeclient.LimeClient(host, database=None, debug=False, verify_ssl_cert=True)

Handles all communication with LIME’s API

Parameters:
  • host – name of host to connect to
  • database – name of database to logon to. Should not be specified when logging on to a hosted LIME solution.
  • debug – if True, print traffic to stdout. Defaults to False
  • verify_ssl_cert – if False, ignore SSL certificate verification. Defaults to True.
login(user=None, password=None)

Log in to LIME.

LimeClient should be used as a context manager. That way logging out and closing a session will be done automatically, even if an error is encountered.

client = LimeClient('localhost', 'mydatabase')
with client.login('user', 'pass') as c:
    # do stuff

LimeTypes

class limeclient.LimeTypes(lime_client)

Retrieve type information about entities in LIME Pro.

Parameters:lime_client – a logged in LimeClient instance
get_by_name(name)

Retrieve a LimeType given its name in LIME Pro.

Parameters:name – name in LIME Pro (e.g. ‘company’)
get_by_url(url)

Retrieve a LimeType given its url.

Parameters:url – this is the url that uniquely identifies an lime type.
class limeclient.LimeType(hal, lime_client)

Represents a type of object in LIME Pro.

name

Name of lime type.

is_system

True if this is a system type.

fields

Retrieve all fields for this lime type.

relations

Retrieve all relations (Relation) for this lime type.

Field Types

class limeclient.SimpleField(hal, lime_client)

Represents a simple field type.

label
length
localname
name
readonly
required
type
class limeclient.OptionField(hal, lime_client)

Represents an option field type.

label
localname
name
readonly
required
type
option_by_id(id)

Retrieve an Option value given its id.

option_by_key(key)

Retrieve an Option value given its key.

option_by_localname(localname)

Retrieve an Option value given its local name.

options

All possible Option values for this field.

class limeclient.Option(raw)

Represents a possible value for an OptionField.

id

Id of the option value

key

Key of the option value

localname

Local name of the option value

Relations

class limeclient.Relation(hal, lime_client)

Represents a relation to another lime type in LIME Pro.

localname
name
related

The related LimeType

ImportFiles

class limeclient.ImportFiles(lime_client)

Handles uploading of import files to LIME

Parameters:lime_client – a logged in LimeClient instance
create(filename, content)

Upload an import file to LIME. Returns an ImportFile instance

Parameters:
  • filename – name of uploaded file
  • content – a file object containing the data to import
class limeclient.ImportFile(hal, lime_client)

Represents a file to import to LIME.

Parameters:
  • hal – representation of an import file as returned from LIME.
  • hal – lime_client LimeClient to use for communication with LIME
delimiter

Use this to set the delimiter used in the file so LIME knows how to parse it.

filename

The name of the file.

headers

Returns the headers (ImportFileHeaders) of the file.

save()

Save the file information in LIME.

class limeclient.ImportFileHeaders(hal, lime_client)

Contains the headers of a parsed import file.

Parameters:
  • hal – representation of an import file as returned from LIME.
  • hal – lime_client LimeClient to use for communication with LIME
headers

A list of the header names in the file

Import Configuration

class limeclient.ImportConfigs(lime_client)

Manages creation of ImportConfig instances in LIME

Parameters:lime_client – a logged in LimeClient instance
create(lime_type, importfile)

Create a new ImportConfig instance in LIME.

Parameters:
  • lime_typeLimeType instance that references what type of data to import
  • importfileImportFile instance to import
class limeclient.ImportConfig(hal, lime_client)

Used for configuring an import.

Parameters:
  • hal – representation of an import file as returned from LIME.
  • hal – lime_client LimeClient to use for communication with LIME
behavior

Determines how the import handles existing objects in LIME Pro. Can be one of the following:

  • ImportConfig.CreateAndUpdate
  • ImportConfig.UpdateOnly
  • ImportConfig.CreateOnly
add_mapping(mapping)

Add information about how to map a column in the import file to data in LIME.

Parameters:mapping – One of SimpleFieldMapping, OptionFieldMapping, or RelationMapping.
static create(lime_client, lime_type, importfile)

Create a new instance of ImportConfig

Parameters:
  • lime_client – a logged in LimeClient instance
  • lime_typeLimeType instance that references what type of data to import
  • importfileImportFile instance to import
save()

Save the import configuration in LIME.

validate()
Ask LIME to validate the import configuration. Returns an
ImportConfigStatus instance.

Mapping

The following types can be passed to ImportConfig.add_mapping() to define how columns in the import file should be mapped to fields in LIME Pro:

class limeclient.SimpleFieldMapping(column, field, key=False)

Maps a column to a simple field on the object we want to import to.

Parameters:
  • column – Name of column in import file
  • field – the field we want to map to
  • key – if True, the value of this column will be used to find existing objects in LIME Pro.
class limeclient.OptionFieldMapping(column, field)

Maps a column to a simple field on the object we want to import to.

Parameters:
  • column – Name of column in import file
  • field – the field we want to map to
default

The value to give the field if none of the mappings apply for the value in the column.

map_option(column_val, option)

Map a value for a column to an option for a field.

Parameters:
  • column_val – a value of the column in the import file
  • option – a Option instance. The option value to map to.
class limeclient.RelationMapping(column, relation, key_field)

Use the value in a column to find a related object in LIME Pro.

Parameters:
  • column – column that we want to map
  • relation – the Relation that we want to map.
  • key_field – the field of the related type that we will match against to find related objects.

Import Jobs

class limeclient.ImportJobs(lime_client)

Handles the creation of a new import job.

Parameters:lime_client – a logged in LimeClient instance
create(import_config)

Create a new ImportJob. This indicates to the server that it can start executing the job as soon as possible.

Parameters:import_config – a ready ImportConfig instance.
get(url)

Retrieve an existing ImportJob from the server.

Parameters:url – the url that identifies the job on the server.
class limeclient.ImportJob(hal, lime_client)

Represents an import job on the server.

Parameters:lime_client – a logged in LimeClient instance
created_time

Time when the job was created.

started_time

Time when job was actually started.

completed_time

Time when job was completed.

created_count

Number of new items created.

updated_count

Number of already existing items that where updated.

errors_count

Number of errors encountered.

status

Current status of the job. Can be one of ‘pending’, ‘running’, ‘done’, ‘done_with_errors’, or ‘failed’

errors

Retrieve a ImportJobErrors that contains all errors for this job

has_errors

Determine if this job has encountered any errors.

refresh()

Retrieve a fresh version of the import job from the server.

class limeclient.ImportJobErrors(hal, lime_client)
count

The number of errors encountered during the job.

errors

A collection of all errors, grouped by rows in the imported file.

Example:

[{'row': 4, 'errors': ["Value of field 'name' is longer than the allowed 32 characters"]}]