python implementation of bigcompany/hook.io-sdk
- Writing tests:
- tests for CLI subcommands (second target - coverage 98% for every file)
- Stoppers:
- 0.0.* - implement hook.io-sdk replacement + (debug) additions (like
account.login
) + CLI + tests + examples - 0.1.* - implement
Hook
replacement (python-style layer) + compilehook - 0.2.* - python-style layer on client
- 0.* - attempt to implement all [plans](#Current plans)
- 0.9.* - documentation (at least auto-documentation) must be ready before 1.0
- Hook
- run
- create
- update
- destroy
- resource
- source
- package
- fork
- view
- presenter
- refresh
- all (
/<user>
or/services
) blocked by bigcompany/hook.io#251
- Datastore
- get
- set
- del
- recent
- Logs
- read
- stream
- flush
- write inside hook (=
sys.stderr.write
) -
write outside hook
- Events
- get
- stream
-
write
- Keys
- checkAccess
- create
- destroy
- all
- Files
- readFile
- writeFile
- removeFile
- readdir
- stat
- createReadStream
- createWriteStream
- download
- upload
- Env
- get
- set
- Metrics
- hits
- Domains
- all
- create
- destroy
- find
- get
- update
- Account
- name blocked by #251 (comment)
- Can be implemented by:
- listing keys (needs
keys::read
) - creating temporary hook (needs
hook::create
andhook::destroy
) - creating temporary file (
readdir
shows owner) (needsfiles::writeFile
,files::readdir
andfiles::removeFile
) - Using
Hook
variable if we are inside hook.io server
- listing keys (needs
- Can be implemented by:
- signup
- login (user/password session instead of API key)
- services (list hooks - maybe should go to hook.all) see stackvana/hook.io#251
- name blocked by #251 (comment)
- server
- languages
- package managers for language (https://hook.io/packages)
- installed packages for PM (package manager)
- queued packages for PM
- failed packages for PM
- list available themes
- hook.resource
- hook.source
- logs.flush
- logs.write
- keys.info
- metrics.hits
- files.createReadStream
- files.createWriteStream
- files.download
- files.upload
- accounts.login
- accounts.services
- In original SDK TO-DO section there are "Better ENV exports configuration" entry. Maybe "support" or "import"?
- In original SDK TO-DO section there are "Add all hook.io API Methods" entry. Where one can get list of all methods?
- Implement current state/plans of js hook.io-sdk:
- Basic client creation and configuration
- Minimal pipeable CLI tool
- Most hook.io API Methods
- Ability to pass command line arguments
- Ability to pipe arbitrary code snippets
- Add ws:// protocol for Websockets API (https://hook.io/websockets)
- More error-waiting tests (like in hook.io-test)
- Test automation
- Misc tests
- List
hookio.keys.roles
up to date with https://hook.io/roles - Test server-side operation
- Import https://github.com/bigcompany/hook.io-test/tree/master/tests/client
- Add tests for rich unicode support
- List
- Tests for basic API
- Client object creation
- Server-side object creation
- Hook run+metadata+creation
-
Hook modification - Metrics
- Datastore
- Logs
- Events
- Keys
- Files
- Env
- Domains
- Tests for CLI
- Basic parsing (test_cli.py)
- Hook run
- Hook modification
- Metrics
- Datastore
- Logs
- Events
- Keys
- Files
- Env
- Domains
- Test env matrix (tox)
- Code beauty (flake8)
- Coverage
- Setup test CI
- travis
- appveyor
- Misc tests
- Auto-test available changes in hook.io-sdk since last sync (helpers/jssdksyncmon.py)
- Auto-generate docs
- CLI improvements:
- Hook download with creation repository
package.json
and so on - Hook creation from
hooks
repositorypackage.json
- Add
hookio
package bundle to top of hook source (helpers/compilehook.py
) - Add package bundle to account files and some loader to top of hook source
- Rely on availability of
hookio
package on server (sometime it will happens)
- Add
- Hook running via
gateway-*
s (https://hook.io/gateways) - Parse
logging.LogRecord
dict-style entries inhookio logs
subcommands - Mass operations (i.e. mass
hookio hook destroy
) - Pseudo-FS (fuse, pyfilesystems, ...):
- Access to vfs (sdk.files)
- hooks (with resources and logs)
- datastore maybe
- Hook download with creation repository
- Server-side operations (use sdk inside hook):
- Hook
logging
to writehookio.logs.write
(maybe as a separate code in run-hook-python - see stackvana/hook.io#236) - All
payload
mentioned in https://github.com/bigcompany/hook.io/blob/master/bin/run-hook- addTrailers
- removeHeader
- setHeader
- setTimeout
- sendDate
- statusMessage
- statusCode
- writeContinue
- writeHead
- error
- log
- Implement WSGI
- Hook
- Rethink support for async operations (depends on async support for requests)
- Second-layer over API with more python-friendly interfaces:
- Interface to fork a thread/threads to join
sdk.logs.stream
tologging
- Converter to make
logging.LogRecord
from parsed logdict
- async access for
logs.stream
with ability to add joined streams (depends on async feature)
- Converter to make
- Wrapper interface to
sdk.files
API (Hook.os
maybe?) -
__call__
interface tosdk.hook.run
(hookio.any.<owner>.<name>()
for anonymous calls?) -
sdk.environ
: Cache?
- Interface to fork a thread/threads to join
def createClient
has js-like interface (gets dict as only argument - you can pass config to it).def createClient
reads environment variables for absent parameters (i.e.$hookAccessKey
).class Client
has some sane defaults, but don't reads any config.- CLI argument parsing is separated from library API. I.e.
argparse
specifics should be kept inrunclient.py
. helpers/compilehook.py
can concat library with hook that uses it.
There are no documentation yet - it's just several lists (plans, implemented parts, decisions). If someone want to add important documentation parts here - help will be appreciated. Also you are free to play in project wiki.
- You must create
Client
instance byClient()
orcreateClient()
call. - If you are on server side (i.e. inside hook) you can create if using
install_hook_sdk()
. This will also attempt to replace__main__.Hook
variable withhookio.utils.Namespace
instance with additional field interface and__main__.Hook.sdk
field referringClient
instance. Client
instance has lazy-import fields associated with modules - methods of these fields are public API.
- Most of
Client
public API corresponds to call to one URL. Such methods hasraw
parameter. Default value of this parameter defers by methods - usuallyFalse
, but can beTrue
(i.e. for streaming methods). Ifraw=True
method will returnrequests.Response
instance. Ifraw=False
method will return some object representation - usually result of JSON parse. Exception is streaming interface. - Some methods of public API supports streaming interface.
You can pass callable object as
streaming
parameter and it will be called for each line or object (depending onraw
). You can passstreaming=True
and useiter_lines()
oriter_content()
methods ofrequests.Response
instance. Precise meaning of combinations ofstreaming
,raw
and other parameters may differ for each methods - look documentation and source.