blob: 754fbd887490ad72bc87f682b176465b7b524799 [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{
19\S4method{initialize}{KorAPConnection}(.Object,
Marc Kupietzf94a6c82019-09-19 11:32:07 +020020 KorAPUrl = "https://korap.ids-mannheim.de/", apiVersion = "v1.0",
Marc Kupietz4862b862019-11-07 10:13:53 +010021 apiUrl, apiToken = getApiToken(KorAPUrl),
22 userAgent = "R-KorAP-Client", timeout = 10, verbose = FALSE,
23 cache = TRUE)
24
25\S4method{persistApiToken}{KorAPConnection}(kco, apiToken = kco@apiToken)
26
27\S4method{clearApiToken}{KorAPConnection}(kco)
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020028
29\S4method{apiCall}{KorAPConnection}(kco, url)
Marc Kupietze95108e2019-09-18 13:23:58 +020030
Marc Kupietz0a96b282019-10-01 11:05:31 +020031\S4method{clearCache}{KorAPConnection}(kco)
32
Marc Kupietze95108e2019-09-18 13:23:58 +020033\S4method{show}{KorAPConnection}(object)
34}
35\arguments{
36\item{.Object}{KorAPConnection object}
37
38\item{KorAPUrl}{the URL of the KorAP server instance you want to access.}
39
40\item{apiVersion}{which version of KorAP's API you want to connect to.}
41
42\item{apiUrl}{URL of the KorAP web service.}
43
Marc Kupietz4862b862019-11-07 10:13:53 +010044\item{apiToken}{OAuth2 API token. To use authorization based on an API token
45in subsequent queries, intialize your KorAP connection with
46\code{kco <- new("KorAPConnection", apiToken="<API Token>")}.
47In order to make the API
48token persistent for the currently used \code{KorAPUrl} (you can have one
49token per KorAPUrl / KorAP server instance), use
50\code{persistApiToken(kco)}. This will store it in your keyring using the
51\code{\link{keyring}} package. Subsequent new("KorAPConnection") calls will
52then automatically retrieve the token from your keying. To stop using a
53persisted token, call \code{clearApiToken(kco)}. Please note that for
54DeReKo, authorized queries will behave differently inside and outside the
55IDS, because of the special license situation. This concerns also cached
56results which do not take into account from where a request was issued. If
57you experience problems or unexpected results, please try \code{kco <-
58new("KorAPConnection", cache=FALSE)} or use
59\code{\link{clearCache}} to clear the cache completely.}
60
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020061\item{userAgent}{user agent string.}
62
63\item{timeout}{time out in seconds.}
64
Marc Kupietz4862b862019-11-07 10:13:53 +010065\item{verbose}{logical. Decides whether following operations will default to
66be verbose.}
Marc Kupietz5a519822019-09-20 21:43:52 +020067
Marc Kupietz4862b862019-11-07 10:13:53 +010068\item{cache}{logical. Decides if API calls are cached locally. You can clear
69the cache with \code{\link{clearCache}()}.}
Marc Kupietz0a96b282019-10-01 11:05:31 +020070
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020071\item{kco}{KorAPConnection object}
72
73\item{url}{request url}
74
Marc Kupietze95108e2019-09-18 13:23:58 +020075\item{object}{KorAPConnection object}
76}
77\value{
Marc Kupietz4862b862019-11-07 10:13:53 +010078\code{\link{KorAPConnection}} object that can be used e.g. with
79 \code{\link{corpusQuery}}
Marc Kupietze95108e2019-09-18 13:23:58 +020080}
81\description{
Marc Kupietz7776dec2019-09-27 16:59:02 +020082\code{KorAPConnection} objects represent the connection to a KorAP server.
83New \code{KorAPConnection} objects can be created by \code{KorAPConnection()}.
Marc Kupietze95108e2019-09-18 13:23:58 +020084}
Marc Kupietze95108e2019-09-18 13:23:58 +020085\examples{
Marc Kupietz5a519822019-09-20 21:43:52 +020086kcon <- new("KorAPConnection", verbose = TRUE)
Marc Kupietze95108e2019-09-18 13:23:58 +020087kq <- corpusQuery(kcon, "Ameisenplage")
Marc Kupietz5a519822019-09-20 21:43:52 +020088kq <- fetchAll(kq)
Marc Kupietze95108e2019-09-18 13:23:58 +020089
Marc Kupietz4862b862019-11-07 10:13:53 +010090\dontrun{
91kcon <- new("KorAPConnection", verbose = TRUE, apiToken="e739u6eOzkwADQPdVChxFg")
92kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE)
93kq <- fetchAll(kq)
94kq@collectedMatches$snippet
95}
96
97\dontrun{
98kco <- new("KorAPConnection", apiToken="e739u6eOzkwADQPdVChxFg")
99persistApiToken(kco)
100}
101
102\dontrun{
103kco <- new("KorAPConnection")
104clearApiToken(kco)
105}
106
Marc Kupietze95108e2019-09-18 13:23:58 +0200107}