All Projects → gsong → python-epo-ops-client

gsong / python-epo-ops-client

Licence: Apache-2.0 license
Python Client for the European Patent Office's Open Patent Services API

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects
API Blueprint
66 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to python-epo-ops-client

patent client
A collection of ORM-style clients to public patent data
Stars: ✭ 14 (-86.54%)
Mutual labels:  ops, epo
Cassandra Operator
Kubernetes operator for Apache Cassandra
Stars: ✭ 215 (+106.73%)
Mutual labels:  ops
Babushka
Test-driven sysadmin.
Stars: ✭ 794 (+663.46%)
Mutual labels:  ops
Ops Cli
Ops - cli wrapper for Terraform, Ansible, Helmfile and SSH for cloud automation
Stars: ✭ 152 (+46.15%)
Mutual labels:  ops
Linuxnotes
Some notes about Linux
Stars: ✭ 10 (-90.38%)
Mutual labels:  ops
K8s App Engine
Application delivery engine for k8s
Stars: ✭ 166 (+59.62%)
Mutual labels:  ops
Spug
开源运维平台:面向中小型企业设计的轻量级无Agent的自动化运维平台,整合了主机管理、主机批量执行、主机在线终端、文件在线上传下载、应用发布部署、在线任务计划、配置中心、监控、报警等一系列功能。
Stars: ✭ 6,810 (+6448.08%)
Mutual labels:  ops
Chain
链喵 CMDB 本项目已停止开发!因长时间未对代码进行维护,可能会造成项目在不同环境上无法部署、运行BUG等问题,请知晓!项目仅供参考!
Stars: ✭ 240 (+130.77%)
Mutual labels:  ops
Bookmarks
🔖 +4.3K awesome resources for geeks and software crafters 🍺
Stars: ✭ 210 (+101.92%)
Mutual labels:  ops
S3 Deploy
NodeJS bash utility for deploying files to Amazon S3
Stars: ✭ 146 (+40.38%)
Mutual labels:  ops
Delta
DELTA is a deep learning based natural language and speech processing platform.
Stars: ✭ 1,479 (+1322.12%)
Mutual labels:  ops
Venona
Codefresh runtime-environment agent
Stars: ✭ 31 (-70.19%)
Mutual labels:  ops
Concourse Up
Deprecated - used Control Tower instead
Stars: ✭ 207 (+99.04%)
Mutual labels:  ops
Ops doc
运维简洁实用手册
Stars: ✭ 819 (+687.5%)
Mutual labels:  ops
Akka Management
Akka Management is a suite of tools for operating Akka Clusters.
Stars: ✭ 218 (+109.62%)
Mutual labels:  ops
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+657.69%)
Mutual labels:  ops
Banshee
Anomalies detection system for periodic metrics.
Stars: ✭ 1,045 (+904.81%)
Mutual labels:  ops
Opbeat Node
DEPRECATED - See Elastic APM instead: https://github.com/elastic/apm-agent-nodejs
Stars: ✭ 155 (+49.04%)
Mutual labels:  ops
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+2775%)
Mutual labels:  ops
Opensa
资产管理、资产采集、灰度发布、反向代理、批量任务、任务编排、计划任务、日志审计、权限管理、角色管理、部门管理、运维自动化
Stars: ✭ 220 (+111.54%)
Mutual labels:  ops

python-epo-ops-client

PyPI PyPI - Python Version Travis.org Coveralls github

python-epo-ops-client is an Apache2 licensed client library for accessing the European Patent Office's ("EPO") Open Patent Services ("OPS") v.3.2 (based on v 1.3.16 of the reference guide).

import epo_ops

client = epo_ops.Client(key='abc', secret='xyz')  # Instantiate client
response = client.published_data(  # Retrieve bibliography data
  reference_type = 'publication',  # publication, application, priority
  input = epo_ops.models.Docdb('1000000', 'EP', 'A1'),  # original, docdb, epodoc
  endpoint = 'biblio',  # optional, defaults to biblio in case of published_data
  constituents = []  # optional, list of constituents
)

Features

python-epo-ops-client abstracts away the complexities of accessing EPO OPS:

  • Format the requests properly
  • Bubble up quota problems as proper HTTP errors
  • Handle token authentication and renewals automatically
  • Handle throttling properly
  • Add optional caching to minimize impact on the OPS servers

There are two main layers to python-epo-ops-client: Client and Middleware.

Client

The Client contains all the formatting and token handling logic and is what you'll interact with mostly.

When you issue a request, the response is a requests.Response object. If response.status_code != 200 then a requests.HTTPError exception will be raised — it's your responsibility to handle those exceptions if you want to. The one case that's handled is when the access token has expired: in this case, the client will automatically handle the HTTP 400 status and renew the token.

Note that the Client does not attempt to interpret the data supplied by OPS, so it's your responsibility to parse the XML or JSON payload for your own purpose.

The following custom exceptions are raised for cases when OPS quotas are exceeded, they are all in the epo_ops.exceptions module and are subclasses of requests.HTTPError, and therefore offer the same behaviors:

  • IndividualQuotaPerHourExceeded
  • RegisteredQuotaPerWeekExceeded

Again, it's up to you to parse the response and decide what to do.

Currently the Client knows how to issue request for the following services:

Client method API end point throttle
family(reference_type, input, endpoint=None, constituents=None) family inpadoc
image(path, range=1, extension='tiff') published-data/images images
number(reference_type, input, output_format) number-service other
published_data(reference_type, input, endpoint='biblio', constituents=None) published-data retrieval
published_data_search(cql, range_begin=1, range_end=25, constituents=None) published-data/search search
register(reference_type, input, constituents=['biblio']) register other
register_search(cql, range_begin=1, range_end=25) register/search other
register_search(cql, range_begin=1, range_end=25) register/search other

Bulk operations can be achieved by passing a list of valid models to the published_data input field.

See the OPS guide or use the Developer's Area for more information on how to use each service.

Please submit pull requests for the following services by enhancing the epo_ops.api.Client class:

  • Legal service

Middleware

All requests and responses are passed through each middleware object listed in client.middlewares. Requests are processed in the order listed, and responses are processed in the reverse order.

Each middleware should subclass middlewares.Middleware and implement the process_request and process_response methods.

There are two middleware classes out of the box: Throttler and Dogpile. Throttler is in charge of the OPS throttling rules and will delay requests accordingly. Dogpile is an optional cache which will cache all HTTP status 200, 404, 405, and 413 responses.

By default, only the Throttler middleware is enabled, if you want to enable caching:

import epo_ops

middlewares = [
    epo_ops.middlewares.Dogpile(),
    epo_ops.middlewares.Throttler(),
]
client = epo_ops.Client(
    key='key',
    secret='secret',
    middlewares=middlewares,
)

You'll also need to install caching dependencies in your projects, such as pip install dogpile.cache.

Note that caching middleware should be first in most cases.

Dogpile

Dogpile is based on (surprise) dogpile.cache. By default it is instantiated with a DBMBackend region with timeout of 2 weeks.

Dogpile takes three optional instantiation parameters:

  • region: You can pass whatever valid dogpile.cache Region you want to backend the cache
  • kwargs_handlers: A list of keyword argument handlers, which it will use to process the kwargs passed to the request object in order to extract elements for generating the cache key. Currently one handler is implemented (and instantiated by default) to make sure that the range request header is part of the cache key.
  • http_status_codes: A list of HTTP status codes that you would like to have cached. By default 200, 404, 405, and 413 responses are cached.

Note: dogpile.cache is not installed by default, if you want to use it, pip install dogpile.cache in your project.

Throttler

Throttler contains all the logic for handling different throttling scenarios. Since OPS throttling is based on a one minute rolling window, we must persist historical (at least for the past minute) throtting data in order to know what the proper request frequency is. Each Throttler must be instantiated with a Storage object.

Storage

The Storage object is responsible for:

  1. Knowing how to update the historical record with each request (Storage.update()), making sure to observe the one minute rolling window rule.
  2. Calculating how long to wait before issuing the next request (Storage.delay_for()).

Currently the only Storage backend provided is SQLite, but you can easily write your own Storage backend (such as file, Redis, etc.). To use a custom Storage type, just pass the Storage object when you're instantiating a Throttler object. See epo_ops.middlewares.throttle.storages.Storage for more implementation details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].