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
Hookreplacement (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::createandhook::destroy) - creating temporary file (
readdirshows owner) (needsfiles::writeFile,files::readdirandfiles::removeFile) - Using
Hookvariable 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.rolesup 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.jsonand so on - Hook creation from
hooksrepositorypackage.json- Add
hookiopackage 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
hookiopackage on server (sometime it will happens)
- Add
- Hook running via
gateway-*s (https://hook.io/gateways) - Parse
logging.LogRecorddict-style entries inhookio logssubcommands - 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
loggingto writehookio.logs.write(maybe as a separate code in run-hook-python - see stackvana/hook.io#236) - All
payloadmentioned 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.streamtologging- Converter to make
logging.LogRecordfrom parsed logdict - async access for
logs.streamwith ability to add joined streams (depends on async feature)
- Converter to make
- Wrapper interface to
sdk.filesAPI (Hook.osmaybe?) -
__call__interface tosdk.hook.run(hookio.any.<owner>.<name>()for anonymous calls?) -
sdk.environ: Cache?
- Interface to fork a thread/threads to join
def createClienthas js-like interface (gets dict as only argument - you can pass config to it).def createClientreads environment variables for absent parameters (i.e.$hookAccessKey).class Clienthas some sane defaults, but don't reads any config.- CLI argument parsing is separated from library API. I.e.
argparsespecifics should be kept inrunclient.py. helpers/compilehook.pycan 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
Clientinstance 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__.Hookvariable withhookio.utils.Namespaceinstance with additional field interface and__main__.Hook.sdkfield referringClientinstance. Clientinstance has lazy-import fields associated with modules - methods of these fields are public API.
- Most of
Clientpublic API corresponds to call to one URL. Such methods hasrawparameter. Default value of this parameter defers by methods - usuallyFalse, but can beTrue(i.e. for streaming methods). Ifraw=Truemethod will returnrequests.Responseinstance. Ifraw=Falsemethod 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
streamingparameter and it will be called for each line or object (depending onraw). You can passstreaming=Trueand useiter_lines()oriter_content()methods ofrequests.Responseinstance. Precise meaning of combinations ofstreaming,rawand other parameters may differ for each methods - look documentation and source.