api

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package api holds an API client for Wikimedia Enterprise API(s).

Index

Constants

View Source
const (
	EventTypeUpdate           = "update"
	EventTypeDelete           = "delete"
	EventTypeVisibilityChange = "visibility-change"
)

Type of events supported by the system.

View Source
const DateFormat = "2006-01-02"

DateFormat is the date format used for the API.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

API interface tha encapsulates the whole functionality of the client. Can be used with composition in unit testing.

func NewClient

func NewClient(ops ...func(clt *Client)) API

NewClient returns a new instance of the Client that implements the API interface. The function takes in optional functional options that allow the caller to configure the client with custom settings.

type AccessTokenSetter

type AccessTokenSetter interface {
	SetAccessToken(tkn string)
}

AccessTokenSetter is an interface for setting an access token.

type AllReader

type AllReader interface {
	ReadAll(ctx context.Context, rdr io.Reader, cbk ReadCallback) error
}

AllReader is an interface for reading all the contents of a reader with a callback function.

type Article

type Article struct {
	// Name is the name of the article.
	Name string `json:"name,omitempty"`

	// Abstract is a summary of the article.
	Abstract string `json:"abstract,omitempty"`

	// Identifier is a unique identifier for the article (in scope of a single project).
	Identifier int `json:"identifier,omitempty"`

	// DateCreated is the date and time the article was created.
	DateCreated *time.Time `json:"date_created,omitempty"`

	// DateModified is the date and time the article was last modified.
	DateModified *time.Time `json:"date_modified,omitempty"`

	// DatePreviouslyModified is the date and time the article was previously modified.
	DatePreviouslyModified *time.Time `json:"date_previously_modified,omitempty"`

	// Protection specifies the access restrictions for the article.
	Protection []*Protection `json:"protection,omitempty"`

	// Version is the metadata about the version of the article.
	Version *Version `json:"version,omitempty"`

	// PreviousVersion is the metadata about the previous version of the article.
	PreviousVersion *PreviousVersion `json:"previous_version,omitempty"`

	// URL is the URL of the article.
	URL string `json:"url,omitempty"`

	// WatchersCount is the number of watchers for the article.
	WatchersCount int `json:"watchers_count,omitempty"`

	// Namespace is the namespace of the article.
	Namespace *Namespace `json:"namespace,omitempty"`

	// InLanguage is the language of the article.
	InLanguage *Language `json:"in_language,omitempty"`

	// MainEntity is the main (Wikidata) entity of the article.
	MainEntity *Entity `json:"main_entity,omitempty"`

	// AdditionalEntities are the additional (Wikidata) entities used in the article.
	AdditionalEntities []*Entity `json:"additional_entities,omitempty"`

	// Categories are the categories of the article.
	Categories []*Category `json:"categories,omitempty"`

	// Templates are the templates used in the article.
	Templates []*Template `json:"templates,omitempty"`

	// Redirects are the redirects for the article.
	Redirects []*Redirect `json:"redirects,omitempty"`

	// IsPartOf is the project that the article belongs to.
	IsPartOf *Project `json:"is_part_of,omitempty"`

	// ArticleBody is the body of the article.
	ArticleBody *ArticleBody `json:"article_body,omitempty"`

	// License specifies the license for the article.
	License []*License `json:"license,omitempty"`

	// Visibility specifies the visibility of the article.
	Visibility *Visibility `json:"visibility,omitempty"`

	// Event specifies the event related to the article.
	Event *Event `json:"event,omitempty"`

	// Image specifies the image related to the article.
	Image *Image `json:"image,omitempty"`
}

Article schema for wikipedia article. Tries to compliant with https://schema.org/Article.

type ArticleBody

type ArticleBody struct {
	// HTML of the article, as a Parsoid HTML.
	// See the specification at https://www.mediawiki.org/wiki/Specs/HTML/2.8.0.
	HTML string `json:"html,omitempty"`

	// WikiText of the article.
	// For more information visit https://www.mediawiki.org/wiki/Wikitext.
	// Specification: https://www.mediawiki.org/wiki/Specs/wikitext/1.0.0.
	WikiText string `json:"wikitext,omitempty"`
}

ArticleBody schema for article content. Not fully compliant with https://schema.org/articleBody, we need multiple article bodies.

type ArticlesGetter

type ArticlesGetter interface {
	GetArticles(ctx context.Context, nme string, req *Request) ([]*Article, error)
}

ArticlesGetter is an interface for getting a lits of articles by name.

type ArticlesStreamer

type ArticlesStreamer interface {
	StreamArticles(ctx context.Context, req *Request, cbk ReadCallback) error
}

ArticlesStreamer is an interface for getting all the article changes in realtime.

type Batch

type Batch struct {
	// Unique identifier for the batch.
	Identifier string `json:"identifier,omitempty"`

	// Version of the batch as a md5 checksum.
	Version string `json:"version,omitempty"`

	// DateModified date and time the batch was last modified.
	DateModified *time.Time `json:"date_modified,omitempty"`

	// IsPartOf the project that this batch belongs to.
	IsPartOf *Project `json:"is_part_of,omitempty"`

	// InLanguage the language of the contents of the batch.
	InLanguage *Language `json:"in_language,omitempty"`

	// Namespace of the batch.
	Namespace *Namespace `json:"namespace,omitempty"`

	// Size of the batch.
	Size *Size `json:"size,omitempty"`
}

Batch represents metadata for the realtime batch in WME API.

type BatchDownloader

type BatchDownloader interface {
	DownloadBatch(ctx context.Context, dte *time.Time, idr string, wsk io.WriteSeeker) error
}

BatchDownloader is an interface that downloads a realtime batch `tar.gz` by ID file from the API.

type BatchGetter

type BatchGetter interface {
	GetBatch(ctx context.Context, dte *time.Time, idr string, req *Request) (*Batch, error)
}

BatchGetter is an interface that retrieves a realtime batch by ID from the API.

type BatchHeader

type BatchHeader interface {
	HeadBatch(ctx context.Context, dte *time.Time, idr string) (*Headers, error)
}

BatchHeader is an interface that retrieves the header of a realtime batch by ID from the API.

type BatchReader

type BatchReader interface {
	ReadBatch(ctx context.Context, dte *time.Time, idr string, cbk ReadCallback) error
}

BatchReader is an interface that reads a realtime batch data by ID from the API.

type BatchesGetter

type BatchesGetter interface {
	GetBatches(ctx context.Context, dte *time.Time, req *Request) ([]*Batch, error)
}

BatchesGetter is an interface that retrieves batches from the API.

type Category

type Category struct {
	// Name is the name of the category.
	Name string `json:"name,omitempty"`

	// URL is the URL of the category.
	URL string `json:"url,omitempty"`
}

Category article category representation.

type Client

type Client struct {
	// HTTPClient is the HTTP client used to send requests.
	HTTPClient *http.Client

	// UserAgent is the user-agent header value sent with each request.
	UserAgent string

	// BaseUrl is the base URL for all API requests.
	BaseURL string

	// RealtimeURL is the base URL for all realtime API requests.
	RealtimeURL string

	// AccessToken is the access token used to authenticate requests.
	AccessToken string

	// DownloadMinChunkSize is the minimum chunk size used for downloading resources.
	DownloadMinChunkSize int

	// DownloadChunkSize is the chunk size used for downloading resources.
	DownloadChunkSize int

	// DownloadConcurrency is the number of simultaneous downloads allowed.
	DownloadConcurrency int

	// ScannerBufferSize is the buffer size for the scanner when it reads from the API.
	ScannerBufferSize int
}

Client is a struct that represents an HTTP client used to interact with the API.

func (*Client) DownloadBatch

func (c *Client) DownloadBatch(ctx context.Context, dte *time.Time, idr string, wsk io.WriteSeeker) error

DownloadBatch downloads the contents of a single batch for a specific date and ID, and writes the data to the specified WriteSeeker.

func (*Client) DownloadSnapshot

func (c *Client) DownloadSnapshot(ctx context.Context, idr string, wsk io.WriteSeeker) error

DownloadSnapshot downloads the contents of a single snapshot for a specific ID, and writes the data to the specified WriteSeeker.

func (*Client) GetArticles

func (c *Client) GetArticles(ctx context.Context, nme string, req *Request) ([]*Article, error)

GetArticles retrieves articles from the API based on the given name and request parameters.

func (*Client) GetBatch

func (c *Client) GetBatch(ctx context.Context, dte *time.Time, idr string, req *Request) (*Batch, error)

GetBatch retrieves a single batch for a specific date and ID, and returns an error if any.

func (*Client) GetBatches

func (c *Client) GetBatches(ctx context.Context, dte *time.Time, req *Request) ([]*Batch, error)

GetBatches retrieves a list of batches for a specific date and request, and returns an error if any.

func (*Client) GetCode

func (c *Client) GetCode(ctx context.Context, idr string, req *Request) (*Code, error)

GetCode retrieves a code by ID, and returns an error if any.

func (*Client) GetCodes

func (c *Client) GetCodes(ctx context.Context, req *Request) ([]*Code, error)

GetCodes retrieves a list of codes, and returns an error if any.

func (*Client) GetLanguage

func (c *Client) GetLanguage(ctx context.Context, idr string, req *Request) (*Language, error)

GetLanguage retrieves a language by ID, and returns an error if any.

func (*Client) GetLanguages

func (c *Client) GetLanguages(ctx context.Context, req *Request) ([]*Language, error)

GetLanguages retrieves a list of languages, and returns an error if any.

func (*Client) GetNamespace

func (c *Client) GetNamespace(ctx context.Context, idr int, req *Request) (*Namespace, error)

GetNamespaces retrieves a namespaces by ID, and returns an error if any.

func (*Client) GetNamespaces

func (c *Client) GetNamespaces(ctx context.Context, req *Request) ([]*Namespace, error)

GetNamespaces retrieves a list of namespaces, and returns an error if any.

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, idr string, req *Request) (*Project, error)

GetProject retrieves a project by ID, and returns an error if any.

func (*Client) GetProjects

func (c *Client) GetProjects(ctx context.Context, req *Request) ([]*Project, error)

GetProjects retrieves a list of projects, and returns an error if any.

func (*Client) GetSnapshot

func (c *Client) GetSnapshot(ctx context.Context, idr string, req *Request) (*Snapshot, error)

GetSnapshot retrieves a single snapshot for a specific ID and returns an error if any.

func (*Client) GetSnapshots

func (c *Client) GetSnapshots(ctx context.Context, req *Request) ([]*Snapshot, error)

GetSnapshots retrieves a list of all snapshots and returns an error if any.

func (*Client) GetStructuredContents

func (c *Client) GetStructuredContents(ctx context.Context, nme string, req *Request) ([]*StructuredContent, error)

GetStructuredContents retrieves structured contents from the API based on the given name and request parameters.

func (*Client) HeadBatch

func (c *Client) HeadBatch(ctx context.Context, dte *time.Time, idr string) (*Headers, error)

HeadBatch retrieves only the headers of a single batch for a specific date and ID, and returns an error if any.

func (*Client) HeadSnapshot

func (c *Client) HeadSnapshot(ctx context.Context, idr string) (*Headers, error)

HeadSnapshot retrieves only the headers of a single snapshot for a specific ID, and returns an error if any.

func (*Client) ReadAll

func (c *Client) ReadAll(ctx context.Context, rdr io.Reader, cbk ReadCallback) error

ReadAll reads the contents of the given io.Reader and calls the given ReadCallback function with each chunk of data read.

func (*Client) ReadBatch

func (c *Client) ReadBatch(ctx context.Context, dte *time.Time, idr string, cbk ReadCallback) error

ReadBatch reads the contents of a single batch for a specific date and ID, and invokes the specified callback function for each chunk read.

func (*Client) ReadSnapshot

func (c *Client) ReadSnapshot(ctx context.Context, idr string, cbk ReadCallback) error

ReadSnapshot reads the contents of a single snapshots for a specific ID, and invokes the specified callback function for each chunk read.

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(tkn string)

SetAccessToken sets the access token for the client.

func (*Client) StreamArticles

func (c *Client) StreamArticles(ctx context.Context, req *Request, cbk ReadCallback) error

StreamArticles streams all available articles from the server and applies a callback function to each article as they arrive. The callback function must implement the ReadCallback interface.

type Code

type Code struct {
	// Identifier is the unique identifier for this code.
	Identifier string `json:"identifier,omitempty"`

	// Name is the human-readable name of this code.
	Name string `json:"name,omitempty"`

	// Description is a description of this code.
	Description string `json:"description,omitempty"`
}

Code is a project code representation in WME API.

type CodeGetter

type CodeGetter interface {
	GetCode(ctx context.Context, idr string, req *Request) (*Code, error)
}

CodeGetter is an interface that retrieves a code by ID from the API.

type CodesGetter

type CodesGetter interface {
	GetCodes(ctx context.Context, req *Request) ([]*Code, error)
}

CodesGetter is an interface that retrieves codes from the API.

type Editor

type Editor struct {
	// Identifier is the unique identifier for this editor.
	Identifier int `json:"identifier,omitempty"`

	// Name is the human-readable name of this editor.
	Name string `json:"name,omitempty"`

	// EditCount is the number of edits made by this editor.
	EditCount int `json:"edit_count,omitempty"`

	// Groups is the list of groups this editor belongs to.
	Groups []string `json:"groups,omitempty"`

	// IsBot is true if this editor is a bot.
	IsBot bool `json:"is_bot,omitempty"`

	// IsAnonymous is true if this editor is anonymous.
	IsAnonymous bool `json:"is_anonymous,omitempty"`

	// IsAdmin is true if this editor is an admin.
	IsAdmin bool `json:"is_admin,omitempty"`

	// IsPatroller is true if this editor is a patroller.
	IsPatroller bool `json:"is_patroller,omitempty"`

	// HasAdvancedRights is true if this editor has advanced rights.
	HasAdvancedRights bool `json:"has_advanced_rights,omitempty"`

	// DateStarted is the date and time this editor started editing.
	DateStarted *time.Time `json:"date_started,omitempty"`
}

Editor for the article version. Combines Person and CreativeWork with custom properties, link https://schema.org/editor.

type Entity

type Entity struct {
	// Identifier is the unique identifier for this entity.
	// For example 'Q937' is the identifier for 'Albert Einstein' see https://www.wikidata.org/wiki/Q937.
	Identifier string `json:"identifier,omitempty"`

	// URL is the URL of the entity.
	// Example: https://www.wikidata.org/wiki/Q937.
	URL string `json:"url,omitempty"`

	// Aspects of the entity that are being used in this article.
	Aspects []string `json:"aspects,omitempty"`
}

Entity schema for wikidata article. Right now will just be a copy of initial wikidata schema. Partially uses https://schema.org/Thing.

type Event

type Event struct {
	// Identifier is the unique identifier for this event (UUID).
	Identifier string `json:"identifier,omitempty"`

	// Type of the event, see EventType* constants.
	Type string `json:"type,omitempty"`

	// DateCreated is the date and time this event was created.
	DateCreated *time.Time `json:"date_created,omitempty"`

	// DatePublished is the date and time this event was published to the stream after processing.
	DatePublished *time.Time `json:"date_published,omitempty"`

	// Partition is the partition this event belongs to.
	Partition *int `json:"partition,omitempty"`

	// Offset what is the offset of the event inside the specified partition.
	Offset *int64 `json:"offset,omitempty"`
}

Event meta data for every event that happens in the system.

type Filter

type Filter struct {
	// Field specifies the field in the dataset that the filter should be applied to.
	Field string `json:"field"`

	// Value specifies the value that the field should be compared to.
	Value interface{} `json:"value"`
}

Filter represents a filter to be applied to a dataset.

type Headers

type Headers struct {
	// ContentLength is the size of the file in bytes.
	// Read more about Content-Length header here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length.
	ContentLength int `json:"content_length,omitempty"`

	// ETag is the entity tag of the file.
	// Read more about ETag header here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag.
	ETag string `json:"etag,omitempty"`

	// LastModified is the date and time the file was last modified.
	// Read more about Last-Modified header here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified.
	LastModified *time.Time `json:"last_modified,omitempty"`

	// ContentType is the content type of the file.
	// Read more about Content-Type header here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type.
	ContentType string `json:"content_type,omitempty"`

	// AcceptRanges is the accept ranges of the file.
	// Read more about Accept-Ranges header here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Ranges.
	AcceptRanges string `json:"accept_ranges,omitempty"`
}

Headers is representation of headers is in the response of HEAD request.

type Image

type Image struct {
	// ContentUrl is the URL of the image.
	ContentURL string `json:"content_url,omitempty"`

	// Width is the width of the image.
	Width int `json:"width,omitempty" avro:"width"`

	// Height is the height of the image.
	Height int `json:"height,omitempty" avro:"height"`

	// AlternativeText is the alternative text of the image.
	AlternativeText string `json:"alternative_text,omitempty"`

	// Caption is the caption of the image.
	Caption string `json:"caption,omitempty"`
}

Image schema for article image. Compliant with https://schema.org/ImageObject,

type Language

type Language struct {
	// Identifier is the unique identifier for this language.
	// For example 'en' is the identifier for 'English'.
	Identifier string `json:"identifier,omitempty"`

	// Name is the human-readable name of this language.
	Name string `json:"name,omitempty"`

	// AlternateName is an alias for the language.
	AlternateName string `json:"alternate_name,omitempty"`

	// Direction is the direction of the language.
	// For example 'ltr' is the direction for 'English'.
	Direction string `json:"direction,omitempty"`
}

Language representation according to https://schema.org/Language.

type LanguageGetter

type LanguageGetter interface {
	GetLanguage(ctx context.Context, idr string, req *Request) (*Language, error)
}

LanguageGetter is an interface that retrieves a language by ID from the API.

type LanguagesGetter

type LanguagesGetter interface {
	GetLanguages(ctx context.Context, req *Request) ([]*Language, error)
}

LanguagesGetter is an interface that retrieves languages from the API.

type License

type License struct {
	// Name is the human-readable name of this license.
	Name string `json:"name,omitempty"`

	// Identifier is the unique identifier for this license.
	// Example: 'CC-BY-SA-3.0'.
	Identifier string `json:"identifier,omitempty"`

	// URL is the URL of the license.
	// Example: https://creativecommons.org/licenses/by-sa/3.0/.
	URL string `json:"url,omitempty"`
}

License representation according to https://schema.org/license.

type Link struct {
	// URL is the URL of the link.
	URL string `json:"url,omitempty"`

	// Text is the text of the link.
	Text string `json:"text,omitempty"`

	// Images are the images included inside  the link.
	Images []*Image `json:"images,omitempty"`
}

Link represents a link that can be found on a Wikipedia page.

type Namespace

type Namespace struct {
	// Name is the human-readable name of this namespace.
	Name string `json:"name,omitempty"`

	// Identifier is the unique identifier for this namespace.
	Identifier int `json:"identifier"`

	// Description is a short description of this namespace.
	Description string `json:"description,omitempty"`
}

Namespace representation of mediawiki namespace. There's nothing related to this in https://schema.org/, we used https://schema.org/Thing. Read more about namespaces here: https://en.wikipedia.org/wiki/Wikipedia:Namespace.

type NamespaceGetter

type NamespaceGetter interface {
	GetNamespace(ctx context.Context, idr int, req *Request) (*Namespace, error)
}

NamespaceGetter is an interface that retrieves a namespace by ID from the API.

type NamespacesGetter

type NamespacesGetter interface {
	GetNamespaces(ctx context.Context, req *Request) ([]*Namespace, error)
}

NamespacesGetter is an interface that retrieves namespaces from the API.

type Part

type Part struct {
	// Name is the name of the part.
	Name string `json:"name,omitempty"`

	// Type is the type of the part, for example 'field' or 'section'.
	Type string `json:"type,omitempty"`

	// Value is the value of the part.
	Value string `json:"value,omitempty"`

	// Values are the values of the part (if there are are more than single value).
	Values []string `json:"values,omitempty"`

	// Images are the images included inside the part.
	Images []*Image `json:"images,omitempty"`

	// Links are the links included inside the part.
	Links []*Link `json:"links,omitempty"`

	// HasParts are the parts included inside the part (recursively parts can contain parts).
	HasParts []*Part `json:"has_parts,omitempty"`
}

Part represents a part of a structured content (section, field etc.).

type PreviousVersion

type PreviousVersion struct {
	// Identifier is the identifier of the previous version.
	Identifier int `json:"identifier,omitempty"`

	// NumberOfCharacters is the number of characters in the previous version.
	NumberOfCharacters int `json:"number_of_characters,omitempty"`
}

PreviousVersion is the representation for an article's previous version.

type Probability

type Probability struct {
	// False is the probability of the prediction being false.
	False float64 `json:"false,omitempty"`

	// True is the probability of the prediction being true.
	True float64 `json:"true,omitempty"`
}

Probability numeric probability values form ORES models.

type ProbabilityScore

type ProbabilityScore struct {
	// Prediction is the prediction of the model.
	Prediction bool `json:"prediction,omitempty"`

	// Probability is the probability of the prediction.
	Probability *Probability `json:"probability,omitempty"`
}

ProbabilityScore probability score representation for ORES models. Read more about ORES here: https://www.mediawiki.org/wiki/ORES.

type Project

type Project struct {
	// Name is the human-readable name of this project.
	Name string `json:"name,omitempty"`

	// Identifier is the unique identifier for this project.
	// For example for English wikipedia it would be 'enwiki'.
	Identifier string `json:"identifier,omitempty"`

	// URL is the URL of the project.
	URL string `json:"url,omitempty"`

	// Code is the code of the project.
	// For example 'wiki' means that it's a Wikipedia project.
	Code string `json:"code,omitempty"`

	// Version is the version of the project in form of md5 checksum.
	Version string `json:"version,omitempty"`

	// DateModified is the date and time the project was last modified.
	DateModified *time.Time `json:"date_modified,omitempty"`

	// InLanguage is the language of the project.
	InLanguage *Language `json:"in_language,omitempty"`

	// Size is the size of the project.
	Size *Size `json:"size,omitempty"`
}

Project representation of mediawiki project according to https://schema.org/Project.

type ProjectGetter

type ProjectGetter interface {
	GetProject(ctx context.Context, idr string, req *Request) (*Project, error)
}

ProjectGetter is an interface that retrieves a project by ID from the API.

type ProjectsGetter

type ProjectsGetter interface {
	GetProjects(ctx context.Context, req *Request) ([]*Project, error)
}

ProjectsGetter is an interface that retrieves projects from the API.

type Protection

type Protection struct {
	// Type is the type of the protection.
	Type string `json:"type,omitempty"`

	// Level is the level of the protection.
	Level string `json:"level,omitempty"`

	// Expiry is the expiry of the protection.
	Expiry string `json:"expiry,omitempty"`
}

Protection level for the article, does not comply with https://schema.org/ custom data. Read more about protection here: https://www.mediawiki.org/wiki/Manual:Protection.

type ReadCallback

type ReadCallback func(art *Article) error

ReadCallback is a function that will be called with each Article object that is read from a batch or snapshot. You can return a custom error to stop the reading.

type Redirect

type Redirect struct {
	// Name is the name of the redirect.
	Name string `json:"name,omitempty"`

	// URL is the URL of the redirect.
	URL string `json:"url,omitempty"`
}

Redirect article redirect representation.

type Request

type Request struct {
	// Since is a parameter used only for streaming endpoints.
	// Will pick up the reading of stream from this timestamp.
	// For the articles endpoint it will be restricted to 48h.
	Since *time.Time `json:"since,omitempty"`

	// Fields represents a list of fields to retrieve from the API.
	// This is an optional argument.
	Fields []string `json:"fields,omitempty"`

	// Filters represents a list of filters to apply to the response.
	// This is an optional argument.
	Filters []*Filter `json:"filters,omitempty"`

	// Limits the amount of results from the API (for now works only with Articles API).
	// This is an optional argument.
	Limit int `json:"limit,omitempty"`

	// Provides a way to open parallel connections to realtime streaming API.
	// Allows to target subsets of partitions in each of the parallel connections.
	// The max allowed number of parallel connections to realtime API is 10, i.e., the allowed range for parts is 0 through 9.
	// Each part value lets one connect to 1/10 th of the total partitions.
	// e.g., [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
	Parts []int `json:"parts,omitempty"`

	// Used for reconnection to realtime streaming API by passing this parameter.
	// This is map of partition:latest offset consumed.
	Offsets map[int]int64 `json:"offsets,omitempty"`

	// Used for reconnection to realtime streaming API by passing this parameter.
	// This is map of partition:latest event.date_published consumed.
	SincePerPartition map[int]time.Time ` json:"since_per_partition,omitempty"`
}

Request contains properties that are used to apply filters to the API.

type Scores

type Scores struct {
	Damaging  *ProbabilityScore `json:"damaging,omitempty"`
	GoodFaith *ProbabilityScore `json:"goodfaith,omitempty"`
}

Scores ORES scores representation, has nothing on https://schema.org/, it's a custom dataset. For more info https://ores.wikimedia.org/.

type Size

type Size struct {
	// Value is the size value.
	Value float64 `json:"value,omitempty"`

	// UnitText is the unit of the size value.
	// For example: 'MB'.
	UnitText string `json:"unit_text,omitempty"`
}

Size representation according to https://schema.org/QuantitativeValue.

type Snapshot

type Snapshot struct {
	// Identifier is the unique identifier for the snapshot.
	Identifier string `json:"identifier,omitempty"`

	// Version of the snapshot as a md5 checksum.
	Version string `json:"version,omitempty"`

	// DateModified date and time the snapshot was last modified.
	DateModified *time.Time `json:"date_modified,omitempty"`

	// IsPartOf the project that this snapshot belongs to.
	IsPartOf *Project `json:"is_part_of,omitempty"`

	// InLanguage the language of the contents of the snapshot.
	InLanguage *Language `json:"in_language,omitempty"`

	// Namespace of the snapshot.
	Namespace *Namespace `json:"namespace,omitempty"`

	// Size of the snapshot.
	Size *Size `json:"size,omitempty"`
}

Batch represents metadata for the daily snapshot in WME API.

type SnapshotDownloader

type SnapshotDownloader interface {
	DownloadSnapshot(ctx context.Context, idr string, wsk io.WriteSeeker) error
}

SnapshotDownloader is an interface for downloading a single snapshot by ID to a writer.

type SnapshotGetter

type SnapshotGetter interface {
	GetSnapshot(ctx context.Context, idr string, req *Request) (*Snapshot, error)
}

SnapshotGetter is an interface for getting a single snapshot by ID.

type SnapshotHeader

type SnapshotHeader interface {
	HeadSnapshot(ctx context.Context, idr string) (*Headers, error)
}

SnapshotHeader is an interface for getting the headers of a single snapshot by ID.

type SnapshotReader

type SnapshotReader interface {
	ReadSnapshot(ctx context.Context, idr string, cbk ReadCallback) error
}

SnapshotReader is an interface for reading the contents of a single snapshot by ID with a callback function.

type SnapshotsGetter

type SnapshotsGetter interface {
	GetSnapshots(ctx context.Context, req *Request) ([]*Snapshot, error)
}

SnapshotsGetter is an interface for getting multiple snapshots.

type StructuredContent

type StructuredContent struct {
	// Name is the name of the structured content (article).
	Name string `json:"name,omitempty"`

	// Identifier is a unique identifier for the structured content (article, in scope of a single project).
	Identifier int `json:"identifier,omitempty"`

	// Abstract is a summary of the structured content (article).
	Abstract string `json:"abstract,omitempty"`

	// Description is a description of the structured content (article).
	Description string `json:"description,omitempty"`

	// Version is the metadata about the version of the structured content (article).
	Version *Version `json:"version,omitempty"`

	// URL is the URL of the structured content (article).
	URL string `json:"url,omitempty"`

	// DateCreated is the date and time the structured content (article) was created.
	DateCreated *time.Time `json:"date_created,omitempty"`

	// DateModified is the date and time the structured content (article) was last modified.
	DateModified *time.Time `json:"date_modified,omitempty"`

	// MainEntity is the main (Wikidata) entity of the structured content (article).
	MainEntity *Entity `json:"main_entity,omitempty"`

	// AdditionalEntities are the additional (Wikidata) entities used in the structured content (article).
	AdditionalEntities []*Entity `json:"additional_entities,omitempty"`

	// IsPartOf is the project that the structured content (article) belongs to.
	IsPartOf *Project `json:"is_part_of,omitempty"`

	// InLanguage is the language of the structured content (article).
	InLanguage *Language `json:"in_language,omitempty"`

	// InfoBox are the parts included inside the structured content (article).
	InfoBox []*Part `json:"infobox,omitempty"`

	// ArticleSections are the section parts included inside the structured content (article).
	ArticleSections []*Part `json:"article_sections,omitempty"`

	// Image specifies the image related to the structured content (article).
	Image *Image `json:"image,omitempty"`
}

StructuredContent schema for Machine Readable structured contents endpoint.

type StructuredContentsGetter

type StructuredContentsGetter interface {
	GetStructuredContents(ctx context.Context, nme string, req *Request) ([]*StructuredContent, error)
}

StructuredContentsGetter is an interface for getting a lits of structured contents by name.

type Template

type Template struct {
	// Name is the name of the template.
	Name string `json:"name,omitempty"`

	// URL is the URL of the template.
	URL string `json:"url,omitempty"`
}

Template article template representation.

type Version

type Version struct {
	// Identifier is the identifier of the version.
	Identifier int `json:"identifier,omitempty"`

	// Comment is the comment from editor for this particular version of the edit.
	Comment string `json:"comment,omitempty"`

	// Tags is the list of tags for this particular version of the edit.
	// Read more about tags: https://www.mediawiki.org/wiki/Manual:Tags.
	Tags []string `json:"tags,omitempty"`

	// IsMinorEdit is the flag for minor edit.
	IsMinorEdit bool `json:"is_minor_edit,omitempty"`

	// IsFlaggedStable is the version flagged stable.
	IsFlaggedStable bool `json:"is_flagged_stable,omitempty"`

	// IsBreakingNews is the version flagged as breaking news.
	IsBreakingNews bool `json:"is_breaking_news,omitempty"`

	// HasTagNeedsCitation is the version flagged as needs citation.
	HasTagNeedsCitation bool `json:"has_tag_needs_citation,omitempty"`

	// Score is ORES scores for the edit.
	Scores *Scores `json:"scores,omitempty"`

	// Editor is the information about the editor who made this edit.
	Editor *Editor `json:"editor,omitempty"`

	// NumberOfCharacters is the number of characters in the version.
	NumberOfCharacters int `json:"number_of_characters,omitempty"`

	// Size is the size of the version.
	Size *Size `json:"size,omitempty"`
}

Version representation for the article. Mainly modeled after https://schema.org/Thing.

type Visibility

type Visibility struct {
	// Text is the visibility of the text ('true' for visible, 'false` for hidden`).
	Text bool `json:"text,omitempty"`

	// Edit is the visibility of the editor ('true' for visible, 'false` for hidden`).
	Editor bool `json:"editor,omitempty"`

	// Comment is the visibility of the comment ('true' for visible, 'false` for hidden`).
	Comment bool `json:"comment,omitempty"`
}

Visibility representing visibility changes for parts of the article. Custom dataset, not modeled after https://schema.org/.

Jump to

Keyboard shortcuts

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