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
- 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.
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¶
- 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
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_type – LimeType instance that references what type of data to import
- importfile – ImportFile 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_type – LimeType instance that references what type of data to import
- importfile – ImportFile 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.
- 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.
- 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.