Commit Graph

95 Commits

Author SHA1 Message Date
Sebastian Thiel
894b5b5ec7 feat(CLI): adjust to serde usage in yup-oauth
* More detailed error type for JsonTokenStorage
* removed all traces of rustc_serialize
* use pretty-printers everywhere to allow writing human-readable json
  files for secretes and for tokens

Fixes #93
2015-04-30 15:20:56 +02:00
Sebastian Thiel
4115d50ca7 fix(API): adjust to latest hyper header macros 2015-04-30 11:15:48 +02:00
Sebastian Thiel
d0ce221ba3 fix(clap):re-introduce UploadProtocol,fix CallType
* CallType now represents either Upload or Standard calls, whereas
  the Upload variant is represented by the UploadProtocol enum.
  That way it's clear what happens, and we don't mix orthogonal concepts
  in one enumeration just for convenience.

All tested APIs seem to build, verified

* upload
* download
* request structures
* parameters
* scopes
* config-dir
* debug[-auth]

Fixes #81
2015-04-30 10:20:02 +02:00
Sebastian Thiel
b039b38244 fix(clap): update docs and fix calltype handling
* mkdoc docs grammar is now hierarchical, making the command structure
  more obvious and easier to understand. It's a nice addition to the
  auto-generated, hierachical usage of clap.
* UploadProtocol enum is now CallType, to ease handling the different
  ways the Call has to be executed. It looks quite clean, even though
  combining upload protocols and the calltype is a bit hacky.
2015-04-30 10:05:55 +02:00
Sebastian Thiel
7a38f7e4d5 fix(clap): various fixes and improvements
* `--version` now includes the API revision we embody
  (using crate_version())
* Allow multiple scopes to be specified, instead of just one. Previously
  this was problemantic due to argument parsing of docopt being greedy.
  However, this also means we have to specify the `-r` flag for each
  invocation. See https://github.com/kbknapp/clap-rs/issues/89 .
* Adapted to new signature of `Arg::possible_values()` and used the
  previously orphaned `UploadProtocol` enum.
* Deduplicated code a little by adding the new `opt_values()` generator
  function.

 Related to #81
2015-04-30 09:03:11 +02:00
Sebastian Thiel
63e23dd48f fix(clap): print usage if command is missing
Also, fixed config-dir substitution in flag's help message
2015-04-29 22:08:47 +02:00
Sebastian Thiel
bac4e1a82f fix(clap): adjust option usage to changed API
Discovery API now builds and seems to work even ! More testing
will have to be done though to be sure.

Related #81
2015-04-29 21:04:50 +02:00
Sebastian Thiel
1aff3135d9 fix(clap): commit before un-using UploadProtocol
We will try to wait for https://github.com/kbknapp/clap-rs/issues/87
to allow us to use the enumeration instead of strings, as well as
an iterator, which will look more idiomatic in the end.
2015-04-29 17:16:50 +02:00
Sebastian Thiel
db4624b467 feat(clap): parse structure and build App
We are currently setting everything up at runtime, and manage to get
nearly all information into it, except for the more complex
`-u (simple|resumable) <file> <mime>` flag.

Fixes #87
Related to #81
2015-04-29 16:49:02 +02:00
Sebastian Thiel
8ac8d3b1cb fix(clap): generate command data structure
We do this in the hopes to circumvent a stack overflow.
This means we will setup the parser entirely at runtime, which actually
saves a little bit of code.
2015-04-29 10:56:10 +02:00
Sebastian Thiel
b6a48bdcd5 fix(CLI): request value cursor handling and docs
* now the cursor will only be set permanently if the -r flag is used in
  'cursor' mode. In 'cursor=value' mode, the cursor change doesn't
  persist among the flags. That way, one can easily distinguish
  between setting the cursor, and setting a field. However,
  '...sublevel.level=value' will still work as it did previously, yet
  the cursor change will not persist.
* Documentation was adjusted to represent the new cursor style.

Fixes #86
2015-04-26 07:58:59 +02:00
Sebastian Thiel
2f3b2d24ce fix(CLI): simple and resumable upload works
* fixed boundary syntax of multi-part message. Was --BOUNDARY, now is
  --BOUNDARY--
* Fixed ContentRange parsing and serialization. We actually managed
  to break it last time we tried to update it to match the Go
  implementation.
* fixed uploadType header parameter. It's based on chosen protocol and
  whether or not the method supports multipart operation for the given
  protocol.

Related to #76
2015-04-25 18:45:37 +02:00
Sebastian Thiel
a328942033 feat(API): improved error handling
We are now able to decode detailed errors and pass them on. This allows
the CLI to provide more useful error responses.
Additionally, the CLI will only print debug responses in --debug mode.

Fixes #82
2015-04-25 09:49:57 +02:00
Sebastian Thiel
e42f6fbedb feat(CLI): per-API-credentials with default
That way, we can provide better service, as CLIs that consume a lot of
quota can easily have their own app credentials, and with it, their
own quota.

The fallback will be a project that allows to use all possible
google APIs.

The user can always put in his own application secret to use his own
quota or even paid services.

Fixes #80
2015-04-24 10:52:43 +02:00
Sebastian Thiel
6d84ef906e fix(token-storage): implement deletion of tokens
Previously this case was entirely uncovered.
Interesting note: when a token is revoked, existing auth-tokens will
still work. However, you may not refresh them in case permissions
have been revoked. It's good as there is only one code-path to deal
with (and we verified it to be working), and bad for the user as
malicious software can keep using an account for certain time until
the token expires.

Fixes #79
2015-04-24 09:37:48 +02:00
Sebastian Thiel
e523ddb6ec fix(API): adapt to changed yup-oauth2 API
The latter changed a lot, to the better, and we handle the new
return types accordingly.

Related to #74
2015-04-23 17:07:28 +02:00
Sebastian Thiel
b830c1c6de feat(CLI): hashmap handling
* with native support for type conversion and error handling
* improved hash-map key-value parsing to at least state that it knows
  it's dealing with a hashmap. Error text is still not what it should
  be because we don't know at runtime (initially) what type we handle.

Fixes #68
Related to #77
2015-04-22 11:09:50 +02:00
Sebastian Thiel
15b78cd1ff feat(CLI): struct value parsing
This works already for simple request values, but doens't generate
compiling code for structures with Parts in them.
Nonetheless, it's a big step towards finishing the overall issue.

Related to #64
2015-04-16 17:44:30 +02:00
Sebastian Thiel
1dd1fcf4b8 feat(CLI): field cursor complete and untested
Tests just need to be run, and of course, the impementation might need
fixing.

Related to #64
2015-04-16 15:25:44 +02:00
Sebastian Thiel
c9c3ad011f test(cursor): initial test
Implementation has to follow next
2015-04-16 14:25:45 +02:00
Sebastian Thiel
4b87d909f2 fix(CLI): NULL default values instead of randoms
Instead of generating nonesense random values, we just map defaults
that represent the respective NULL value of a given type.
2015-04-15 18:29:21 +02:00
Sebastian Thiel
9eed4056e5 feat(CLI): upload flag parsing
We handle errors gracefully with costum types and minimal amount of
code. Unfortunately, Mime type parsing is very 'flexible', allowing
nonesense types to be passed easily.

Related to #62
2015-04-15 17:23:01 +02:00
Sebastian Thiel
830529c40b fix(CLI): optional parameter default handling
Now we provide a matching default for each paramter, thus alleviating
the previous issue of unncecessary follow-up errors.
2015-04-15 11:27:48 +02:00
Sebastian Thiel
6ae6ee88a0 feat(CLI): parse method parameters and set them
It's implemented in a working fashion, except that the default value
is not currently set to something sensible, causing duplicate errors in
case the key-value syntax is wrong.

Related to #61
2015-04-15 11:02:23 +02:00
Sebastian Thiel
fa011315c3 fix(test): add rustc_serialize to test-crate
A top-level `cargo test` didn't work anymore thanks to a missing
mention of rustc_serialize.

[skip ci]
2015-04-15 09:04:16 +02:00
Sebastian Thiel
3f49f50ac2 feat(CLI):handle output json encoding and ostreams
* support for encoding response schemas to json
* support for simple downloads (without alt=media)

Fixes #63
2015-04-14 21:57:58 +02:00
Sebastian Thiel
c3a9f1e8e5 feat(CLI): interpret output arguments
For now we don't properly handle errors when opening files, but the
code is there.
Will panic in next commit.

Related to #63
2015-04-14 21:18:57 +02:00
Sebastian Thiel
76841da098 fix(CLI): optimze argument handling and conversion
* Thanks to a generic function, we save a lot of code within main.rs
* more effcient signature for ParseError

Fixes #65
2015-04-14 20:17:30 +02:00
Sebastian Thiel
e34e24e049 feat(CLI):required arg parsing + first doit() call
We are parsing required scalar values and handle parse-errors correctly,
to the point were we make a simple, non-upload doit() call.

It shows that we seem to build invalid calls, for now,but that's nothing
we can't fix once the time is ripe.

Next goals will be related to finalizing the argument parsing code.

Fixes #60
2015-04-14 17:17:21 +02:00
Sebastian Thiel
8afc76a7fe feat(CLI): Implementation of JsonTokenStorage
It's also used by the code, replacing the previous standing,
MemoryStorage.

Fixes #58
2015-04-14 15:13:37 +02:00
Sebastian Thiel
f71c286285 feat(CLI): init hub + refactor for dry-run mode
The hub is just using preset types - we will have to implement our own
storage and auth-delegate, as well as a Hub delegate at some point.

Dry run mode allows us to check for errors and use a call builder
using the very same code.

Fixes #57
2015-04-14 11:54:46 +02:00
Sebastian Thiel
7dc9972445 feat(API): Display + Error traits for Error struct
* improved documentation about error handling, it's less verbose yet
  explains what you can do.

Fixes #56
2015-04-14 10:28:59 +02:00
Sebastian Thiel
be228f1994 feat(CLI): engine checks resource and method args
We are now at a spot where we can actually start parsing arguments.

* ArgumentError -> ClIError - seems more fitting

Fixes #55
2015-04-14 09:41:55 +02:00
Sebastian Thiel
e45eb053d5 fix(CLI): Display for Errors + refactor
* refactored errors into a hierarchy
* implemented `Display` trait for all error types, including some
  'hierarchy-aware' printing.

Fixes #54
2015-04-14 08:34:53 +02:00
Sebastian Thiel
4548644cb1 feat(CLI):write default and read app-secret
* if there is no secret file in json format, we write a default one
  that we will then read in a second iteration of the loop.
  That way, the user has an example of how such a file must look like.

Next step is to cleanup the error type and implement the Error trait.

Fixes #53
2015-04-13 21:21:05 +02:00
Sebastian Thiel
5799d44fce feat(config): create config directory, if possible
* Only supports one level of directory
* full error handling, and uses memory efficiently
2015-04-13 18:45:29 +02:00
Sebastian Thiel
ca8e8c0622 feat(engine): infrastructure
* allow usage of cmn.rs for common types (like Error types)
* instantiate an engine and handle errors, in an initial quick and dirty
  way.

 Fixes #52
2015-04-13 17:08:50 +02:00
Sebastian Thiel
b9a469c0a4 fix(cmn): use bytes=... when sending as well
Previously, `bytes=` was just parsed, but not sent to the server.
This change is motivated by a similar change in this commit:
http://goo.gl/AvyvLb
2015-04-11 09:31:23 +02:00
Sebastian Thiel
191e822c5a fix(hyper-client): adjust to hyper client
* deal with hyper client not using a type-parameter anymore
* fix incorrect documentation link (use '_' instead of '-')

Fixes #47
2015-04-08 16:51:46 +02:00
Sebastian Thiel
dd1d191966 fix(publish): v0.1.4
* macro 'alias' was renamed to 'rename'
* fixed `cargo test` on main project

The latter pointed me to the serde issue, which would have made
everything fail when actually used to communicate with google servers.
2015-04-07 15:53:30 +02:00
Sebastian Thiel
91861dcb71 fix(rustup): rustc (be9bd7c93 2015-04-05)
* using std::convert
* update to latest hyper (and other dependencies)

Related to #46
2015-04-07 11:59:10 +02:00
Sebastian Thiel
cefd606b53 feat(make): cli depends on API, generically
This allows us to build efficiently. CLI programs can now have their
own cmn.rs implementation, which we can test standalone with
`cargo test`.

The primary makefile currently just explicitly pulls in the type-*.yaml,
one day we could possibly put it into a loop.

Fixes #11
2015-03-24 12:56:24 +01:00
Sebastian Thiel
e5b013e97c fix(result): remove custom Result Enum
Instead, we just use a customized `Result` tyoe and thus stick to
common Rust conventions.

Fixes #39
2015-03-23 14:57:31 +01:00
Sebastian Thiel
ea161897f5 fix(docs): typo fixes and misc. improvements
Fixes #42
2015-03-23 11:19:57 +01:00
Sebastian Thiel
6ad0c2ef79 fix(misc): whitespace and trait rename
* `ResourceMethodsBuilder` -> `MethodsBuilder`. This is now precise
   enough. Previously it was just to similar to what's now a
   `CallBuilder`
* Fixed whitespace issue in `doit()`
2015-03-23 08:49:27 +01:00
Sebastian Thiel
04f4c95688 fix(mbuild): upload size now taken properly
Previously, it would query the size from the wrong dict and obtain
the value 0 all the time. This would have made every upload fail with
`UploadSizeLimitExeeded`.
Now we obtain the actual size limit, and will ignore it if unset/0
for some reason.

Patch += 1
2015-03-22 22:39:36 +01:00
Sebastian Thiel
cd1ff18ba9 fix(cmn): upload() return value handling
Now deals with Cancellation and non-OK status codes correctly.

Fixes #18
2015-03-22 20:21:21 +01:00
Sebastian Thiel
29ee94b4c0 feat(cmn): Resumable upload implemented
With all bells and whisles. For now, we don't have a good return value
to indicate that the operation was cancelled, which needs fixing.
2015-03-22 19:56:35 +01:00
Sebastian Thiel
065753cc3a feat(cmn): implement query_transfer_status()
The delegate logic is implemented and seems sound.
It's somewhat funny that after all this back and forth, all we get
is a valid start position for the upload.
2015-03-22 17:58:34 +01:00
Sebastian Thiel
42a76e4655 feat(cmn): ContentRange header (parse and format)
Now we are able to send the transfer-update requests and implement the
actual chunk logic.
2015-03-22 16:24:39 +01:00