api

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package api provides datastructures and functions to interface with the OpenDOAR API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIGet

func APIGet(cli *gentleman.Client, url string) (int, []byte, error)

APIGet performs a GET request on the given URL and returns the status code, body and error

func Harvest

func Harvest(itemType string, format string)

Harvest harvests data from OpenDOAR, writing the results to files in the harvest data folder

func InitialiseAPI

func InitialiseAPI(apiConfig APIConfiguration, l *zap.SugaredLogger)

InitialiseAPI initialises the API package

func NewGetClient

func NewGetClient() *gentleman.Client

NewGetClient returns a new Gentleman (HTTP) client with a GET request

func RandomSleep

func RandomSleep(longest int)

RandomSleep sleeps for a random number of seconds up to the given number

Types

type APIConfiguration

type APIConfiguration struct {
	HarvestDataFolderPath string `yaml:"harvestDataFolderPath"`
	HarvestPageSize       int    `yaml:"harvestPageSize"`
	HarvestPageLimit      int    `yaml:"harvestPageLimit"`
	ApiBaseURL            string `yaml:"apiBaseURL"`
	ApiKeyENVName         string `yaml:"apiKeyENVKey"`
}

APIConfiguration is the configuration for the API package

type OpenDOARIdentifier

type OpenDOARIdentifier struct {
	Identifier     string `json:"identifier"`
	IdentifierType string `json:"type"`
}

OpenDOARIdentifier is the identifier for the repository

type OpenDOARName

type OpenDOARName struct {
	Name     string `json:"name"`
	Acronym  string `json:"acronym"`
	Language string `json:"language"`
}

OpenDOARName is the name of the repository

type OpenDOAROrganisation

type OpenDOAROrganisation struct {
	Name        []OpenDOARName       `json:"name"`
	URL         string               `json:"url"`
	Country     string               `json:"country"`
	Identifiers []OpenDOARIdentifier `json:"identifiers"`
}

OpenDOAROrganisation is the organisation that the repository belongs to

type OpenDOARRepository

type OpenDOARRepository struct {
	SystemMetadata     OpenDOARSystemMetadata     `json:"system_metadata"`
	Organisation       OpenDOAROrganisation       `json:"organisation"`
	RepositoryMetadata OpenDOARRepositoryMetadata `json:"repository_metadata"`
}

OpenDOARRepository is the main repository struct

type OpenDOARRepositoryMetadata

type OpenDOARRepositoryMetadata struct {
	Name            []OpenDOARName   `json:"name"`
	RepoType        string           `json:"type"`
	URL             string           `json:"url"`
	OAIURL          string           `json:"oai_url"`
	Software        OpenDOARSoftware `json:"software"`
	ContentTypes    []string         `json:"content_types"`
	ContentSubjects []string         `json:"content_subjects"`
}

OpenDOARRepositoryMetadata is the metadata for the repository

type OpenDOARSoftware

type OpenDOARSoftware struct {
	Name string `json:"name"`
}

OpenDOARSoftware is the software platform that the repository uses

type OpenDOARSystemMetadata

type OpenDOARSystemMetadata struct {
	ID int `json:"id"`
}

OpenDOARSystemMetadata is the system metadata for the repository

type RepositoryList added in v0.1.4

type RepositoryList struct {
	Items []OpenDOARRepository `yaml:"items"`
}

RepositoryList is a list of OpenDOAR repository records

func (*RepositoryList) IsEmpty added in v0.1.4

func (l *RepositoryList) IsEmpty() bool

IsEmpty returns true if the RepositoryList is empty

func (*RepositoryList) MarshallToFile added in v0.1.4

func (l *RepositoryList) MarshallToFile(filePath string) error

MarshallToFile marshalls a RepositoryList into a JSON file

func (*RepositoryList) UnMarshall added in v0.1.4

func (l *RepositoryList) UnMarshall(bytes []byte) error

UnMarshall unmarshalls JSON data in a byte array into a RepositoryList

Jump to

Keyboard shortcuts

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