Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 1 | % 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 Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 8 | \alias{persistAccessToken,KorAPConnection-method} |
| 9 | \alias{persistAccessToken} |
| 10 | \alias{clearAccessToken,KorAPConnection-method} |
| 11 | \alias{clearAccessToken} |
Marc Kupietz | d0d3e9b | 2019-09-24 17:36:03 +0200 | [diff] [blame] | 12 | \alias{apiCall,KorAPConnection-method} |
| 13 | \alias{apiCall} |
Marc Kupietz | 0a96b28 | 2019-10-01 11:05:31 +0200 | [diff] [blame] | 14 | \alias{clearCache,KorAPConnection-method} |
| 15 | \alias{clearCache} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 16 | \alias{show,KorAPConnection-method} |
| 17 | \title{Class KorAPConnection} |
| 18 | \usage{ |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 19 | \S4method{initialize}{KorAPConnection}( |
| 20 | .Object, |
| 21 | KorAPUrl = "https://korap.ids-mannheim.de/", |
| 22 | apiVersion = "v1.0", |
| 23 | apiUrl, |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 24 | accessToken = getAccessToken(KorAPUrl), |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 25 | userAgent = "R-KorAP-Client", |
Marc Kupietz | b38b73e | 2020-02-18 12:40:27 +0100 | [diff] [blame] | 26 | timeout = 110, |
Marc Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 27 | verbose = FALSE, |
| 28 | cache = TRUE |
| 29 | ) |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 30 | |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 31 | \S4method{persistAccessToken}{KorAPConnection}(kco, accessToken = kco@accessToken) |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 32 | |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 33 | \S4method{clearAccessToken}{KorAPConnection}(kco) |
Marc Kupietz | d0d3e9b | 2019-09-24 17:36:03 +0200 | [diff] [blame] | 34 | |
Marc Kupietz | b49afa0 | 2020-06-04 15:50:29 +0200 | [diff] [blame] | 35 | \S4method{apiCall}{KorAPConnection}(kco, url, json = TRUE, getHeaders = FALSE, cache = kco@cache) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 36 | |
Marc Kupietz | 0a96b28 | 2019-10-01 11:05:31 +0200 | [diff] [blame] | 37 | \S4method{clearCache}{KorAPConnection}(kco) |
| 38 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 39 | \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 Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 50 | \item{accessToken}{OAuth2 access token. To use authorization based on an access token |
Marc Kupietz | 43a6ade | 2020-02-18 17:01:44 +0100 | [diff] [blame] | 51 | in subsequent queries, initialize your KorAP connection with |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 52 | \code{kco <- new("KorAPConnection", accessToken="<access token>")}. |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 53 | In order to make the API |
| 54 | token persistent for the currently used \code{KorAPUrl} (you can have one |
| 55 | token per KorAPUrl / KorAP server instance), use |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 56 | \code{persistAccessToken(kco)}. This will store it in your keyring using the |
Marc Kupietz | 67edcb5 | 2021-09-20 21:54:24 +0200 | [diff] [blame] | 57 | \code{\link[=keyring]{keyring()}} package. Subsequent new("KorAPConnection") calls will |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 58 | then automatically retrieve the token from your keying. To stop using a |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 59 | persisted token, call \code{clearAccessToken(kco)}. Please note that for |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 60 | DeReKo, authorized queries will behave differently inside and outside the |
| 61 | IDS, because of the special license situation. This concerns also cached |
| 62 | results which do not take into account from where a request was issued. If |
Marc Kupietz | 67edcb5 | 2021-09-20 21:54:24 +0200 | [diff] [blame] | 63 | you 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 Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 65 | |
Marc Kupietz | d0d3e9b | 2019-09-24 17:36:03 +0200 | [diff] [blame] | 66 | \item{userAgent}{user agent string.} |
| 67 | |
| 68 | \item{timeout}{time out in seconds.} |
| 69 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 70 | \item{verbose}{logical. Decides whether following operations will default to |
| 71 | be verbose.} |
Marc Kupietz | 5a51982 | 2019-09-20 21:43:52 +0200 | [diff] [blame] | 72 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 73 | \item{cache}{logical. Decides if API calls are cached locally. You can clear |
Marc Kupietz | 67edcb5 | 2021-09-20 21:54:24 +0200 | [diff] [blame] | 74 | the cache with \code{\link[=clearCache]{clearCache()}}.} |
Marc Kupietz | 0a96b28 | 2019-10-01 11:05:31 +0200 | [diff] [blame] | 75 | |
Marc Kupietz | d0d3e9b | 2019-09-24 17:36:03 +0200 | [diff] [blame] | 76 | \item{kco}{KorAPConnection object} |
| 77 | |
| 78 | \item{url}{request url} |
| 79 | |
Marc Kupietz | b2b32a3 | 2020-03-24 13:56:50 +0100 | [diff] [blame] | 80 | \item{json}{logical that determines if json result is expected} |
| 81 | |
Marc Kupietz | b49afa0 | 2020-06-04 15:50:29 +0200 | [diff] [blame] | 82 | \item{getHeaders}{logical that determines if headers and content should be returned (as a list)} |
| 83 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 84 | \item{object}{KorAPConnection object} |
| 85 | } |
| 86 | \value{ |
Marc Kupietz | 67edcb5 | 2021-09-20 21:54:24 +0200 | [diff] [blame] | 87 | \code{\link[=KorAPConnection]{KorAPConnection()}} object that can be used e.g. with |
| 88 | \code{\link[=corpusQuery]{corpusQuery()}} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 89 | } |
| 90 | \description{ |
Marc Kupietz | 7776dec | 2019-09-27 16:59:02 +0200 | [diff] [blame] | 91 | \code{KorAPConnection} objects represent the connection to a KorAP server. |
Marc Kupietz | 7715e9d | 2019-11-08 15:59:58 +0100 | [diff] [blame] | 92 | New \code{KorAPConnection} objects can be created by \code{new("KorAPConnection")}. |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 93 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 94 | \examples{ |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 95 | \donttest{ |
Marc Kupietz | 5a51982 | 2019-09-20 21:43:52 +0200 | [diff] [blame] | 96 | kcon <- new("KorAPConnection", verbose = TRUE) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 97 | kq <- corpusQuery(kcon, "Ameisenplage") |
Marc Kupietz | 5a51982 | 2019-09-20 21:43:52 +0200 | [diff] [blame] | 98 | kq <- fetchAll(kq) |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 99 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 100 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 101 | \dontrun{ |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 102 | kcon <- new("KorAPConnection", verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg") |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 103 | kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE) |
| 104 | kq <- fetchAll(kq) |
| 105 | kq@collectedMatches$snippet |
| 106 | } |
| 107 | |
| 108 | \dontrun{ |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 109 | kco <- new("KorAPConnection", accessToken="e739u6eOzkwADQPdVChxFg") |
| 110 | persistAccessToken(kco) |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | \dontrun{ |
| 114 | kco <- new("KorAPConnection") |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 115 | clearAccessToken(kco) |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 116 | } |
| 117 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 118 | } |