Package: lojack-clients
lojack-clientsA collection of client libraries and OpenAPI documentation files for accessing Spireon LoJack's APIs.DescriptionThis package first and foremost contains unofficial OpenAPI documentation for the APIs that are used for the Spireon LoJack's application. There are four different services that have been identified, each with an API that has its own subdomain. These includeidentity,automotive,maintenance, andservices.The OpenAPI documentation files can be found under theopenapidirectory. Each service has their own subdirectory which contains only a singleopenapi.yamlfile documenting the services' API.Additionally, this package contains Python client libraries that have been generated from the OpenAPI documentation using theopenapi-generators/openapi-python-client. Everything inside thelojack_clientsdirectory has been generated using the client generator. There are however some minor customizations made to the templates that the generator uses to generate the client classes. These customizations were necessary to make the client work with the APIs' authentication schemes.ServicesEach different service has its own purpose with separate endpoints. You will likely primarily be interacting with theidentityandservicesservices. It is likely that there are more services and endpoints that exist, however these ones listed are only the ones that have been discovered so far.identityThis service contains a single endpoint which is used for authenticating and generating an access token that can be used with other services.automotiveThis service contains a single endpoint used to get information about the dealership that your account is associated with.maintenanceThis service contains two endpoints that relate to maintenance of your car, one for getting repair orders and another for getting a vehicle's suggested maintenance schedule.servicesThis service contains several endpoints which are responsible for the vast majority of the functionality within the LoJack application.UsageEach service acts as its own library with its own client class.First, you will need to instantiate the identity client which you will use to generate an access token. You should use thefrom_loginclass factory method to instantiate the identity client.fromlojack_clients.identityimportAuthenticatedClientasIdentityClientidentity_client=IdentityClient.from_login(username,password)Here theAuthenticatedClientimport is aliased asIdentityClientto avoid conflicts withAuthenticatedClientclasses from the other services' client libraries.All endpoints require authentication so you will only use theAuthenticatedClient.Next, you will need to call the get_identity_token endpoint to retrieve an access token:fromlojack_clients.identity.modelsimportGetIdentityTokenResponse200fromlojack_clients.identity.api.defaultimportget_identity_tokenfromlojack_clients.identity.typesimportResponseasIdentityResponsetoken_response:GetIdentityTokenResponse200=get_identity_token.sync(client=identity_client)# or if you need more info (e.g. status_code)token_response:Response[GetIdentityTokenResponse200]=get_identity_token.sync_detailed(client=identity_client)Or do the same thing with an async version:fromlojack_clients.identity.modelsimportGetIdentityTokenResponse200fromlojack_clients.identity.api.defaultimportget_identity_tokenfromlojack_clients.identity.typesimportResponseasIdentityResponsetoken_response:GetIdentityTokenResponse200=awaitget_identity_token.asyncio(client=identity_client)# or if you need more info (e.g. status_code)token_response:Response[GetIdentityTokenResponse200]=awaitget_identity_token.asyncio_detailed(client=identity_client)Here theResponseimport is aliased asIdentityResponseto avoid conflicts withResponseclasses from the other services' client libraries.Because each of the client libraries are automatically generated, theResponseclasses for each library are all the same and interchangeable.You can then instantiate any of the other three clients using the access token found in the identity response. You should use thefrom_tokenclass factory method to instantiate any of the other three clients.fromlojack_clients.servicesimportAuthenticatedClientasServicesClient# if you used the sync or asyncio methodsservices_client=ServicesClient.from_token(token_response.token)# or if you used sync_detailed or asyncio_detailed methodsservices_client=ServicesClient.from_token(token_response.parsed.token)You can now use this client to call any of the other endpoints from within the service, similar to how the identity client was used to call the get_identity_token endpoint.fromlojack_clients.services.modelsimportGetAllUserAssetsResponse200fromlojack_clients.services.api.defaultimportget_all_user_assetsfromlojack_clients.services.typesimportResponseasServicesResponseassets_response:GetAllUserAssetsResponse200=get_all_user_assets.sync(client=services_client)Just as the endpoint before, you can usesync_detailedif you need more information about the response, andasyncio/asyncio_detailedto do the same with async calls.Putting all the steps together, this is what it would look like to authenticate and make a call to retrieve all user assets.fromlojack_clients.identityimportAuthenticatedClientasIdentityClientfromlojack_clients.identity.modelsimportGetIdentityTokenResponse200fromlojack_clients.identity.api.defaultimportget_identity_tokenfromlojack_clients.identity.typesimportResponseasIdentityResponsefromlojack_clients.servicesimportAuthenticatedClientasServicesClientfromlojack_clients.services.modelsimportGetAllUserAssetsResponse200fromlojack_clients.services.api.defaultimportget_all_user_assetsfromlojack_clients.services.typesimportResponseasServicesResponseidentity_client=IdentityClient.from_login(username,password)token_response:GetIdentityTokenResponse200=get_identity_token.sync(client=identity_client)services_client=ServicesClient.from_token(token_response.token)assets_response:GetAllUserAssetsResponse200=get_all_user_assets.sync(client=services_client)Things to know:Every path/method combo becomes a Python module with four functions:sync: Blocking request that returns parsed data (if successful) orNonesync_detailed: Blocking request that always returns aRequest, optionally withparsedset if the request was successful.asyncio: Likesyncbut the async instead of blockingasyncio_detailed: Likesync_detailedby async instead of blockingAll path/query params, and bodies become method arguments.All endpoints can be found underlojack_clients/{service}/api/default/{endpoint}.py.Endpoint file names are generated using the request'soperationIdkey in the OpenAPI documentation (converted to snake_case).DevelopmentAll code inside thelojack_clientsdirectory is automatically generated. If any changes are made to any of the services' openapi.yaml file, you can update the service's client library by running./scripts/build_api_clients. You can pass in specific services that you want to build libraries for, or you can call it without any arguments to build client libraries for all four services. For eg../scripts/build_api_clients services identitywould build the libraries for only theservicesandidentityclients.Customized template files for the client libraries exist under./client-generator/templates/{service}. If you need to customize some of the generated code you can add or modify Jinja template files there.Other information about how the code is generated and how it can be configured can be found within theopenapi-generators/openapi-python-clientproject on GitHub.ContributingIf you know of any endpoints or services that aren't disclosed here you're welcome to open up a pull request to add them to the OpenAPI documentation. If there are any other improvements or suggestions, feel free to open a pull request or an issue.DisclaimerThis project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Spireon, Inc. The names Spireon and LoJack are trademarks or registered trademarks of Spireon and its subsidiaries. Any related names, marks, emblems and images are registered trademarks of their respective owners. This project has been developed entirely through the use and observation of publicly available information. Use of this project or information within this project comes with no guarantees or warranties. Whenever using or interacting with any services from Spireon, Inc. you must ensure that you are following the Spireon, Inc. terms of service agreement as well as any other agreements that may apply. If you are associated with Spireon, inc and have any questions or concerns, pleasesubmit an issueon the GitHub repository.