Name | nextplus JSON |
Version |
0.1.2
JSON |
| download |
home_page | |
Summary | A Python SDK for interacting with the Next Plus MES system |
upload_time | 2024-01-23 11:37:38 |
maintainer | |
docs_url | None |
author | NPO Systems LTD |
requires_python | >=2.7 |
license | MIT |
keywords |
nextplus
mes
api
sdk
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Nextplus Python SDK
## Introduction
The Nextplus Python SDK is a powerful and user-friendly package that allows developers to interact with the Nextplus API. With this SDK, developers can easily perform CRUD operations on tables and records within the Nextplus system.
## Features
- User authentication with Nextplus API
- Retrieve, create, update, and delete records in tables
- Customizable queries with filtering options
## Requirements
- Python 3.x
- requests library
## Installation
To install the Nextplus Python SDK, you can use the following command:
```bash
pip install nextplus
```
## Usage
### Setting Up the Client
First, you need to set up the NextplusClient with your Nextplus server URL, username or email, and password. These can either be passed directly or set as environment variables.
```python
from nextplus import NextplusClient
# Note that you can use email or username
client = NextplusClient(
server_url='https://your.nextplus.server.url',
email='your@email.com',
password='yourpassword'
)
```
### Working with Tables
You can perform operations on tables such as finding a specific table or fetching a list of all tables.
#### Find Tables
```python
tables = client.Tables.find({'where': {'name': 'YourTableName'}})
print(json.dumps(tables))
```
Response:
```json
[
{
"id": "1958dbd0-b9bf-11ee-a4d7-950198b3451e",
"name": "Machine Status Log",
"columns": [
{
"id": "_id",
"name": "id",
"type": "string"
},
{
"id": "deletedAt",
"name": "deletedAt",
"type": "date"
},
{
"id": "createdAt",
"name": "createdAt",
"type": "date"
},
{
"id": "modified",
"name": "modified",
"type": "date"
},
{
"id": "workflowSessionItemId",
"name": "workflowSessionItemId",
"type": "string"
},
{
"id": "formId",
"name": "formId",
"type": "string"
},
{
"name": "Machine ID",
"type": "string",
"required": true,
"id": "COLUMN_machine-id"
},
{
"name": "Status",
"type": "string",
"id": "COLUMN_status"
},
{
"name": "Change Time",
"type": "date",
"id": "COLUMN_change-time",
"deletedAt": "2024-01-23T08:06:42.426Z"
}
],
"created": "2024-01-23T07:14:51.021Z",
"modified": "2024-01-23T08:06:44.500Z",
"serverModified": "2024-01-23T08:06:44.500Z",
"deletedAt": null,
"deletedBy": null
}
]
```
Note that you can only write to columns that prefixed with `COLUMN_`.
Other columns are auto-generated and read only.
#### Working with Records in a Table
You can create, update, find, and delete records in a specific table.
##### Insert a Record
```python
table = client.Table('your_table_id')
record = {
"COLUMN_machine-id": "Machine1",
"COLUMN_status": "idle"
}
result = table.insert(record)
print(f"Record inserted with ID: {result['_id']}")
```
Response:
```json
{
"COLUMN_machine-id": "Machine1",
"COLUMN_status": "idle",
"_id": "7b74899f-f863-473a-9a96-d37a75e1c7fe",
"createdAt": "2024-01-23T11:33:37.205Z",
"modified": "2024-01-23T11:33:37.205Z",
"serverModified": "2024-01-23T11:33:37.205Z",
"deletedAt": null
}
```
##### Update a Record
```python
updated_record = {
"_id": "record_id",
"COLUMN_status": "busy"
}
update_result = table.update(updated_record)
print(update_result)
```
Response:
```json
{
"_id": "7b74899f-f863-473a-9a96-d37a75e1c7fe",
"COLUMN_machine-id": "Machine1",
"COLUMN_status": "busy",
"createdAt": "2024-01-23T11:33:37.205Z",
"modified": "2024-01-23T11:34:52.185Z",
"serverModified": "2024-01-23T11:34:52.185Z",
"deletedAt": null
}
```
##### Find Records
```python
rows = table.find({'where': {'COLUMN_machine-id': 'Machine1'}})
print(rows)
```
Response:
```json
{
"_id": "7b74899f-f863-473a-9a96-d37a75e1c7fe",
"COLUMN_machine-id": "Machine1",
"COLUMN_status": "busy",
"createdAt": "2024-01-23T11:33:37.205Z",
"modified": "2024-01-23T11:34:52.185Z",
"serverModified": "2024-01-23T11:34:52.185Z",
"deletedAt": null,
"id": "7b74899f-f863-473a-9a96-d37a75e1c7fe"
}
```
##### Delete a Record
```python
table.remove("record_id")
```
Response:
```json
{
"_id": "7b74899f-f863-473a-9a96-d37a75e1c7fe",
"COLUMN_machine-id": "Machine1",
"COLUMN_status": "busy",
"createdAt": "2024-01-23T11:33:37.205Z",
"modified": "2024-01-23T11:36:23.226Z",
"serverModified": "2024-01-23T11:36:23.226Z",
"deletedAt": "2024-01-23T11:36:23.226Z"
}
```
## Development
### Building a new version
- Update version code in `nextplus/client.py` and `setup.py`
- Run build command
```bash
python setup.py sdist
```
### Release new version
- Make sure twine is installed
```bash
pip install twine
```
- Then, upload your package
```bash
twine upload dist/*
```
When username & password prompt, enter `__token__` as username and token as password
Raw data
{
"_id": null,
"home_page": "",
"name": "nextplus",
"maintainer": "",
"docs_url": null,
"requires_python": ">=2.7",
"maintainer_email": "",
"keywords": "nextplus mes api sdk",
"author": "NPO Systems LTD",
"author_email": "info@nextplus.io",
"download_url": "https://files.pythonhosted.org/packages/64/91/d426aa649cb9c82bcce68345b698733aea4fe88c6e23eea94a39371770ae/nextplus-0.1.2.tar.gz",
"platform": null,
"description": "# Nextplus Python SDK\r\n\r\n## Introduction\r\n\r\nThe Nextplus Python SDK is a powerful and user-friendly package that allows developers to interact with the Nextplus API. With this SDK, developers can easily perform CRUD operations on tables and records within the Nextplus system.\r\n\r\n## Features\r\n\r\n- User authentication with Nextplus API\r\n- Retrieve, create, update, and delete records in tables\r\n- Customizable queries with filtering options\r\n\r\n## Requirements\r\n\r\n- Python 3.x\r\n- requests library\r\n\r\n## Installation\r\n\r\nTo install the Nextplus Python SDK, you can use the following command:\r\n\r\n```bash\r\npip install nextplus\r\n```\r\n\r\n## Usage\r\n\r\n### Setting Up the Client\r\n\r\nFirst, you need to set up the NextplusClient with your Nextplus server URL, username or email, and password. These can either be passed directly or set as environment variables.\r\n\r\n```python\r\nfrom nextplus import NextplusClient\r\n# Note that you can use email or username\r\nclient = NextplusClient(\r\n server_url='https://your.nextplus.server.url',\r\n email='your@email.com',\r\n password='yourpassword'\r\n)\r\n```\r\n\r\n### Working with Tables\r\n\r\nYou can perform operations on tables such as finding a specific table or fetching a list of all tables.\r\n\r\n#### Find Tables\r\n\r\n```python\r\ntables = client.Tables.find({'where': {'name': 'YourTableName'}})\r\nprint(json.dumps(tables))\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n[\r\n {\r\n \"id\": \"1958dbd0-b9bf-11ee-a4d7-950198b3451e\",\r\n \"name\": \"Machine Status Log\",\r\n \"columns\": [\r\n {\r\n \"id\": \"_id\",\r\n \"name\": \"id\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"id\": \"deletedAt\",\r\n \"name\": \"deletedAt\",\r\n \"type\": \"date\"\r\n },\r\n {\r\n \"id\": \"createdAt\",\r\n \"name\": \"createdAt\",\r\n \"type\": \"date\"\r\n },\r\n {\r\n \"id\": \"modified\",\r\n \"name\": \"modified\",\r\n \"type\": \"date\"\r\n },\r\n {\r\n \"id\": \"workflowSessionItemId\",\r\n \"name\": \"workflowSessionItemId\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"id\": \"formId\",\r\n \"name\": \"formId\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"name\": \"Machine ID\",\r\n \"type\": \"string\",\r\n \"required\": true,\r\n \"id\": \"COLUMN_machine-id\"\r\n },\r\n {\r\n \"name\": \"Status\",\r\n \"type\": \"string\",\r\n \"id\": \"COLUMN_status\"\r\n },\r\n {\r\n \"name\": \"Change Time\",\r\n \"type\": \"date\",\r\n \"id\": \"COLUMN_change-time\",\r\n \"deletedAt\": \"2024-01-23T08:06:42.426Z\"\r\n }\r\n ],\r\n \"created\": \"2024-01-23T07:14:51.021Z\",\r\n \"modified\": \"2024-01-23T08:06:44.500Z\",\r\n \"serverModified\": \"2024-01-23T08:06:44.500Z\",\r\n \"deletedAt\": null,\r\n \"deletedBy\": null\r\n }\r\n]\r\n```\r\n\r\nNote that you can only write to columns that prefixed with `COLUMN_`.\r\nOther columns are auto-generated and read only.\r\n\r\n#### Working with Records in a Table\r\n\r\nYou can create, update, find, and delete records in a specific table.\r\n\r\n##### Insert a Record\r\n\r\n```python\r\ntable = client.Table('your_table_id')\r\nrecord = {\r\n\"COLUMN_machine-id\": \"Machine1\",\r\n\"COLUMN_status\": \"idle\"\r\n}\r\nresult = table.insert(record)\r\nprint(f\"Record inserted with ID: {result['_id']}\")\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n \"COLUMN_machine-id\": \"Machine1\",\r\n \"COLUMN_status\": \"idle\",\r\n \"_id\": \"7b74899f-f863-473a-9a96-d37a75e1c7fe\",\r\n \"createdAt\": \"2024-01-23T11:33:37.205Z\",\r\n \"modified\": \"2024-01-23T11:33:37.205Z\",\r\n \"serverModified\": \"2024-01-23T11:33:37.205Z\",\r\n \"deletedAt\": null\r\n}\r\n```\r\n\r\n##### Update a Record\r\n\r\n```python\r\nupdated_record = {\r\n\"_id\": \"record_id\",\r\n\"COLUMN_status\": \"busy\"\r\n}\r\nupdate_result = table.update(updated_record)\r\nprint(update_result)\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n \"_id\": \"7b74899f-f863-473a-9a96-d37a75e1c7fe\",\r\n \"COLUMN_machine-id\": \"Machine1\",\r\n \"COLUMN_status\": \"busy\",\r\n \"createdAt\": \"2024-01-23T11:33:37.205Z\",\r\n \"modified\": \"2024-01-23T11:34:52.185Z\",\r\n \"serverModified\": \"2024-01-23T11:34:52.185Z\",\r\n \"deletedAt\": null\r\n}\r\n```\r\n\r\n##### Find Records\r\n\r\n```python\r\nrows = table.find({'where': {'COLUMN_machine-id': 'Machine1'}})\r\nprint(rows)\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n \"_id\": \"7b74899f-f863-473a-9a96-d37a75e1c7fe\",\r\n \"COLUMN_machine-id\": \"Machine1\",\r\n \"COLUMN_status\": \"busy\",\r\n \"createdAt\": \"2024-01-23T11:33:37.205Z\",\r\n \"modified\": \"2024-01-23T11:34:52.185Z\",\r\n \"serverModified\": \"2024-01-23T11:34:52.185Z\",\r\n \"deletedAt\": null,\r\n \"id\": \"7b74899f-f863-473a-9a96-d37a75e1c7fe\"\r\n}\r\n```\r\n\r\n##### Delete a Record\r\n\r\n```python\r\ntable.remove(\"record_id\")\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n \"_id\": \"7b74899f-f863-473a-9a96-d37a75e1c7fe\",\r\n \"COLUMN_machine-id\": \"Machine1\",\r\n \"COLUMN_status\": \"busy\",\r\n \"createdAt\": \"2024-01-23T11:33:37.205Z\",\r\n \"modified\": \"2024-01-23T11:36:23.226Z\",\r\n \"serverModified\": \"2024-01-23T11:36:23.226Z\",\r\n \"deletedAt\": \"2024-01-23T11:36:23.226Z\"\r\n}\r\n```\r\n\r\n## Development\r\n\r\n### Building a new version\r\n\r\n- Update version code in `nextplus/client.py` and `setup.py`\r\n- Run build command\r\n ```bash\r\n python setup.py sdist\r\n ```\r\n\r\n### Release new version\r\n\r\n- Make sure twine is installed\r\n ```bash\r\n pip install twine\r\n ```\r\n- Then, upload your package\r\n ```bash\r\n twine upload dist/*\r\n ```\r\n When username & password prompt, enter `__token__` as username and token as password\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python SDK for interacting with the Next Plus MES system",
"version": "0.1.2",
"project_urls": null,
"split_keywords": [
"nextplus",
"mes",
"api",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6491d426aa649cb9c82bcce68345b698733aea4fe88c6e23eea94a39371770ae",
"md5": "591ffc5c523e937560eabd7c52ef4fa4",
"sha256": "fe08394a11e3ac1619dc90ffbe09ff6dea0e584a864991e5d9d1867d520aacf9"
},
"downloads": -1,
"filename": "nextplus-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "591ffc5c523e937560eabd7c52ef4fa4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 6219,
"upload_time": "2024-01-23T11:37:38",
"upload_time_iso_8601": "2024-01-23T11:37:38.724061Z",
"url": "https://files.pythonhosted.org/packages/64/91/d426aa649cb9c82bcce68345b698733aea4fe88c6e23eea94a39371770ae/nextplus-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-23 11:37:38",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nextplus"
}