haveapi-rust-client 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ // Generated by HaveAPI. Regenerate from the saved schema; do not edit.
2
+ pub mod runtime;
3
+ pub mod resources;
4
+ pub use runtime::*;
5
+ pub const API_VERSION: &str = <%= generator.literal(schema.fetch('api_version')) %>;
6
+ pub const SCHEMA_SHA256: &str = <%= generator.literal(HaveAPI::RustClient::Snapshot.sha256(schema)) %>;
7
+ pub static API_SPEC: runtime::ApiSpec = runtime::ApiSpec {
8
+ api_version: API_VERSION,
9
+ protocol_major: 2,
10
+ schema_sha256: SCHEMA_SHA256,
11
+ basic_auth: <%= schema.dig('description', 'authentication').has_key?('basic') %>,
12
+ token_header: <%= generator.option(schema.dig('description', 'authentication', 'token', 'http_header')) %>,
13
+ oauth2_header: <%= generator.option(schema.dig('description', 'authentication', 'oauth2', 'http_header')) %>,
14
+ };
15
+ pub type Client = runtime::Client<runtime::AsyncTransport>;
16
+ impl runtime::Client<runtime::AsyncTransport> {
17
+ pub fn builder(base: impl AsRef<str>) -> runtime::ClientBuilder<runtime::AsyncTransport> {
18
+ runtime::ClientBuilder::new(base, &API_SPEC)
19
+ }
20
+ }
21
+ #[cfg(feature = "blocking")]
22
+ pub mod blocking {
23
+ pub type Client = super::runtime::Client<super::runtime::BlockingTransport>;
24
+ }
25
+ #[cfg(feature = "blocking")]
26
+ impl runtime::Client<runtime::BlockingTransport> {
27
+ pub fn builder(base: impl AsRef<str>) -> runtime::ClientBuilder<runtime::BlockingTransport> {
28
+ runtime::ClientBuilder::new(base, &API_SPEC)
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ use crate::runtime;
2
+ use std::collections::BTreeMap;
3
+ <% resource[:actions].each do |action| -%>
4
+ pub mod <%= action[:method] %>;
5
+ <% end -%>
6
+
7
+ pub struct Handle<'a, C: runtime::Mode> {
8
+ client: &'a runtime::Client<C>,
9
+ path_params: BTreeMap<String, String>,
10
+ }
11
+ impl<C: runtime::Mode> runtime::Client<C> {
12
+ pub fn <%= resource[:module] %>(&self<%= resource[:bound].map { |name| ", #{HaveAPI::RustClient::Naming.snake(name)}: impl ToString" }.join %>) -> Handle<'_, C> {
13
+ let path_params = BTreeMap::from([<%= resource[:bound].map { |name| "(#{generator.literal(name)}.to_owned(), #{HaveAPI::RustClient::Naming.snake(name)}.to_string())" }.join(',') %>]);
14
+ Handle { client: self, path_params }
15
+ }
16
+ }
17
+ impl<'a, C: runtime::Mode> Handle<'a, C> {
18
+ <% resource[:actions].each do |action| -%>
19
+ <% ([action[:method]] + action[:aliases]).each do |method_name| -%>
20
+ pub fn <%= method_name %>(&self<%= (action[:placeholders] - resource[:bound]).map { |name| ", #{action[:arguments].fetch(name)}: impl ToString" }.join %>) -> runtime::Request<'a, C, <%= generator.input_type(action).gsub(/\bInput\b/, "#{action[:method]}::Input") %>, <%= generator.output_type(action).gsub(/\bOutput\b/, "#{action[:method]}::Output") %>, <%= action[:method] %>::Meta> {
21
+ #[allow(unused_mut)]
22
+ let mut path_params = self.path_params.clone();
23
+ <% (action[:placeholders] - resource[:bound]).each do |name| -%>
24
+ path_params.insert(<%= generator.literal(name) %>.to_owned(), <%= action[:arguments].fetch(name) %>.to_string());
25
+ <% end -%>
26
+ runtime::Request::new(self.client, &<%= action[:method] %>::SPEC, path_params, Default::default())
27
+ }
28
+ <% end -%>
29
+ <% end -%>
30
+ }
@@ -0,0 +1,4 @@
1
+ // Generated resource modules. Component boundaries use double underscores.
2
+ <% ir.resources.each do |resource| -%>
3
+ pub mod <%= resource[:module] %>;
4
+ <% end -%>
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haveapi-rust-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.30.0
5
+ platform: ruby
6
+ authors:
7
+ - Jakub Skokan
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-01 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: haveapi-client
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.30.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.30.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: tomlrb
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ description: Generate self-contained async and blocking Rust clients from saved HaveAPI
41
+ descriptions.
42
+ email:
43
+ - jakub.skokan@vpsfree.cz
44
+ executables:
45
+ - haveapi-rust-client
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Gemfile.lock
50
+ - LICENSE.txt
51
+ - README.md
52
+ - bin/haveapi-rust-client
53
+ - docs/documentation.md
54
+ - docs/generation.md
55
+ - docs/releasing.md
56
+ - lib/haveapi/rust_client.rb
57
+ - lib/haveapi/rust_client/cli.rb
58
+ - lib/haveapi/rust_client/documentation.rb
59
+ - lib/haveapi/rust_client/generator.rb
60
+ - lib/haveapi/rust_client/ir.rb
61
+ - lib/haveapi/rust_client/naming.rb
62
+ - lib/haveapi/rust_client/snapshot.rb
63
+ - lib/haveapi/rust_client/version.rb
64
+ - runtime/src/runtime/auth.rs
65
+ - runtime/src/runtime/client.rs
66
+ - runtime/src/runtime/error.rs
67
+ - runtime/src/runtime/mod.rs
68
+ - runtime/src/runtime/protocol.rs
69
+ - runtime/src/runtime/transport.rs
70
+ - runtime/src/runtime/types.rs
71
+ - runtime/src/runtime/validation.rs
72
+ - template/Cargo.toml.erb
73
+ - template/action.rs.erb
74
+ - template/mod.rs.erb
75
+ - template/resource.rs.erb
76
+ - template/resources.rs.erb
77
+ homepage: https://github.com/vpsfreecz/haveapi
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '3.2'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubygems_version: 3.7.2
96
+ specification_version: 4
97
+ summary: Typed Rust client generator for HaveAPI
98
+ test_files: []