Qore RestClient Module Reference 2.2.0
Loading...
Searching...
No Matches
RestClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* RestClient.qm Copyright (C) 2013 - 2024 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum qore version
26
27// require type definitions everywhere
28
29// enable all warnings
30
31// don't use "$" for vars, members, and methods, assume local variable scope
32
33
34
35
36
37
38
39/* Version History - see below in docs
40*/
41
270namespace RestClient {
272
274public hashdecl AuthCodeInfo {
276 string response_type = "code";
277
280
282 *list<string> scopes;
283
285 *string state;
286};
287
290
291public:
293 const DataSerializationSupport = ...;
294
295
296 const DeserializeYaml = ...;
297
298 const DeserializeXml = ...;
299
300
302 const AcceptList = ...;
303
304
306 const Accept = AcceptList.join(",");
307
309 const AcceptMap = map {$1: True}, AcceptList;
310
312 const Version = "2.2";
313
315 const VersionString = sprintf("Qore-RestClient/%s", RestClient::Version);
316
318 const DefaultHeaders = ...;
319
320
322 const DefaultOAuth2RedirectUrl = "auto";
323
325 const DefaultOptions = ...;
326
327
329
339 const DataSerializationOptions = ...;
340
341
343
349 const EncodingSupport = ...;
350
351
353 const CompressionThreshold = 1024;
354
356
358 const OAuth2GrantOptions = ...;
359
360
362 const OAuth2AuthHeaders = ...;
363
364
366 const MinimumTokenRefresh = 1m;
367
369 const Oauth2TokenRefreshWindow = 10m;
370
371protected:
372 // headers to send with every request
373 hash<auto> headers;
374 // data serialization code
375 string ds;
376 // serialization content type
377 string sct;
378 // send content encoding hash
379 *hash<auto> seh;
380 // REST schema validator
382 // no_charset option
383 *bool noCharset;
384
386 string username;
388 string password;
389
397 *softlist<string> oauth2_scopes;
401 *hash<auto> oauth2_auth_args;
403 *hash<auto> oauth2_token_args;
417 string token;
423 bool oauth2_auto_refresh = True;
425 bool oauth2_token_auth_secret_only = False;
427 bool oauth2_token_use_basic_auth = False;
433
435 bool oauth2_pkce = False;
437
444
446 transient *code alt_token_signer;
448 transient *string alt_token_signer_header;
449
450public:
451
453
566 constructor(*hash<auto> opts, *softbool do_not_connect) ;
567
568
570 setLogger(*LoggerInterface logger);
571
572
575
576
578
582 setOAuth2Options(hash<auto> new_opts);
583
584
586
590 hash<auto> getOAuth2Options();
591
592
594
597
598
600
613 setSerialization(string data = 'auto');
614
615
617
634 setSendEncoding(string enc = 'auto');
635
636
638
655 setContentEncoding(string enc = 'auto');
656
657
659
675 addDefaultHeaders(hash<auto> h);
676
677
679
692 hash<auto> getDefaultHeaders();
693
694
696
701 replaceDefaultHeaders(*hash<auto> hdr);
702
703
705
721
722
724
737
738
740
782 hash<auto> get(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
783
784
786
825 hash<auto> put(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
826
827
829
868 hash<auto> patch(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
869
870
872
911 hash<auto> post(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
912
913
915
954 hash<auto> del(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
955
956
958
963
964
966
969
970
972
975
976
978
981
982
984
987
988
990
992 setToken(string token_type, string token, *string refresh_token, *date token_expiry);
993
994
996
998 string getTokenType();
999
1000
1002
1004 *string getToken();
1005
1006
1008
1010 AbstractPollOperation startOAuth2PollSendRecv();
1011
1012
1014
1016 AbstractPollOperation startOAuth2PollRefreshToken();
1017
1018
1020
1067 hash<auto> doRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr);
1068
1069
1071
1124 hash<auto> doSignedRequest(string shdr, code signer, string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr);
1125
1126
1128protected:
1129 bool needsRefresh(*hash<ExceptionInfo> ex, *hash<auto> info, *bool body_deserialized, auto body);
1130public:
1131
1132
1134
1138 bool isAuthTokenError(int status_code, hash<auto> headers, *bool body_deserialized, *string body_content_type, auto body);
1139
1140
1142
1152 hash<auto> getNewToken();
1153
1154
1156
1159protected:
1160 hash<auto> getNewTokenIntern(*reference<hash<auto>> info);
1161public:
1162
1163
1165
1169protected:
1170 hash<auto> refreshTokenIntern(*reference<hash<auto>> info);
1171public:
1172
1173
1175protected:
1176 hash<auto> doRequestIntern(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr, *string assume_content_type, *string shdr, *code signer);
1177public:
1178
1179
1181
1188 prepareToSend(string method, reference<string> path, reference<auto> body, *reference<hash<auto>> hdr);
1189
1190
1192
1194 hash<auto> doValidatedRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr);
1195
1196
1198
1205 hash<auto> processRestResponse(hash<auto> resp, string method, string path, *reference<hash<auto>> info);
1206
1207
1209
1213 hash<auto> gotOAuth2LoginInfo(hash<auto> h, *bool refresh);
1214
1215
1217
1221 auto preprocessRequestBody(auto request_body);
1222
1223
1225 *LoggerInterface getLogger();
1226
1227
1229
1234 static *string getScopeString(*list<auto> scopes, string separator = ' ');
1235
1237
1239 setAltTokenSigner(code signer, string signer_header);
1240
1241
1243
1246
1247
1249
1251protected:
1252 setOAuth2LoginInfo(hash<auto> h);
1253public:
1254
1255
1257
1259protected:
1260 *hash<auto> getUpdateOptionsAfterLogin(hash<auto> h, *bool refresh);
1261public:
1262
1263
1265
1267protected:
1268 setupAuth(hash<auto> opts, *bool no_exceptions);
1269public:
1270
1271
1273
1275protected:
1276 checkOAuth2Options(hash<auto> opts, *bool no_exceptions);
1277public:
1278
1279
1281
1283protected:
1284 hash<auto> loginIntern(*reference<hash<auto>> info);
1285public:
1286
1287
1289
1291protected:
1292 AbstractPollOperation startOAuth2AuthPoll(hash<auto> login);
1293public:
1294
1295
1297
1299protected:
1300 hash<auto> oauth2Auth(hash<auto> login, *reference<hash<auto>> info, *bool refresh);
1301public:
1302
1303
1305
1307protected:
1308 hash<auto> oauth2AuthIntern(hash<auto> login, *reference<hash<auto>> info, *bool refresh);
1309public:
1310
1311
1313
1315protected:
1316 hash<auto> doOAuth2LoginRequest(string url, hash<auto> login, *reference<hash<auto>> info);
1317public:
1318
1319
1321
1323protected:
1325public:
1326
1327
1329
1331protected:
1332 hash<auto> getOAuth2LoginInfo(string grant_type);
1333public:
1334
1335
1337
1339protected:
1341public:
1342
1343
1345protected:
1346 nothing prepareMsg(string method, string path, reference<auto> body, reference<hash<auto>> hdr, string ct = 'Content-Type');
1347public:
1348
1349
1351protected:
1352 nothing preparePath(reference<string> path);
1353public:
1354
1355
1357protected:
1358 checkLogin(*reference<hash<auto>> info);
1359public:
1360
1361
1363protected:
1364 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors, *string assume_content_type, *string shdr, *code signer);
1365public:
1366
1367
1369protected:
1370 static decodeError(hash<auto> h, *reference<hash<auto>> info);
1371public:
1372
1373
1375private:
1376 static tryDecodeErrorResponse(reference<hash<auto>> h, *reference<hash<auto>> info);
1377public:
1378
1379}; // class RestClient
1380
1382
1462
1463public:
1465 hash<auto> real_opts;
1466
1469
1471 const ConnectionScheme = ...;
1472
1473
1475 const Options = map {$1: True}, keys ConnectionScheme.options;
1476
1478 const OptionList = keys ConnectionScheme.options;
1479
1482
1483
1485 const OAuth2Options = ...;
1486
1487
1489
1492 const RCF_OAUTH2_AUTH_CODE = "oauth2-auth-code";
1493
1494protected:
1496 transient *code alt_token_signer;
1498 transient *string alt_token_signer_header;
1499
1501 hash<string, bool> features = {
1502 CF_LOGGER: True,
1503 };
1504
1505public:
1506
1508
1521 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {})
1522 ;
1523
1524
1526
1543 constructor(hash<auto> config, *hash<auto> attr) ;
1544
1545
1547 setLogger(*LoggerInterface logger);
1548
1549
1551 *LoggerInterface getLogger();
1552
1553
1555
1561
1562
1564
1568
1569
1571
1575
1576
1578
1580 string getOAuth2OptionName(string opt);
1581
1582
1584
1588 object getPollImpl();
1589
1590
1592
1596 hash<auto> getOptions();
1597
1598
1600 string getType();
1601
1602
1604
1606 hash<auto> getOAuth2Options();
1607
1608
1610
1612 hash<auto> processOAuth2TokenResponse(hash<auto> resp);
1613
1614
1616
1619
1620
1622
1630 DataProvider::AbstractDataProvider getDataProvider(*hash<auto> constructor_options);
1631
1632
1634
1639
1640
1642
1647 Qore::AbstractPollOperation startPollConnect(*Logger::LoggerInterface logger);
1648
1649
1651
1653 static hash<auto> processOptions(string name, *hash<auto> opts);
1654
1656
1663 string getAuthorizationCodeRequest(hash<AuthCodeInfo> info = <AuthCodeInfo>{});
1664
1665
1667 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1668 is to return a full URL
1669
1670 @since %RestClient 2.0
1671 */
1672 string getAuthUrl(*bool allow_relative);
1673
1674
1676 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1677 is to return a full URL
1678
1679 @since %RestClient 2.0
1680 */
1681 string getTokenUrl(*bool allow_relative);
1682
1683
1685 *hash<auto> getConnectionOptions(*hash<auto> rtopts);
1686
1687
1689
1691 setAltTokenSigner(code signer, string signer_header);
1692
1693
1695
1698
1699
1701
1703 RestClient get(bool connect = True, *hash<auto> rtopts);
1704
1705
1707
1709protected:
1711public:
1712
1713
1715
1717protected:
1719public:
1720
1721
1723
1729protected:
1731public:
1732
1733
1735 /* @param opt the URL option name
1736 @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1737 is to return a full URL
1738
1739 @since %RestClient 2.1.1
1740 */
1741protected:
1742 string getUrlOption(string opt, *bool allow_relative);
1743public:
1744
1745
1747 /* @param uri the URL value
1748 @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1749 is to return a full URL
1750
1751 @since %RestClient 2.2
1752 */
1753protected:
1754 string getUrlOptionIntern(string uri, *bool allow_relative);
1755public:
1756
1757
1759 /*
1760 @since %RestClient 2.0
1761 */
1762protected:
1763 static softstring getUriValue(auto v, string separator = ' ');
1764public:
1765
1766
1768protected:
1769 *hash<auto> processOAuth2TokenResponseImpl(hash<auto> resp);
1770public:
1771
1772
1774protected:
1776public:
1777
1778
1780
1788protected:
1789 RestClient getImpl(bool connect = True, *hash<auto> rtopts);
1790public:
1791
1792
1794
1797protected:
1799public:
1800
1801
1803
1805protected:
1807public:
1808
1809
1811protected:
1812 *string getPingPath();
1813public:
1814
1815
1817protected:
1819public:
1820
1821
1823
1825protected:
1826 *hash<string, bool> getFeaturesImpl();
1827public:
1828
1829
1831protected:
1833public:
1834
1835
1837protected:
1838 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
1839public:
1840
1841};
1842
1844
1847
1848public:
1850 const SPS_GET_SWAGGER = 'get-swagger';
1851
1853 const SPS_OAUTH2_GET_TOKEN = "oauth2-get-token";
1854
1856 const SPS_OAUTH2_REFRESH_TOKEN = "oauth2-refresh-token";
1857
1859 const SPS_REST_PING = "rest-ping";
1860
1862 const SPS_COMPLETE = "complete";
1863
1864protected:
1867
1870
1872 hash<auto> real_opts;
1873
1875 AbstractPollOperation poller;
1876
1878 bool goal_reached = False;
1879
1881 string method;
1882
1884 string path;
1885
1887 *auto body;
1888
1890 *hash<auto> headers;
1891
1893 string state;
1894
1896 Mutex m();
1897
1900
1903
1904public:
1905
1908
1909
1912
1913
1915
1917 string getGoal();
1918
1919
1921
1923 string getState();
1924
1925
1927
1930
1931
1933 *hash<SocketPollInfo> continuePoll();
1934
1935
1936 abort();
1937
1938
1939protected:
1940 checkOtherStates();
1941public:
1942
1943
1944protected:
1945 gotOAuth2LoginInfo(hash<auto> h);
1946public:
1947
1948
1949protected:
1950 doStartGetToken();
1951public:
1952
1953
1954protected:
1955 doStartRefresh();
1956public:
1957
1958
1959protected:
1960 doStartPing();
1961public:
1962
1963
1964protected:
1965 checkUrl();
1966public:
1967
1968};
1969};
bool requiresRefresh()
Returns True if the client requires a tokenm refresh.
string oauth2_scope_separator_char
OAuth2 scope separator char.
Definition RestClient.qm.dox.h:399
auto preprocessRequestBody(auto request_body)
Preprocesses the request body before serialization.
hash< auto > oauth2AuthIntern(hash< auto > login, *reference< hash< auto > > info, *bool refresh)
Perform OAuth2 authentication.
*string getToken()
Returns any token set for the connection.
string oauth2_app
OAuth2 app name.
Definition RestClient.qm.dox.h:439
string token_api_key_header
If this option is set along with a token, it indicates a header to send the token in as an API key.
Definition RestClient.qm.dox.h:421
checkOAuth2Options(hash< auto > opts, *bool no_exceptions)
Validates and sets any OAuth2 options.
hash< auto > patch(string path, auto body, *reference< hash< auto > > info, *hash< auto > hdr)
sends an HTTP PATCH request to the REST server and returns the response
bool usingOAuth2()
Returns True if the client is configured for authentication with OAuth2.
*hash< auto > getUpdateOptionsAfterLogin(hash< auto > h, *bool refresh)
Returns options to update after an OAuth2 login.
hash< auto > getNewToken()
Get a new token from the server either with an OAuth2 token request or using the refresh token.
hash< auto > doSignedRequest(string shdr, code signer, string m, string path, auto body, *reference< hash< auto > > info, softbool decode_errors=True, *hash< auto > hdr)
sends a signed HTTP request to the REST server and returns the response
static tryDecodeErrorResponse(reference< hash< auto > > h, *reference< hash< auto > > info)
tries to decode an error response
string oauth2_grant_type
OAuth2 grant type.
Definition RestClient.qm.dox.h:391
string oauth2_redirect_url
OAuth2 redirect URL.
Definition RestClient.qm.dox.h:407
hash< auto > loginIntern(*reference< hash< auto > > info)
Authenticates with OAuth2 if configured.
constructor(*hash< auto > opts, *softbool do_not_connect)
calls the base class HTTPClient constructor and optionally connects to the REST server
transient *code alt_token_signer
To use to sign requests to the any alt token URL.
Definition RestClient.qm.dox.h:446
string token
Any token set for the connection; will be passed as a bearer token (Authorization: Bearer ....
Definition RestClient.qm.dox.h:417
hash< auto > post(string path, auto body, *reference< hash< auto > > info, *hash< auto > hdr)
sends an HTTP POST request to the REST server and returns the response
hash< auto > get(string path, auto body, *reference< hash< auto > > info, *hash< auto > hdr)
sends an HTTP GET request to the REST server and returns the response
date oauth2_token_expiry
The token expiry date.
Definition RestClient.qm.dox.h:431
transient *string alt_token_signer_header
The header for the alt token signer.
Definition RestClient.qm.dox.h:448
*LoggerInterface getLogger()
Returns the logger interface for logging.
setContentEncoding(string enc='auto')
sets the request and desired response encoding for the object; see EncodingSupport for valid options
hash< auto > getNewTokenIntern(*reference< hash< auto > > info)
Get a new token from the server.
string oauth2_token_url
OAuth2 token URL.
Definition RestClient.qm.dox.h:409
nothing preparePath(reference< string > path)
sets up the path for the HTTP request URI
setupAuth(hash< auto > opts, *bool no_exceptions)
Sets up authentication info.
hash< auto > getDefaultHeaders()
returns the hash of default headers to sent in all requests
hash< auto > del(string path, auto body, *reference< hash< auto > > info, *hash< auto > hdr)
sends an HTTP DELETE request to the REST server and returns the response
setOAuth2LoginInfo(hash< auto > h)
Sets options from the OAuth2 login response on the local object.
hash< auto > doOAuth2LoginRequest(string url, hash< auto > login, *reference< hash< auto > > info)
Returns the deserialized response body of an OAuth2 authorization / token request.
setToken(string token_type, string token, *string refresh_token, *date token_expiry)
Sets a token for authentication.
hash< auto > doValidatedRequest(string m, string path, auto body, *reference< hash< auto > > info, softbool decode_errors=True, *hash< auto > hdr)
The same as doRequest() except no schema validation is performed on the request.
clearAltTokenSigner()
Clears alt token signer code and the header for it.
bool isAuthTokenError(int status_code, hash< auto > headers, *bool body_deserialized, *string body_content_type, auto body)
Returns True if the response was related to an authorization token error.
string getTokenType()
Returns the token type for any token.
hash< auto > refreshTokenIntern(*reference< hash< auto > > info)
Gets a new token using the refresh token.
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
hash< auto > getOAuth2RefreshInfo()
Returns an OAuth2 refresh hash.
checkLogin(*reference< hash< auto > > info)
Checks if a login is necessary; if so, then the login is performed.
string oauth2_client_id
OAuth2 client ID.
Definition RestClient.qm.dox.h:393
*hash< auto > oauth2_alt_url_subst
Alternate OAuth2 URL substitution info.
Definition RestClient.qm.dox.h:411
bool requiresOAuth2Token()
Returns True if the client requires an OAuth2 token.
string oauth2_client_secret
OAuth2 client secret.
Definition RestClient.qm.dox.h:395
bool needsRestBodyAuthErrorCheck()
Returns True if the object needs to have deserialized bodies check for authentication errors.
string token_type
The token type, if any.
Definition RestClient.qm.dox.h:415
hash< auto > put(string path, auto body, *reference< hash< auto > > info, *hash< auto > hdr)
sends an HTTP PUT request to the REST server and returns the response
RestSchemaValidator::AbstractRestSchemaValidator getValidator()
returns the current validator object
int oauth2_token_expiry_hint
An expiry date hint as a value in minutes.
Definition RestClient.qm.dox.h:429
setSerialization(string data='auto')
change the serialization option for the object; see DataSerializationOptions for valid options
clearConnectionPath()
Clears the connection path when a validator is present that manages the URI path.
string oauth2_alt_token_url
Alternate OAuth2 token URL.
Definition RestClient.qm.dox.h:413
bool needsRefresh(*hash< ExceptionInfo > ex, *hash< auto > info, *bool body_deserialized, auto body)
Returns True if the request error indicates that a refresh operation should be performed.
setSendEncoding(string enc='auto')
change the data content encoding (compression) option for the object
*hash< auto > oauth2_token_args
OAuth2 extra token args.
Definition RestClient.qm.dox.h:403
hash< auto > oauth2Auth(hash< auto > login, *reference< hash< auto > > info, *bool refresh)
Perform OAuth2 authentication.
static decodeError(hash< auto > h, *reference< hash< auto > > info)
decode any REST errors returned if possible
hash< auto > getOAuth2LoginInfo(string grant_type)
Returns an OAuth2 login hash.
setOAuth2Options(hash< auto > new_opts)
Sets OAuth2 options.
AbstractPollOperation startOAuth2AuthPoll(hash< auto > login)
Starts a non-blocking I/O operation to authenticate with an OAuth2 server and acquire an auth token.
AbstractPollOperation startOAuth2PollRefreshToken()
Starts an OAuth2 refresh token request in a non-blocking I/O operation.
hash< auto > processRestResponse(hash< auto > resp, string method, string path, *reference< hash< auto > > info)
Process the raw REST response received.
hash< auto > getOAuth2Options()
Return OAuth2 options.
*hash< auto > rest_body_auth_error_check
A hash to check all deserialized bodies in 200 OK server responses for authentication errors.
Definition RestClient.qm.dox.h:441
*softlist< string > oauth2_scopes
OAuth2 scope.
Definition RestClient.qm.dox.h:397
replaceDefaultHeaders(*hash< auto > hdr)
replaces default headers
setAltTokenSigner(code signer, string signer_header)
Sets alt token signer code and the header for it.
hash< auto > doRequestIntern(string m, string path, auto body, *reference< hash< auto > > info, softbool decode_errors=True, *hash< auto > hdr, *string assume_content_type, *string shdr, *code signer)
Makes a REST request and returns the result.
static *string getScopeString(*list< auto > scopes, string separator=' ')
Returns a scope string URI argument.
hash< auto > doRequest(string m, string path, auto body, *reference< hash< auto > > info, softbool decode_errors=True, *hash< auto > hdr)
sends an HTTP request to the REST server and returns the response
string password
password for authentication
Definition RestClient.qm.dox.h:388
addDefaultHeaders(hash< auto > h)
adds default headers to each request
nothing prepareMsg(string method, string path, reference< auto > body, reference< hash< auto > > hdr, string ct='Content-Type')
sets up the Content-Type header and encodes any body for sending
*hash< auto > getOAuth2AuthHeaders()
Returns headers to use with OAuth2 authorization / token requests.
AbstractPollOperation startOAuth2PollSendRecv()
Starts an OAuth2 token request in a non-blocking I/O operation.
*hash< auto > oauth2_auth_args
OAuth2 extra auth args.
Definition RestClient.qm.dox.h:401
string getSerialization()
returns the current data serialization format currently in effect for the object
hash< auto > gotOAuth2LoginInfo(hash< auto > h, *bool refresh)
Called when OAuth2 login information has been received.
*string getSendEncoding()
returns the current data content encoding (compression) object or NOTHING if no encoding option is se...
const Version
RestClient Version.
Definition RestClient.qm.dox.h:312
string oauth2_auth_url
OAuth2 auth URL.
Definition RestClient.qm.dox.h:405
string refresh_token
Any refresh token granted to the client.
Definition RestClient.qm.dox.h:419
string username
username for authentication
Definition RestClient.qm.dox.h:386
prepareToSend(string method, reference< string > path, reference< auto > body, *reference< hash< auto > > hdr)
Prepares and processes message parameters for sending without sending the message.
date token_timestamp
Last timestamp for token acquisition.
Definition RestClient.qm.dox.h:443
setValidator(RestSchemaValidator::AbstractRestSchemaValidator validator)
Sets a new REST schema validator.
hash< auto > sendAndDecodeResponse(*data body, string m, string path, hash< auto > hdr, *reference< hash< auto > > info, *softbool decode_errors, *string assume_content_type, *string shdr, *code signer)
sends the outgoing HTTP message and recodes the response to data
class for REST HTTP connections; returns RestClient::RestClient objects
Definition RestClient.qm.dox.h:1461
bool hasDataProvider()
returns True, as this connection always returns a data provider with the getDataProvider() method
authSuccess()
Flags a successful connection.
transient *string alt_token_signer_header
The header for the alt token signer.
Definition RestClient.qm.dox.h:1498
string getOAuth2OptionName(string opt)
Returns the OAuth2 option name for this connection.
pingImpl()
performs the internal ping
const OptionList
object connection option list
Definition RestClient.qm.dox.h:1478
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the RestConnection connection object
string getUrlOption(string opt, *bool allow_relative)
Returns the value of a URL option or throws an exception if not set.
hash< auto > real_opts
real options used when creating an object
Definition RestClient.qm.dox.h:1465
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
RestClient get(bool connect=True, *hash< auto > rtopts)
returns the underlying connection object
Qore::AbstractPollOperation startPollConnect(*Logger::LoggerInterface logger)
Called to start a non-blocking polling ping operation on the remote REST server.
const Options
object connection options
Definition RestClient.qm.dox.h:1475
*string getPingPath()
Returns the ping path from the ping_path option.
*hash< auto > getConnectionOptions(*hash< auto > rtopts)
Returns options for creating a new connection.
hash< auto > getOAuth2Options()
Returns OAuth2 options in a standard format.
*hash< auto > processOAuth2TokenResponseImpl(hash< auto > resp)
Processes OAuth2 login responses and returns updated options.
string getAuthorizationCodeRequest(hash< AuthCodeInfo > info=< AuthCodeInfo >{})
Returns a URI for an authorization code request.
auto getPingBody()
Returns the ping body from the ping_body option.
const OAuth2AuthRequestOptions
Options required for an OAuth2 authorization request.
Definition RestClient.qm.dox.h:1481
bool needs_auth
Connections needs authorization?
Definition RestClient.qm.dox.h:1468
RestClient setupRestClientConfig(RestClient rest)
Sets the alt token signer code and header on a RestClient object if applicable.
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
DataProvider::AbstractDataProvider getDataProvider(*hash< auto > constructor_options)
returns a data provider object for this connection
bool needsAuth()
Returns True if the connection requires OAuth2 authorization before it can be used.
checkCanConnect()
Checks if the connection can theoretically communicate, if not, sets the connection as down.
checkAuthCodeFeature()
Sets the auth code feature if supported.
string getAuthUrl(*bool allow_relative)
Returns the OAuth2 authorization URL or throws an exception if not set.
object getPollImpl()
Returns an unconnected object for a non-blocking poll operation.
transient *code alt_token_signer
To use to sign requests to the any alt token URL.
Definition RestClient.qm.dox.h:1496
*hash< string, bool > getFeaturesImpl()
Returns a list of connection-defined features.
static hash< auto > processOptions(string name, *hash< auto > opts)
processes options for the constructor
const RCF_OAUTH2_AUTH_CODE
RestClient feature: OAuth2 Auth Code support.
Definition RestClient.qm.dox.h:1492
hash< auto > processOAuth2TokenResponse(hash< auto > resp)
Processes the OAuth2 token response.
string getUrlOptionIntern(string uri, *bool allow_relative)
Returns the value of a URL option.
setChildCapabilities()
Sets child data provider capabilities.
*hash< auto > getOAuth2AuthHeaders()
Returns headers to use with OAuth2 authorization / token requests.
RestClient getImpl(bool connect=True, *hash< auto > rtopts)
returns a RestClient object
setFeatures()
Sets features during REST client initialization.
authFailure()
Flags an authorization failure.
setupRest()
Common REST client initialization.
hash< auto > getOptions()
gets options
const OAuth2Options
All OAuth2 options.
Definition RestClient.qm.dox.h:1485
clearAltTokenSigner()
Clears alt token signer code and the header for it.
const ConnectionScheme
Connection entry info.
Definition RestClient.qm.dox.h:1471
setAltTokenSigner(code signer, string signer_header)
Sets alt token signer code and the header for it.
*LoggerInterface getLogger()
Returns the logger interface for logging.
hash< string, bool > features
Hash of supported features.
Definition RestClient.qm.dox.h:1501
static softstring getUriValue(auto v, string separator=' ')
Returns a value for use as a URI parameter.
string getType()
returns "rest"
string getTokenUrl(*bool allow_relative)
Returns the OAuth2 token URL or throws an exception if not set.
constructor(hash< auto > config, *hash< auto > attr)
creates the RestConnection connection object
REST ping polling I/O class with OAuth2 authentication.
Definition RestClient.qm.dox.h:1846
const SPS_OAUTH2_REFRESH_TOKEN
OAuth2 refresh token state.
Definition RestClient.qm.dox.h:1856
*hash< SocketPollInfo > continuePoll()
Returns a hash to be used for I/O polling or NOTHING in case the poll operation is complete.
bool in_refresh
token refresh flag
Definition RestClient.qm.dox.h:1899
RestConnection conn
The REST connection.
Definition RestClient.qm.dox.h:1866
string state
Current state.
Definition RestClient.qm.dox.h:1893
string path
The URI path to use.
Definition RestClient.qm.dox.h:1884
destructor()
Destroys the object and makes any connection option updates.
string getGoal()
Returns the goal.
const SPS_OAUTH2_GET_TOKEN
OAuth2 get token state.
Definition RestClient.qm.dox.h:1853
hash< auto > real_opts
RestClient options.
Definition RestClient.qm.dox.h:1872
const SPS_GET_SWAGGER
Retrieve Swagger schema.
Definition RestClient.qm.dox.h:1850
RestClient rc
The RestClient object to use for polling I/O.
Definition RestClient.qm.dox.h:1869
const SPS_COMPLETE
Complete state.
Definition RestClient.qm.dox.h:1862
bool use_path_as_is
Use path directly / ping path already prepared.
Definition RestClient.qm.dox.h:1902
*hash< auto > headers
Headers to send.
Definition RestClient.qm.dox.h:1890
const SPS_REST_PING
Execute ping request.
Definition RestClient.qm.dox.h:1859
bool goalReached()
Returns True when the goal as been reached.
AbstractPollOperation poller
The polling object.
Definition RestClient.qm.dox.h:1875
*auto body
The message body to send.
Definition RestClient.qm.dox.h:1887
bool goal_reached
Goal reached flag.
Definition RestClient.qm.dox.h:1878
string getState()
Returns the current state.
string method
The HTTP method to use.
Definition RestClient.qm.dox.h:1881
Mutex m()
Lock for atomicity.
constructor(RestConnection conn, RestClient rc, hash< auto > real_opts)
Creates the poller with the REST client and option hash.
the RestClient namespace contains all the objects in the RestClient module
Definition RestClient.qm.dox.h:270
Hash to use for generating authorization code requests.
Definition RestClient.qm.dox.h:274
*string redirect_uri
To override the redirect_uri; if not set, the oauth2_redirect_url option will be used instead.
Definition RestClient.qm.dox.h:279
*list< string > scopes
Scopes to use in the request; if not set, the oauth2_scopes option will be used instead.
Definition RestClient.qm.dox.h:282
string response_type
The response type value to use in the request.
Definition RestClient.qm.dox.h:276
*string state
The state value to use in the request.
Definition RestClient.qm.dox.h:285