diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-07 21:51:31 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-07 21:51:31 -0700 |
commit | d2070ba3718978a9615ae2aa3d81825803522a91 (patch) | |
tree | f62fe241fdbbd32180e582bd5533582558c6b979 /rust/fatcat-api/src/client.rs | |
parent | 20c5cf5a8b9acf98db7487ab49de8dcbc1ddb2f9 (diff) | |
parent | 8cccbcdef11e7ddc761ec494cb894a8d49a0d510 (diff) | |
download | fatcat-d2070ba3718978a9615ae2aa3d81825803522a91.tar.gz fatcat-d2070ba3718978a9615ae2aa3d81825803522a91.zip |
Merge branch 'autoaccept' into http-verbs
Started resolving conflicts in:
TODO
notes/cloud_instances.txt
rust/fatcat-api/README.md
rust/src/api_server.rs
Diffstat (limited to 'rust/fatcat-api/src/client.rs')
-rw-r--r-- | rust/fatcat-api/src/client.rs | 95 |
1 files changed, 85 insertions, 10 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 9b2caa32..6f61f773 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -298,8 +298,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_container_batch(&self, param_entity_list: &Vec<models::ContainerEntity>, context: &Context) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/container/batch", self.base_path); + fn create_container_batch( + &self, + param_entity_list: &Vec<models::ContainerEntity>, + param_autoaccept: Option<bool>, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = CreateContainerBatchResponse, Error = ApiError> + Send> { + // Query parameters + let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/container/batch?{autoaccept}{editgroup}", + self.base_path, + autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -428,8 +443,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_creator_batch(&self, param_entity_list: &Vec<models::CreatorEntity>, context: &Context) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/creator/batch", self.base_path); + fn create_creator_batch( + &self, + param_entity_list: &Vec<models::CreatorEntity>, + param_autoaccept: Option<bool>, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = CreateCreatorBatchResponse, Error = ApiError> + Send> { + // Query parameters + let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/creator/batch?{autoaccept}{editgroup}", + self.base_path, + autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -616,8 +646,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_file_batch(&self, param_entity_list: &Vec<models::FileEntity>, context: &Context) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/file/batch", self.base_path); + fn create_file_batch( + &self, + param_entity_list: &Vec<models::FileEntity>, + param_autoaccept: Option<bool>, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = CreateFileBatchResponse, Error = ApiError> + Send> { + // Query parameters + let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/file/batch?{autoaccept}{editgroup}", + self.base_path, + autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -746,8 +791,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_release_batch(&self, param_entity_list: &Vec<models::ReleaseEntity>, context: &Context) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/release/batch", self.base_path); + fn create_release_batch( + &self, + param_entity_list: &Vec<models::ReleaseEntity>, + param_autoaccept: Option<bool>, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = CreateReleaseBatchResponse, Error = ApiError> + Send> { + // Query parameters + let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/release/batch?{autoaccept}{editgroup}", + self.base_path, + autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); @@ -876,8 +936,23 @@ impl Api for Client { Box::new(futures::done(result)) } - fn create_work_batch(&self, param_entity_list: &Vec<models::WorkEntity>, context: &Context) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send> { - let url = format!("{}/v0/work/batch", self.base_path); + fn create_work_batch( + &self, + param_entity_list: &Vec<models::WorkEntity>, + param_autoaccept: Option<bool>, + param_editgroup: Option<String>, + context: &Context, + ) -> Box<Future<Item = CreateWorkBatchResponse, Error = ApiError> + Send> { + // Query parameters + let query_autoaccept = param_autoaccept.map_or_else(String::new, |query| format!("autoaccept={autoaccept}&", autoaccept = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); + + let url = format!( + "{}/v0/work/batch?{autoaccept}{editgroup}", + self.base_path, + autoaccept = utf8_percent_encode(&query_autoaccept, QUERY_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_ENCODE_SET) + ); let body = serde_json::to_string(¶m_entity_list).expect("impossible to fail to serialize"); |