Compare commits

..

No commits in common. "main" and "0.1.4" have entirely different histories.
main ... 0.1.4

17 changed files with 601 additions and 2523 deletions

99
Cargo.lock generated
View file

@ -65,9 +65,9 @@ checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.62" version = "1.2.61"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"shlex", "shlex",
@ -81,13 +81,12 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]] [[package]]
name = "ckanaction" name = "ckanaction"
version = "0.2.0" version = "0.1.4"
dependencies = [ dependencies = [
"bon", "bon",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"thiserror",
"tokio", "tokio",
] ]
@ -321,9 +320,9 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.14" version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733" checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54"
dependencies = [ dependencies = [
"atomic-waker", "atomic-waker",
"bytes", "bytes",
@ -349,9 +348,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.17.1" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
[[package]] [[package]]
name = "heck" name = "heck"
@ -597,7 +596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.17.1", "hashbrown 0.17.0",
"serde", "serde",
"serde_core", "serde_core",
] ]
@ -608,6 +607,16 @@ version = "2.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2"
[[package]]
name = "iri-string"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20"
dependencies = [
"memchr",
"serde",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.18" version = "1.0.18"
@ -616,9 +625,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.98" version = "0.3.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08" checksum = "a1840c94c045fbcf8ba2812c95db44499f7c64910a912551aaaa541decebcacf"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"futures-util", "futures-util",
@ -723,14 +732,15 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.79" version = "0.10.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf0b434746ee2832f4f0baf10137e1cabb18cbe6912c69e2e33263c45250f542" checksum = "f38c4372413cdaaf3cc79dd92d29d7d9f5ab09b51b10dded508fb90bb70b9222"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
"foreign-types", "foreign-types",
"libc", "libc",
"once_cell",
"openssl-macros", "openssl-macros",
"openssl-sys", "openssl-sys",
] ]
@ -754,9 +764,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.115" version = "0.9.114"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "158fe5b292746440aa6e7a7e690e55aeb72d41505e2804c23c6973ad0e9c9781" checksum = "13ce1245cd07fcc4cfdb438f7507b0c7e4f3849a69fd84d52374c66d83741bb6"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -1024,6 +1034,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [ dependencies = [
"serde_core", "serde_core",
"serde_derive",
] ]
[[package]] [[package]]
@ -1192,26 +1203,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "tinystr" name = "tinystr"
version = "0.8.3" version = "0.8.3"
@ -1224,9 +1215,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.52.3" version = "1.52.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" checksum = "b67dee974fe86fd92cc45b7a95fdd2f99a36a6d7b0d431a231178d3d670bbcc6"
dependencies = [ dependencies = [
"bytes", "bytes",
"libc", "libc",
@ -1300,20 +1291,20 @@ dependencies = [
[[package]] [[package]]
name = "tower-http" name = "tower-http"
version = "0.6.10" version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http",
"http-body", "http-body",
"iri-string",
"pin-project-lite", "pin-project-lite",
"tower", "tower",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"url",
] ]
[[package]] [[package]]
@ -1436,9 +1427,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.121" version = "0.2.120"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790" checksum = "df52b6d9b87e0c74c9edfa1eb2d9bf85e5d63515474513aa50fa181b3c4f5db1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell", "once_cell",
@ -1449,9 +1440,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.71" version = "0.4.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8" checksum = "af934872acec734c2d80e6617bbb5ff4f12b052dd8e6332b0817bce889516084"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@ -1459,9 +1450,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.121" version = "0.2.120"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578" checksum = "78b1041f495fb322e64aca85f5756b2172e35cd459376e67f2a6c9dffcedb103"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -1469,9 +1460,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.121" version = "0.2.120"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2" checksum = "9dcd0ff20416988a18ac686d4d4d0f6aae9ebf08a389ff5d29012b05af2a1b41"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"proc-macro2", "proc-macro2",
@ -1482,9 +1473,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.121" version = "0.2.120"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441" checksum = "49757b3c82ebf16c57d69365a142940b384176c24df52a087fb748e2085359ea"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -1538,9 +1529,9 @@ dependencies = [
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.98" version = "0.3.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b572dff8bcf38bad0fa19729c89bb5748b2b9b1d8be70cf90df697e3a8f32aa" checksum = "2eadbac71025cd7b0834f20d1fe8472e8495821b4e9801eb0a60bd1f19827602"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@ -1788,9 +1779,9 @@ dependencies = [
[[package]] [[package]]
name = "zerofrom" name = "zerofrom"
version = "0.1.8" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df"
dependencies = [ dependencies = [
"zerofrom-derive", "zerofrom-derive",
] ]

View file

@ -1,10 +1,10 @@
[package] [package]
name = "ckanaction" name = "ckanaction"
version = "0.2.0" version = "0.1.4"
edition = "2024" edition = "2024"
description = "Rust library crate featuring an API wrapper of the CKAN Action v3 API." description = "Rust library crate featuring an API wrapper of the CKAN Action v3 API."
homepage = "https://ckanaction.dathere.com"
repository = "https://github.com/dathere/ckanaction" repository = "https://github.com/dathere/ckanaction"
homepage = "https://ckanaction.dathere.com"
license = "Unlicense" license = "Unlicense"
keywords = ["ckan"] keywords = ["ckan"]
categories = ["api-bindings", "asynchronous"] categories = ["api-bindings", "asynchronous"]
@ -15,7 +15,6 @@ bon = "3.9.1"
reqwest = { version = "0.12.28", features = ["json", "multipart", "stream"] } reqwest = { version = "0.12.28", features = ["json", "multipart", "stream"] }
serde = "1.0.228" serde = "1.0.228"
serde_json = "1.0.149" serde_json = "1.0.149"
thiserror = "2.0.18"
[dev-dependencies] [dev-dependencies]
tokio = { version = "1.52.3", features = ["full"] } tokio = { version = "1.52.1", features = ["full"] }

View file

@ -13,11 +13,10 @@ cargo add ckanaction
Run `/package_list` endpoint with a limit of 5 results per page and print the output: Run `/package_list` endpoint with a limit of 5 results per page and print the output:
```rust ```rust
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -90,12 +89,3 @@ To run some of the tests in the `tests` directory, first replace the values for
```bash ```bash
cargo test cargo test
``` ```
## Examples
You can run an example from the `examples` directory by first changing into the directory then running `cargo run`. For example:
```bash
cd examples/status-show
cargo run
```

View file

@ -1,2 +0,0 @@
NEXT_TELEMETRY_DISABLED=1
DO_NOT_TRACK=1

View file

@ -11,11 +11,10 @@ This means that instead of using generic request library crates such as `reqwest
For example the following code can be ran to send an HTTP POST request to the `/package_list` endpoint of a local CKAN instance's API by using the `ckanaction` crate: For example the following code can be ran to send an HTTP POST request to the `/package_list` endpoint of a local CKAN instance's API by using the `ckanaction` crate:
```rust ```rust
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;

View file

@ -7,11 +7,11 @@ _openapi:
structuredData: structuredData:
headings: [] headings: []
contents: contents:
- content: Return a list of the name of the site's datasets (packages). - content: This endpoint lists CKAN resources.
--- ---
{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
Return a list of the name of the site's datasets (packages). This endpoint lists CKAN resources.
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"package_list","method":"post"}]} /> <APIPage document={"./lib/openapi.yml"} operations={[{"path":"package_list","method":"post"}]} />

View file

@ -30,7 +30,7 @@ paths:
post: post:
operationId: package_list operationId: package_list
summary: package_list summary: package_list
description: Return a list of the name of the site's datasets (packages). description: This endpoint lists CKAN resources.
requestBody: requestBody:
required: false required: false
content: content:
@ -48,11 +48,10 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -421,11 +420,10 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -816,11 +814,10 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -1027,11 +1024,10 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;

View file

@ -1,2 +0,0 @@
.env
target/

File diff suppressed because it is too large Load diff

View file

@ -1,8 +0,0 @@
[package]
name = "package-list"
version = "0.1.0"
edition = "2024"
[dependencies]
ckanaction = "0.2.0"
tokio = { version = "1.52.2", features = ["full"] }

View file

@ -1,8 +0,0 @@
# Example of using ckanaction to run the /package_list API endpoint
## Usage
the following command to run the `/package_list` CKAN Action API endpoint on `http://localhost:5000` and print the formatted debug output.
```bash
cargo run
```

View file

@ -1,15 +0,0 @@
use ckanaction::CKANError;
#[tokio::main]
async fn main() -> Result<(), CKANError> {
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.build();
// Send request to /package_list and print formatted debug output
let package_list = ckan.package_list().call().await?;
println!("{package_list:#?}");
Ok(())
}

File diff suppressed because it is too large Load diff

View file

@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
ckanaction = "0.2.0" ckanaction = "0.1.3"
tokio = { version = "1.52.2", features = ["full"] } tokio = { version = "1.49.0", features = ["full"] }

View file

@ -1,7 +1,6 @@
use ckanaction::CKANError;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), CKANError> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize and build CKAN struct // Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder() let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000") .url("http://localhost:5000")

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
use ckanaction::{CKAN, CKANError}; use ckanaction::CKAN;
const CKAN_API_TOKEN: &str = ""; const CKAN_API_TOKEN: &str = "";
const CKAN_URL: &str = ""; const CKAN_URL: &str = "";
@ -12,7 +12,7 @@ pub async fn get_ckan_builder() -> CKAN {
#[tokio::test] #[tokio::test]
#[ignore = "Set values for const at top of tests file locally."] #[ignore = "Set values for const at top of tests file locally."]
async fn status_show() -> Result<(), CKANError> { async fn status_show() -> Result<(), Box<dyn std::error::Error>> {
let ckan = get_ckan_builder().await; let ckan = get_ckan_builder().await;
let response = ckan.status_show().await?; let response = ckan.status_show().await?;
assert!(response.is_object()); assert!(response.is_object());
@ -28,7 +28,7 @@ async fn status_show() -> Result<(), CKANError> {
} }
#[tokio::test] #[tokio::test]
async fn print_ckan_struct_with_debug() -> Result<(), CKANError> { async fn print_ckan_struct_with_debug() -> Result<(), Box<dyn std::error::Error>> {
let ckan = get_ckan_builder().await; let ckan = get_ckan_builder().await;
assert_eq!(format!("{ckan:?}"), r#"CKAN { url: "", token: Some("") }"#); assert_eq!(format!("{ckan:?}"), r#"CKAN { url: "", token: Some("") }"#);
Ok(()) Ok(())