ckanaction/docs/lib/openapi.yml

196 lines
No EOL
6.4 KiB
YAML

info:
title: ckanaction
security:
- apiTokenHeader:
description: CKAN API token
type: apiKey
name: Authorization
in: header
components:
securitySchemes:
apiTokenHeader:
type: apiKey
in: header
name: Authorization
description: CKAN API token
servers:
- url: http://localhost:5000/api/3/action
- url: '{protocol}://{domain}/api/3/action'
description: Your custom server running the CKAN Actions API (v3).
variables:
protocol:
enum:
- https
- http
default: https
domain:
default: 'demo.ckan.org'
paths:
'/status_show':
get:
operationId: /status_show
summary: /status_show
description: This endpoint shows information about the CKAN instance.
x-codeSamples:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenv()?;
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.token(dotenvy::var("CKAN_API_TOKEN")?)
.build();
// Send request to /status_show and print output
let result = ckan.status_show().await?;
println!("{result:#?}");
Ok(())
}
'/package_list':
post:
operationId: /package_list
summary: /package_list
description: This endpoint lists CKAN resources.
requestBody:
required: false
content:
application/json:
schema:
# required:
# - project_uuid
type: object
properties:
limit:
type: integer
description: if given, the list of datasets will be broken into pages of at most `limit` datasets per page and only one page will be returned at a time
offset:
type: integer
description: when limit is given, the offset to start returning packages from
x-codeSamples:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenv()?;
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.token(dotenvy::var("CKAN_API_TOKEN")?)
.build();
// 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(())
}
'/package_show':
post:
operationId: /package_show
summary: /package_show
description: Return the metadata of a dataset and its resources.
requestBody:
required: true
content:
application/json:
schema:
required:
- id
type: object
properties:
id:
type: string
description: the id or name of the dataset
default: ""
use_default_schema:
type: boolean
description: use default package schema instead of a custom schema defined with an IDatasetForm plugin
include_plugin_data:
type: boolean
description: Include the internal plugin data object (sysadmin only)
x-codeSamples:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenv()?;
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.token(dotenvy::var("CKAN_API_TOKEN")?)
.build();
// Send request to /package_show and print output
let result = ckan.package_show()
.id("6b044c6b-e896-4800-a94d-9e5147b25a25".to_string())
.call()
.await?;
println!("{result:#?}");
Ok(())
}
'/package_search':
post:
operationId: /package_search
summary: /package_search
description: Searches for packages satisfying a given search criteria.
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
q:
type: string
description: the solr query.
fq:
type: string
description: "any filter queries to apply. Note: `+site_id:{ckan_site_id}` is added to this string prior to the query being executed."
x-codeSamples:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenv()?;
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.token(dotenvy::var("CKAN_API_TOKEN")?)
.build();
// Send request to /package_search and print output
let result = ckan.package_search()
.q("*:*".to_string())
.call()
.await?;
println!("{result:#?}");
Ok(())
}