blob: 75a165ef761622bd3ec0d783534da03bf294e0c9 [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 Kupietzb956b812019-11-25 17:53:13 +01008\alias{persistAccessToken,KorAPConnection-method}
9\alias{persistAccessToken}
10\alias{clearAccessToken,KorAPConnection-method}
11\alias{clearAccessToken}
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,
Marc Kupietzb956b812019-11-25 17:53:13 +010024 accessToken = getAccessToken(KorAPUrl),
Marc Kupietz76685f52019-11-25 17:46:06 +010025 userAgent = "R-KorAP-Client",
Marc Kupietz6a3185b2021-12-07 10:23:16 +010026 timeout = 240,
Marc Kupietz76685f52019-11-25 17:46:06 +010027 verbose = FALSE,
28 cache = TRUE
29)
Marc Kupietz4862b862019-11-07 10:13:53 +010030
Marc Kupietzb956b812019-11-25 17:53:13 +010031\S4method{persistAccessToken}{KorAPConnection}(kco, accessToken = kco@accessToken)
Marc Kupietz4862b862019-11-07 10:13:53 +010032
Marc Kupietzb956b812019-11-25 17:53:13 +010033\S4method{clearAccessToken}{KorAPConnection}(kco)
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020034
Marc Kupietzb49afa02020-06-04 15:50:29 +020035\S4method{apiCall}{KorAPConnection}(kco, url, json = TRUE, getHeaders = FALSE, cache = kco@cache)
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 Kupietzb956b812019-11-25 17:53:13 +010050\item{accessToken}{OAuth2 access token. To use authorization based on an access token
Marc Kupietz43a6ade2020-02-18 17:01:44 +010051in subsequent queries, initialize your KorAP connection with
Marc Kupietzb956b812019-11-25 17:53:13 +010052\code{kco <- new("KorAPConnection", accessToken="<access token>")}.
Marc Kupietz4862b862019-11-07 10:13:53 +010053In order to make the API
54token persistent for the currently used \code{KorAPUrl} (you can have one
55token per KorAPUrl / KorAP server instance), use
Marc Kupietzb956b812019-11-25 17:53:13 +010056\code{persistAccessToken(kco)}. This will store it in your keyring using the
Marc Kupietz67edcb52021-09-20 21:54:24 +020057\code{\link[=keyring]{keyring()}} package. Subsequent new("KorAPConnection") calls will
Marc Kupietz4862b862019-11-07 10:13:53 +010058then automatically retrieve the token from your keying. To stop using a
Marc Kupietzb956b812019-11-25 17:53:13 +010059persisted token, call \code{clearAccessToken(kco)}. Please note that for
Marc Kupietz4862b862019-11-07 10:13:53 +010060DeReKo, 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
Marc Kupietz67edcb52021-09-20 21:54:24 +020063you experience problems or unexpected results, please try \code{kco <- new("KorAPConnection", cache=FALSE)} or use
64\code{\link[=clearCache]{clearCache()}} to clear the cache completely.}
Marc Kupietz4862b862019-11-07 10:13:53 +010065
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020066\item{userAgent}{user agent string.}
67
68\item{timeout}{time out in seconds.}
69
Marc Kupietz4862b862019-11-07 10:13:53 +010070\item{verbose}{logical. Decides whether following operations will default to
71be verbose.}
Marc Kupietz5a519822019-09-20 21:43:52 +020072
Marc Kupietz4862b862019-11-07 10:13:53 +010073\item{cache}{logical. Decides if API calls are cached locally. You can clear
Marc Kupietz67edcb52021-09-20 21:54:24 +020074the cache with \code{\link[=clearCache]{clearCache()}}.}
Marc Kupietz0a96b282019-10-01 11:05:31 +020075
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020076\item{kco}{KorAPConnection object}
77
78\item{url}{request url}
79
Marc Kupietzb2b32a32020-03-24 13:56:50 +010080\item{json}{logical that determines if json result is expected}
81
Marc Kupietzb49afa02020-06-04 15:50:29 +020082\item{getHeaders}{logical that determines if headers and content should be returned (as a list)}
83
Marc Kupietze95108e2019-09-18 13:23:58 +020084\item{object}{KorAPConnection object}
85}
86\value{
Marc Kupietz67edcb52021-09-20 21:54:24 +020087\code{\link[=KorAPConnection]{KorAPConnection()}} object that can be used e.g. with
88\code{\link[=corpusQuery]{corpusQuery()}}
Marc Kupietze95108e2019-09-18 13:23:58 +020089}
90\description{
Marc Kupietz7776dec2019-09-27 16:59:02 +020091\code{KorAPConnection} objects represent the connection to a KorAP server.
Marc Kupietz7715e9d2019-11-08 15:59:58 +010092New \code{KorAPConnection} objects can be created by \code{new("KorAPConnection")}.
Marc Kupietze95108e2019-09-18 13:23:58 +020093}
Marc Kupietze95108e2019-09-18 13:23:58 +020094\examples{
Marc Kupietz6ae76052021-09-21 10:34:00 +020095\dontrun{
96
Marc Kupietz5a519822019-09-20 21:43:52 +020097kcon <- new("KorAPConnection", verbose = TRUE)
Marc Kupietze95108e2019-09-18 13:23:58 +020098kq <- corpusQuery(kcon, "Ameisenplage")
Marc Kupietz5a519822019-09-20 21:43:52 +020099kq <- fetchAll(kq)
Marc Kupietz05b22772020-02-18 21:58:42 +0100100}
Marc Kupietze95108e2019-09-18 13:23:58 +0200101
Marc Kupietz4862b862019-11-07 10:13:53 +0100102\dontrun{
Marc Kupietz6ae76052021-09-21 10:34:00 +0200103
Marc Kupietzb956b812019-11-25 17:53:13 +0100104kcon <- new("KorAPConnection", verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg")
Marc Kupietz4862b862019-11-07 10:13:53 +0100105kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE)
106kq <- fetchAll(kq)
107kq@collectedMatches$snippet
108}
109
110\dontrun{
Marc Kupietz6ae76052021-09-21 10:34:00 +0200111
Marc Kupietzb956b812019-11-25 17:53:13 +0100112kco <- new("KorAPConnection", accessToken="e739u6eOzkwADQPdVChxFg")
113persistAccessToken(kco)
Marc Kupietz4862b862019-11-07 10:13:53 +0100114}
115
116\dontrun{
Marc Kupietz6ae76052021-09-21 10:34:00 +0200117
Marc Kupietz4862b862019-11-07 10:13:53 +0100118kco <- new("KorAPConnection")
Marc Kupietzb956b812019-11-25 17:53:13 +0100119clearAccessToken(kco)
Marc Kupietz4862b862019-11-07 10:13:53 +0100120}
121
Marc Kupietze95108e2019-09-18 13:23:58 +0200122}