mirror of
https://github.com/dathere/ckanaction.git
synced 2025-11-09 14:19:49 +00:00
docs: improve examples and clarification about status_show
This commit is contained in:
parent
8f888e96e1
commit
02915feb1c
1 changed files with 14 additions and 11 deletions
25
README.md
25
README.md
|
|
@ -4,7 +4,7 @@ Rust library crate to access CKAN Action API endpoints through Rust builders. Ba
|
|||
|
||||
## Examples
|
||||
|
||||
Run `/status_show` endpoint for a CKAN instance and print the output:
|
||||
Run `/package_list` endpoint with a limit of 5 results per page and print the output:
|
||||
|
||||
```rust
|
||||
use dotenvy::dotenv;
|
||||
|
|
@ -20,9 +20,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.token(dotenvy::var("CKAN_API_TOKEN")?)
|
||||
.build();
|
||||
|
||||
// Send request to /status_show and print output
|
||||
let status_show = ckan.status_show().await?;
|
||||
println!("{status_show:#?}");
|
||||
// Send request to /package_list and print output
|
||||
let result = ckan.package_list()
|
||||
.limit(5) // <-- This is an optional parameter you can remove
|
||||
.call()
|
||||
.await?;
|
||||
println!("{result:#?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -30,13 +33,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
> The following examples won't include the boilerplate code.
|
||||
|
||||
List packages:
|
||||
|
||||
```rust
|
||||
let result = ckan.package_list().call().await?;
|
||||
println!("{result:#?}");
|
||||
```
|
||||
|
||||
Create a new package (dataset) with custom fields:
|
||||
|
||||
```rust
|
||||
|
|
@ -69,6 +65,13 @@ let result = ckan
|
|||
println!("{result:#?}");
|
||||
```
|
||||
|
||||
Some endpoints without any parameters may not need a builder such as `/status_show` so there is no need to run `.call()` on `.status_show()`:
|
||||
|
||||
```rust
|
||||
let status_show = ckan.status_show().await?;
|
||||
println!("{status_show:#?}");
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Add the `CKAN_API_TOKEN` environment variable to a `.env` file where the program runs to include the token when making requests to the CKAN API.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue