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
251namespace RestClient {
253
255public hashdecl AuthCodeInfo {
257 string response_type = "code";
258
261
263 *list<string> scopes;
264
266 *string state;
267};
268
271
272public:
274 const DataSerializationSupport = ...;
275
276
277 const DeserializeYaml = ...;
278
279 const DeserializeXml = ...;
280
281
283 const AcceptList = ...;
284
285
287 const Accept = AcceptList.join(",");
288
290 const AcceptMap = map {$1: True}, AcceptList;
291
293 const Version = "2.2";
294
296 const VersionString = sprintf("Qore-RestClient/%s", RestClient::Version);
297
299 const DefaultHeaders = ...;
300
301
303 const DefaultOAuth2RedirectUrl = "auto";
304
306 const DefaultOptions = ...;
307
308
310
320 const DataSerializationOptions = ...;
321
322
324
330 const EncodingSupport = ...;
331
332
334 const CompressionThreshold = 1024;
335
337
339 const OAuth2GrantOptions = ...;
340
341
343 const OAuth2AuthHeaders = ...;
344
345
347 const MinimumTokenRefresh = 1m;
348
349protected:
350 // headers to send with every request
351 hash<auto> headers;
352 // data serialization code
353 string ds;
354 // serialization content type
355 string sct;
356 // send content encoding hash
357 *hash<auto> seh;
358 // REST schema validator
360 // no_charset option
361 *bool noCharset;
362
364 string username;
366 string password;
367
375 *softlist<string> oauth2_scopes;
377 *hash<auto> oauth2_auth_args;
379 *hash<auto> oauth2_token_args;
391 string token;
395 bool oauth2_auto_refresh = True;
397 bool oauth2_token_auth_secret_only = False;
399 bool oauth2_token_use_basic_auth = False;
401
403 bool oauth2_pkce = False;
405
410
411public:
412
414
520 constructor(*hash<auto> opts, *softbool do_not_connect) ;
521
522
524 setLogger(*LoggerInterface logger);
525
526
528
532 setOAuth2Options(hash<auto> new_opts);
533
534
536
540 hash<auto> getOAuth2Options();
541
542
544
547
548
550
563 setSerialization(string data = 'auto');
564
565
567
584 setSendEncoding(string enc = 'auto');
585
586
588
605 setContentEncoding(string enc = 'auto');
606
607
609
625 addDefaultHeaders(hash<auto> h);
626
627
629
642 hash<auto> getDefaultHeaders();
643
644
646
651 replaceDefaultHeaders(*hash<auto> hdr);
652
653
655
671
672
674
687
688
690
744 hash<auto> get(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
745
746
748
799 hash<auto> put(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
800
801
803
854 hash<auto> patch(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
855
856
858
909 hash<auto> post(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
910
911
913
964 hash<auto> del(string path, auto body, *reference<hash<auto>> info, *hash<auto> hdr);
965
966
968
973
974
976
979
980
982
985
986
988
991
992
994
996 setToken(string token_type, string token, *string refresh_token);
997
998
1000
1003
1004
1006
1008 *string getToken();
1009
1010
1012
1014 AbstractPollOperation startOAuth2PollSendRecv();
1015
1016
1018
1020 AbstractPollOperation startOAuth2PollRefreshToken();
1021
1022
1024
1069 hash<auto> doRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr);
1070
1071
1073protected:
1074 bool needsRefresh(hash<ExceptionInfo> ex, *hash<auto> info, bool decode_errors);
1075public:
1076
1077
1079
1083 bool isAuthTokenError(int status_code, hash<auto> headers, bool body_decoded, *string body_content_type, auto body);
1084
1085
1087
1097 hash<auto> getNewToken();
1098
1099
1101
1104protected:
1105 hash<auto> getNewTokenIntern(*reference<hash<auto>> info);
1106public:
1107
1108
1110
1114protected:
1115 hash<auto> refreshTokenIntern(*reference<hash<auto>> info);
1116public:
1117
1118
1120protected:
1121 hash<auto> doRequestIntern(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr, *string assume_content_type);
1122public:
1123
1124
1126
1133 prepareToSend(string method, reference<string> path, reference<auto> body, *reference<hash<auto>> hdr);
1134
1135
1137
1139 hash<auto> doValidatedRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr);
1140
1141
1143
1150 hash<auto> processRestResponse(hash<auto> resp, string method, string path, *reference<hash<auto>> info);
1151
1152
1154
1156 hash<auto> gotOAuth2LoginInfo(hash<auto> h);
1157
1158
1160
1164 auto preprocessRequestBody(auto request_body);
1165
1166
1168
1170protected:
1171 setOAuth2LoginInfo(hash<auto> h);
1172public:
1173
1174
1176
1178protected:
1179 *hash<auto> getUpdateOptionsAfterLogin(hash<auto> h);
1180public:
1181
1182
1184
1186protected:
1187 setupAuth(hash<auto> opts, *bool no_exceptions);
1188public:
1189
1190
1192
1194protected:
1195 checkOAuth2Options(hash<auto> opts, *bool no_exceptions);
1196public:
1197
1198
1200
1202protected:
1203 hash<auto> loginIntern(*reference<hash<auto>> info);
1204public:
1205
1206
1208
1210protected:
1211 AbstractPollOperation startOAuth2AuthPoll(hash<auto> login);
1212public:
1213
1214
1216
1218protected:
1219 hash<auto> oauth2Auth(hash<auto> login, *reference<hash<auto>> info);
1220public:
1221
1222
1224
1226protected:
1227 hash<auto> oauth2AuthIntern(hash<auto> login, *reference<hash<auto>> info);
1228public:
1229
1230
1232
1234protected:
1235 hash<auto> doOAuth2LoginRequest(string url, hash<auto> login, *reference<hash<auto>> info);
1236public:
1237
1238
1240
1242protected:
1244public:
1245
1246
1248
1250protected:
1251 hash<auto> getOAuth2LoginInfo(string grant_type);
1252public:
1253
1254
1256
1258protected:
1260public:
1261
1262
1264protected:
1265 nothing prepareMsg(string method, string path, reference<auto> body, reference<hash<auto>> hdr, string ct = 'Content-Type');
1266public:
1267
1268
1270protected:
1271 nothing preparePath(reference<string> path);
1272public:
1273
1274
1276protected:
1277 checkLogin(*reference<hash<auto>> info);
1278public:
1279
1280
1282protected:
1283 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors, *string assume_content_type);
1284public:
1285
1286
1288protected:
1289 static decodeError(hash<auto> h, *reference<hash<auto>> info);
1290public:
1291
1292
1294private:
1295 static tryDecodeErrorResponse(reference<hash<auto>> h, *reference<hash<auto>> info);
1296public:
1297
1298}; // class RestClient
1299
1301
1377
1378public:
1380 hash<auto> real_opts;
1381
1384
1386 const ConnectionScheme = ...;
1387
1388
1390 const Options = map {$1: True}, keys ConnectionScheme.options;
1391
1393 const OptionList = keys ConnectionScheme.options;
1394
1397
1398
1400 const OAuth2Options = ...;
1401
1402
1404
1407 const RCF_OAUTH2_AUTH_CODE = "oauth2-auth-code";
1408
1409protected:
1411 hash<string, bool> features = {
1412 CF_LOGGER: True,
1413 };
1414
1415public:
1416
1418
1431 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {})
1432 ;
1433
1434
1436
1453 constructor(hash<auto> config, *hash<auto> attr) ;
1454
1455
1457 setLogger(*LoggerInterface logger);
1458
1459
1461
1467
1468
1470
1474
1475
1477
1481
1482
1484
1486 string getOAuth2OptionName(string opt);
1487
1488
1490
1494 object getPollImpl();
1495
1496
1498
1502 hash<auto> getOptions();
1503
1504
1506 string getType();
1507
1508
1510
1512 hash<auto> getOAuth2Options();
1513
1514
1516
1518 hash<auto> processOAuth2TokenResponse(hash<auto> resp);
1519
1520
1522
1525
1526
1528
1536 DataProvider::AbstractDataProvider getDataProvider(*hash<auto> constructor_options);
1537
1538
1540
1545
1546
1548
1554
1555
1557
1559 static hash<auto> processOptions(string name, *hash<auto> opts);
1560
1562
1569 string getAuthorizationCodeRequest(hash<AuthCodeInfo> info = <AuthCodeInfo>{});
1570
1571
1573 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1574 is to return a full URL
1575
1576 @since %RestClient 2.0
1577 */
1578 string getAuthUrl(*bool allow_relative);
1579
1580
1582 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1583 is to return a full URL
1584
1585 @since %RestClient 2.0
1586 */
1587 string getTokenUrl(*bool allow_relative);
1588
1589
1591 *hash<auto> getConnectionOptions(*hash<auto> rtopts);
1592
1593
1595
1597protected:
1599public:
1600
1601
1603
1605protected:
1607public:
1608
1609
1611
1617protected:
1619public:
1620
1621
1623 /* @param opt the URL option name
1624 @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1625 is to return a full URL
1626
1627 @since %RestClient 2.1.1
1628 */
1629protected:
1630 string getUrlOption(string opt, *bool allow_relative);
1631public:
1632
1633
1635 /* @param uri the URL value
1636 @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
1637 is to return a full URL
1638
1639 @since %RestClient 2.2
1640 */
1641protected:
1642 string getUrlOptionIntern(string uri, *bool allow_relative);
1643public:
1644
1645
1647 /*
1648 @since %RestClient 2.0
1649 */
1650protected:
1651 static softstring getUriValue(auto v);
1652public:
1653
1654
1656protected:
1657 *hash<auto> processOAuth2TokenResponseImpl(hash<auto> resp);
1658public:
1659
1660
1662protected:
1664public:
1665
1666
1668
1676protected:
1677 RestClient getImpl(bool connect = True, *hash<auto> rtopts);
1678public:
1679
1680
1682
1684protected:
1686public:
1687
1688
1690protected:
1691 *string getPingPath();
1692public:
1693
1694
1696protected:
1698public:
1699
1700
1702
1704protected:
1705 *hash<string, bool> getFeaturesImpl();
1706public:
1707
1708
1710protected:
1712public:
1713
1714
1716protected:
1717 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
1718public:
1719
1720};
1721
1723
1726
1727public:
1729 const SPS_GET_SWAGGER = 'get-swagger';
1730
1732 const SPS_OAUTH2_GET_TOKEN = "oauth2-get-token";
1733
1735 const SPS_OAUTH2_REFRESH_TOKEN = "oauth2-refresh-token";
1736
1738 const SPS_REST_PING = "rest-ping";
1739
1741 const SPS_COMPLETE = "complete";
1742
1743protected:
1746
1749
1751 hash<auto> real_opts;
1752
1754 AbstractPollOperation poller;
1755
1757 bool goal_reached = False;
1758
1760 string method;
1761
1763 string path;
1764
1766 *auto body;
1767
1769 *hash<auto> headers;
1770
1772 string state;
1773
1775 Mutex m();
1776
1779
1782
1783public:
1784
1787
1788
1790
1792 string getGoal();
1793
1794
1796
1798 string getState();
1799
1800
1802
1805
1806
1808 *hash<SocketPollInfo> continuePoll();
1809
1810
1811protected:
1812 checkOtherStates();
1813public:
1814
1815
1816protected:
1817 gotOAuth2LoginInfo(hash<auto> h);
1818public:
1819
1820
1821protected:
1822 doStartGetToken();
1823public:
1824
1825
1826protected:
1827 doStartRefresh();
1828public:
1829
1830
1831protected:
1832 doStartPing();
1833public:
1834
1835};
1836};
auto preprocessRequestBody(auto request_body)
Preprocesses the request body before serialization.
*string getToken()
Returns any token set for the connection.
string oauth2_app
OAuth2 app name.
Definition RestClient.qm.dox.h:407
*hash< auto > getUpdateOptionsAfterLogin(hash< auto > h)
Returns options to update after an OAuth2 login.
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 > getNewToken()
Get a new token from the server either with an OAuth2 token request or using the refresh token.
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:369
hash< auto > oauth2AuthIntern(hash< auto > login, *reference< hash< auto > > info)
Perform OAuth2 authentication.
string oauth2_redirect_url
OAuth2 redirect URL.
Definition RestClient.qm.dox.h:383
hash< auto > sendAndDecodeResponse(*data body, string m, string path, hash< auto > hdr, *reference< hash< auto > > info, *softbool decode_errors, *string assume_content_type)
sends the outgoing HTTP message and recodes the response to data
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
string token
Any token set for the connection; will be passed as a bearer token (Authorization: Bearer ....
Definition RestClient.qm.dox.h:391
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
bool needsRefresh(hash< ExceptionInfo > ex, *hash< auto > info, bool decode_errors)
Returns True if the request error indicates that a refresh operation should be performed.
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.
hash< auto > gotOAuth2LoginInfo(hash< auto > h)
Called when OAuth2 login information has been received.
string oauth2_token_url
OAuth2 token URL.
Definition RestClient.qm.dox.h:385
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.
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.
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:371
bool requiresOAuth2Token()
Returns True if the client requires an OAuth2 token.
hash< auto > oauth2Auth(hash< auto > login, *reference< hash< auto > > info)
Perform OAuth2 authentication.
bool isAuthTokenError(int status_code, hash< auto > headers, bool body_decoded, *string body_content_type, auto body)
Returns True if the response was related to an authorization token error.
string oauth2_client_secret
OAuth2 client secret.
Definition RestClient.qm.dox.h:373
string token_type
The token type, if any.
Definition RestClient.qm.dox.h:389
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
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:387
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:379
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.
*softlist< string > oauth2_scopes
OAuth2 scope.
Definition RestClient.qm.dox.h:375
replaceDefaultHeaders(*hash< auto > hdr)
replaces default headers
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
setToken(string token_type, string token, *string refresh_token)
Sets a token for authentication.
string password
password for authentication
Definition RestClient.qm.dox.h:366
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:377
string getSerialization()
returns the current data serialization format currently in effect for the object
*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:293
string oauth2_auth_url
OAuth2 auth URL.
Definition RestClient.qm.dox.h:381
string refresh_token
Any refresh token granted to the client.
Definition RestClient.qm.dox.h:393
string username
username for authentication
Definition RestClient.qm.dox.h:364
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:409
hash< auto > doRequestIntern(string m, string path, auto body, *reference< hash< auto > > info, softbool decode_errors=True, *hash< auto > hdr, *string assume_content_type)
Makes a REST request and returns the result.
setValidator(RestSchemaValidator::AbstractRestSchemaValidator validator)
Sets a new REST schema validator.
class for REST HTTP connections; returns RestClient::RestClient objects
Definition RestClient.qm.dox.h:1376
bool hasDataProvider()
returns True, as this connection always returns a data provider with the getDataProvider() method
authSuccess()
Flags a successful connection.
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:1393
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:1380
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
const Options
object connection options
Definition RestClient.qm.dox.h:1390
*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.
static softstring getUriValue(auto v)
Returns a value for use as a URI parameter.
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:1396
bool needs_auth
Connections needs authorization?
Definition RestClient.qm.dox.h:1383
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.
Qore::AbstractPollOperation startPollConnect()
Called to start a non-blocking polling ping operation on the remote REST server.
object getPollImpl()
Returns an unconnected object for a non-blocking poll operation.
*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:1407
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:1400
const ConnectionScheme
Connection entry info.
Definition RestClient.qm.dox.h:1386
hash< string, bool > features
Hash of supported features.
Definition RestClient.qm.dox.h:1411
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:1725
const SPS_OAUTH2_REFRESH_TOKEN
OAuth2 refresh token state.
Definition RestClient.qm.dox.h:1735
*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:1778
RestConnection conn
The REST connection.
Definition RestClient.qm.dox.h:1745
string state
Current state.
Definition RestClient.qm.dox.h:1772
string path
The URI path to use.
Definition RestClient.qm.dox.h:1763
string getGoal()
Returns the goal.
const SPS_OAUTH2_GET_TOKEN
OAuth2 get token state.
Definition RestClient.qm.dox.h:1732
hash< auto > real_opts
RestClient options.
Definition RestClient.qm.dox.h:1751
const SPS_GET_SWAGGER
Retrieve Swagger schema.
Definition RestClient.qm.dox.h:1729
RestClient rc
The RestClient object to use for polling I/O.
Definition RestClient.qm.dox.h:1748
const SPS_COMPLETE
Complete state.
Definition RestClient.qm.dox.h:1741
bool use_path_as_is
Use path directly / ping path already prepared.
Definition RestClient.qm.dox.h:1781
*hash< auto > headers
Headers to send.
Definition RestClient.qm.dox.h:1769
const SPS_REST_PING
Execute ping request.
Definition RestClient.qm.dox.h:1738
bool goalReached()
Returns True when the goal as been reached.
AbstractPollOperation poller
The polling object.
Definition RestClient.qm.dox.h:1754
*auto body
The message body to send.
Definition RestClient.qm.dox.h:1766
bool goal_reached
Goal reached flag.
Definition RestClient.qm.dox.h:1757
string getState()
Returns the current state.
string method
The HTTP method to use.
Definition RestClient.qm.dox.h:1760
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:251
Hash to use for generating authorization code requests.
Definition RestClient.qm.dox.h:255
*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:260
*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:263
string response_type
The response type value to use in the request.
Definition RestClient.qm.dox.h:257
*string state
The state value to use in the request.
Definition RestClient.qm.dox.h:266