Client for Maptek BlastLogic server.
Project description
maptekblastlogic
This is a client library for accessing the BlastLogic Server Integration API.
This package enables you to connect to an API that has been created on the Maptek BlastLogic Server to integrate third party systems, custom software, scripts and tools with the BlastLogic ecosystem. The primary focus of the API is to facilitate adding backfilling, dipping and loaded charge deck data.
This package was generated using the open-python-client package package with minimal modifications.
The API component of the BlastLogic Server is a separate licensable component. This means this package will not function without a number of BlastLogic Extend licences equal to the number of sites on the server.
Configuration
In order to be able to use the BlastLogic Extend API, an API key needs to be generated for the BlastLogic server that you will be wanting to access and work with.
The API key is essentially like a username and password and authenticates your requests with the BlastLogic server.
Log into the web interface for BlastLogic Server and click on "User Keys". On this page click the "New" button to generate a key.
When creating the key, provide a useful description so you know what the key was for, such as saying "Python Blast Truck Integration". If you are not sure exactly what you are building, consider "Python Experiment".
Copy the key to your password manager as once the key is generated the server won't tell you what it is again.
WARNING Do not store the API key within the Python script itself.
Doing this means anyone you share the script with will be able to interact
with the BlastLogic Server as you. Read it from another file or from a password
storage service.
Example Script
The following can be used to test that the package was installed and the API key is set-up. It can also be used as a starting point for your script.
The script use Python's built in getpass library to provide a prompt on the command line where the user can enter their token. It is more robust to use the 3rd party keyring package to store your key securely.
Once you have generated the key, you will need to create an AuthenticatedClient object to
connect the Python Script to the server:
server_url = "your_server_address_here"
token = getpass.getpass("Token for BlastLogic Server:")
with AuthenticatedClient(
base_url=f"{server_url}/api",
raise_on_unexpected_status=True,
token=token,
) as client:
...
Where in the above snippet the server_url is the URL for your BlastLogic Server. Once
a script is connected the server, you can interact with the server through the functions
defined in the subpackages of maptekblastlogic.api. For example, to print the status of
all sites on the server:
import getpass
from maptekblastlogic import AuthenticatedClient
from maptekblastlogic.api.sites import get_sites
from maptekblastlogic.models import ErrorModel
token = getpass.getpass("Token for BlastLogic Server:")
with AuthenticatedClient(
base_url=f"{server_url}/api",
raise_on_unexpected_status=True,
token=token,
) as client:
sites = get_sites.sync(client=client)
if isinstance(sites, ErrorModel):
raise RuntimeError(
"Error when reading sites:",
sites.title,
"\n",
sites.details,
)
if not sites:
raise RuntimeError("No sites found on server.")
for site in sites:
print(site.name)
print("Site Code:", site.site_code)
print("Is active", site.is_active)
print("=~" * 10)
- The first lines import packages (libraries) to be used in the script. This is common for Python scripts.
- The getpass.getpass() line causes the script to ask for an API token.
- The client is set-up with the token and the URL To the BlastLogic server
to connect to.
This needs to be replaced with the URL of the server that you have access to. - Next the list of sites is requested.
- If there was an error it is raised as an error.
- If there are no sites, it raises an error to say there are no sites.
- Otherwise, for each site, it prints out the name of the site and site code if it is active.
See the maptekblastlogic.api package for other operations available on the server.
Another useful reference is the API specification, which can be seen by going to
<server_url>/api/swagger in a web browser.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maptekblastlogic-0.8-py3-none-any.whl.
File metadata
- Download URL: maptekblastlogic-0.8-py3-none-any.whl
- Upload date:
- Size: 92.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b64e2daffaf7a2066a2636e23bbf4e3060a49ca50186a29479403b1a239e6c1d
|
|
| MD5 |
767bc8bdc629284b7e2fe476754b3328
|
|
| BLAKE2b-256 |
f459b333fd38ede0b4419dad6499b7bf16ab1a360e9d0354e7847b3c89d3ae47
|