Commit Graph

82 Commits

Author SHA1 Message Date
Sebastian Thiel
cfb8faefb8 fix(json): Vec/HashMap are Optionals
That assures that we can decode partial server responses, and send
partial structures as well.
2015-03-20 14:47:26 +01:00
Sebastian Thiel
d3bb130be0 feat(lib): use serge instead of serialize
However, for some reason, the `Serialize/Deserialize` macros don't work
for me, even though they work just fine in the respective tests of
the serge crate. What am I possibly doing wrong ?
2015-03-20 11:28:09 +01:00
Sebastian Thiel
265b448297 feat(doit): simplify delegate calls
Now we use the DefaultDelegate as standin in case there is user-delgate.
That way, we save plenty of complexity as no additional
`if let Some(ref mut dlg) = delegate` is necesary.

Fixes #30
2015-03-19 19:26:19 +01:00
Sebastian Thiel
3a15430339 feat(types): prevent duplicate schema types
These could clash with types we import from Cmn. When that happens,
just a single list must be adjusted for a fix, see
`unique_type_name`

Fixes #26
2015-03-19 19:09:53 +01:00
Sebastian Thiel
508d14eafb feat(delegate): begin()/finished() calls
During `begin()`, the delegate receives additional information about the
current call, which can be useful for performance tracking, among
other things.

Fixes #25
2015-03-19 15:30:39 +01:00
Sebastian Thiel
aadf37004e docs(methods):deal with 'virtual' methods resource
We assure to know about it, instead of writing nonsense about that
'methods' resources which does not actually exist.

I am relatively sure to have found all the spots.

Fixes #22
2015-03-19 11:56:18 +01:00
Sebastian Thiel
2f293f5e1b docs(ul/dl): method features and general info
* add method listing for various categories, like 'downloads' and
  'uploads'
* add general information on how to do downloads and uploads using
  various protocols

Fixes #28
2015-03-19 11:00:59 +01:00
Sebastian Thiel
02d7a06fdf feat(downloads): alt 'media' handling to allow dls
This also includes documentation to state which methods actually support
media download, and how to achieve that.

Added TODO to not forget we should tell the user how to achieve these
kinds of things.

Fixes #21
2015-03-19 09:31:29 +01:00
Sebastian Thiel
cb5a0a35bc feat(hub): allow to set user-agent
Fixes #24
2015-03-19 07:54:15 +01:00
Sebastian Thiel
9d401f5486 feat(doit): optimizations and simplification; seek
* MultiPartReader is using match to handle state, reducing unnecessary
  calls to 0 in that regard.
* Fixed seek() calls on readers, assuring they are reset to start each
  time the loop is done.
* both media-parameters now use `ReadSeek` streams.
* Use `seek()` to figure out size, simplifying the interface.

Closes #17
2015-03-19 07:30:43 +01:00
Sebastian Thiel
224af64068 feat(doit):optimized memory allocation and options
* reserve_exact(X) where possible (params, multi-part-reader)
* `if let` used whereever possible to prevent duplicate checks

This increases the possible performance, and makes for more readable,
concise code.
2015-03-18 22:03:52 +01:00
Sebastian Thiel
71c827b306 feat(doit): initial part writing
We are a state-machine, and handle parts of it correctly.
However, we don't yet write the boundary at all, and could improve
our use of match.
2015-03-18 17:53:39 +01:00
Sebastian Thiel
fc589cb965 feat(doit): multi-part mime-type and add_parts()
Next we will implement the actual Read method
2015-03-18 16:15:51 +01:00
Sebastian Thiel
3ea5e19485 feat(doit): handle 'alt' param
It's conditionally set to json, if we expect a response value.

Fixes #20
2015-03-18 15:41:23 +01:00
Sebastian Thiel
29d9e45c9f fix(doit): fix lifetime issues
Those were totally real, actually, and I am happy the borrow checker
exists !

Only one weirdness happened with RefCell<BorrowMut<C>>, but it could be
fixed by checking actual types using `let foo: () = something_nasty()`.
2015-03-18 15:05:01 +01:00
Sebastian Thiel
b0a1f518e9 feat(doit): more multipart infrastructure
* outer frame of `MultiPartReader` to allow using it in `doit()`
* restructured `doit()` to get content-types right

There is more work to do, as it currently doesn't compile, nor
do we deal with our streams correctly.

But we are on a good way.
2015-03-18 12:40:18 +01:00
Sebastian Thiel
7cfb5afd39 feat(doit): improve body infrastructure
This will support choosing custom readers at runtime, depending on
whether we have a resumable or simple media upload.
2015-03-18 08:50:22 +01:00
Sebastian Thiel
76827ff665 refactor(mbuild+lib): remove map!, better dlg call
* map! wasn't used.
* improved delegate calls, using `match` or `delegate.is_some()` to
  get the nicest looking, shortest-possible code
2015-03-17 21:56:34 +01:00
Sebastian Thiel
b90a191688 fix(doit): repeated params string addition
It seems odd that String + &str is required.
In any way, previously it would try to add i32 to a string.
2015-03-17 19:59:04 +01:00
Sebastian Thiel
d2bf24ca85 feat(doit): simplify URL_ENCODE handling
More maintainable template code, with less redundancy.
2015-03-17 19:21:12 +01:00
Sebastian Thiel
1fee21de24 feat(doit): uri-template handling complete
We now handle url-encoding for the parameters that would require it,
and can deal with repeated params that will match '/param*'.
2015-03-17 19:12:44 +01:00
Sebastian Thiel
54eb784a55 feat(doit): uri-template generation works
This doesn't mean it's correctly implemented, but we are on our way.
It does compile, at least
2015-03-17 18:27:25 +01:00
Sebastian Thiel
863a98c0d7 fix(docs): repeated parameters docs improvement
Previously, it said it would 'set' the property, which is not the case
after all.
2015-03-17 17:34:33 +01:00
Sebastian Thiel
64219e7e7e feat(doit): repeated types in examples
Made sure usage examples know how to use repeated types.
2015-03-17 17:28:03 +01:00
Sebastian Thiel
d758f410f6 feat(doit): repeatable parameters working
The code dealing with them currently assumes they are "/" separated.
2015-03-17 17:16:27 +01:00
Sebastian Thiel
354370705d feat(doit): partial implementation of url expr
URL expressions allow to substitute values within the URL with
parameters. However, this is not only a simple key-value replacement,
but supports expressions that need a parser.

This one will have to be implemented next.
2015-03-17 11:41:51 +01:00
Sebastian Thiel
33e85ddd29 feat(doit): set upload media type
Related to #17
2015-03-17 10:39:11 +01:00
Sebastian Thiel
91f69ffd6e fix(test): unit-tests work once again
Added missing Result cases to make match exhaustive
2015-03-17 09:30:20 +01:00
Sebastian Thiel
60adacf8d4 feat(doit): pre-request delegate call.
This one is likely to change the further we advance in the upload-media
implementation.
2015-03-17 09:21:18 +01:00
Sebastian Thiel
eef1471357 feat(doit): json decode and delegation
Now json errors are handled and delegated with the option to retry,
and all other values are just decoded according to plan.

For now, I brutally unwrap json values assuming this will work, because
it really should work.
2015-03-16 17:14:04 +01:00
Sebastian Thiel
2c79f6e3cf feat(doit): authentication with and without scopes
It's quite rough around the edges, but has a slight chance to work.
Will still to handle return values accordingly.
2015-03-16 15:23:38 +01:00
Sebastian Thiel
1349c786b7 fix(doit): remove BorrowMut until it's cleared
See stackoverflow at http://goo.gl/f27zJkj.

Now we can actually call out client and move on with handling the result
2015-03-16 11:51:12 +01:00
Sebastian Thiel
9a58b0badd feat(doit): attempt to send json-encoded request
This doesn't work yet, as I am unable to unwrap the client properly.
It's a refcell that contains a BorrowMut to a hyper::Client, and
lets just, it's complicated.
2015-03-16 10:35:26 +01:00
Sebastian Thiel
8006bb8ca9 fix(activities): fully qualified activity names
Fixes #7
2015-03-14 11:23:01 +01:00
Sebastian Thiel
4cf365d026 docs(todos): result handling and remaining todos
Basically there is no todo left, which puts us in a good position for
implementing more features, and get some feedback in the meanwhile.
2015-03-13 15:01:32 +01:00
Sebastian Thiel
9a17ab9e4e feat(docs): full usage example on landing page
Related to #4
2015-03-12 16:40:28 +01:00
Sebastian Thiel
614539a925 fix(type-clashes): protect from nested-type-clash
It was possible for a nested type to be generated with a name that in
fact CLASHED with an existing schema type. What are the odds !

The clash-check added will just verify against clashes with schema
types, which seems to be doing it for now.
2015-03-11 15:30:11 +01:00
Sebastian Thiel
538120f7d1 fix(mbuild): scope -> add_scope
This is not only more precisely saying what it does, but also doesn't
clash with scope parameters on resources ;) (happened in dfareporting)
2015-03-11 13:47:55 +01:00
Sebastian Thiel
5d563c88a8 fix(hash): nested type resolution and hashes
It seems we do it better than the actual Go implementation, which fails
to detect that scopes are actually having a string member.

However, there still is an issue, as it's as hashmap for us, but just
a member for go ... lets see ...
https://developers.google.com/discovery/v1/reference/apis#resource
shows that we implement it correctly :) !!
2015-03-11 10:19:51 +01:00
Sebastian Thiel
bfc3922916 fix(compile): no compiler warnings
This involves disabling the dead-code lint, which is just to ease
debugging, currently there is a lot of dead code as 'hub' is never used.

Soon, this will change, so the lint will be enabled again.
2015-03-11 08:43:24 +01:00
Sebastian Thiel
cf258bf4e5 fix(build): fixes to help more projects to build
Involving
* complete list of reserved words (keywords in Rust)
* use namespace for otherwise clashing types in cmn::, io::
2015-03-11 08:16:10 +01:00
Sebastian Thiel
d99ba9c5b3 fix(mako): fix name clashes
Scopes could be invalid, previosly, and the hub type could clash
with other types provided as Schema.

Also, we used reserved identifiers
2015-03-10 18:03:35 +01:00
Sebastian Thiel
df9f0299bf fix(mako): deal with missing auth information
Now all APIs can be built successfully, which should help to
prevent things from getting hardcoded in any way.
2015-03-10 17:10:07 +01:00
Sebastian Thiel
c7e169dff3 fix(util): resource-to-category map
It allows to obtain category, which we previously dropped
2015-03-10 16:23:22 +01:00
Sebastian Thiel
92d8fa76d0 fix(apis): intermediate improvements ...
... it shows that the override I used previously won't work for `admin`.
Therefore we have to keep the actual value, instead of degenrating it.

Makes sense ... it's interesting how much one tends to hard-code things
to work just for a few cases, unless you opt in to see the whole picture
2015-03-10 15:54:43 +01:00
Sebastian Thiel
2531011fc5 fix(resource): now with flattened activities
That way, we don't have recursive method builders, but instead
flatten the hierarchy. In our case, this is easier and means
less to type. E.g.

`hub.user().message().import(...)` now is
`hub.user().message_import(...)`

In go it would look like this though
`hub.user.messages.import(...)
which is neater.

We will never have that though, as it will initialize a massive amount
of data right on the stack, even though only some of it is ever used
... .
2015-03-10 11:55:11 +01:00
Sebastian Thiel
6d2b0fc264 fix(scope): scopes are sorted Strings now
That way, we make retrieved tokens independent of the order scopes
were passed in. Additionally, we can pass any scopes, just in case
someone uses one token for multiple APIs.
Let's keep it flexible.
2015-03-10 09:31:29 +01:00
Sebastian Thiel
28878e0618 fix(Scope): Manual scope parameter ...
... however, it should better be a set, and there must be a way to
control certain global names using the configuration :)
2015-03-10 09:05:03 +01:00
Sebastian Thiel
9bcb3f8ba9 docs(params): for additional parameters
Based on the parameters suitable for the entire API. One could also
make them available in the builder ... .
2015-03-10 07:54:58 +01:00
Sebastian Thiel
aabed38581 feat(doit): query string setup
It works for uploads as well as for others.

Next up is to setup the head and authentication. It will be as simple
as calling and handling `GetToken`, even though I think that there
needs to be better support for the scope that is asked for ... .
2015-03-09 17:29:44 +01:00