ckan_api_client.objects

Base objects

Classes to represent / validate Ckan objects.

class ckan_api_client.objects.base.BaseField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: object

Pseudo-descriptor, accepting field names along with instance, to allow better retrieving data for the instance itself.

Warning

Beware that fields shouldn’t carry state of their own, a part from the one used for generic field configuration, as they are shared between instances.

default = None
is_key = False
get(instance, name)[source]

Get the value for the field from the main instace, by looking at the first found in:

  • the updated value
  • the initial value
  • the default value
get_default()[source]
validate(instance, name, value)[source]

The validate method should be the (updated) value to be used as the field value, or raise an exception in case it is not acceptable at all.

set_initial(instance, name, value)[source]

Set the initial value for a field

set(instance, name, value)[source]

Set the modified value for a field

delete(instance, name)[source]

Delete the modified value for a field (logically restores the original one)

serialize(instance, name)[source]

Returns the “serialized” (json-encodable) version of the object.

is_modified(instance, name)[source]

Check whether this field has been modified on the main instance.

is_equivalent(instance, name, other, ignore_key=True)[source]
class ckan_api_client.objects.base.BaseObject(values=None)[source]

Bases: object

Base for the other objects, dispatching get/set/deletes to BaseField instances, if available.

classmethod from_dict(data)[source]
set_initial(values)[source]

Set initial values for all fields

to_dict()[source]
serialize()[source]

Create a serializable representation of the object.

iter_fields()[source]

Iterate over fields in this objects, yielding (name, field) pairs.

is_equivalent(other, ignore_key=True)[source]

Equivalency check between objects. Will make sure that values in all the non-key fields match.

Parameters:
  • other – other object to compare
  • ignore_key – if set to True (the default), it will ignore “key” fields during comparison
compare(other)[source]

Compare differences between this object and another

is_modified()[source]

The object is modified if any of its fields reports itself as modified.

Base fields

class ckan_api_client.objects.fields.StringField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: ckan_api_client.objects.base.BaseField

default = None
validate(instance, name, value)[source]
class ckan_api_client.objects.fields.ListField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: ckan_api_client.objects.fields.MutableFieldMixin, ckan_api_client.objects.base.BaseField

static default()
validate(instance, name, value)[source]
class ckan_api_client.objects.fields.DictField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: ckan_api_client.objects.fields.MutableFieldMixin, ckan_api_client.objects.base.BaseField

static default()
validate(instance, name, value)[source]
class ckan_api_client.objects.fields.GroupsField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: ckan_api_client.objects.fields.SetField

validate(instance, name, value)[source]
class ckan_api_client.objects.fields.ExtrasField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: ckan_api_client.objects.fields.DictField

validate(instance, name, value)[source]
is_equivalent(instance, name, other, ignore_key=True)[source]

Ckan dataset / resource

class ckan_api_client.objects.ckan_dataset.ResourcesField(default=<object object at 0x7ff97d4b5bd0>, is_key=<object object at 0x7ff97d4b5bd0>, required=False)[source]

Bases: ckan_api_client.objects.fields.ListField

The ResourcesField should behave pretty much as a list field, but will keep track of changes, and make sure all elements are CkanResources.

validate(instance, name, value)[source]
serialize(instance, name)[source]
is_equivalent(instance, name, other, ignore_key=True)[source]
class ckan_api_client.objects.ckan_dataset.CkanDataset(values=None)[source]

Bases: ckan_api_client.objects.base.BaseObject

id = StringField(default=None, is_key=True, required=False)
name = StringField(default=None, is_key=False, required=False)
title = StringField(default=None, is_key=False, required=False)
author = StringField(default='', is_key=False, required=False)
author_email = StringField(default='', is_key=False, required=False)
license_id = StringField(default='', is_key=False, required=False)
maintainer = StringField(default='', is_key=False, required=False)
maintainer_email = StringField(default='', is_key=False, required=False)
notes = StringField(default='', is_key=False, required=False)
owner_org = StringField(default='', is_key=False, required=False)
private = BoolField(default=False, is_key=False, required=False)
state = StringField(default='active', is_key=False, required=False)
type = StringField(default='dataset', is_key=False, required=False)
url = StringField(default='', is_key=False, required=False)
extras = ExtrasField(default=<function <lambda> at 0x7ff97d1cf410>, is_key=False, required=False)
groups = GroupsField(default=<function <lambda> at 0x7ff97d1cf2a8>, is_key=False, required=False)
resources = ResourcesField(default=<function <lambda> at 0x7ff97d1cf1b8>, is_key=False, required=False)
tags = SetField(default=<function <lambda> at 0x7ff97d1cf2a8>, is_key=False, required=False)
class ckan_api_client.objects.ckan_dataset.CkanResource(values=None)[source]

Bases: ckan_api_client.objects.base.BaseObject

id = StringField(default=None, is_key=True, required=False)
description = StringField(default='', is_key=False, required=False)
format = StringField(default='', is_key=False, required=False)
mimetype = StringField(default=None, is_key=False, required=False)
mimetype_inner = StringField(default=None, is_key=False, required=False)
name = StringField(default='', is_key=False, required=False)
resource_type = StringField(default='', is_key=False, required=False)
size = StringField(default=None, is_key=False, required=False)
url = StringField(default='', is_key=False, required=False)
url_type = StringField(default=None, is_key=False, required=False)

Ckan group

class ckan_api_client.objects.ckan_group.CkanGroup(values=None)[source]

Bases: ckan_api_client.objects.base.BaseObject

id = StringField(default=None, is_key=True, required=False)
name = StringField(default=None, is_key=False, required=False)
title = StringField(default='', is_key=False, required=False)
approval_status = StringField(default='approved', is_key=False, required=False)
description = StringField(default='', is_key=False, required=False)
image_url = StringField(default='', is_key=False, required=False)
is_organization = BoolField(default=False, is_key=False, required=False)
state = StringField(default='active', is_key=False, required=False)
type = StringField(default='group', is_key=False, required=False)
extras = ExtrasField(default=<function <lambda> at 0x7ff97d1cf410>, is_key=False, required=False)
groups = GroupsField(default=<function <lambda> at 0x7ff97d1cf2a8>, is_key=False, required=False)
tags = ListField(default=<function <lambda> at 0x7ff97d1cf1b8>, is_key=False, required=False)

Ckan organization

class ckan_api_client.objects.ckan_organization.CkanOrganization(values=None)[source]

Bases: ckan_api_client.objects.base.BaseObject

id = StringField(default=None, is_key=True, required=False)
name = StringField(default=None, is_key=False, required=False)
title = StringField(default='', is_key=False, required=False)
approval_status = StringField(default='approved', is_key=False, required=False)
description = StringField(default='', is_key=False, required=False)
image_url = StringField(default='', is_key=False, required=False)
is_organization = BoolField(default=True, is_key=False, required=False)
state = StringField(default='active', is_key=False, required=False)
type = StringField(default='organization', is_key=False, required=False)
extras = ExtrasField(default=<function <lambda> at 0x7ff97d1cf410>, is_key=False, required=False)
groups = GroupsField(default=<function <lambda> at 0x7ff97d1cf2a8>, is_key=False, required=False)
tags = ListField(default=<function <lambda> at 0x7ff97d1cf1b8>, is_key=False, required=False)