• Stars
    star
    1,011
  • Rank 45,471 (Top 0.9 %)
  • Language
    Rust
  • License
    Other
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A binding and CLI generator for all Google APIs

This repository holds mako scripts to generate all Google APIs as described by the google discovery service.

The generate source code of each google API can be found in the gen subdirectory. Each google API resides in it's own crate which can be used as any other crate.

To find a library of your interest, you might want to proceed looking at the API documentation index.

Maintenance Mode

These crates are considered done and only minimal time will be invested to keep them relevant. This includes the following tasks:

  • reply to issues, triage them
  • provide support for PRs
  • occasional updates of all crates to update them with the latest API definitions, probably no more than twice a year
  • dependency updates to avoid security issues and keep the crates usable in modern projects

New features will not be implemented but PRs are welcome. Please feel free to start a discussion to talk about desired features.

Please be aware of the alternative implementation of these crates, which may be better suited for you.

Project Features

  • provide an idiomatic rust implementation for google APIs
  • first-class documentation with cross-links and complete code-examples
  • support all features, including downloads and resumable uploads
  • safety and resilience are built-in, allowing you to create highly available tools on top of it. For example, you can trigger retries for all operations that may temporarily fail, e.g. due to network outage.

Build Instructions

Prerequisites

To generate the APIs yourself, you will need to meet the following prerequisites:

  • make
  • Make is used to automate and efficiently call all involved programs
  • python
  • As mako is a python program, you will need python installed on your system to run it. Some other programs we call depend on python being present as well. Note that you need python 3.8, as 3.9+ introduced some breaking changes that breaks the dependencies.
  • an internet connection and wget
  • Make will download all other prerequisites automatically into hidden directories within this repository, which requires it to make some downloads via wget.
  • Rust Stable
  • This project compiles on stable Rust 1.6 or greater only. You might consider using Rustup to control the toolchain on a per-project basis.

Using Make

The makefile is written to be self-documenting. Just calling make will yield a list of all valid targets.

➜  google-apis-rs git:(main) make
using template engine: '.pyenv/bin/python etc/bin/mako-render'

Targets
help-api       -   show all api targets to build individually
help-cli       -   show all cli targets to build individually
docs-all       -   cargo-doc on all APIs and associates, assemble them together and generate index
docs-all-clean -   remove the entire set of generated documentation
github-pages   -   invoke ghp-import on all documentation
regen-apis     -   clear out all generated apis, and regenerate them
license        -   regenerate the main license file
update-json    -   rediscover API schema json files and update api-list.yaml with latest versions
deps           -   generate a file to tell how to build libraries and programs
help           -   print this help
make: Nothing to be done for `help'.

You can easily build the documentation index using make docs-all and individual API documentation using make <api-name>-doc. Run doctests on all apis with make cargo-api ARGS=test or on individual ones using make <api-name>-cargo ARGS=test. To see which API targets exist, run make help-api.

The same goes for commandline programs, just ust -cli instead of -api, and have a look at help-cli for individual targets.

Make and parallel job execution

In theory, you can run make with -j4 to process 4 jobs in parallel. However, please note that cargo may be run for some jobs and do a full build, which could cause it to fail as it will be updating it's index. The latter isn't working for multiple cargo processes at once as the index is a shared resource.

Nonetheless, once you have built all dependencies for all APIs once, you can safely run cargo in parallel, as it will not update it's index again.

In other words: The first time, you run make docs and make cargo ARGS=test, you shouldn't run things in parallel. The second time, you are free to parallelize at will.

Adding new APIs and updating API schemas

The list of available APIs to generate is based on a query of the Google discovery API, and then baked into a make-compatible dependency file. That will represents a cache, and the only way to enforce a full update is to delete it and run make again.

For example, to update all json files and possibly retrieve new API schemas, do as follows:

# -j8 will allow 8 parallel schema downloads
rm -f .api.deps .cli.deps && FETCH_APIS=1 make update-json -j8

Now run make cargo-api ARGS=check and each time that fails, add it to the list of forbidden APIs along with a note as to why it fails, regenerate all APIs with the make invocation above. When done and all APIs pass cargo check, commit changes in the shared.yml file.

Setup API and CLI version numbers

The version numbers for the respective program types are setup in etc/api/type-*.yaml where * resolves to the supported program types, being cli and api at the time of writing. You can change the version for all expected artifacts by editing the respective key inside of the yaml (cargo.build_version at the time of writing).

The following script would regenerate all higher-level programs (CLI), add the result to git and push it.

$ make gen-all-cli
# Use the version you are comfortable with in the changelog - sometimes you only want to
# update one program type. Here we go with a multi-version, containing all version strings
# in one heading. It's just for the visuals, after all.
$ clog --setversion=api-v<api-version>
$ git add .
$ git commit -m "chore(versionup): added code for latest version"
$ git tag api-v<api-version> cli-v<cli-version> && git push --tags origin master

Publish API to Cargo

Before anything else happens, be sure we publish the latest APIs to cargo.

# We want as many publishes to work as possible ... -k keeps going on error.
# sometimes uploads fail spuriously, and just need to be retried.
$ make publish-api publish-cli -k
# another attempt to do this should not do actual work
$ make publish-api publish-cli
# all clear ? Please proceed ... .

The previous call will have created plenty of marker files, which need to be committed to the repository to prevent to attempt multiple publishes of the same version.

git add .
git commit -m "chore(cargo): publish latest version to crates.io"
git push origin main

Build Documentation and post it onto GitHub

The last step will update the documentation index to point to the latest program versions. For now we assume hosting on GitHub-Pages, but the compiled documentation directory can be hosted statically anywhere if required.

# This will run rust-doc on all APIs, generate the index html file and run gh-import at the end.
# The latter might require user-input in case no credentials are setup.
$ make github-pages

License

The license of everything not explicitly under a different license are licensed as specified in LICENSE.md.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Archive of Development Videos

Rust Stackshare.io

All work done on the project is based on github issues, not only to track progress and show what's going on, but to have a place to link screen-recordings to. Milestones are used to provide a bigger picture.

Additionally, there is a development diary which serves as summary of major steps taken so far. As opposed to issue-screencasts, it is not made live, but is authored and narrated, which should make it more accessible.

Click the image below to see the playlist with all project related content:

thumb

Super-Entertaining Videos

Each episode sums up one major step in project development:

More Repositories

1

gitoxide

An idiomatic, lean, fast & safe pure Rust implementation of Git
Rust
7,202
star
2

dua-cli

View disk space usage and delete unwanted data, fast.
Rust
2,803
star
3

prodash

report progress of concurrent applications and display it in various ways
Rust
255
star
4

open-rs

Open a path or URL with the system-defined program
Rust
234
star
5

jwalk

Filesystem walk performed in parallel with streamed and sorted results
Rust
209
star
6

trash-rs

A Rust library for moving files to the Recycle Bin
Rust
168
star
7

crates-io-cli

Interact with crates.io from the command-line
Rust
93
star
8

treediff-rs

Extract differences between arbitrary datastructures
Rust
69
star
9

github-star-counter

A tool to query direct (and indirect) stars of a GitHub user or organization
Rust
59
star
10

termbook

A runner for `mdbooks` to keep your documentation tested.
Rust
46
star
11

pulldown-cmark-to-cmark

Convert pulldown-cmark Events back to the string they were parsed from
Rust
38
star
12

cargo-smart-release

Release complex cargo-workspaces automatically with changelog generation, used by `gitoxide`
Rust
37
star
13

learning-rust-with-gitoxide

Our sessions when learning Rust with gitoxide
Rust
36
star
14

yup-hyper-mock

`hyper-mock` is a utility library to help hyper clients with their testing
Rust
29
star
15

benchmarksgame-cvs-mirror

A git mirror of the benchmarksgame cvs repository
Java
17
star
16

bsuite

Provide a plugin with tools to handle ptex files
C++
16
star
17

json-tools

A zero-copy json-lexer, filters and serializer.
Rust
15
star
18

rust-tracer

A pet raytracer to see how fast rust can go
Rust
15
star
19

crates-index-diff-rs

Learn what's changed on crates.io
Rust
14
star
20

fs-utils-rs

Utilities to help working with the filesytem
Rust
12
star
21

godi

Tool to verify data integrity with maximised performance
Go
9
star
22

bcore

powerful application framework built to integrate, not separate
Python
8
star
23

tui-crates

Various crates related to handling terminal user interfaces
Rust
7
star
24

catchit-rs

A simple and fun game made with Piston and Rust
Rust
7
star
25

anon-csv-cli

A command-line utility for anonymising CSV files
Rust
6
star
26

therror

`thiserror` + killer-feature
Rust
6
star
27

cli-template-rs

A template for command-line applications in Rust - just clone to get started
Shell
5
star
28

dotfiles

My configuration files, with auto-setup for quick account initialization
Shell
4
star
29

git-count

A simple program to count objects in git repositories - for trying the `git2` library
Rust
4
star
30

BPT

*unmaintained repository * - see BSuite
C++
3
star
31

pgit

Git Command-Line Tools in Python
Python
3
star
32

git-reconstruct

A Rust tool to reconstruct git history from tarball dumps. This is especially useful when a device vendor bases its code on an unknown commit of the git of a system on a chip vendor.
Rust
3
star
33

merchants-guide

An implementation of the merchants guide coding challenge in Rust the way I would love to see it
Rust
2
star
34

rust-hack-and-learn

A web-app for managing Katas for Rust
JavaScript
2
star
35

gitplusplus

Rewrite git using c++11 facilities
C++
2
star
36

bit

A collection of frameworks most useful to running IT infrastructure
Python
2
star
37

shallow-source

for observing shallow protocol interactions with a remote
2
star
38

kattis-autori

https://open.kattis.com/problems/autori
Shell
1
star
39

kattis-sibice

https://open.kattis.com/problems/sibice
Shell
1
star
40

javascript_the-good-parts

Repository with the book's examples, in comparison with Rust
JavaScript
1
star
41

bshotgun

Write better shotgun tools, faster
Python
1
star
42

kattis-aaah

Shell
1
star
43

reproduce-rayon-hang

minimal sample to reproduce a hang caused by jwalk running within par_iter()
Rust
1
star
44

npm-tools-rs

A Rust library to help dealing with NPM modules
Rust
1
star
45

kattis-scaling-recipes

https://open.kattis.com/problems/recipes
Rust
1
star
46

kattis-aliencodebreaker

https://open.kattis.com/problems/aliencodebreaking
Rust
1
star
47

kattis-tarifa

https://open.kattis.com/problems/tarifa
Shell
1
star
48

failure-tools

Various tools to be used in conjunction with the 'failure' crate.
Rust
1
star
49

and-rs

Porcelain for your Android-SDK tool suite
Rust
1
star
50

bbuild

A cmake based multi-platform build system with bcore integration
Python
1
star
51

kattis-pig-latin

https://open.kattis.com/problems/piglatin
Shell
1
star
52

kattis-filip

https://open.kattis.com/problems/filip
Shell
1
star
53

kattis-cli-template-rs

A template for quickly getting started on kattis samples
Shell
1
star
54

gogit

If I ever wanted to learn go programming, I would implement the git-core. Probably this is never going to happen.
Go
1
star
55

hotel-reservations

An implementation of the hotel reservations coding challenge in Rust the way I would love to see it
Rust
1
star
56

kattis-recount

https://open.kattis.com/problems/recount
Shell
1
star
57

git-commits-by-blob

An alternative backend for https://github.com/ali1234/gitxref
Rust
1
star
58

byron

1
star
59

atom-byrons-edittools

Comforts you with smart tools aiding your editing workflow in Atom
CoffeeScript
1
star
60

kattis-shattered-cake

https://open.kattis.com/problems/shatteredcake
Shell
1
star
61

mars-rover

An implementation of the mars rover coding challenge in Rust the way I would love to see it
Rust
1
star
62

kattis-quadrant

https://open.kattis.com/problems/quadrant
Shell
1
star