ckan

package
v0.0.0-...-e9a8072 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ckan

type Ckan struct {
	// contains filtered or unexported fields
}

func New

func New(base, token string) (*Ckan, error)

func (*Ckan) CreatePackage

func (c *Ckan) CreatePackage(ctx context.Context, pkg Package) (Package, error)

func (*Ckan) CreateResource

func (c *Ckan) CreateResource(ctx context.Context, resource Resource) (Resource, error)

func (*Ckan) PatchPackage

func (c *Ckan) PatchPackage(ctx context.Context, pkg Package) (Package, error)

func (*Ckan) PatchResource

func (c *Ckan) PatchResource(ctx context.Context, resource Resource) (Resource, error)

func (*Ckan) ReorderResource

func (c *Ckan) ReorderResource(ctx context.Context, pkgID string, resourceIDs []string) error

func (*Ckan) SavePackage

func (c *Ckan) SavePackage(ctx context.Context, pkg Package) (Package, error)

func (*Ckan) SaveResource

func (c *Ckan) SaveResource(ctx context.Context, resource Resource) (Resource, error)

func (*Ckan) SearchPackageByName

func (c *Ckan) SearchPackageByName(ctx context.Context, name string) (List[Package], error)

func (*Ckan) ShowPackage

func (c *Ckan) ShowPackage(ctx context.Context, id string) (Package, error)

func (*Ckan) UploadResource

func (c *Ckan) UploadResource(ctx context.Context, resource Resource, filename string, data []byte) (Resource, error)

type Error

type Error struct {
	Message string `json:"message,omitempty"`
	Type    string `json:"__type,omitempty"`
}

type Interface

type Interface interface {
	ShowPackage(ctx context.Context, id string) (Package, error)
	SearchPackageByName(ctx context.Context, name string) (List[Package], error)
	CreatePackage(ctx context.Context, pkg Package) (Package, error)
	PatchPackage(ctx context.Context, pkg Package) (Package, error)
	SavePackage(ctx context.Context, pkg Package) (Package, error)
	CreateResource(ctx context.Context, resource Resource) (Resource, error)
	PatchResource(ctx context.Context, resource Resource) (Resource, error)
	UploadResource(ctx context.Context, resource Resource, filename string, data []byte) (Resource, error)
	SaveResource(ctx context.Context, resource Resource) (Resource, error)
	ReorderResource(ctx context.Context, pkgID string, resourceIDs []string) error
}

type List

type List[T any] struct {
	Count   int    `json:"count,omitempty"`
	Sort    string `json:"sort,omitempty"`
	Results []T    `json:"results,omitempty"`
}

func (List[T]) IsEmpty

func (l List[T]) IsEmpty() bool

type Mock

type Mock struct {
	// contains filtered or unexported fields
}

func NewMock

func NewMock(org string, packages []Package, resources []Resource) *Mock

func (*Mock) CreatePackage

func (c *Mock) CreatePackage(ctx context.Context, pkg Package) (Package, error)

func (*Mock) CreateResource

func (c *Mock) CreateResource(ctx context.Context, resource Resource) (Resource, error)

func (*Mock) PatchPackage

func (c *Mock) PatchPackage(ctx context.Context, pkg Package) (Package, error)

func (*Mock) PatchResource

func (c *Mock) PatchResource(ctx context.Context, resource Resource) (Resource, error)

func (*Mock) ReorderResource

func (c *Mock) ReorderResource(ctx context.Context, pkgID string, resourceIDs []string) error

func (*Mock) SavePackage

func (c *Mock) SavePackage(ctx context.Context, pkg Package) (Package, error)

func (*Mock) SaveResource

func (c *Mock) SaveResource(ctx context.Context, resource Resource) (Resource, error)

func (*Mock) SearchPackageByName

func (c *Mock) SearchPackageByName(ctx context.Context, name string) (List[Package], error)

func (*Mock) ShowPackage

func (c *Mock) ShowPackage(ctx context.Context, id string) (Package, error)

func (*Mock) UploadResource

func (c *Mock) UploadResource(ctx context.Context, resource Resource, filename string, data []byte) (Resource, error)

type Package

type Package struct {
	ID string `json:"id,omitempty"`
	// The name of the new dataset, must be between 2 and 100 characters long and
	// contain only lowercase alphanumeric characters, - and _, e.g. 'warandpeace'
	Name string `json:"name,omitempty"`
	// The title of the dataset (optional, default: same as name)
	Title string `json:"title,omitempty"`
	// If True creates a private dataset
	Private *bool `json:"private,omitempty"`
	// The name of the dataset's author (optional)
	Author string `json:"author,omitempty"`
	// The email address of the dataset's author (optional)
	AuthorEmail string `json:"author_email,omitempty"`
	// The name of the dataset's maintainer (optional)
	Maintainer string `json:"maintainer,omitempty"`
	// The email address of the dataset's maintainer (optional)
	MaintainerEmail string `json:"maintainer_email,omitempty"`
	// The id of the dataset's license, see `~ckan.logic.action.get.license_list` for available values (optional)
	LicenseID string `json:"license_id,omitempty"`
	// A description of the dataset (optional)
	Notes string `json:"notes,omitempty"`
	// A URL for the dataset's source (optional)
	URL string `json:"url,omitempty"`
	// (optional)
	Version string `json:"version,omitempty"`
	// The current state of the dataset, e.g. 'active' or
	// 'deleted', only active datasets show up in search results and
	// other lists of datasets, this parameter will be ignored if you are not
	// authorized to change the state of the dataset (optional, default:
	// 'active')
	State string `json:"state,omitempty"`
	// The type of the dataset (optional),
	// `~ckan.plugins.interfaces.IDatasetForm` plugins
	// associate themselves with different dataset types and provide custom
	// dataset handling behaviour for these types
	Type string `json:"type,omitempty"`
	// The dataset's resources, see
	// `resource_create` for the format of resource dictionaries (optional)
	Resources []Resource `json:"resources,omitempty"`
	// The dataset's tags, see `tag_create` for the format
	// of tag dictionaries (optional)
	Tags []Tag `json:"tags,omitempty"`

	// The id of the dataset's owning organization, see
	// `~ckan.logic.action.get.organization_list` or
	// `~ckan.logic.action.get.organization_list_for_user` for
	// available values. This parameter can be made optional if the config
	// option `ckan.auth.create_unowned_dataset` is set to True.
	// Note: name is also available instead of ID on creating a package
	OwnerOrg string `json:"owner_org,omitempty"`

	// geospatialjp
	Restriction      string `json:"restriction,omitempty"`
	LicenseAgreement string `json:"license_agreement,omitempty"`
	RegisterdDate    string `json:"registerd_date,omitempty"`
	Fee              string `json:"fee,omitempty"`
	Charge           string `json:"charge,omitempty"`
	Area             string `json:"area,omitempty"`
	Quality          string `json:"quality,omitempty"`
	Emergency        string `json:"emergency,omitempty"`
	LicenseTitle     string `json:"license_title,omitempty"`
	ThumbnailURL     string `json:"thumbnail_url,omitempty"`
	LicenseURL       string `json:"license_url,omitempty"`
	Spatial          string `json:"spatial,omitempty"`
}

type Resource

type Resource struct {
	ID string `json:"id,omitempty"`
	// id of package that the resource should be added to.
	PackageID string `json:"package_id,omitempty"`
	// url of resource
	URL              string `json:"url,omitempty"`
	URLType          string `json:"url_type,omitempty"`
	RevisionID       string `json:"revision_id,omitempty"`
	Description      string `json:"description,omitempty"`
	Format           string `json:"format,omitempty"`
	Hash             string `json:"hash,omitempty"`
	Name             string `json:"name,omitempty"`
	ResourceType     string `json:"resource_type,omitempty"`
	Mimetype         string `json:"mimetype,omitempty"`
	MimetypeInner    string `json:"mimetype_inner,omitempty"`
	CacheUrl         string `json:"cache_url,omitempty"`
	Size             int    `json:"size,omitempty"`
	Created          string `json:"created,omitempty"`
	LastModified     string `json:"last_modified,omitempty"`
	CacheLastUpdated string `json:"cache_last_updated,omitempty"`
}

func (Resource) WriteMultipart

func (r Resource) WriteMultipart(m *multipart.Writer) error

type Response

type Response[T any] struct {
	Help    string `json:"help,omitempty"`
	Success bool   `json:"success,omitempty"`
	Error   *Error `json:"error,omitempty"`
	Result  T      `json:"result,omitempty"`
}

type Tag

type Tag struct {
	ID           string `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	DisplayName  string `json:"display_name,omitempty"`
	State        string `json:"state,omitempty"`
	VocabularyID string `json:"vocabulary_id,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL