Move endpoints to sub module in api_core

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 3 years ago
parent 039d510a61
commit 0e8c28c948
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,32 +1,36 @@
use crate::api_core::access_management::{
use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord, OptionalStringNumber};
use crate::api_core::endpoints::access_management::{
ApiVersion, ApiVersionResponse, GetServices, GetServicesResponse, SessionKey,
SessionKeyResponse, VerifyAccessKey, VerifyAccessKeyResponse,
};
use crate::api_core::adding_files::{
use crate::api_core::endpoints::adding_files::{
AddFile, AddFileRequest, AddFileResponse, ArchiveFiles, ArchiveFilesRequest, DeleteFiles,
DeleteFilesRequest, UnarchiveFiles, UnarchiveFilesRequest, UndeleteFiles, UndeleteFilesRequest,
};
use crate::api_core::adding_notes::{DeleteNotes, DeleteNotesRequest, SetNotes, SetNotesRequest};
use crate::api_core::adding_tags::{AddTags, AddTagsRequest, CleanTags, CleanTagsResponse};
use crate::api_core::adding_urls::{
use crate::api_core::endpoints::adding_notes::{
DeleteNotes, DeleteNotesRequest, SetNotes, SetNotesRequest,
};
use crate::api_core::endpoints::adding_tags::{
AddTags, AddTagsRequest, CleanTags, CleanTagsResponse,
};
use crate::api_core::endpoints::adding_urls::{
AddUrl, AddUrlRequest, AddUrlResponse, AssociateUrl, AssociateUrlRequest, GetUrlFiles,
GetUrlFilesResponse, GetUrlInfo, GetUrlInfoResponse,
};
use crate::api_core::client_builder::ClientBuilder;
use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord, OptionalStringNumber};
use crate::api_core::managing_cookies_and_http_headers::{
use crate::api_core::endpoints::client_builder::ClientBuilder;
use crate::api_core::endpoints::managing_cookies_and_http_headers::{
GetCookies, GetCookiesResponse, SetCookies, SetCookiesRequest, SetUserAgent,
SetUserAgentRequest,
};
use crate::api_core::managing_pages::{
use crate::api_core::endpoints::managing_pages::{
AddFiles, AddFilesRequest, FocusPage, FocusPageRequest, GetPageInfo, GetPageInfoResponse,
GetPages, GetPagesResponse,
};
use crate::api_core::searching_and_fetching_files::{
use crate::api_core::endpoints::searching_and_fetching_files::{
FileMetadata, FileMetadataResponse, FileSearchOptions, GetFile, SearchFileHashes,
SearchFileHashesResponse, SearchFiles, SearchFilesResponse, SearchQueryEntry,
};
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
use crate::error::{Error, Result};
use bytes::Buf;
use reqwest::Response;

@ -1,5 +1,5 @@
use crate::api_core::common::BasicServiceInfo;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
use std::collections::HashMap;
pub static SERVICE_TYPE_LOCAL_TAGS: &str = "local_tags";

@ -1,5 +1,5 @@
use crate::api_core::common::{BasicHashList, ServiceIdentifier};
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
use serde::Serialize;
pub static STATUS_IMPORT_SUCCESS: u8 = 1;

@ -1,5 +1,5 @@
use crate::api_core::common::FileIdentifier;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
use std::collections::HashMap;
pub struct SetNotes;

@ -1,5 +1,5 @@
use crate::api_core::common::ServiceIdentifier;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
use std::collections::HashMap;
#[derive(Debug, Clone, Deserialize)]

@ -1,5 +1,5 @@
use crate::api_core::common::ServiceIdentifier;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
use serde::Serialize;
use std::collections::HashMap;
@ -74,7 +74,7 @@ pub struct AddUrlRequest {
///
/// Example:
/// ```
/// use hydrus_api::api_core::adding_urls::AddUrlRequestBuilder;
/// use hydrus_api::api_core::endpoints::adding_urls::AddUrlRequestBuilder;
/// use hydrus_api::api_core::common::ServiceIdentifier;
///
/// let request = AddUrlRequestBuilder::default()

@ -1,5 +1,5 @@
use crate::api_core::common::OptionalStringNumber;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
#[derive(Clone, Debug, Deserialize)]
pub struct GetCookiesResponse {

@ -1,5 +1,5 @@
use crate::api_core::common::PageInformation;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
#[derive(Clone, Debug, Deserialize)]
pub struct GetPagesResponse {

@ -0,0 +1,20 @@
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::fmt::Debug;
pub mod access_management;
pub mod adding_files;
pub mod adding_notes;
pub mod adding_tags;
pub mod adding_urls;
pub mod client_builder;
pub mod managing_cookies_and_http_headers;
pub mod managing_pages;
pub mod searching_and_fetching_files;
pub(crate) trait Endpoint {
type Request: Serialize + Debug;
type Response: DeserializeOwned + Debug;
fn path() -> String;
}

@ -1,5 +1,5 @@
use crate::api_core::common::FileMetadataInfo;
use crate::api_core::Endpoint;
use crate::api_core::endpoints::Endpoint;
pub mod file_sort_type {
pub const SORT_FILE_SIZE: u8 = 0;

@ -1,24 +1,3 @@
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::fmt::Debug;
pub mod access_management;
pub mod adding_files;
pub mod adding_tags;
pub mod adding_urls;
pub mod client;
pub mod client_builder;
pub mod common;
pub mod managing_cookies_and_http_headers;
pub mod managing_pages;
pub mod searching_and_fetching_files;
pub mod adding_notes;
pub use searching_and_fetching_files::file_sort_type;
pub(crate) trait Endpoint {
type Request: Serialize + Debug;
type Response: DeserializeOwned + Debug;
fn path() -> String;
}
pub mod endpoints;

@ -56,7 +56,7 @@
//! ## Client Usage Example
//! ```
//! use hydrus_api::Client;
//! use hydrus_api::api_core::adding_tags::{AddTagsRequestBuilder, TagAction};
//! use hydrus_api::api_core::endpoints::adding_tags::{AddTagsRequestBuilder, TagAction};
//! use std::env;
//! use hydrus_api::api_core::common::ServiceIdentifier;
//! # #[tokio::test]

@ -1,5 +1,5 @@
use crate::api_core::common::OptionalStringNumber;
use crate::api_core::managing_cookies_and_http_headers::CookieBuilder;
use crate::api_core::endpoints::managing_cookies_and_http_headers::CookieBuilder;
use crate::error::Result;
use crate::Client;
use std::time::{Duration, SystemTime, UNIX_EPOCH};

@ -1,5 +1,5 @@
use crate::api_core::adding_files::DeleteFilesRequest;
use crate::api_core::common::{FileIdentifier, ServiceIdentifier};
use crate::api_core::endpoints::adding_files::DeleteFilesRequest;
use crate::error::Result;
use crate::Client;

@ -1,6 +1,6 @@
use crate::api_core::adding_files::{STATUS_IMPORT_FAILED, STATUS_IMPORT_VETOED};
use crate::api_core::adding_urls::AddUrlRequestBuilder;
use crate::api_core::common::ServiceIdentifier;
use crate::api_core::endpoints::adding_files::{STATUS_IMPORT_FAILED, STATUS_IMPORT_VETOED};
use crate::api_core::endpoints::adding_urls::AddUrlRequestBuilder;
use crate::error::{Error, Result};
use crate::utils::tag_list_to_string_list;
use crate::wrapper::hydrus_file::HydrusFile;

@ -1,4 +1,6 @@
use crate::api_core::searching_and_fetching_files::{FileSearchOptions, SearchQueryEntry};
use crate::api_core::endpoints::searching_and_fetching_files::{
FileSearchOptions, SearchQueryEntry,
};
use crate::error::Result;
use crate::wrapper::hydrus_file::HydrusFile;
use crate::wrapper::or_chain::OrChain;

@ -1,5 +1,5 @@
use crate::api_core::adding_tags::{AddTagsRequestBuilder, TagAction};
use crate::api_core::common::ServiceIdentifier;
use crate::api_core::endpoints::adding_tags::{AddTagsRequestBuilder, TagAction};
use crate::error::Result;
use crate::wrapper::tag::Tag;
use crate::Client;

@ -1,5 +1,5 @@
use crate::api_core::adding_tags::{AddTagsRequestBuilder, TagAction};
use crate::api_core::common::{FileIdentifier, FileMetadataInfo, FileRecord, ServiceIdentifier};
use crate::api_core::endpoints::adding_tags::{AddTagsRequestBuilder, TagAction};
use crate::error::{Error, Result};
use crate::utils::tag_list_to_string_list;
use crate::wrapper::builders::delete_files_builder::DeleteFilesBuilder;

@ -1,5 +1,5 @@
use crate::api_core::access_management::GetServicesResponse;
use crate::api_core::access_management::{
use crate::api_core::endpoints::access_management::GetServicesResponse;
use crate::api_core::endpoints::access_management::{
SERVICE_TYPE_ALL_KNOWN_FILES, SERVICE_TYPE_ALL_KNOWN_TAGS, SERVICE_TYPE_ALL_LOCAL_FILES,
SERVICE_TYPE_FILE_REPOSITORIES, SERVICE_TYPE_LOCAL_FILES, SERVICE_TYPE_LOCAL_TAGS,
SERVICE_TYPE_TAG_REPOSITORIES, SERVICE_TYPE_TRASH,

@ -1,4 +1,4 @@
use crate::api_core::adding_urls::{
use crate::api_core::endpoints::adding_urls::{
URL_TYPE_FILE, URL_TYPE_GALLERY, URL_TYPE_POST, URL_TYPE_WATCHABLE,
};
use crate::error::Result;

@ -1,7 +1,7 @@
use crate::common;
use crate::common::create_testdata;
use crate::common::test_data::get_test_hashes;
use hydrus_api::api_core::adding_files::DeleteFilesRequest;
use hydrus_api::api_core::endpoints::adding_files::DeleteFilesRequest;
use hydrus_api::wrapper::service::ServiceName;
#[tokio::test]

@ -1,7 +1,7 @@
use super::super::common;
use crate::common::test_data::EMPTY_HASH;
use hydrus_api::api_core::adding_tags::{AddTagsRequestBuilder, TagAction};
use hydrus_api::api_core::common::ServiceIdentifier;
use hydrus_api::api_core::endpoints::adding_tags::{AddTagsRequestBuilder, TagAction};
#[tokio::test]
async fn it_cleans_tags() {

@ -1,7 +1,7 @@
use super::super::common;
use crate::common::test_data::{get_test_hashes, get_test_urls, TEST_URL_1};
use hydrus_api::api_core::adding_urls::{AddUrlRequestBuilder, URL_TYPE_POST};
use hydrus_api::api_core::common::ServiceIdentifier;
use hydrus_api::api_core::endpoints::adding_urls::{AddUrlRequestBuilder, URL_TYPE_POST};
#[tokio::test]
async fn it_returns_files_for_an_url() {

@ -1,5 +1,5 @@
use super::super::common;
use hydrus_api::api_core::managing_cookies_and_http_headers::CookieBuilder;
use hydrus_api::api_core::endpoints::managing_cookies_and_http_headers::CookieBuilder;
#[tokio::test]
async fn it_returns_cookies_for_a_domain() {

@ -1,7 +1,9 @@
use super::super::common;
use hydrus_api::api_core::common::FileIdentifier;
use hydrus_api::api_core::file_sort_type::SORT_FILE_PIXEL_COUNT;
use hydrus_api::api_core::searching_and_fetching_files::{FileSearchOptions, SearchQueryEntry};
use hydrus_api::api_core::endpoints::searching_and_fetching_files::file_sort_type::SORT_FILE_PIXEL_COUNT;
use hydrus_api::api_core::endpoints::searching_and_fetching_files::{
FileSearchOptions, SearchQueryEntry,
};
#[tokio::test]
async fn is_searches_files() {

@ -1,5 +1,5 @@
use hydrus_api::api_core::adding_urls::AddUrlRequestBuilder;
use hydrus_api::api_core::client::Client;
use hydrus_api::api_core::endpoints::adding_urls::AddUrlRequestBuilder;
use hydrus_api::Hydrus;
use std::env;
use std::sync::{Arc, Mutex, MutexGuard};

@ -1,8 +1,8 @@
use super::super::common;
use crate::common::test_data::TEST_HASH_2;
use crate::common::{create_testdata, get_client};
use hydrus_api::api_core::adding_tags::TagAction;
use hydrus_api::api_core::common::FileIdentifier;
use hydrus_api::api_core::endpoints::adding_tags::TagAction;
use hydrus_api::wrapper::hydrus_file::HydrusFile;
use hydrus_api::wrapper::service::ServiceName;

@ -1,5 +1,5 @@
use super::super::common;
use hydrus_api::api_core::adding_tags::TagAction;
use hydrus_api::api_core::endpoints::adding_tags::TagAction;
use hydrus_api::wrapper::builders::or_chain_builder::OrChainBuilder;
use hydrus_api::wrapper::builders::search_builder::SortType;
use hydrus_api::wrapper::builders::tag_builder::TagBuilder;

Loading…
Cancel
Save