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] |
Maintainer: | Emmanuel Blondel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.7-2 |
Built: | 2024-11-14 04:29:25 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]
GNAbstractManager
GNAbstractManager
R6Class
object.
Object of R6Class
with methods for communication with
the REST API of a GeoNetwork instance.
verbose.info
If package info log messages have to be printed out
verbose.debug
If curl debug log messages have to be printed out
loggerType
the type of logger
url
the Base url of GeoNetwork
version
the version of GeoNetwork. Handled as GNVersion
object
lang
the language for Geonetwork service. Default is eng
basicAuth
if basic auth is performed
logger()
Provides log messages
GNAbstractManager$logger(type, text)
type
type of log ("INFO", "WARN", "ERROR")
text
the log message text
INFO()
Provides INFO log messages
GNAbstractManager$INFO(text)
text
the log message text
WARN()
Provides WARN log messages
GNAbstractManager$WARN(text)
text
the log message text
ERROR()
Provides ERROR log messages
GNAbstractManager$ERROR(text)
text
the 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" )
url
url
user
user
pwd
pwd
version
version
logger
logger
keyring_backend
keyring 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)
user
user
pwd
pwd
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)
deep
Whether 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" )
url
url
user
user
pwd
pwd
version
version
logger
logger
keyring_backend
keyring backend. Default is 'env'
login()
#' This methods attempts a connection to GeoNetwork REST API. User internally
during initialization of GNLegacyAPIManager
.
GNLegacyAPIManager$login(user, pwd)
user
user
pwd
pwd
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. In that case on object of class
geometa::INSPIREMetadataValidator
, with a proper user API key, should be specified as
geometa_inspireValidator
argument.
GNLegacyAPIManager$insertMetadata( xml = NULL, file = NULL, geometa = NULL, group, category = NULL, stylesheet = NULL, validate = FALSE, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
xml
xml object of class XMLInternalNode-class from XML
file
file
geometa
geometa, object of class ISOMetadata
or ISOFeatureCatalogue
from geometa
group
group
category
category
stylesheet
stylesheet
validate
validate
geometa_validate
validate geometa object
geometa_inspire
validate geometa object vs. INSPIRE
geometa_inspireValidator
geometa INSPIRE validator to use
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)
id
id
config
config
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)
id
id
by
by
output
output
getMetadataByID()
Get a metadata by Id
GNLegacyAPIManager$getMetadataByID(id)
id
id
an object of class ISOMetadata
(ISO 19115) or ISOFeatureCatalogue
(ISO 19110) (from geometa package)
getMetadataByUUID()
Get a metadata by UUID
GNLegacyAPIManager$getMetadataByUUID(uuid)
uuid
uuid
an object of class ISOMetadata
(ISO 19115) or ISOFeatureCatalogue
(ISO 19110) (from geometa package)
getInfoByID()
Get a metadata Info by Id.
GNLegacyAPIManager$getInfoByID(id)
id
id
an XML document object
getInfoByUUID()
Get a metadata Info by UUID
GNLegacyAPIManager$getInfoByUUID(uuid)
uuid
uuid
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. In that case on object of class
geometa::INSPIREMetadataValidator
, with a proper user API key, should be specified as
geometa_inspireValidator
argument.
GNLegacyAPIManager$updateMetadata( id, xml = NULL, file = NULL, geometa = NULL, geometa_validate = TRUE, geometa_inspire = FALSE, geometa_inspireValidator = NULL )
id
metadata id
xml
xml object of class XMLInternalNode-class from XML
file
file
geometa
geometa, object of class ISOMetadata
or ISOFeatureCatalogue
from geometa
geometa_validate
validate geometa object
geometa_inspire
validate geometa object vs. INSPIRE
geometa_inspireValidator
geometa INSPIRE validator to use
deleteMetadata()
Deletes metadata by Id.
GNLegacyAPIManager$deleteMetadata(id)
id
id
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)
deep
Whether to make a deep clone.
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)
url
url
user
user
pwd
pwd
version
version
logger
logger
clone()
The objects of this class are cloneable with this method.
GNManager$clone(deep = FALSE)
deep
Whether 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" )
url
url
user
user
pwd
pwd
version
version
logger
logger
keyring_backend
keyring backend
login()
This methods attempts a connection to GeoNetwork REST API. User internally
during initialization of GNLegacyAPIManager
.
GNOpenAPIManager$login(user, pwd)
user
user
pwd
pwd
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
getMetadataByUUID()
Get a metadata by UUID.
GNOpenAPIManager$getMetadataByUUID( uuid, addSchemaLocation = TRUE, increasePopularity = TRUE, approved = TRUE )
uuid
uuid
addSchemaLocation
add schema location. Default is TRUE
increasePopularity
increase popularity. Default is TRUE
approved
approved
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. In that case on object of class
geometa::INSPIREMetadataValidator
, with a proper user API key, should be specified as geometa_inspireValidator
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 )
xml
object of class XMLInternalNode-class from XML
file
file
geometa
geometa object of class ISOMetadata
or ISOFeatureCatalogue
metadataType
metadata type. By default METADATA
uuidProcessing
UUID processing. By default NOTHING
. Other possible value: OVERWRITE
group
group
category
category
rejectIfInvalid
reject if invalid. Default FALSE
publishToAll
publish to all. Default TRUE
transformWith
transform with. Default is _none_
schema
schema
extra
extra
geometa_validate
validate geometa object
geometa_inspire
validate geometa object vs. INSPIRE
geometa_inspireValidator
geometa INSPIRE validator to use
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. In that case on object of class
geometa::INSPIREMetadataValidator
, with a proper user API key, should be specified as
geometa_inspireValidator
argument.
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 )
xml
object of class XMLInternalNode-class from XML
file
file
geometa
geometa object of class ISOMetadata
or ISOFeatureCatalogue
metadataType
metadata type. By default METADATA
uuidProcessing
UUID processing. By default NOTHING
. Other possible value: OVERWRITE
group
group
category
category
rejectIfInvalid
reject if invalid. Default FALSE
publishToAll
publish to all. Default TRUE
transformWith
transform with. Default is _none_
schema
schema
extra
extra
geometa_validate
validate geometa object
geometa_inspire
validate geometa object vs. INSPIRE
geometa_inspireValidator
geometa INSPIRE validator to use
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. In that case on object of class
geometa::INSPIREMetadataValidator
, with a proper user API key, should be specified as
geometa_inspireValidator
argument.
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 )
xml
object of class XMLInternalNode-class from XML
file
file
geometa
geometa object of class ISOMetadata
or ISOFeatureCatalogue
metadataType
metadata type. By default METADATA
group
group
category
category
rejectIfInvalid
reject if invalid. Default FALSE
publishToAll
publish to all. Default TRUE
transformWith
transform with. Default is _none_
schema
schema
extra
extra
geometa_validate
validate geometa object
geometa_inspire
validate geometa object vs. INSPIRE
geometa_inspireValidator
geometa INSPIRE validator to use
deleteMetadata()
Deletes a metadata by ID
GNOpenAPIManager$deleteMetadata(id, withBackup = TRUE)
id
id
withBackup
proceed with backup. Default is TRUE
uploadAttachment()
Uploads attachment
GNOpenAPIManager$uploadAttachment( id, file, visibility = "public", approved = TRUE )
id
metadata identifier
file
file to upload
visibility
public or private
approved
object 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 = "")
id
metadata identifier
url
thumbnail URL
desc
thumbnail description
TRUE
if published, FALSE
otherwise
doiCheckPreConditions()
Checks pre-conditions to publish DOI
GNOpenAPIManager$doiCheckPreConditions(id)
id
metadata 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)
id
metadata 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)
id
clone()
The objects of this class are cloneable with this method.
GNOpenAPIManager$clone(deep = FALSE)
deep
Whether to make a deep clone.
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
This class is an utility to configure privileges
R6Class
object.
R6Class
object.
GeoNetwork REST API - GeoNetwork privilege configuration
GeoNetwork REST API - GeoNetwork privilege configuration
Object of R6Class
for modelling a GeoNetwork Privilege configuration
Object of R6Class
for modelling a GeoNetwork Privilege configuration
group
group
privileges
privileges
new()
Initializes a GNPriv object
GNPriv$new(group, privileges)
group
group
privileges
privileges
clone()
The objects of this class are cloneable with this method.
GNPriv$clone(deep = FALSE)
deep
Whether to make a deep clone.
privileges
privileges
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)
group
group
privileges
privileges
clone()
The objects of this class are cloneable with this method.
GNPrivConfiguration$clone(deep = FALSE)
deep
Whether 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: pcfg <- GNPrivConfiguration$new() pcfg$setPrivileges("all", c("view","dynamic","featured")) ## End(Not run)
## Not run: priv <- GNPriv$new(group="all", privileges=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
rootName
root name
children
children
new()
Initializes a GNRESTRequest
GNRESTRequest$new(...)
...
any parameter to pass to the request
setChild()
Set child
GNRESTRequest$setChild(key, value)
key
key
value
value
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)
deep
Whether 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)
deep
Whether 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
version
version
value
value
new()
Initializes an object of class GNVersion
GNVersion$new(version)
version
version
lowerThan()
Compares to a version and returns TRUE if it is lower, FALSE otherwise
GNVersion$lowerThan(version)
version
version
TRUE
if lower, FALSE
otherwise
greaterThan()
Compares to a version and returns TRUE if it is greater, FALSE otherwise
GNVersion$greaterThan(version)
version
version
TRUE
if lower, FALSE
otherwise
equalTo()
Compares to a version and returns TRUE if it is equal, FALSE otherwise
GNVersion$equalTo(version)
version
version
TRUE
if lower, FALSE
otherwise
clone()
The objects of this class are cloneable with this method.
GNVersion$clone(deep = FALSE)
deep
Whether 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)