enebularのクラウド実行環境上で動作するアプリケーションを開発するためのSDKです。
Project description
enebular-sdk
enebularのクラウド実行環境上で動作するアプリケーションを開発するためのSDKです。 本SDKを利用することにより、enebularのデータストアを利用するアプリケーションを開発できます。
対応環境
- 実行環境: enebularのクラウド実行環境
- ランタイム: Python 3.13
インストール
pip install enebular-sdk
クイックスタート
from enebular_sdk import CloudDataStoreClient
import time
import json
datastore = CloudDataStoreClient()
def handler(event, context):
# データの保存
datastore.put_item({
'table_id': 'sensor-data',
'item': {
'deviceId': 'device-001',
'timestamp': int(time.time() * 1000),
'temperature': 25.5
}
})
result = datastore.query({
'table_id': 'sensor-data',
'expression': '#deviceId = :deviceId',
'values': {'deviceId': 'device-001'},
'order': False, # False = descending
'limit': 10
})
return {
'statusCode': 200,
'body': json.dumps(result.get('params', {}).get('Items'))
}
機能
データストア
enebularのデータストアのテーブルに対してデータの読み書き削除等の操作を行います。 主な操作の種類は以下の通りです。
- CloudDataStoreClient - データストア操作のインスタンス作成
- get_item - データの取得
- put_item - データの保存
- delete_item - データの削除
- query - データのクエリ
あらかじめenebularで、操作対象のテーブルを作成しておく必要があります。
以下に使い方を示します。
データストア操作のインスタンス作成
from enebular_sdk import CloudDataStoreClient
datastore = CloudDataStoreClient()
以降の使用例ではこのdatastoreインスタンスを利用して、データストアの操作を行います。
データの取得
result = datastore.get_item({
'table_id': 'sensor-data',
'key': {'deviceId': 'device-001', 'timestamp': 1234567890}
})
if result['result'] == 'success':
print(result.get('params', {}).get('Item'))
get_itemの戻り値の形式:
{
"result": "success" | "fail", # 成功(success)/失敗(fail)を表します
"error": str, # 失敗の場合、エラーメッセージを保持します
"params": {"Item": any} # 成功した場合、Itemに取得したデータを保持します
}
データの保存
datastore.put_item({
'table_id': 'sensor-data',
'item': {
'deviceId': 'device-001',
'timestamp': int(time.time() * 1000),
'temperature': 25.5,
'humidity': 60
}
})
put_itemの戻り値の形式:
{
"result": "success" | "fail", # 成功(success)/失敗(fail)を表します
"params": {"Item": any}, # 成功した場合、Itemに登録したデータを保持します
"error": str # 失敗の場合、エラーメッセージを保持します
}
データの削除
datastore.delete_item({
'table_id': 'sensor-data',
'key': {'deviceId': 'device-001', 'timestamp': 1234567890}
})
delete_itemの戻り値の形式:
{
"result": "success" | "fail", # 成功(success)/失敗(fail)を表します
"error": str, # 失敗の場合、エラーメッセージを保持します
"params": {"Item": any} # 成功した場合、Itemに削除したデータを保持します
}
データの検索
import time
result = datastore.query({
'table_id': 'sensor-data',
'expression': '#deviceId = :deviceId and #timestamp > :timestamp',
'values': {
'deviceId': 'device-001',
'timestamp': int(time.time() * 1000) - 86400000 # 過去24時間
},
'order': True, # True=昇順, False=降順
'limit': 100 # limitを設定しない場合は10とする
})
queryの戻り値の形式:
{
"result": "success" | "fail", # 成功(success)/失敗(fail)を表します
"error": str, # 失敗の場合、エラーメッセージを保持します
"params": {
"Items": [any], # 成功した場合、Itemに取得したデータを保持します
"LastEvaluatedKey": str, # 今回取得したデータの続きのデータを取得するキーを保持します*1
"Count": int # 取得したデータ数を保持します
}
}
*1: LastEvaluatedKeyの値をquery実行時のパラメーターにstart_keyとして追加することで続きを取得できます
ロガー
ログを出力します。 出力したログは、enebularのクラウド実行環境画面で閲覧できます。
以下に使い方を示します。
from enebular_sdk import Logger
logger = Logger("MyContext")
logger.error("エラーメッセージ", error)
logger.warn("警告メッセージ", data)
logger.info("情報メッセージ", data)
logger.debug("デバッグメッセージ", data)
ログの出力例:
[Dec 19th 2025, 13:00:50]: 2025-12-19T04:00:50.491Z adfff29c-658d-4c44-9530-9a33298950b6 ERROR 2025-12-19T04:00:50.491Z [enebular-sdk] [ERROR] [MyContext] エラーメッセージ
出力対象のログは環境変数 LOG_LEVEL で設定できます。
- ERROR: error関数のログのみ出力します
- WARN: error、warn関数のログを出力します
- INFO: error、warn、info関数のログを出力します
- DEBUG: error、warn、info、debug関数のログを出力します
- TRACE: error、warn、info、debug、trace関数のログを出力します
環境変数は、enebularのクラウド実行環境画面で設定できます。
型ヒントサポート
このSDKは型ヒントを提供しています。IDEでの自動補完やタイプチェックが利用できます。
enebularへのデプロイ
作成したプログラムをenebularのクラウド実行環境にデプロイして実行します。 デプロイする方法については、enebularのチュートリアルをご参照ください。
ライセンス
MIT
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 Distribution
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 enebular_sdk-1.0.0.tar.gz.
File metadata
- Download URL: enebular_sdk-1.0.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bb39717329e50671d8ae56c525ba772c9e76ad5f91caac17c6e71144a618f78
|
|
| MD5 |
543fc37f1062149f0c5413ade07a3049
|
|
| BLAKE2b-256 |
a964adedc0589d3040d24c649b1713b43dbf7e46b0f19a9a75e55294e5469810
|
Provenance
The following attestation bundles were made for enebular_sdk-1.0.0.tar.gz:
Publisher:
python-publish.yml on Uhuru-Corporation/enebular-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
enebular_sdk-1.0.0.tar.gz -
Subject digest:
2bb39717329e50671d8ae56c525ba772c9e76ad5f91caac17c6e71144a618f78 - Sigstore transparency entry: 779335478
- Sigstore integration time:
-
Permalink:
Uhuru-Corporation/enebular-sdk@3bd9f88f386d28b3ddca6c09d8caf2815bea0c77 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/Uhuru-Corporation
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3bd9f88f386d28b3ddca6c09d8caf2815bea0c77 -
Trigger Event:
release
-
Statement type:
File details
Details for the file enebular_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: enebular_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bae0e8a48fb52535e0ba1b9a62cff8414a6c12558c3e0bccaa673877d977f64
|
|
| MD5 |
365f78c4757837e1f1a2a318fa3cc722
|
|
| BLAKE2b-256 |
95d855733ee945f2faf0ef1defd51a44646bbd8bf94b28422bfc71c518be5148
|
Provenance
The following attestation bundles were made for enebular_sdk-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on Uhuru-Corporation/enebular-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
enebular_sdk-1.0.0-py3-none-any.whl -
Subject digest:
7bae0e8a48fb52535e0ba1b9a62cff8414a6c12558c3e0bccaa673877d977f64 - Sigstore transparency entry: 779335480
- Sigstore integration time:
-
Permalink:
Uhuru-Corporation/enebular-sdk@3bd9f88f386d28b3ddca6c09d8caf2815bea0c77 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/Uhuru-Corporation
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3bd9f88f386d28b3ddca6c09d8caf2815bea0c77 -
Trigger Event:
release
-
Statement type: