oasislmf.platform_api.client¶
Classes¶
Used to Implement the default requests common to all Oasis API |
|
Used for JSON data End points. |
|
File Resources Endpoint for Upload / Downloading |
|
Used to Implement the default requests common to all Oasis API |
|
Used to Implement the default requests common to all Oasis API |
|
Used to Implement the default requests common to all Oasis API |
|
Module Contents¶
- class oasislmf.platform_api.client.ApiEndpoint(session, url_endpoint, logger=None)[source]¶
Bases:
objectUsed to Implement the default requests common to all Oasis API End points.
- class oasislmf.platform_api.client.JsonEndpoint(session, url_endpoint, url_resource, logger=None)[source]¶
Bases:
objectUsed for JSON data End points.
- class oasislmf.platform_api.client.FileEndpoint(session, url_endpoint, url_resource, logger=None)[source]¶
Bases:
objectFile Resources Endpoint for Upload / Downloading
- class oasislmf.platform_api.client.API_models(session, url_endpoint)[source]¶
Bases:
ApiEndpointUsed to Implement the default requests common to all Oasis API End points.
- class oasislmf.platform_api.client.API_portfolios(session, url_endpoint)[source]¶
Bases:
ApiEndpointUsed to Implement the default requests common to all Oasis API End points.
- class oasislmf.platform_api.client.API_analyses(session, url_endpoint)[source]¶
Bases:
ApiEndpointUsed to Implement the default requests common to all Oasis API End points.
- class oasislmf.platform_api.client.APIClient(api_url='http://localhost:8000', api_ver='V2', auth_type=None, username='admin', password='password', client_id='oasis-service', client_secret='serviceNotSoSecret', access_token=None, refresh_token=None, token_url=None, scope=None, timeout=25, logger=None, **kwargs)[source]¶
Bases:
object- upload_portfolio_file(portfolio_id, portfolio_file, upload_data)[source]¶
Upload a portfolio file using the API. Supports absolute filepaths or bytestreams.
If uploading a byte stream upload_data is a dict with the keys name which is a str containing the filename and bytes containing the byte stream of the file data. For example:
```python upload_portfolio_file(<portfolio_id>, “location_file”,
{‘bytes’: <byte_stream>, ‘name’: <filename>})
- Parameters:
portfolio_id (int) – Portfolio {id} from
portfolio_file (str) – The name of the portfolio file to update. One of the following options location_file, accounts_file, reinsurance_info_file, reinsurance_scope_file or currency_conversion_json.
upload_data ([str, dict]) – The file to upload through the api. This should be a str if it is a filepath or a dict if it is a byte stream with the keys name and bytes corresponding to the filename and bytestream respectively.
- upload_inputs(portfolio_name=None, portfolio_id=None, location_fp=None, accounts_fp=None, ri_info_fp=None, ri_scope_fp=None, currency_conversion_fp=None, reporting_currency=None)[source]¶
- get_currency_conversion(filepath)[source]¶
Gets either the json or csv file referenced in the json and tells the endpoint which is needed
- Parameters:
filepath (str) – path to json file
- Returns:
path to either same json file or csv file referenced by json file
- Return type:
string
- upload_settings(analyses_id, settings)[source]¶
Upload an analyses run settings to an API
Method to post JSON data or upload a settings file containing JSON data
- run_generate(analysis_id, poll_interval=5)[source]¶
Generates the inputs for the analysis based on the portfolio. The analysis must have one of the following statuses, NEW, INPUTS_GENERATION_ERROR, INPUTS_GENERATION_CANCELLED, READY, RUN_COMPLETED, RUN_CANCELLED or RUN_ERROR.
- run_analysis(analysis_id, analysis_settings_fp=None, poll_interval=5)[source]¶
Runs all the analysis. The analysis must have one of the following statuses, NEW, RUN_COMPLETED, RUN_CANCELLED or RUN_ERROR
- reconnect(analysis_id, output_dir=None, poll_interval=5)[source]¶
Reconnects to an analysis that is still generating inputs or running, and resumes polling from its current status - without re-triggering input generation or the run itself. If the run has already completed, downloads the output (when output_dir is given).
- download_output(analysis_id, download_path='', filename=None, clean_up=False, overwrite=True)[source]¶