Utilities¶
Utility methods for Django Heroku Connect.
- class heroku_connect.utils.WriteAlgorithm(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- heroku_connect.utils.create_heroku_connect_schema(using='default')[source]¶
Create Heroku Connect schema.
Note
This function is only meant to be used for local development. In a production environment the schema will be created by Heroku Connect.
- heroku_connect.utils.get_connected_model_for_table_name(table_name)[source]¶
Return a connected model’s table name (which read and written to by Heroku Connect).
- heroku_connect.utils.get_connection(connection_id, deep=False)[source]¶
Get Heroku Connection connection information.
For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-8-monitor-the-connection-and-mapping-status
Sample response from API call is below:
{ "id": "<connection_id>", "name": "<app_name>", "resource_name": "<resource_name>", "schema_name": "salesforce", "db_key": "DATABASE_URL", "state": "IDLE", "mappings":[ { "id": "<mapping_id>", "object_name": "Account", "state": "SCHEMA_CHANGED", … }, { "id": "<mapping_id>", "object_name": "Contact", "state": "SCHEMA_CHANGED", … }, … ] … }
- Parameters:
- Returns:
Heroku Connection connection information.
- Return type:
- Raises:
requests.HTTPError – If an error occurred when accessing the connection detail API.
ValueError – If response is not a valid JSON.
- heroku_connect.utils.get_connections(app)[source]¶
Return all Heroku Connect connections setup with the given application.
For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-4-retrieve-the-new-connection-s-id
Sample response from the API call is below:
{ "count": 1, "results":[{ "id": "<connection_id>", "name": "<app_name>", "resource_name": "<resource_name>", … }], … }
- Parameters:
app (str) – Heroku application name.
- Returns:
List of all Heroku Connect connections associated with the Heroku application.
- Return type:
List[dict]
- Raises:
requests.HTTPError – If an error occurred when accessing the connections API.
ValueError – If response is not a valid JSON.
- heroku_connect.utils.get_heroku_connect_models()[source]¶
Return all registered Heroku Connect Models.
- Returns:
All registered models that are subclasses of .HerokuConnectModel. Abstract models are excluded, since they are not registered.
- Return type:
(Iterator)
- heroku_connect.utils.get_mapping(version=1, exported_at=None, app_name=None)[source]¶
Return Heroku Connect mapping for the entire project.
- Parameters:
version (int) – Version of the Heroku Connect mapping, default:
1
.exported_at (datetime.datetime) – Time the export was created, default is
now()
.app_name (str) – Name of Heroku application associated with Heroku Connect the add-on.
- Returns:
Heroku Connect mapping.
- Return type:
Note
The version does not need to be incremented. Exports from the Heroku Connect website will always have the version number
1
.
- heroku_connect.utils.import_mapping(connection_id, mapping)[source]¶
Import Heroku Connection mapping for given connection.
- Parameters:
- Raises:
requests.HTTPError – If an error occurs uploading the mapping.
ValueError – If the mapping is not JSON serializable.