changeset 21:474387f2a457

Add README
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 17 Oct 2020 19:33:18 +0200
parents fe401e1e025c
children 9325dda642b4
files README.md generate/gen/.nonempty generate/generate.py
diffstat 2 files changed, 49 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Sat Oct 17 19:33:18 2020 +0200
@@ -0,0 +1,48 @@
+# `async-google-apis`
+
+This software generates asynchronous API stubs for Google APIs (and most likely
+any other API described by a Discovery document). It uses
+[`yup-oauth2`](https://github.com/dermesser/yup-oauth2) for the authorization
+logic.
+
+This project is still experimental. While for many complex APIs (Cloud Storage,
+Drive v3, Sheets v4) usable APIs including types and documentation are generated
+successfully, this doesn't mean that it will work on any other current or future
+Google API.
+
+## Parts
+
+`manual_demo` is just a demo crate with some code for developers (well, me) to
+experiment if the generated APIs work, and also to work manually with the Google
+APIs to gain insights on which code to generate.
+
+`generate` contains a Python program fetching current Google Discovery documents
+(https://www.googleapis.com/discovery/v1/apis, see
+ [documentation](https://developers.google.com/discovery/v1/reference)) and
+generating Rust code in the `generate/gen` directory. This is done very
+non-fancily using a few mustache templates and the `chevron` package. The script
+only takes two parameters, which you can discover using `--help`. In short, to
+generate an API stub for the API with ID `storage:v1` (Google Cloud Storage v1),
+run
+
+```shell
+$ pipenv run ./generate.py --only_apis=storage:v1
+```
+
+(install `pipenv` using `pip install --user pipenv` before, if you don't have it
+yet)
+
+Consult `drive_example` for a simple but useful example of using the generated
+code. As you can see, it is reasonably easy! Use `cargo doc` to generate the
+documentation for generated code, as the API comments is translated into Rust
+doc comments.
+
+## To Do
+
+* Multipart uploads are not yet supported. As a crutch, uploadable API endpoints
+are defined using two methods: `method()` and `method_upload()`, where
+`method_upload()` only uploads data, and `method()` only works with metadata.
+This works at least for my favorite API, the Google Drive API (v3). @Byron has a
+simple implementation of multipart HTTP in his excellent
+[Byron/google-apis-rs](https://github.com/Byron/google-apis-rs) crate; something
+similar may be useful here.
--- a/generate/generate.py	Sat Oct 17 19:27:57 2020 +0200
+++ b/generate/generate.py	Sat Oct 17 19:33:18 2020 +0200
@@ -152,7 +152,6 @@
     Returns a list of source code strings.
     """
     frags = []
-    print('processing:', resources.keys())
     for resourcename, resource in resources.items():
         for methodname, method in resource.get('methods', {}).items():
             param_type_name = capitalize_first(super_name) + capitalize_first(resourcename) + capitalize_first(
@@ -334,7 +333,7 @@
                    help='Base Discovery document.')
     p.add_argument('--only_apis', default='drive:v3', help='Only process APIs with these IDs (comma-separated)')
     args = p.parse_args()
-    docs = fetch_discovery_base(args.discovery_base, args.only_apis)
+    docs = fetch_discovery_base(args.discovery_base, args.only_apis.split(','))
     for doc in docs:
         discdoc = fetch_discovery_doc(doc)
         generate_structs(discdoc)