Mercurial > lbo > hg > async-google-apis
changeset 84:e27daa2da21c
Enable generating Google Photos API and add more arguments
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sat, 24 Oct 2020 17:27:32 +0200 |
parents | 218cb13f4f01 |
children | 8affd19aab34 |
files | async-google-apis-common/Cargo.lock generate/generate.py manual_demo/Cargo.lock manual_demo/src/main.rs |
diffstat | 4 files changed, 103 insertions(+), 686 deletions(-) [+] |
line wrap: on
line diff
--- a/async-google-apis-common/Cargo.lock Sat Oct 24 16:52:21 2020 +0200 +++ b/async-google-apis-common/Cargo.lock Sat Oct 24 17:27:32 2020 +0200 @@ -14,7 +14,7 @@ [[package]] name = "async-google-apis-common" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "chrono",
--- a/generate/generate.py Sat Oct 24 16:52:21 2020 +0200 +++ b/generate/generate.py Sat Oct 24 17:27:32 2020 +0200 @@ -31,13 +31,16 @@ return name[0].upper() + name[1:] -def snake_case(name): +def rust_identifier(name): + def sanitize(s): + return s.replace('$', 'dollar').replace('#', 'hash').replace('.', '_') + def r(c): if not c.isupper(): return c return '_' + c.lower() - return ''.join([(r(c) if i > 0 else c.lower()) for i, c in enumerate(name)]) + return ''.join([(r(c) if i > 0 else c.lower()) for i, c in enumerate(sanitize(name))]) def global_params_name(api_name): @@ -87,10 +90,10 @@ cleaned_pn = replace_keywords(pn) if type(cleaned_pn) is tuple: jsonname = cleaned_pn[1] - cleaned_pn = snake_case(cleaned_pn[0]) + cleaned_pn = rust_identifier(cleaned_pn[0]) else: jsonname = pn - cleaned_pn = snake_case(cleaned_pn) + cleaned_pn = rust_identifier(cleaned_pn) struct['fields'].append({ 'name': cleaned_pn, @@ -195,7 +198,7 @@ req_query_parameters = [] opt_query_parameters = [] struct['fields'].append({ - 'name': snake_case(global_params), + 'name': rust_identifier(global_params), 'typ': optionalize(global_params, True), 'attr': '#[serde(flatten)]', 'comment': 'General attributes applying to any API call' @@ -205,7 +208,7 @@ for paramname, param in method['parameters'].items(): (typ, desc), substructs = parse_schema_types('', param, optional=False) field = { - 'name': snake_case(paramname), + 'name': rust_identifier(paramname), 'original_name': paramname, 'typ': optionalize(typ, not param.get('required', False)), 'comment': desc, @@ -229,10 +232,11 @@ def resolve_parameters(string, paramsname='params', suffix=''): """Returns a Rust syntax for formatting the given string with API parameters, and a list of (snake-case) API parameters that are used. """ - pat = re.compile('\{(\w+)\}') + pat = re.compile('\{\+?(\w+)\}') params = re.findall(pat, string) - snakeparams = [snake_case(p) for p in params] + snakeparams = [rust_identifier(p) for p in params] format_params = ','.join(['{}={}.{}{}'.format(p, paramsname, sp, suffix) for (p, sp) in zip(params, snakeparams)]) + string = string.replace('{+', '{') # Some required parameters are in the URL. This rust syntax formats the relative URL part appropriately. return 'format!("{}", {})'.format(string, format_params), snakeparams @@ -259,12 +263,12 @@ params_type_name = service + capitalize_first(methodname) + 'Params' # All parameters that are optional (as URL parameters) parameters = { - p: snake_case(p) + p: rust_identifier(p) for p, pp in method.get('parameters', {}).items() if ('required' not in pp and pp['location'] != 'path') } # All required parameters not represented in the path. required_parameters = { - p: snake_case(p) + p: rust_identifier(p) for p, pp in method.get('parameters', {}).items() if ('required' in pp and pp['location'] != 'path') } # Types of the function @@ -286,7 +290,7 @@ if is_download: assert out_type == '()' data_download = { - 'name': snake_case(methodname), + 'name': rust_identifier(methodname), 'param_type': params_type_name, 'in_type': in_type, 'out_type': out_type, @@ -301,7 +305,7 @@ 'snake_param': sp } for (p, sp) in required_parameters.items()], 'global_params_name': - snake_case(global_params_name(discdoc.get('name', ''))) if has_global_params else None, + rust_identifier(global_params_name(discdoc.get('name', ''))) if has_global_params else None, 'scopes': [{ 'scope': method.get('scopes', [''])[-1] }], @@ -313,7 +317,7 @@ method_fragments.append(chevron.render(DownloadMethodTmpl, data_download)) else: data_normal = { - 'name': snake_case(methodname), + 'name': rust_identifier(methodname), 'param_type': params_type_name, 'in_type': in_type, 'out_type': out_type, @@ -324,7 +328,7 @@ 'snake_param': sp } for (p, sp) in parameters.items()], 'global_params_name': - snake_case(global_params_name(discdoc.get('name', ''))) if has_global_params else None, + rust_identifier(global_params_name(discdoc.get('name', ''))) if has_global_params else None, 'required_params': [{ 'param': p, 'snake_param': sp @@ -342,14 +346,14 @@ # We generate an additional implementation with the option of uploading data. if is_upload: data_upload = { - 'name': snake_case(methodname), + 'name': rust_identifier(methodname), 'param_type': params_type_name, 'in_type': in_type, 'out_type': out_type, 'base_path': discdoc['rootUrl'], 'rel_path_expr': '"' + upload_path.lstrip('/') + '"', 'global_params_name': - snake_case(global_params_name(discdoc.get('name', ''))) if has_global_params else None, + rust_identifier(global_params_name(discdoc.get('name', ''))) if has_global_params else None, 'params': [{ 'param': p, 'snake_param': sp @@ -455,9 +459,10 @@ return [it for it in doc['items'] if (not apis or it['id'] in apis)] -def fetch_discovery_doc(api_doc): +def fetch_discovery_doc(api_doc=None, url=None): """Fetch discovery document for a given (short) API doc from the overall discovery document.""" - url = api_doc['discoveryRestUrl'] + if api_doc: + url = api_doc['discoveryRestUrl'] return json.loads(requests.get(url).text) @@ -467,13 +472,32 @@ default='https://www.googleapis.com/discovery/v1/apis', help='Base Discovery document.') p.add_argument('--only_apis', default='drive:v3', help='Only process APIs with these IDs (comma-separated)') + p.add_argument('--doc', default='', help='Directly process Discovery document from this URL') + p.add_argument('--list', default=False, help='List available APIs', action='store_true') + args = p.parse_args() + if args.only_apis: apilist = args.only_apis.split(',') else: apilist = [] + if args.list: + docs = fetch_discovery_base(args.discovery_base, []) + for doc in docs: + print('API:', doc['title'], 'ID:', doc['id']) + return + + if args.doc: + discdoc = fetch_discovery_doc(url=args.doc) + if 'error' in discdoc: + print('Error while fetching document for', doc['id'], ':', discdoc) + return + generate_all(discdoc) + return + docs = fetch_discovery_base(args.discovery_base, apilist) + for doc in docs: try: discdoc = fetch_discovery_doc(doc)
--- a/manual_demo/Cargo.lock Sat Oct 24 16:52:21 2020 +0200 +++ b/manual_demo/Cargo.lock Sat Oct 24 17:27:32 2020 +0200 @@ -13,18 +13,25 @@ checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" [[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] name = "async-google-apis-common" -version = "0.1.0" +version = "0.1.4" dependencies = [ "anyhow", "chrono", - "follow-redirects", - "hyper 0.13.8", + "hyper", "hyper-rustls", - "percent-encoding 2.1.0", + "log", + "percent-encoding", + "radix64", "serde", "serde_json", - "tokio 0.2.22", + "tokio", "yup-oauth2", ] @@ -36,16 +43,6 @@ [[package]] name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - -[[package]] -name = "base64" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" @@ -75,22 +72,6 @@ checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" [[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] name = "bytes" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -123,15 +104,6 @@ ] [[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] name = "core-foundation" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -148,54 +120,6 @@ checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" [[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if", - "lazy_static", -] - -[[package]] name = "ct-logs" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -211,24 +135,6 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "follow-redirects" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46cba3494deee922e0673bf0ed89b87239abc3ce114dc7cea04e1670a16a6dc9" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "http 0.1.21", - "hyper 0.11.27", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -246,12 +152,6 @@ [[package]] name = "futures" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" - -[[package]] -name = "futures" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8e3078b7b2a8a671cb7a3d17b4760e4181ea243227776ba83fd043b4ca034e" @@ -282,16 +182,6 @@ checksum = "d674eaa0056896d5ada519900dbf97ead2e46a7b6621e8160d79e2f2e1e2784b" [[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures 0.1.30", - "num_cpus", -] - -[[package]] name = "futures-executor" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -352,7 +242,7 @@ "pin-utils", "proc-macro-hack", "proc-macro-nested", - "slab 0.4.2", + "slab", ] [[package]] @@ -361,15 +251,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" dependencies = [ - "bytes 0.5.6", + "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.1", + "http", "indexmap", - "slab 0.4.2", - "tokio 0.2.22", + "slab", + "tokio", "tokio-util", "tracing", ] @@ -391,22 +281,11 @@ [[package]] name = "http" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" -dependencies = [ - "bytes 0.4.12", - "fnv", - "itoa", -] - -[[package]] -name = "http" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes 0.5.6", + "bytes", "fnv", "itoa", ] @@ -417,8 +296,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes 0.5.6", - "http 0.2.1", + "bytes", + "http", ] [[package]] @@ -435,53 +314,26 @@ [[package]] name = "hyper" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7" -dependencies = [ - "base64 0.9.3", - "bytes 0.4.12", - "futures 0.1.30", - "futures-cpupool", - "httparse", - "iovec", - "language-tags", - "log 0.4.11", - "mime", - "net2", - "percent-encoding 1.0.1", - "relay", - "time", - "tokio-core", - "tokio-io", - "tokio-proto", - "tokio-service", - "unicase", - "want 0.0.4", -] - -[[package]] -name = "hyper" version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" dependencies = [ - "bytes 0.5.6", + "bytes", "futures-channel", "futures-core", "futures-util", "h2", - "http 0.2.1", + "http", "http-body", "httparse", "httpdate", "itoa", "pin-project", "socket2", - "tokio 0.2.22", + "tokio", "tower-service", "tracing", - "want 0.3.0", + "want", ] [[package]] @@ -490,14 +342,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac965ea399ec3a25ac7d13b8affd4b8f39325cca00858ddf5eb29b79e6b14b08" dependencies = [ - "bytes 0.5.6", + "bytes", "ct-logs", "futures-util", - "hyper 0.13.8", - "log 0.4.11", + "hyper", + "log", "rustls", "rustls-native-certs", - "tokio 0.2.22", + "tokio", "tokio-rustls", "webpki", ] @@ -558,12 +410,6 @@ ] [[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" - -[[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -576,24 +422,6 @@ checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" [[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -dependencies = [ - "log 0.4.11", -] - -[[package]] name = "log" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -610,11 +438,11 @@ "async-google-apis-common", "base64 0.13.0", "chrono", - "hyper 0.13.8", + "hyper", "hyper-rustls", "serde", "serde_json", - "tokio 0.2.22", + "tokio", "yup-oauth2", ] @@ -625,33 +453,12 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] name = "memchr" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] name = "mio" version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -663,10 +470,10 @@ "iovec", "kernel32-sys", "libc", - "log 0.4.11", + "log", "miow 0.2.1", "net2", - "slab 0.4.2", + "slab", "winapi 0.2.8", ] @@ -676,7 +483,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" dependencies = [ - "log 0.4.11", + "log", "mio", "miow 0.3.5", "winapi 0.3.9", @@ -768,38 +575,6 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.9", -] - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - -[[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -868,50 +643,13 @@ ] [[package]] -name = "rand" -version = "0.3.23" +name = "radix64" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +checksum = "999718fa65c3be3a74f3f6dae5a98526ff436ea58a82a574f0de89eecd342bee" dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", + "arrayref", + "cfg-if", ] [[package]] @@ -921,15 +659,6 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] -name = "relay" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" -dependencies = [ - "futures 0.1.30", -] - -[[package]] name = "ring" version = "0.16.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -945,22 +674,13 @@ ] [[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] name = "rustls" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" dependencies = [ "base64 0.11.0", - "log 0.4.11", + "log", "ring", "sct", "webpki", @@ -985,12 +705,6 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - -[[package]] name = "schannel" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1001,18 +715,6 @@ ] [[package]] -name = "scoped-tls" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] name = "sct" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1052,21 +754,6 @@ ] [[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] name = "serde" version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1109,32 +796,11 @@ [[package]] name = "slab" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" - -[[package]] -name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] -name = "smallvec" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - -[[package]] name = "socket2" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1164,12 +830,6 @@ ] [[package]] -name = "take" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" - -[[package]] name = "time" version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1188,35 +848,11 @@ [[package]] name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "mio", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - -[[package]] -name = "tokio" version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" dependencies = [ - "bytes 0.5.6", + "bytes", "fnv", "futures-core", "iovec", @@ -1229,84 +865,12 @@ "num_cpus", "pin-project-lite", "signal-hook-registry", - "slab 0.4.2", + "slab", "tokio-macros", "winapi 0.3.9", ] [[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "tokio-io", -] - -[[package]] -name = "tokio-core" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "iovec", - "log 0.4.11", - "mio", - "scoped-tls", - "tokio 0.1.22", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-timer", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.30", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils", - "futures 0.1.30", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -dependencies = [ - "futures 0.1.30", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "log 0.4.11", -] - -[[package]] name = "tokio-macros" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1318,43 +882,6 @@ ] [[package]] -name = "tokio-proto" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" -dependencies = [ - "futures 0.1.30", - "log 0.3.9", - "net2", - "rand 0.3.23", - "slab 0.3.0", - "smallvec 0.2.1", - "take", - "tokio-core", - "tokio-io", - "tokio-service", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils", - "futures 0.1.30", - "lazy_static", - "log 0.4.11", - "mio", - "num_cpus", - "parking_lot", - "slab 0.4.2", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] name = "tokio-rustls" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1362,117 +889,22 @@ dependencies = [ "futures-core", "rustls", - "tokio 0.2.22", + "tokio", "webpki", ] [[package]] -name = "tokio-service" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" -dependencies = [ - "futures 0.1.30", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.30", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "futures 0.1.30", - "lazy_static", - "log 0.4.11", - "num_cpus", - "slab 0.4.2", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils", - "futures 0.1.30", - "slab 0.4.2", - "tokio-executor", -] - -[[package]] -name = "tokio-udp" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "log 0.4.11", - "mio", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-uds" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.30", - "iovec", - "libc", - "log 0.4.11", - "mio", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] name = "tokio-util" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes 0.5.6", + "bytes", "futures-core", "futures-sink", - "log 0.4.11", + "log", "pin-project-lite", - "tokio 0.2.22", + "tokio", ] [[package]] @@ -1488,7 +920,7 @@ checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" dependencies = [ "cfg-if", - "log 0.4.11", + "log", "pin-project-lite", "tracing-core", ] @@ -1504,26 +936,11 @@ [[package]] name = "try-lock" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" - -[[package]] -name = "try-lock" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] name = "unicode-bidi" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1561,24 +978,7 @@ dependencies = [ "idna", "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[package]] -name = "want" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" -dependencies = [ - "futures 0.1.30", - "log 0.4.11", - "try-lock 0.1.0", + "percent-encoding", ] [[package]] @@ -1587,8 +987,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" dependencies = [ - "log 0.4.11", - "try-lock 0.2.3", + "log", + "try-lock", ] [[package]] @@ -1615,7 +1015,7 @@ dependencies = [ "bumpalo", "lazy_static", - "log 0.4.11", + "log", "proc-macro2", "quote", "syn", @@ -1723,16 +1123,16 @@ dependencies = [ "base64 0.12.3", "chrono", - "futures 0.3.6", - "http 0.2.1", - "hyper 0.13.8", + "futures", + "http", + "hyper", "hyper-rustls", - "log 0.4.11", - "percent-encoding 2.1.0", + "log", + "percent-encoding", "rustls", "seahash", "serde", "serde_json", - "tokio 0.2.22", + "tokio", "url", ]
--- a/manual_demo/src/main.rs Sat Oct 24 16:52:21 2020 +0200 +++ b/manual_demo/src/main.rs Sat Oct 24 17:27:32 2020 +0200 @@ -1,6 +1,7 @@ // A manual client for a Google API (e.g. Drive), to test what makes sense and what doesn't. mod drive_v3_types; +mod photoslibrary_v1_types; use drive_v3_types as drive; @@ -86,22 +87,14 @@ let data = hyper::body::Bytes::from(fs::read(&f).unwrap()); let mut params = drive::FilesCreateParams::default(); params.include_permissions_for_view = Some("published".to_string()); + let mut file = drive::File::default(); + file.name = Some("profilepic.jpg".to_string()); - let resp = cl.create_upload(¶ms, data).await.unwrap(); + let resp = cl.create_upload(¶ms, &file, data).await.unwrap(); println!("{:?}", resp); let file_id = resp.id.unwrap(); - - let mut params = drive::FilesUpdateParams::default(); - println!("{:?}", params); - params.file_id = file_id.clone(); - params.include_permissions_for_view = Some("published".to_string()); - let mut file = drive::File::default(); - file.name = Some("profilepic.jpg".to_string()); - let update_resp = cl.update(¶ms, &file).await; - println!("{:?}", update_resp); - let mut params = drive::FilesGetParams::default(); params.file_id = file_id.clone(); println!("{:?}", cl.get(¶ms).await.unwrap());