mirror of
https://github.com/dathere/ckanaction.git
synced 2025-11-09 14:19:49 +00:00
feat(docs): add more endpoints
This commit is contained in:
parent
2f4edc08cf
commit
5b7999b6ea
7 changed files with 454 additions and 64 deletions
20
docs/content/docs/format_autocomplete.mdx
Normal file
20
docs/content/docs/format_autocomplete.mdx
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: format_autocomplete
|
||||||
|
full: true
|
||||||
|
_openapi:
|
||||||
|
method: POST
|
||||||
|
route: format_autocomplete
|
||||||
|
toc: []
|
||||||
|
structuredData:
|
||||||
|
headings: []
|
||||||
|
contents:
|
||||||
|
- content: |
|
||||||
|
Return a list of resource formats whose names contain a string.
|
||||||
|
---
|
||||||
|
|
||||||
|
{/* 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 resource formats whose names contain a string.
|
||||||
|
|
||||||
|
|
||||||
|
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"format_autocomplete","method":"post"}]} webhooks={[]} hasHead={false} />
|
||||||
20
docs/content/docs/group_autocomplete.mdx
Normal file
20
docs/content/docs/group_autocomplete.mdx
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: group_autocomplete
|
||||||
|
full: true
|
||||||
|
_openapi:
|
||||||
|
method: POST
|
||||||
|
route: group_autocomplete
|
||||||
|
toc: []
|
||||||
|
structuredData:
|
||||||
|
headings: []
|
||||||
|
contents:
|
||||||
|
- content: |
|
||||||
|
Return a list of group names that contain a string.
|
||||||
|
---
|
||||||
|
|
||||||
|
{/* 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 group names that contain a string.
|
||||||
|
|
||||||
|
|
||||||
|
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"group_autocomplete","method":"post"}]} webhooks={[]} hasHead={false} />
|
||||||
20
docs/content/docs/organization_autocomplete.mdx
Normal file
20
docs/content/docs/organization_autocomplete.mdx
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: organization_autocomplete
|
||||||
|
full: true
|
||||||
|
_openapi:
|
||||||
|
method: POST
|
||||||
|
route: organization_autocomplete
|
||||||
|
toc: []
|
||||||
|
structuredData:
|
||||||
|
headings: []
|
||||||
|
contents:
|
||||||
|
- content: |
|
||||||
|
Return a list of organization names that contain a string.
|
||||||
|
---
|
||||||
|
|
||||||
|
{/* 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 organization names that contain a string.
|
||||||
|
|
||||||
|
|
||||||
|
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"organization_autocomplete","method":"post"}]} webhooks={[]} hasHead={false} />
|
||||||
26
docs/content/docs/package_autocomplete.mdx
Normal file
26
docs/content/docs/package_autocomplete.mdx
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
title: package_autocomplete
|
||||||
|
full: true
|
||||||
|
_openapi:
|
||||||
|
method: POST
|
||||||
|
route: package_autocomplete
|
||||||
|
toc: []
|
||||||
|
structuredData:
|
||||||
|
headings: []
|
||||||
|
contents:
|
||||||
|
- content: >
|
||||||
|
Return a list of datasets (packages) that match a string.
|
||||||
|
|
||||||
|
|
||||||
|
Datasets with names or titles that contain the query string will be
|
||||||
|
returned.
|
||||||
|
---
|
||||||
|
|
||||||
|
{/* 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 datasets (packages) that match a string.
|
||||||
|
|
||||||
|
Datasets with names or titles that contain the query string will be returned.
|
||||||
|
|
||||||
|
|
||||||
|
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"package_autocomplete","method":"post"}]} webhooks={[]} hasHead={false} />
|
||||||
127
docs/content/docs/resource_search.mdx
Normal file
127
docs/content/docs/resource_search.mdx
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
---
|
||||||
|
title: resource_search
|
||||||
|
full: true
|
||||||
|
_openapi:
|
||||||
|
method: POST
|
||||||
|
route: resource_search
|
||||||
|
toc: []
|
||||||
|
structuredData:
|
||||||
|
headings: []
|
||||||
|
contents:
|
||||||
|
- content: >
|
||||||
|
Searches for resources in public Datasets satisfying the search
|
||||||
|
criteria.
|
||||||
|
|
||||||
|
|
||||||
|
It returns a dictionary with 2 fields: `count` and `results`. The
|
||||||
|
`count` field contains the total number of Resources found without the
|
||||||
|
limit or query parameters having an effect. The `results` field is a
|
||||||
|
list of dictized Resource objects.
|
||||||
|
|
||||||
|
|
||||||
|
The 'query' parameter is a required field. It is a string of the form
|
||||||
|
`{field}:{term}` or a list of strings, each of the same form. Within
|
||||||
|
each string, `{field}` is a field or extra field on the Resource
|
||||||
|
domain object.
|
||||||
|
|
||||||
|
|
||||||
|
If `{field}` is `"hash"`, then an attempt is made to match the
|
||||||
|
`{term}` as a *prefix* of the `Resource.hash` field.
|
||||||
|
|
||||||
|
|
||||||
|
If `{field}` is an extra field, then an attempt is made to match
|
||||||
|
against the extra fields stored against the Resource.
|
||||||
|
|
||||||
|
|
||||||
|
Note: The search is limited to search against extra fields declared in
|
||||||
|
the config setting `ckan.extra_resource_fields`.
|
||||||
|
|
||||||
|
|
||||||
|
Note: Due to a Resource's extra fields being stored as a json blob,
|
||||||
|
the match is made against the json string representation. As such,
|
||||||
|
false positives may occur:
|
||||||
|
|
||||||
|
|
||||||
|
If the search criteria is:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
query = "field1:term1"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Then a json blob with the string representation of:
|
||||||
|
|
||||||
|
|
||||||
|
```json
|
||||||
|
|
||||||
|
{"field1": "foo", "field2": "term1"}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
will match the search criteria! This is a known short-coming of this
|
||||||
|
approach.
|
||||||
|
|
||||||
|
|
||||||
|
All matches are made ignoring case; and apart from the `"hash"` field,
|
||||||
|
a term matches if it is a substring of the field’s value.
|
||||||
|
|
||||||
|
|
||||||
|
Finally, when specifying more than one search criteria, the criteria
|
||||||
|
are AND-ed together.
|
||||||
|
|
||||||
|
|
||||||
|
The `order` parameter is used to control the ordering of the results.
|
||||||
|
Currently only ordering one field is available, and in ascending order
|
||||||
|
only.
|
||||||
|
|
||||||
|
|
||||||
|
The context may contain a flag, *search_query*, which if True will
|
||||||
|
make this action behave as if being used by the internal search api.
|
||||||
|
ie - the results will not be dictized, and SearchErrors are thrown for
|
||||||
|
bad search queries (rather than ValidationErrors).
|
||||||
|
---
|
||||||
|
|
||||||
|
{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
|
||||||
|
|
||||||
|
Searches for resources in public Datasets satisfying the search criteria.
|
||||||
|
|
||||||
|
It returns a dictionary with 2 fields: `count` and `results`. The `count` field contains the total number of Resources found without the limit or query parameters having an effect. The `results` field is a list of dictized Resource objects.
|
||||||
|
|
||||||
|
The 'query' parameter is a required field. It is a string of the form `{field}:{term}` or a list of strings, each of the same form. Within each string, `{field}` is a field or extra field on the Resource domain object.
|
||||||
|
|
||||||
|
If `{field}` is `"hash"`, then an attempt is made to match the `{term}` as a *prefix* of the `Resource.hash` field.
|
||||||
|
|
||||||
|
If `{field}` is an extra field, then an attempt is made to match against the extra fields stored against the Resource.
|
||||||
|
|
||||||
|
Note: The search is limited to search against extra fields declared in the config setting `ckan.extra_resource_fields`.
|
||||||
|
|
||||||
|
Note: Due to a Resource's extra fields being stored as a json blob, the match is made against the json string representation. As such, false positives may occur:
|
||||||
|
|
||||||
|
If the search criteria is:
|
||||||
|
|
||||||
|
```
|
||||||
|
query = "field1:term1"
|
||||||
|
```
|
||||||
|
|
||||||
|
Then a json blob with the string representation of:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"field1": "foo", "field2": "term1"}
|
||||||
|
```
|
||||||
|
|
||||||
|
will match the search criteria! This is a known short-coming of this approach.
|
||||||
|
|
||||||
|
All matches are made ignoring case; and apart from the `"hash"` field, a term matches if it is a substring of the field’s value.
|
||||||
|
|
||||||
|
Finally, when specifying more than one search criteria, the criteria are AND-ed together.
|
||||||
|
|
||||||
|
The `order` parameter is used to control the ordering of the results. Currently only ordering one field is available, and in ascending order only.
|
||||||
|
|
||||||
|
The context may contain a flag, *search_query*, which if True will make this action behave as if being used by the internal search api. ie - the results will not be dictized, and SearchErrors are thrown for bad search queries (rather than ValidationErrors).
|
||||||
|
|
||||||
|
|
||||||
|
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"resource_search","method":"post"}]} webhooks={[]} hasHead={false} />
|
||||||
20
docs/content/docs/user_autocomplete.mdx
Normal file
20
docs/content/docs/user_autocomplete.mdx
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: user_autocomplete
|
||||||
|
full: true
|
||||||
|
_openapi:
|
||||||
|
method: POST
|
||||||
|
route: user_autocomplete
|
||||||
|
toc: []
|
||||||
|
structuredData:
|
||||||
|
headings: []
|
||||||
|
contents:
|
||||||
|
- content: |
|
||||||
|
Return a list of user names that contain a string.
|
||||||
|
---
|
||||||
|
|
||||||
|
{/* 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 user names that contain a string.
|
||||||
|
|
||||||
|
|
||||||
|
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"user_autocomplete","method":"post"}]} webhooks={[]} hasHead={false} />
|
||||||
|
|
@ -585,81 +585,105 @@ paths:
|
||||||
include_plugin_extras:
|
include_plugin_extras:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: "include the internal plugin extras object (sysadmin only, default: `False`)"
|
description: "include the internal plugin extras object (sysadmin only, default: `False`)"
|
||||||
status_show:
|
package_autocomplete:
|
||||||
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:
|
post:
|
||||||
operationId: package_list
|
operationId: package_autocomplete
|
||||||
summary: package_list
|
summary: package_autocomplete
|
||||||
description: This endpoint lists CKAN resources.
|
description: |
|
||||||
|
Return a list of datasets (packages) that match a string.
|
||||||
|
|
||||||
|
Datasets with names or titles that contain the query string will be returned.
|
||||||
requestBody:
|
requestBody:
|
||||||
required: false
|
required: false
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
# required:
|
|
||||||
# - project_uuid
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
q:
|
||||||
|
type: string
|
||||||
|
description: the string to search for
|
||||||
limit:
|
limit:
|
||||||
type: integer
|
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
|
# Original docs typo? Should this be max number of datasets?
|
||||||
offset:
|
description: "the maximum number of datasets to return (default: `10`)"
|
||||||
|
format_autocomplete:
|
||||||
|
post:
|
||||||
|
operationId: format_autocomplete
|
||||||
|
summary: format_autocomplete
|
||||||
|
description: |
|
||||||
|
Return a list of resource formats whose names contain a string.
|
||||||
|
requestBody:
|
||||||
|
required: false
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
q:
|
||||||
|
type: string
|
||||||
|
description: the string to search for
|
||||||
|
limit:
|
||||||
type: integer
|
type: integer
|
||||||
description: when limit is given, the offset to start returning packages from
|
description: "the maximum number of resource formats to return (default: `5`)"
|
||||||
x-codeSamples:
|
user_autocomplete:
|
||||||
- lang: rust
|
post:
|
||||||
label: Rust SDK (ckanaction) example
|
operationId: user_autocomplete
|
||||||
source: |
|
summary: user_autocomplete
|
||||||
use dotenvy::dotenv;
|
description: |
|
||||||
|
Return a list of user names that contain a string.
|
||||||
#[tokio::main]
|
requestBody:
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
required: false
|
||||||
// Load environment variables from .env file
|
content:
|
||||||
dotenv()?;
|
application/json:
|
||||||
|
schema:
|
||||||
// Initialize and build CKAN struct
|
type: object
|
||||||
let ckan = ckanaction::CKAN::builder()
|
properties:
|
||||||
.url("http://localhost:5000")
|
q:
|
||||||
.token(dotenvy::var("CKAN_API_TOKEN")?)
|
type: string
|
||||||
.build();
|
description: the string to search for
|
||||||
|
limit:
|
||||||
// Send request to /package_list and print output
|
type: integer
|
||||||
let result = ckan.package_list()
|
description: "the maximum number of user names to return (default: `20`)"
|
||||||
.limit(5) // <-- This is an optional parameter you can remove
|
group_autocomplete:
|
||||||
.call()
|
post:
|
||||||
.await?;
|
operationId: group_autocomplete
|
||||||
println!("{result:#?}");
|
summary: group_autocomplete
|
||||||
|
description: |
|
||||||
Ok(())
|
Return a list of group names that contain a string.
|
||||||
}
|
requestBody:
|
||||||
'package_search':
|
required: false
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
q:
|
||||||
|
type: string
|
||||||
|
description: the string to search for
|
||||||
|
limit:
|
||||||
|
type: integer
|
||||||
|
description: "the maximum number of groups to return (default: `20`)"
|
||||||
|
organization_autocomplete:
|
||||||
|
post:
|
||||||
|
operationId: organization_autocomplete
|
||||||
|
summary: organization_autocomplete
|
||||||
|
description: |
|
||||||
|
Return a list of organization names that contain a string.
|
||||||
|
requestBody:
|
||||||
|
required: false
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
q:
|
||||||
|
type: string
|
||||||
|
description: the string to search for
|
||||||
|
limit:
|
||||||
|
type: integer
|
||||||
|
description: "the maximum number of organizations to return (default: `20`)"
|
||||||
|
package_search:
|
||||||
post:
|
post:
|
||||||
operationId: package_search
|
operationId: package_search
|
||||||
summary: package_search
|
summary: package_search
|
||||||
|
|
@ -766,5 +790,138 @@ paths:
|
||||||
.await?;
|
.await?;
|
||||||
println!("{result:#?}");
|
println!("{result:#?}");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
resource_search:
|
||||||
|
post:
|
||||||
|
operationId: resource_search
|
||||||
|
summary: resource_search
|
||||||
|
description: |
|
||||||
|
Searches for resources in public Datasets satisfying the search criteria.
|
||||||
|
|
||||||
|
It returns a dictionary with 2 fields: `count` and `results`. The `count` field contains the total number of Resources found without the limit or query parameters having an effect. The `results` field is a list of dictized Resource objects.
|
||||||
|
|
||||||
|
The 'query' parameter is a required field. It is a string of the form `{field}:{term}` or a list of strings, each of the same form. Within each string, `{field}` is a field or extra field on the Resource domain object.
|
||||||
|
|
||||||
|
If `{field}` is `"hash"`, then an attempt is made to match the `{term}` as a *prefix* of the `Resource.hash` field.
|
||||||
|
|
||||||
|
If `{field}` is an extra field, then an attempt is made to match against the extra fields stored against the Resource.
|
||||||
|
|
||||||
|
Note: The search is limited to search against extra fields declared in the config setting `ckan.extra_resource_fields`.
|
||||||
|
|
||||||
|
Note: Due to a Resource's extra fields being stored as a json blob, the match is made against the json string representation. As such, false positives may occur:
|
||||||
|
|
||||||
|
If the search criteria is:
|
||||||
|
|
||||||
|
```
|
||||||
|
query = "field1:term1"
|
||||||
|
```
|
||||||
|
|
||||||
|
Then a json blob with the string representation of:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"field1": "foo", "field2": "term1"}
|
||||||
|
```
|
||||||
|
|
||||||
|
will match the search criteria! This is a known short-coming of this approach.
|
||||||
|
|
||||||
|
All matches are made ignoring case; and apart from the `"hash"` field, a term matches if it is a substring of the field’s value.
|
||||||
|
|
||||||
|
Finally, when specifying more than one search criteria, the criteria are AND-ed together.
|
||||||
|
|
||||||
|
The `order` parameter is used to control the ordering of the results. Currently only ordering one field is available, and in ascending order only.
|
||||||
|
|
||||||
|
The context may contain a flag, *search_query*, which if True will make this action behave as if being used by the internal search api. ie - the results will not be dictized, and SearchErrors are thrown for bad search queries (rather than ValidationErrors).
|
||||||
|
requestBody:
|
||||||
|
required: false
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
query:
|
||||||
|
type: string
|
||||||
|
description: the search criteria
|
||||||
|
order_by:
|
||||||
|
type: string
|
||||||
|
description: a field on the Resource model that orders the results
|
||||||
|
offset:
|
||||||
|
type: integer
|
||||||
|
description: apply an offset to the query
|
||||||
|
limit:
|
||||||
|
type: integer
|
||||||
|
description: apply a limit to the query
|
||||||
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue