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 | 6a3185b | 2021-12-07 10:23:16 +0100 | [diff] [blame] | 26 | timeout = 240, |
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 | a467572 | 2022-02-23 23:55:15 +0100 | [diff] [blame^] | 35 | \S4method{apiCall}{KorAPConnection}( |
| 36 | kco, |
| 37 | url, |
| 38 | json = TRUE, |
| 39 | getHeaders = FALSE, |
| 40 | cache = kco@cache, |
| 41 | timeout = kco@timeout |
| 42 | ) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 43 | |
Marc Kupietz | 0a96b28 | 2019-10-01 11:05:31 +0200 | [diff] [blame] | 44 | \S4method{clearCache}{KorAPConnection}(kco) |
| 45 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 46 | \S4method{show}{KorAPConnection}(object) |
| 47 | } |
| 48 | \arguments{ |
| 49 | \item{.Object}{KorAPConnection object} |
| 50 | |
| 51 | \item{KorAPUrl}{the URL of the KorAP server instance you want to access.} |
| 52 | |
| 53 | \item{apiVersion}{which version of KorAP's API you want to connect to.} |
| 54 | |
| 55 | \item{apiUrl}{URL of the KorAP web service.} |
| 56 | |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 57 | \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] | 58 | in subsequent queries, initialize your KorAP connection with |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 59 | \code{kco <- new("KorAPConnection", accessToken="<access token>")}. |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 60 | In order to make the API |
| 61 | token persistent for the currently used \code{KorAPUrl} (you can have one |
| 62 | token per KorAPUrl / KorAP server instance), use |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 63 | \code{persistAccessToken(kco)}. This will store it in your keyring using the |
Marc Kupietz | 67edcb5 | 2021-09-20 21:54:24 +0200 | [diff] [blame] | 64 | \code{\link[=keyring]{keyring()}} package. Subsequent new("KorAPConnection") calls will |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 65 | then automatically retrieve the token from your keying. To stop using a |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 66 | persisted token, call \code{clearAccessToken(kco)}. Please note that for |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 67 | DeReKo, authorized queries will behave differently inside and outside the |
| 68 | IDS, because of the special license situation. This concerns also cached |
| 69 | 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] | 70 | you experience problems or unexpected results, please try \code{kco <- new("KorAPConnection", cache=FALSE)} or use |
| 71 | \code{\link[=clearCache]{clearCache()}} to clear the cache completely.} |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 72 | |
Marc Kupietz | d0d3e9b | 2019-09-24 17:36:03 +0200 | [diff] [blame] | 73 | \item{userAgent}{user agent string.} |
| 74 | |
| 75 | \item{timeout}{time out in seconds.} |
| 76 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 77 | \item{verbose}{logical. Decides whether following operations will default to |
| 78 | be verbose.} |
Marc Kupietz | 5a51982 | 2019-09-20 21:43:52 +0200 | [diff] [blame] | 79 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 80 | \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] | 81 | the cache with \code{\link[=clearCache]{clearCache()}}.} |
Marc Kupietz | 0a96b28 | 2019-10-01 11:05:31 +0200 | [diff] [blame] | 82 | |
Marc Kupietz | d0d3e9b | 2019-09-24 17:36:03 +0200 | [diff] [blame] | 83 | \item{kco}{KorAPConnection object} |
| 84 | |
| 85 | \item{url}{request url} |
| 86 | |
Marc Kupietz | b2b32a3 | 2020-03-24 13:56:50 +0100 | [diff] [blame] | 87 | \item{json}{logical that determines if json result is expected} |
| 88 | |
Marc Kupietz | b49afa0 | 2020-06-04 15:50:29 +0200 | [diff] [blame] | 89 | \item{getHeaders}{logical that determines if headers and content should be returned (as a list)} |
| 90 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 91 | \item{object}{KorAPConnection object} |
| 92 | } |
| 93 | \value{ |
Marc Kupietz | 67edcb5 | 2021-09-20 21:54:24 +0200 | [diff] [blame] | 94 | \code{\link[=KorAPConnection]{KorAPConnection()}} object that can be used e.g. with |
| 95 | \code{\link[=corpusQuery]{corpusQuery()}} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 96 | } |
| 97 | \description{ |
Marc Kupietz | 7776dec | 2019-09-27 16:59:02 +0200 | [diff] [blame] | 98 | \code{KorAPConnection} objects represent the connection to a KorAP server. |
Marc Kupietz | 7715e9d | 2019-11-08 15:59:58 +0100 | [diff] [blame] | 99 | New \code{KorAPConnection} objects can be created by \code{new("KorAPConnection")}. |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 100 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 101 | \examples{ |
Marc Kupietz | 6ae7605 | 2021-09-21 10:34:00 +0200 | [diff] [blame] | 102 | \dontrun{ |
| 103 | |
Marc Kupietz | 5a51982 | 2019-09-20 21:43:52 +0200 | [diff] [blame] | 104 | kcon <- new("KorAPConnection", verbose = TRUE) |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 105 | kq <- corpusQuery(kcon, "Ameisenplage") |
Marc Kupietz | 5a51982 | 2019-09-20 21:43:52 +0200 | [diff] [blame] | 106 | kq <- fetchAll(kq) |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 107 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 108 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 109 | \dontrun{ |
Marc Kupietz | 6ae7605 | 2021-09-21 10:34:00 +0200 | [diff] [blame] | 110 | |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 111 | kcon <- new("KorAPConnection", verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg") |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 112 | kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE) |
| 113 | kq <- fetchAll(kq) |
| 114 | kq@collectedMatches$snippet |
| 115 | } |
| 116 | |
| 117 | \dontrun{ |
Marc Kupietz | 6ae7605 | 2021-09-21 10:34:00 +0200 | [diff] [blame] | 118 | |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 119 | kco <- new("KorAPConnection", accessToken="e739u6eOzkwADQPdVChxFg") |
| 120 | persistAccessToken(kco) |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | \dontrun{ |
Marc Kupietz | 6ae7605 | 2021-09-21 10:34:00 +0200 | [diff] [blame] | 124 | |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 125 | kco <- new("KorAPConnection") |
Marc Kupietz | b956b81 | 2019-11-25 17:53:13 +0100 | [diff] [blame] | 126 | clearAccessToken(kco) |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 127 | } |
| 128 | |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 129 | } |