aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api/examples
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-06-30 17:53:28 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-06-30 17:57:32 -0700
commita82cffed703665496913d9ca0155e888ec35716b (patch)
treed04bb9242e1333fc7e671a645bd97ae528c21459 /rust/fatcat-api/examples
parentf4064c19ec140987e15c64e80a3bf0c70025b31b (diff)
downloadfatcat-a82cffed703665496913d9ca0155e888ec35716b.tar.gz
fatcat-a82cffed703665496913d9ca0155e888ec35716b.zip
add remaining history endpoints
Diffstat (limited to 'rust/fatcat-api/examples')
-rw-r--r--rust/fatcat-api/examples/client.rs30
-rw-r--r--rust/fatcat-api/examples/server_lib/server.rs49
2 files changed, 74 insertions, 5 deletions
diff --git a/rust/fatcat-api/examples/client.rs b/rust/fatcat-api/examples/client.rs
index 93b2d21d..eecb0c58 100644
--- a/rust/fatcat-api/examples/client.rs
+++ b/rust/fatcat-api/examples/client.rs
@@ -13,9 +13,9 @@ use clap::{App, Arg};
#[allow(unused_imports)]
use fatcat::{AcceptEditgroupResponse, ApiError, ApiNoContext, ContextWrapperExt, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse,
CreateEditgroupResponse, CreateFileBatchResponse, CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse,
- GetContainerHistoryResponse, GetContainerResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileResponse,
- GetReleaseFilesResponse, GetReleaseResponse, GetStatsResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse,
- LookupReleaseResponse};
+ GetContainerHistoryResponse, GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse,
+ GetEditorResponse, GetFileHistoryResponse, GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse,
+ GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse};
#[allow(unused_imports)]
use futures::{future, stream, Future, Stream};
@@ -34,15 +34,19 @@ fn main() {
"GetContainer",
"GetContainerHistory",
"GetCreator",
+ "GetCreatorHistory",
"GetCreatorReleases",
"GetEditgroup",
"GetEditor",
"GetEditorChangelog",
"GetFile",
+ "GetFileHistory",
"GetRelease",
"GetReleaseFiles",
+ "GetReleaseHistory",
"GetStats",
"GetWork",
+ "GetWorkHistory",
"GetWorkReleases",
"LookupContainer",
"LookupCreator",
@@ -152,6 +156,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
+ Some("GetCreatorHistory") => {
+ let result = client.get_creator_history("id_example".to_string(), Some(789)).wait();
+ println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ }
+
Some("GetCreatorReleases") => {
let result = client.get_creator_releases("id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
@@ -177,6 +186,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
+ Some("GetFileHistory") => {
+ let result = client.get_file_history("id_example".to_string(), Some(789)).wait();
+ println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ }
+
Some("GetRelease") => {
let result = client.get_release("id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
@@ -187,6 +201,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
+ Some("GetReleaseHistory") => {
+ let result = client.get_release_history("id_example".to_string(), Some(789)).wait();
+ println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ }
+
Some("GetStats") => {
let result = client.get_stats(Some("more_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
@@ -197,6 +216,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
+ Some("GetWorkHistory") => {
+ let result = client.get_work_history("id_example".to_string(), Some(789)).wait();
+ println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ }
+
Some("GetWorkReleases") => {
let result = client.get_work_releases("id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs
index 0155782b..062fca02 100644
--- a/rust/fatcat-api/examples/server_lib/server.rs
+++ b/rust/fatcat-api/examples/server_lib/server.rs
@@ -12,8 +12,9 @@ use swagger;
use fatcat::models;
use fatcat::{AcceptEditgroupResponse, Api, ApiError, Context, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse,
CreateFileBatchResponse, CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, GetContainerHistoryResponse,
- GetContainerResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileResponse, GetReleaseFilesResponse,
- GetReleaseResponse, GetStatsResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse};
+ GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse,
+ GetFileHistoryResponse, GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse,
+ GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse};
#[derive(Copy, Clone)]
pub struct Server;
@@ -118,6 +119,17 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
+ fn get_creator_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ println!(
+ "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ limit,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
+ Box::new(futures::failed("Generic failure".into()))
+ }
+
fn get_creator_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("get_creator_releases(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
@@ -148,6 +160,17 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
+ fn get_file_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ println!(
+ "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ limit,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
+ Box::new(futures::failed("Generic failure".into()))
+ }
+
fn get_release(&self, id: String, context: &Context) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("get_release(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
@@ -160,6 +183,17 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
+ fn get_release_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ println!(
+ "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ limit,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
+ Box::new(futures::failed("Generic failure".into()))
+ }
+
fn get_stats(&self, more: Option<String>, context: &Context) -> Box<Future<Item = GetStatsResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("get_stats({:?}) - X-Span-ID: {:?}", more, context.x_span_id.unwrap_or(String::from("<none>")).clone());
@@ -172,6 +206,17 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
+ fn get_work_history(&self, id: String, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ println!(
+ "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ limit,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
+ Box::new(futures::failed("Generic failure".into()))
+ }
+
fn get_work_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("get_work_releases(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());