High-level¶
-
class
ckan_api_client.high_level.
CkanHighlevelClient
(base_url, api_key=None)[source]¶ High-level client, handling CRUD of objects.
This class only returns / handles CkanObjects, to make sure we are handling consistent data (they have validators in place)
-
get_dataset
(id, allow_deleted=False)[source]¶ Get a specific dataset, by id
Note
Since the Ckan API use both ids and names as keys, both
get_dataset()
andget_dataset_by_name()
will perform the exact same request in the background.The difference is only in the high-level handling: the function will check whether the expected id has the correct value, and raise an HTTPError(404, ..) otherwise..
Parameters: - id (str) – the dataset id
- allow_deleted – Whether to return even logically deleted objects.
If set to
False
(the default) will raise aHTTPError(404, ..)
ifstate != 'active'
Return type:
-
get_dataset_by_name
(name, allow_deleted=False)[source]¶ Get a specific dataset, by name
Note
See note on
get_dataset()
Parameters: - name (str) – the dataset name
- allow_deleted – Whether to return even logically deleted objects.
If set to
False
(the default) will raise aHTTPError(404, ..)
ifstate != 'active'
Return type:
-
save_dataset
(dataset)[source]¶ If the dataset already has an id, call
update_dataset()
, otherwise, callcreate_dataset()
.Returns: as returned by the called function. Return type: CkanDataset
-
create_dataset
(dataset)[source]¶ Create a dataset
Return type: CkanDataset
-
update_dataset
(dataset)[source]¶ Update a dataset
Return type: CkanDataset
-
get_organization
(id, allow_deleted=False)[source]¶ Get organization, by id.
Note
See note on
get_dataset()
Parameters: - id (str) – the organization id
- allow_deleted – Whether to return even logically deleted objects.
If set to
False
(the default) will raise aHTTPError(404, ..)
ifstate != 'active'
Return type:
-
get_organization_by_name
(name, allow_deleted=False)[source]¶ Get organization by name.
Note
See note on
get_dataset()
Parameters: - name (str) – the organization name
- allow_deleted – Whether to return even logically deleted objects.
If set to
False
(the default) will raise aHTTPError(404, ..)
ifstate != 'active'
Return type:
-
create_organization
(organization)[source]¶ Create an organization
Return type: CkanOrganization
-
update_organization
(organization)[source]¶ Return type: CkanOrganization
-
get_group
(id, allow_deleted=False)[source]¶ Get group, by id.
Note
See note on
get_dataset()
Parameters: - id (str) – the group id
- allow_deleted – Whether to return even logically deleted objects.
If set to
False
(the default) will raise aHTTPError(404, ..)
ifstate != 'active'
Return type:
-
get_group_by_name
(name, allow_deleted=False)[source]¶ Get group by name.
Note
See note on
get_dataset()
Parameters: - name (str) – the group name
- allow_deleted – Whether to return even logically deleted objects.
If set to
False
(the default) will raise aHTTPError(404, ..)
ifstate != 'active'
Return type:
-