diff options
Diffstat (limited to 'rust/fatcat-api-spec/examples/client.rs')
-rw-r--r-- | rust/fatcat-api-spec/examples/client.rs | 253 |
1 files changed, 124 insertions, 129 deletions
diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 5d600965..43f002fc 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -28,45 +28,43 @@ fn main() { Arg::with_name("operation") .help("Sets the operation to run") .possible_values(&[ - "AcceptEditgroup", "CreateContainerBatch", - "CreateCreatorBatch", - "CreateFileBatch", - "CreateReleaseBatch", - "CreateWorkBatch", "DeleteContainer", - "DeleteCreator", - "DeleteFile", - "DeleteRelease", - "DeleteWork", - "GetChangelog", - "GetChangelogEntry", "GetContainer", "GetContainerHistory", + "LookupContainer", + "CreateCreatorBatch", + "DeleteCreator", "GetCreator", "GetCreatorHistory", "GetCreatorReleases", - "GetEditgroup", + "LookupCreator", "GetEditor", "GetEditorChangelog", + "GetStats", + "AcceptEditgroup", + "GetChangelog", + "GetChangelogEntry", + "GetEditgroup", + "CreateFileBatch", + "DeleteFile", "GetFile", "GetFileHistory", + "LookupFile", + "CreateReleaseBatch", + "DeleteRelease", "GetRelease", "GetReleaseFiles", "GetReleaseHistory", - "GetStats", + "LookupRelease", + "CreateWorkBatch", + "DeleteWork", "GetWork", "GetWorkHistory", "GetWorkReleases", - "LookupContainer", - "LookupCreator", - "LookupFile", - "LookupRelease", - ]) - .required(true) + ]).required(true) .index(1), - ) - .arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) + ).arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) .arg(Arg::with_name("host").long("host").takes_value(true).default_value("localhost").help("Hostname to contact")) .arg(Arg::with_name("port").long("port").takes_value(true).default_value("8080").help("Port to contact")) .get_matches(); @@ -90,11 +88,6 @@ fn main() { let client = client.with_context(fatcat::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string())); match matches.value_of("operation") { - Some("AcceptEditgroup") => { - let result = client.accept_editgroup("id_example".to_string()).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - // Disabled because there's no example. // Some("CreateContainer") => { // let result = client.create_container(???, Some("editgroup_example".to_string())).wait(); @@ -105,54 +98,39 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - // Disabled because there's no example. - // Some("CreateCreator") => { - // let result = client.create_creator(???, Some("editgroup_example".to_string())).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateCreatorBatch") => { - let result = client.create_creator_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); + Some("DeleteContainer") => { + let result = client.delete_container("id_example".to_string(), Some("editgroup_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - // Disabled because there's no example. - // Some("CreateEditgroup") => { - // let result = client.create_editgroup(???).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, + Some("GetContainer") => { + let result = client.get_container("id_example".to_string(), Some("expand_example".to_string())).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + } - // Disabled because there's no example. - // Some("CreateFile") => { - // let result = client.create_file(???, Some("editgroup_example".to_string())).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateFileBatch") => { - let result = client.create_file_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); + Some("GetContainerHistory") => { + let result = client.get_container_history("id_example".to_string(), Some(789)).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - // Disabled because there's no example. - // Some("CreateRelease") => { - // let result = client.create_release(???, Some("editgroup_example".to_string())).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - Some("CreateReleaseBatch") => { - let result = client.create_release_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); + Some("LookupContainer") => { + let result = client.lookup_container("issnl_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } // Disabled because there's no example. - // Some("CreateWork") => { - // let result = client.create_work(???, Some("editgroup_example".to_string())).wait(); + // Some("UpdateContainer") => { + // let result = client.update_container("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); // }, - Some("CreateWorkBatch") => { - let result = client.create_work_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); - println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - } - Some("DeleteContainer") => { - let result = client.delete_container("id_example".to_string(), Some("editgroup_example".to_string())).wait(); + // Disabled because there's no example. + // Some("CreateCreator") => { + // let result = client.create_creator(???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("CreateCreatorBatch") => { + let result = client.create_creator_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } @@ -161,53 +139,63 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("DeleteFile") => { - let result = client.delete_file("id_example".to_string(), Some("editgroup_example".to_string())).wait(); + Some("GetCreator") => { + let result = client.get_creator("id_example".to_string(), Some("expand_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("DeleteRelease") => { - let result = client.delete_release("id_example".to_string(), Some("editgroup_example".to_string())).wait(); + 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("DeleteWork") => { - let result = client.delete_work("id_example".to_string(), Some("editgroup_example".to_string())).wait(); + 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>"))); } - Some("GetChangelog") => { - let result = client.get_changelog(Some(789)).wait(); + Some("LookupCreator") => { + let result = client.lookup_creator("orcid_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetChangelogEntry") => { - let result = client.get_changelog_entry(789).wait(); + // Disabled because there's no example. + // Some("UpdateCreator") => { + // let result = client.update_creator("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("GetEditor") => { + let result = client.get_editor("id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetContainer") => { - let result = client.get_container("id_example".to_string(), Some("expand_example".to_string())).wait(); + Some("GetEditorChangelog") => { + let result = client.get_editor_changelog("id_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetContainerHistory") => { - let result = client.get_container_history("id_example".to_string(), Some(789)).wait(); + 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>"))); } - Some("GetCreator") => { - let result = client.get_creator("id_example".to_string(), Some("expand_example".to_string())).wait(); + Some("AcceptEditgroup") => { + let result = client.accept_editgroup("id_example".to_string()).wait(); 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(); + // Disabled because there's no example. + // Some("CreateEditgroup") => { + // let result = client.create_editgroup(???).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("GetChangelog") => { + let result = client.get_changelog(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(); + Some("GetChangelogEntry") => { + let result = client.get_changelog_entry(789).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } @@ -216,13 +204,18 @@ fn main() { println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetEditor") => { - let result = client.get_editor("id_example".to_string()).wait(); + // Disabled because there's no example. + // Some("CreateFile") => { + // let result = client.create_file(???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("CreateFileBatch") => { + let result = client.create_file_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetEditorChangelog") => { - let result = client.get_editor_changelog("id_example".to_string()).wait(); + Some("DeleteFile") => { + let result = client.delete_file("id_example".to_string(), Some("editgroup_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } @@ -236,84 +229,86 @@ fn main() { 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(), Some("expand_example".to_string())).wait(); + Some("LookupFile") => { + let result = client.lookup_file("sha1_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetReleaseFiles") => { - let result = client.get_release_files("id_example".to_string()).wait(); + // Disabled because there's no example. + // Some("UpdateFile") => { + // let result = client.update_file("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + + // Disabled because there's no example. + // Some("CreateRelease") => { + // let result = client.create_release(???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("CreateReleaseBatch") => { + let result = client.create_release_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); 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(); + // Disabled because there's no example. + // Some("CreateWork") => { + // let result = client.create_work(???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("DeleteRelease") => { + let result = client.delete_release("id_example".to_string(), Some("editgroup_example".to_string())).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(); + Some("GetRelease") => { + let result = client.get_release("id_example".to_string(), Some("expand_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("GetWork") => { - let result = client.get_work("id_example".to_string(), Some("expand_example".to_string())).wait(); + Some("GetReleaseFiles") => { + let result = client.get_release_files("id_example".to_string()).wait(); 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(); + 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("GetWorkReleases") => { - let result = client.get_work_releases("id_example".to_string()).wait(); + Some("LookupRelease") => { + let result = client.lookup_release("doi_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("LookupContainer") => { - let result = client.lookup_container("issnl_example".to_string()).wait(); + // Disabled because there's no example. + // Some("UpdateRelease") => { + // let result = client.update_release("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); + // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + // }, + Some("CreateWorkBatch") => { + let result = client.create_work_batch(&Vec::new(), Some(true), Some("editgroup_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("LookupCreator") => { - let result = client.lookup_creator("orcid_example".to_string()).wait(); + Some("DeleteWork") => { + let result = client.delete_work("id_example".to_string(), Some("editgroup_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("LookupFile") => { - let result = client.lookup_file("sha1_example".to_string()).wait(); + Some("GetWork") => { + let result = client.get_work("id_example".to_string(), Some("expand_example".to_string())).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } - Some("LookupRelease") => { - let result = client.lookup_release("doi_example".to_string()).wait(); + 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>"))); } - // Disabled because there's no example. - // Some("UpdateContainer") => { - // let result = client.update_container("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateCreator") => { - // let result = client.update_creator("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateFile") => { - // let result = client.update_file("id_example".to_string(), ???, Some("editgroup_example".to_string())).wait(); - // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); - // }, - - // Disabled because there's no example. - // Some("UpdateRelease") => { - // let result = client.update_release("id_example".to_string(), ???, Some("editgroup_example".to_string())).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>"))); + } // Disabled because there's no example. // Some("UpdateWork") => { |