gov

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHost is an immutable default host of government data registry.
	DefaultHost = "https://data.gov.ua"
	// DefaultBasePath is an immutable base path of government data registry.
	DefaultBasePath = "/api/3/action"
)
View Source
const TimeFormat = "2006-01-02T15:04:05.999999"

TimeFormat is default time format of the government website.

Variables

View Source
var (
	// BaseHost equals to DefaultHost by default, it is mutable.
	BaseHost = DefaultHost
	// BasePath equals to DefaultBasePath by default, it is mutable.
	BasePath = DefaultBasePath
)

Functions

This section is empty.

Types

type Client

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

Client is core http client struct.

func NewClient

func NewClient() *Client

NewClient creates new http client with timeout equal to 5 seconds.

func (*Client) Package

func (c *Client) Package(id string) (*Package, error)

Package returns detailed information about package from government registry. Makes a simple HTTP Get request under the hood.

type Group

type Group struct {
	DisplayName     string `json:"display_name"`
	Description     string `json:"description"`
	ImageDisplayURL string `json:"image_display_url"`
	Title           string `json:"title"`
	ID              string `json:"id"`
	Name            string `json:"name"`
}

Group is a REST object.

type Package

type Package struct {
	LicenseTitle                   string     `json:"license_title"`
	Maintainer                     string     `json:"maintainer"`
	TagString                      string     `json:"tag_string"`
	PurposeOfCollectingInformation string     `json:"purpose_of_collecting_information"`
	Private                        bool       `json:"private"`
	MaintainerEmail                string     `json:"maintainer_email"`
	NumTags                        int        `json:"num_tags"`
	UpdateFrequency                string     `json:"update_frequency"`
	ID                             string     `json:"id"`
	MetadataCreated                string     `json:"metadata_created"`
	MetadataModified               string     `json:"metadata_modified"`
	Author                         string     `json:"author"`
	AuthorEmail                    string     `json:"author_email"`
	State                          string     `json:"state"`
	Version                        string     `json:"version"`
	IsDataPackage                  string     `json:"is_datapackage"`
	CreatorUserID                  string     `json:"creator_user_id"`
	Type                           string     `json:"type"`
	Resources                      []Resource `json:"resources"`
	NumResources                   int        `json:"num_resources"`
	Tags                           []Tag      `json:"tags"`
	Language                       string     `json:"language"`
	Groups                         []Group    `json:"groups"`
	LicenseID                      string     `json:"license_id"`
	Name                           string     `json:"name"`
	IsOpen                         bool       `json:"isopen"`
	Notes                          string     `json:"notes"`
	OwnerOrg                       string     `json:"owner_org"`
	LicenseURL                     string     `json:"license_url"`
	Title                          string     `json:"title"`
	RevisionID                     string     `json:"revision_id"`
}

Package is a REST object.

type Resource

type Resource struct {
	PackageID       string `json:"package_id"`
	DataStoreActive bool   `json:"datastore_active"`
	ID              string `json:"id"`
	Size            int    `json:"size"`
	FileHashSum     string `json:"file_hash_sum"`
	State           string `json:"state"`
	Hash            string `json:"hash"`
	Description     string `json:"description"`
	Format          string `json:"format"`
	LastModified    Time   `json:"last_modified"`
	URLType         string `json:"url_type"`
	MIMEType        string `json:"mimetype"`
	Name            string `json:"name"`
	Created         string `json:"created"`
	URL             string `json:"url"`
	Position        int    `json:"position"`
	RevisionID      string `json:"revision_id"`
}

Resource is a REST object.

type Response

type Response struct {
	Help    string          `json:"help"`
	Success bool            `json:"success"`
	Result  json.RawMessage `json:"result"`
}

Response from data registry has always same base payload.

type Sorter added in v0.0.21

type Sorter []Resource

Sorter sorts array by LastModified field.

func (Sorter) Len added in v0.0.21

func (e Sorter) Len() int

func (Sorter) Less added in v0.0.21

func (e Sorter) Less(i, j int) bool

func (Sorter) Swap added in v0.0.21

func (e Sorter) Swap(i, j int)

type Tag

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

Tag is a REST object.

type Time

type Time struct {
	time.Time
}

Time is almost the same as time.Time, but has behaves differently on JSON serialization.

func (*Time) MarshalJSON

func (ct *Time) MarshalJSON() ([]byte, error)

MarshalJSON overrides JSON serialization.

func (*Time) UnmarshalJSON

func (ct *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON overrides JSON deserialization.

Jump to

Keyboard shortcuts

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