跳转到主要内容

InUse官方客户端

项目描述

pyinuse

pyinuseInUse API的官方Python客户端。

它提供了以下主要API方法

  • list
  • create
  • update
  • partial_update
  • retrieve
  • destroy

对于主要端点,如

  • manufacturers
  • machine_models
  • machines
  • producers
  • sites
  • lines
  • machines
  • properties
  • multispans
  • csvs
  • posts
  • triggers
  • synoptics
  • files
  • agents
  • groups
  • favorites
  • notifications
  • alerts
  • sandboxes

有关更多详细信息,请参阅InUse API文档(可在工作室中访问)。

API版本化

实际的API版本是内部API(未版本化)并且可能发生变化。稍后阶段将创建一个版本化的公共API,并在此Python客户端中使用。

使用示例

# Library used to type a password in a secured way.
import getpass
# Client library for the InUse API.
from pyinuse import InUse
# Library for logging
import logging
logging.basicConfig(format="%(asctime)s, %(name)s, %(levelname)s, %(message)s", level=logging.INFO)

manufacturer_code="mycompany" # replace with your manufacturer code

# login
inuse = InUse(base_url=f"https://studio.{manufacturer_code}.productinuse.com")
inuse.login(input("Username? "), getpass.getpass("Password? "))

# get my manufacturer
# each endpoint is accessible by its name as an attribute of InUse instance
manufacturer = inuse.manufacturers.list()[0]

# create a new machine_model
machine_model = inuse.machine_models.update_or_create(
    params={"manufacturer": manufacturer["pk"], "code": "my-machine-model"},
    data={
        "manufacturer": manufacturer["pk"],
        "code": "my-machine-model",
        "name": "my machine model",
    },
)

# logout once you're done
inuse.logout()

历史

0.1.2

  • 添加会话头

0.1.1

  • 处理响应错误

0.1.0

  • 基于内部API的第一个版本

项目详情


下载文件

下载适合您平台的文件。如果您不确定要选择哪一个,请了解有关安装包的更多信息。

源分布

pyinuse-0.1.2.tar.gz (5.2 kB 查看哈希值)

上传时间 源码

构建分发版

pyinuse-0.1.2-py3-none-any.whl (4.7 kB 查看哈希值)

上传时间 Python 3

由以下支持