blob: 08350e02c9634caf699e402330257c5f68df4374 [file] [log] [blame]
Marc Kupietze95108e2019-09-18 13:23:58 +02001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/KorAPConnection.R
3\docType{class}
4\name{KorAPConnection-class}
5\alias{KorAPConnection-class}
6\alias{KorAPConnection}
7\alias{initialize,KorAPConnection-method}
Marc Kupietz4862b862019-11-07 10:13:53 +01008\alias{persistApiToken,KorAPConnection-method}
9\alias{persistApiToken}
10\alias{clearApiToken,KorAPConnection-method}
11\alias{clearApiToken}
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020012\alias{apiCall,KorAPConnection-method}
13\alias{apiCall}
Marc Kupietz0a96b282019-10-01 11:05:31 +020014\alias{clearCache,KorAPConnection-method}
15\alias{clearCache}
Marc Kupietze95108e2019-09-18 13:23:58 +020016\alias{show,KorAPConnection-method}
17\title{Class KorAPConnection}
18\usage{
Marc Kupietz76685f52019-11-25 17:46:06 +010019\S4method{initialize}{KorAPConnection}(
20 .Object,
21 KorAPUrl = "https://korap.ids-mannheim.de/",
22 apiVersion = "v1.0",
23 apiUrl,
24 apiToken = getApiToken(KorAPUrl),
25 userAgent = "R-KorAP-Client",
26 timeout = 10,
27 verbose = FALSE,
28 cache = TRUE
29)
Marc Kupietz4862b862019-11-07 10:13:53 +010030
31\S4method{persistApiToken}{KorAPConnection}(kco, apiToken = kco@apiToken)
32
33\S4method{clearApiToken}{KorAPConnection}(kco)
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020034
35\S4method{apiCall}{KorAPConnection}(kco, url)
Marc Kupietze95108e2019-09-18 13:23:58 +020036
Marc Kupietz0a96b282019-10-01 11:05:31 +020037\S4method{clearCache}{KorAPConnection}(kco)
38
Marc Kupietze95108e2019-09-18 13:23:58 +020039\S4method{show}{KorAPConnection}(object)
40}
41\arguments{
42\item{.Object}{KorAPConnection object}
43
44\item{KorAPUrl}{the URL of the KorAP server instance you want to access.}
45
46\item{apiVersion}{which version of KorAP's API you want to connect to.}
47
48\item{apiUrl}{URL of the KorAP web service.}
49
Marc Kupietz4862b862019-11-07 10:13:53 +010050\item{apiToken}{OAuth2 API token. To use authorization based on an API token
51in subsequent queries, intialize your KorAP connection with
52\code{kco <- new("KorAPConnection", apiToken="<API Token>")}.
53In order to make the API
54token persistent for the currently used \code{KorAPUrl} (you can have one
55token per KorAPUrl / KorAP server instance), use
56\code{persistApiToken(kco)}. This will store it in your keyring using the
57\code{\link{keyring}} package. Subsequent new("KorAPConnection") calls will
58then automatically retrieve the token from your keying. To stop using a
59persisted token, call \code{clearApiToken(kco)}. Please note that for
60DeReKo, authorized queries will behave differently inside and outside the
61IDS, because of the special license situation. This concerns also cached
62results which do not take into account from where a request was issued. If
63you experience problems or unexpected results, please try \code{kco <-
64new("KorAPConnection", cache=FALSE)} or use
65\code{\link{clearCache}} to clear the cache completely.}
66
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020067\item{userAgent}{user agent string.}
68
69\item{timeout}{time out in seconds.}
70
Marc Kupietz4862b862019-11-07 10:13:53 +010071\item{verbose}{logical. Decides whether following operations will default to
72be verbose.}
Marc Kupietz5a519822019-09-20 21:43:52 +020073
Marc Kupietz4862b862019-11-07 10:13:53 +010074\item{cache}{logical. Decides if API calls are cached locally. You can clear
75the cache with \code{\link{clearCache}()}.}
Marc Kupietz0a96b282019-10-01 11:05:31 +020076
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020077\item{kco}{KorAPConnection object}
78
79\item{url}{request url}
80
Marc Kupietze95108e2019-09-18 13:23:58 +020081\item{object}{KorAPConnection object}
82}
83\value{
Marc Kupietz4862b862019-11-07 10:13:53 +010084\code{\link{KorAPConnection}} object that can be used e.g. with
85 \code{\link{corpusQuery}}
Marc Kupietze95108e2019-09-18 13:23:58 +020086}
87\description{
Marc Kupietz7776dec2019-09-27 16:59:02 +020088\code{KorAPConnection} objects represent the connection to a KorAP server.
Marc Kupietz7715e9d2019-11-08 15:59:58 +010089New \code{KorAPConnection} objects can be created by \code{new("KorAPConnection")}.
Marc Kupietze95108e2019-09-18 13:23:58 +020090}
Marc Kupietze95108e2019-09-18 13:23:58 +020091\examples{
Marc Kupietz5a519822019-09-20 21:43:52 +020092kcon <- new("KorAPConnection", verbose = TRUE)
Marc Kupietze95108e2019-09-18 13:23:58 +020093kq <- corpusQuery(kcon, "Ameisenplage")
Marc Kupietz5a519822019-09-20 21:43:52 +020094kq <- fetchAll(kq)
Marc Kupietze95108e2019-09-18 13:23:58 +020095
Marc Kupietz4862b862019-11-07 10:13:53 +010096\dontrun{
97kcon <- new("KorAPConnection", verbose = TRUE, apiToken="e739u6eOzkwADQPdVChxFg")
98kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE)
99kq <- fetchAll(kq)
100kq@collectedMatches$snippet
101}
102
103\dontrun{
104kco <- new("KorAPConnection", apiToken="e739u6eOzkwADQPdVChxFg")
105persistApiToken(kco)
106}
107
108\dontrun{
109kco <- new("KorAPConnection")
110clearApiToken(kco)
111}
112
Marc Kupietze95108e2019-09-18 13:23:58 +0200113}