| Title: | 'GeoNetwork' API R Interface |
|---|---|
| Description: | Provides an R interface to the 'GeoNetwork' API (<https://geonetwork-opensource.org/#api>) allowing to upload and publish metadata in a 'GeoNetwork' web-application and expose it to OGC CSW. |
| Authors: | Emmanuel Blondel [aut, cre] (ORCID: <https://orcid.org/0000-0002-5870-5762>) |
| Maintainer: | Emmanuel Blondel <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.8-2 |
| Built: | 2026-05-09 08:25:28 UTC |
| Source: | https://github.com/eblondel/geonapi |
Provides an R interface to the 'GeoNetwork' API (<https://geonetwork-opensource.org/#api>) allowing to upload and publish metadata in a 'GeoNetwork' web-application and expose it to OGC CSW Web-Services (Catalogue Service for the Web).
Emmanuel Blondel [email protected]
Useful links:
Report bugs at https://github.com/eblondel/geonapi/issues
GNAbstractManager
GNAbstractManager
R6Class object.
Object of R6Class with methods for communication with
the REST API of a GeoNetwork instance.
verbose.infoIf package info log messages have to be printed out
verbose.debugIf curl debug log messages have to be printed out
loggerTypethe type of logger
urlthe Base url of GeoNetwork
versionthe version of GeoNetwork. Handled as GNVersion object
langthe language for Geonetwork service. Default is eng
basicAuthif basic auth is performed
logger()
Provides log messages
GNAbstractManager$logger(type, text)
typetype of log ("INFO", "WARN", "ERROR")
textthe log message text
INFO()
Provides INFO log messages
GNAbstractManager$INFO(text)
textthe log message text
WARN()
Provides WARN log messages
GNAbstractManager$WARN(text)
textthe log message text
ERROR()
Provides ERROR log messages
GNAbstractManager$ERROR(text)
textthe log message text
new()
This method is used to instantiate a GNAbstractManager with the url of the
GeoNetwork and credentials to authenticate (user/pwd). By default,
the logger argument will be set to NULL (no logger).
The keyring_backend can be set to use a different backend for storing
the Geonetwork password/token with keyring (Default value is 'env').
The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)
GNAbstractManager$new( url, user = NULL, pwd = NULL, version, logger = NULL, keyring_backend = "env" )
urlurl
useruser
pwdpwd
versionversion
loggerlogger
keyring_backendkeyring backend. Default is 'env'
getUrl()
Get URL
GNAbstractManager$getUrl()
an object of class character
getLang()
Get service language
GNAbstractManager$getLang()
an object of class character
login()
Log-ins. This methods (here abstract) attempts a connection to GeoNetwork API. Used internally by subclasses of GNAbstractManager to login Geonetwork.
GNAbstractManager$login(user, pwd)
useruser
pwdpwd
getClassName()
Get class name
GNAbstractManager$getClassName()
an object of class character
clone()
The objects of this class are cloneable with this method.
GNAbstractManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
GNLegacyAPIManager
GNLegacyAPIManager
R6Class object.
Object of R6Class with methods for communication with
the REST API of a GeoNetwork instance using the legacy API.
geonapi::GNAbstractManager -> GNLegacyAPIManager
new()
This method is used to instantiate a GNLegacyAPIManager with the url of the
GeoNetwork and credentials to authenticate (user/pwd).
The keyring_backend can be set to use a different backend for storing
the Geonetwork password/token with keyring (Default value is 'env').
The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)
GNLegacyAPIManager$new( url, user = NULL, pwd = NULL, version, logger = NULL, keyring_backend = "env" )
urlurl
useruser
pwdpwd
versionversion
loggerlogger
keyring_backendkeyring backend. Default is 'env'
login()
#' This methods attempts a connection to GeoNetwork REST API. User internally
during initialization of GNLegacyAPIManager.
GNLegacyAPIManager$login(user, pwd)
useruser
pwdpwd
getGroups()
Retrieves the list of user groups available in Geonetwork
GNLegacyAPIManager$getGroups()
an object of class data.frame
getCategories()
Retrieves the list of categories available in Geonetwork
GNLegacyAPIManager$getCategories()
an object of class data.frame
insertMetadata()
Inserts a metadata by file, XML object or geometa object of class
ISOMetadata or ISOFeatureCatalogue. If successful, returns the Geonetwork
metadata internal identifier (integer). Extra parameters geometa_validate (TRUE
by default) and geometa_inspire (FALSE by default) can be used with geometa objects
for perform ISO and INSPIRE validation respectively.
GNLegacyAPIManager$insertMetadata( xml = NULL, file = NULL, geometa = NULL, group, category = NULL, stylesheet = NULL, validate = FALSE, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
xmlxml object of class XMLInternalNode-class
filefile
geometageometa, object of class ISOMetadata or ISOFeatureCatalogue
groupgroup
categorycategory
stylesheetstylesheet
validatevalidate
geometa_validatevalidate geometa object
geometa_inspirevalidate geometa object vs. INSPIRE
geometa_inspireValidatorgeometa INSPIRE validator to use. Deprecated, see below note
setPrivConfiguration()
Set the privilege configuration for a metadata. 'id' is the metadata integer id. 'config' is an object of class "GNPrivConfiguration".
GNLegacyAPIManager$setPrivConfiguration(id, config)
idid
configconfig
get()
Generic getter for metadata. Possible values for by are 'id', 'uuid'. Used internally only. The 'output' argument gives the type of output to return, with possible values "id", "metadata", "info".
GNLegacyAPIManager$get(id, by, output)
idid
byby
outputoutput
getMetadataByID()
Get a metadata by Id
GNLegacyAPIManager$getMetadataByID(id)
idid
an object of class ISOMetadata (ISO 19115) or ISOFeatureCatalogue
(ISO 19110) (from geometa package)
getMetadataByUUID()
Get a metadata by UUID
GNLegacyAPIManager$getMetadataByUUID(uuid)
uuiduuid
an object of class ISOMetadata (ISO 19115) or ISOFeatureCatalogue
(ISO 19110) (from geometa package)
getInfoByID()
Get a metadata Info by Id.
GNLegacyAPIManager$getInfoByID(id)
idid
an XML document object
getInfoByUUID()
Get a metadata Info by UUID
GNLegacyAPIManager$getInfoByUUID(uuid)
uuiduuid
an XML document object
updateMetadata()
Updates a metadata by file, XML object or geometa object of class
'ISOMetadata' or 'ISOFeatureCatalogue'. Extra parameters geometa_validate (TRUE
by default) and geometa_inspire (FALSE by default) can be used with geometa objects
for perform ISO and INSPIRE validation respectively.
GNLegacyAPIManager$updateMetadata( id, xml = NULL, file = NULL, geometa = NULL, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
idmetadata id
xmlxml object of class XMLInternalNode-class
filefile
geometageometa, object of class ISOMetadata or ISOFeatureCatalogue
geometa_validatevalidate geometa object
geometa_inspirevalidate geometa object vs. INSPIRE
geometa_inspireValidatorgeometa INSPIRE validator to use. Deprecated, see below note.
deleteMetadata()
Deletes metadata by Id.
GNLegacyAPIManager$deleteMetadata(id)
idid
the id of the record deleted, NULL otherwise
deleteMetadataAll()
Deletes all metadata
GNLegacyAPIManager$deleteMetadataAll()
clone()
The objects of this class are cloneable with this method.
GNLegacyAPIManager$clone(deep = FALSE)
deepWhether to make a deep clone.
From 2025-05-02, the INSPIRE metadata validation does not require anymore an API Key. Therefore, it is not
required to specify an geometa_inspireValidator. To send your metadata to INSPIRE, just set geometa_inspire
to TRUE.
From 2025-05-02, the INSPIRE metadata validation does not require anymore an API Key. Therefore, it is not
required to specify an geometa_inspireValidator. To send your metadata to INSPIRE, just set geometa_inspire
to TRUE.
Emmanuel Blondel <[email protected]>
## Not run: GNLegacyAPIManager$new("http://localhost:8080/geonetwork", "admin", "geonetwork", "3.0.0") ## End(Not run)## Not run: GNLegacyAPIManager$new("http://localhost:8080/geonetwork", "admin", "geonetwork", "3.0.0") ## End(Not run)
The function GNManager$new will set-up the right Geonetwork
manager depending on the GeoNetwork version specified by the user. For the time-being,
GeoNetwork with version < 4 will be interfaced with the GeoNetwork legacy API (see detailed
documentation at GNLegacyAPIManager), while starting with GeoNetwork 3.2, the new
GeoNetwork OpenAPI will be used.
R6Class object.
Object of R6Class with methods for communication with
the API of a GeoNetwork instance.
geonapi::GNAbstractManager -> GNManager
new()
Initializes a GNManager
GNManager$new(url, user = NULL, pwd = NULL, version, logger = NULL)
urlurl
useruser
pwdpwd
versionversion
loggerlogger
clone()
The objects of this class are cloneable with this method.
GNManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
## Not run: GMManager$new("http://localhost:8080/geonetwork", "admin", "geonetwork", "3.0.0") ## End(Not run)## Not run: GMManager$new("http://localhost:8080/geonetwork", "admin", "geonetwork", "3.0.0") ## End(Not run)
GNOpenAPIManager
GNOpenAPIManager
R6Class object.
Object of R6Class with methods for communication with
the REST API of a GeoNetwork instance using the legacy API.
geonapi::GNAbstractManager -> GNOpenAPIManager
new()
This method is used to instantiate a GNOpenAPIManager with the url of the
GeoNetwork and credentials to authenticate (user/pwd).
The keyring_backend can be set to use a different backend for storing
the Geonetwork password/token with keyring (Default value is 'env').
The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)
GNOpenAPIManager$new( url, user = NULL, pwd = NULL, version, logger = NULL, keyring_backend = "env" )
urlurl
useruser
pwdpwd
versionversion
loggerlogger
keyring_backendkeyring backend
login()
This methods attempts a connection to GeoNetwork REST API. User internally
during initialization of GNLegacyAPIManager.
GNOpenAPIManager$login(user, pwd)
useruser
pwdpwd
getGroups()
Retrieves the list of user groups available in Geonetwork
GNOpenAPIManager$getGroups()
an object of class data.frame
getTags()
Retrieves the list of tags (categories) available in Geonetwork
GNOpenAPIManager$getTags()
an object of class data.frame
getCategories()
Retrieves the list of categories (same as tags) available in Geonetwork
GNOpenAPIManager$getCategories()
an object of class data.frame
downloadMetadataByUUID()
Download a metadata by UUID.
GNOpenAPIManager$downloadMetadataByUUID( uuid, addSchemaLocation = TRUE, increasePopularity = TRUE, approved = TRUE, filename )
uuiduuid
addSchemaLocationadd schema location. Default is TRUE
increasePopularityincrease popularity. Default is TRUE
approvedapproved
filenameoutput filename
getMetadataByUUID()
Get a metadata by UUID.
GNOpenAPIManager$getMetadataByUUID( uuid, addSchemaLocation = TRUE, increasePopularity = TRUE, approved = TRUE )
uuiduuid
addSchemaLocationadd schema location. Default is TRUE
increasePopularityincrease popularity. Default is TRUE
approvedapproved
Returns an object of class ISOMetadata (ISO 19115)
or ISOFeatureCatalogue (ISO 19110) (from geometa package)
insertRecord()
Inserts a record by file, XML object or geometa object of class ISOMetadata or ISOFeatureCatalogue.
Extra parameters related to geometa objects: geometa_validate (TRUE by default) and geometa_inspire
(FALSE by default) can be used to perform ISO and INSPIRE validation respectively.
argument.
GNOpenAPIManager$insertRecord( xml = NULL, file = NULL, geometa = NULL, metadataType = "METADATA", uuidProcessing = "NOTHING", group, category = NULL, rejectIfInvalid = FALSE, publishToAll = TRUE, transformWith = "_none_", schema = NULL, extra = NULL, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
xmlobject of class XMLInternalNode-class
filefile
geometageometa object of class ISOMetadata or ISOFeatureCatalogue
metadataTypemetadata type. By default METADATA
uuidProcessingUUID processing. By default NOTHING. Other possible value: OVERWRITE
groupgroup
categorycategory
rejectIfInvalidreject if invalid. Default FALSE
publishToAllpublish to all. Default TRUE
transformWithtransform with. Default is _none_
schemaschema
extraextra
geometa_validatevalidate geometa object
geometa_inspirevalidate geometa object vs. INSPIRE
geometa_inspireValidatorgeometa INSPIRE validator to use. Deprecated, see below note.
insertMetadata()
Inserts a metadata by file, XML object or geometa object of class ISOMetadata or ISOFeatureCatalogue.
Extra parameters related to geometa objects: geometa_validate (TRUE by default) and geometa_inspire
(FALSE by default) can be used to perform ISO and INSPIRE validation respectively.
GNOpenAPIManager$insertMetadata( xml = NULL, file = NULL, geometa = NULL, metadataType = "METADATA", uuidProcessing = "NOTHING", group, category = NULL, rejectIfInvalid = FALSE, publishToAll = TRUE, transformWith = "_none_", schema = NULL, extra = NULL, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
xmlobject of class XMLInternalNode-class
filefile
geometageometa object of class ISOMetadata or ISOFeatureCatalogue
metadataTypemetadata type. By default METADATA
uuidProcessingUUID processing. By default NOTHING. Other possible value: OVERWRITE
groupgroup
categorycategory
rejectIfInvalidreject if invalid. Default FALSE
publishToAllpublish to all. Default TRUE
transformWithtransform with. Default is _none_
schemaschema
extraextra
geometa_validatevalidate geometa object
geometa_inspirevalidate geometa object vs. INSPIRE
geometa_inspireValidatorgeometa INSPIRE validator to use. Deprecated, see below note.
updateMetadata()
Inserts a metadata by file, XML object or geometa object of class ISOMetadata or ISOFeatureCatalogue.
Extra parameters related to geometa objects: geometa_validate (TRUE by default) and geometa_inspire
(FALSE by default) can be used to perform ISO and INSPIRE validation respectively.
GNOpenAPIManager$updateMetadata( xml = NULL, file = NULL, geometa = NULL, metadataType = "METADATA", group, category = NULL, rejectIfInvalid = FALSE, publishToAll = TRUE, transformWith = "_none_", schema = NULL, extra = NULL, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
xmlobject of class XMLInternalNode-class
filefile
geometageometa object of class ISOMetadata or ISOFeatureCatalogue
metadataTypemetadata type. By default METADATA
groupgroup
categorycategory
rejectIfInvalidreject if invalid. Default FALSE
publishToAllpublish to all. Default TRUE
transformWithtransform with. Default is _none_
schemaschema
extraextra
geometa_validatevalidate geometa object
geometa_inspirevalidate geometa object vs. INSPIRE
geometa_inspireValidatorgeometa INSPIRE validator to use. Deprecated, see below note.
deleteMetadata()
Deletes a metadata by ID
GNOpenAPIManager$deleteMetadata(id, withBackup = TRUE)
idid
withBackupproceed with backup. Default is TRUE
Set privilege configuration using Geonetwork OpenAPI
setPrivConfiguration()
GNOpenAPIManager$setPrivConfiguration(id, config)
idcharacter; metadata Id
configobject of class GNPrivConfiguration (same structure as legacy)
logical TRUE on success, FALSE otherwise
uploadAttachment()
Uploads attachment
GNOpenAPIManager$uploadAttachment( id, file, visibility = "public", approved = TRUE )
idmetadata identifier
filefile to upload
visibilitypublic or private
approvedobject of class logical
a named list of the uploaded attachment, including the url, size, id and type, NULL otherwise
publishThumbnail()
Publishes thumbnail based on URL
GNOpenAPIManager$publishThumbnail(id, url, desc = "")
idmetadata identifier
urlthumbnail URL
descthumbnail description
TRUE if published, FALSE otherwise
doiCheckPreConditions()
Checks pre-conditions to publish DOI
GNOpenAPIManager$doiCheckPreConditions(id)
idmetadata identifier
TRUE if DOI pre-conditions are fulfiled, FALSE otherwise
createDOI()
Submit a record to the Datacite metadata store in order to create a DOI.
GNOpenAPIManager$createDOI(id)
idmetadata identifier
TRUE if metadata record has been submitted with DOI created, FALSE otherwise
deleteDOI()
Remove a DOI (this is not recommended, DOI are supposed to be persistent once created. This is mainly here for testing).
GNOpenAPIManager$deleteDOI(id)
idclone()
The objects of this class are cloneable with this method.
GNOpenAPIManager$clone(deep = FALSE)
deepWhether to make a deep clone.
From 2025-05-02, the INSPIRE metadata validation does not require anymore an API Key. Therefore, it is not
required to specify an geometa_inspireValidator. To send your metadata to INSPIRE, just set geometa_inspire
to TRUE.
From 2025-05-02, the INSPIRE metadata validation does not require anymore an API Key. Therefore, it is not
required to specify an geometa_inspireValidator. To send your metadata to INSPIRE, just set geometa_inspire
to TRUE.
From 2025-05-02, the INSPIRE metadata validation does not require anymore an API Key. Therefore, it is not
required to specify an geometa_inspireValidator. To send your metadata to INSPIRE, just set geometa_inspire
to TRUE.
Emmanuel Blondel <[email protected]>
## Not run: GNOpenAPIManager$new("http://localhost:8080/geonetwork", "admin", "geonetwork", "4.0.5") ## End(Not run)## Not run: GNOpenAPIManager$new("http://localhost:8080/geonetwork", "admin", "geonetwork", "4.0.5") ## End(Not run)
This class is an utility to configure privileges
R6Class object.
GeoNetwork REST API - GeoNetwork privilege configuration
Object of R6Class for modelling a GeoNetwork Privilege configuration
groupgroup
privilegesprivileges
new()
Initializes a GNPriv object
GNPriv$new(group, privileges)
groupgroup
privilegesprivileges
clone()
The objects of this class are cloneable with this method.
GNPriv$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
## Not run: priv <- GNPriv$new(group="all", privileges=c("view","dynamic","featured")) ## End(Not run)## Not run: priv <- GNPriv$new(group="all", privileges=c("view","dynamic","featured")) ## End(Not run)
This class is an utility to configure privileges
R6Class object.
GeoNetwork REST API - GeoNetwork privilege configuration
Object of R6Class for modelling a GeoNetwork Privilege configuration
privilegesprivileges
new()
Initializes an object of class GNPrivConfiguration
GNPrivConfiguration$new()
setPrivileges()
Sets the operation privileges for a particular group. Allowed group values are "guest","intranet" and "all". Allowed values for operation privileges are "view", "download", "editing", "notify", "dynamic" and "featured".
GNPrivConfiguration$setPrivileges(group, privileges)
groupgroup
privilegesprivileges
clone()
The objects of this class are cloneable with this method.
GNPrivConfiguration$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
## Not run: pcfg <- GNPrivConfiguration$new() pcfg$setPrivileges("all", c("view","dynamic","featured")) ## End(Not run)## Not run: pcfg <- GNPrivConfiguration$new() pcfg$setPrivileges("all", c("view","dynamic","featured")) ## End(Not run)
GeoNetwork REST API REST Request
GeoNetwork REST API REST Request
R6Class object.
Object of R6Class for modelling a GeoNetwork REST request
rootNameroot name
childrenchildren
new()
Initializes a GNRESTRequest
GNRESTRequest$new(...)
...any parameter to pass to the request
setChild()
Set child
GNRESTRequest$setChild(key, value)
keykey
valuevalue
encode()
Encodes request as XML
GNRESTRequest$encode()
an object of class character representing the XML
clone()
The objects of this class are cloneable with this method.
GNRESTRequest$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
GeoNetwork REST API Manager Utils
GeoNetwork REST API Manager Utils
R6Class object.
Object of R6Class with static util methods for communication
with the REST API of a GeoNetwork instance.
getUserAgent()This method is used to get the user agent for performing GeoNetwork API requests. Here the user agent will be compound by geonapi package name and version.
getUserToken(user, pwd)This method is used to get the user authentication token for performing GeoNetwork API requests. Token is given a Base64 encoded string.
GET(url, path, token, verbose)This method performs a GET request for a given path to GeoNetwork REST API
PUT(url, path, token, filename, contentType, verbose)This method performs a PUT request for a given path to GeoNetwork REST API,
to upload a file of name filename with given contentType
POST(url, path, token, content, contentType, encode, verbose)This method performs a POST request for a given path to GeoNetwork REST API,
to post content of given contentType
DELETE(url, path, token, verbose)This method performs a DELETE request for a given GeoNetwork resource identified
by a path in GeoNetwork REST API
parseResponseXML(req)Convenience method to parse XML response from GeoNetwork REST API. Although package httr suggests the use of xml2 package for handling XML, geonapi still relies on the package XML. Response from httr is retrieved as text, and then parsed as XML 'xmlParse' function.
getPayloadXML(obj)Convenience method to create payload XML to send to GeoNetwork.
clone()
The objects of this class are cloneable with this method.
GNUtils$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
This class is an utility wrap the Geonetwork version
R6Class object.
GeoNetwork REST API - GeoNetwork Version
Object of R6Class for modelling a GeoNetwork version
versionversion
valuevalue
new()
Initializes an object of class GNVersion
GNVersion$new(version)
versionversion
lowerThan()
Compares to a version and returns TRUE if it is lower, FALSE otherwise
GNVersion$lowerThan(version)
versionversion
TRUE if lower, FALSE otherwise
greaterThan()
Compares to a version and returns TRUE if it is greater, FALSE otherwise
GNVersion$greaterThan(version)
versionversion
TRUE if lower, FALSE otherwise
equalTo()
Compares to a version and returns TRUE if it is equal, FALSE otherwise
GNVersion$equalTo(version)
versionversion
TRUE if lower, FALSE otherwise
clone()
The objects of this class are cloneable with this method.
GNVersion$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
## Not run: version <- GNVersion$new("2.6.4") ## End(Not run)## Not run: version <- GNVersion$new("2.6.4") ## End(Not run)