Qore CdsRestClient Module Reference 2.0
Loading...
Searching...
No Matches
CdsRestClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* CdsRestClient.qm Copyright (C) 2023 - 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// do not ignore argument errors
34
35
36
89namespace CdsRestClient {
91
102
103public:
105 const OAuth2BaseUrl = "https://login.microsoftonline.com/";
106
108 const OAuth2AuthUriPathSuffix = "/oauth2/v2.0/authorize";
109
111 const OAuth2TokenUriPathSuffix = "/oauth2/v2.0/token";
112
114 const OAuth2AuthUrl= sprintf("%scommon%s", OAuth2BaseUrl, OAuth2AuthUriPathSuffix);
115
117 const OAuth2TokenUrl = sprintf("%scommon%s", OAuth2BaseUrl, OAuth2TokenUriPathSuffix);
118
120 const DefaultApiVersion = "9.2";
121
123 const RequestUriPathPrefix = "/api/data/v";
124
126 const DefaultBusinessCentralBaseUri = "https://api.businesscentral.dynamics.com/";
127
129 const DefaultDynamicsPingMethod = "GET";
130
132 const DefaultDynamicsPingPath = "{api_uri_path}/WhoAmI";
133
135 const DefaultDynamicsPingHeaders = ...;
136
137
139 const ApiProfiles = ...;
140
141
142private:
143 string api;
144 string uri_path_pfx;
145
146public:
147
149
176 constructor(hash<auto> opts, *softbool do_not_connect) ;
177
178
180 string getApi();
181
182
184 static raiseError(string fmt, ...);
185
187 static hash<auto> getOptions(hash<auto> opts);
188
190protected:
191 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);
192public:
193
194};
195
197
211
212public:
214 const ConnectionScheme = ...;
215
216
219
220
222 const OAuth2Options = ...;
223
224
226 const OAuth2StandardToCdsOptionMap = map {$1.value: $1.key}, OAuth2Options.pairIterator();
227
229 const OAuth2DifferentOptionMap = map {$1.value: $1.key}, OAuth2Options.pairIterator(), $1.key != $1.value;
230
232
249 constructor(hash<auto> config, *hash<auto> attr) ;
250
251
253 string getType();
254
255
257
262
263
265
269 DataProvider::AbstractDataProvider getDataProvider(*hash<auto> constructor_options);
270
271
273
280 string getAuthorizationCodeRequest(hash<AuthCodeInfo> info = <AuthCodeInfo>{});
281
282
284
286 string getOAuth2OptionName(string opt);
287
288
290
292 hash<auto> getOAuth2Options();
293
294
296 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
297 is to return a full URL
298
299 @since %CdsRestClient 2.0
300 */
301 string getAuthUrl(*bool allow_relative);
302
303
305 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
306 is to return a full URL
307
308 @since %CdsRestClient 2.0
309 */
310 string getTokenUrl(*bool allow_relative);
311
312
314
316 bool isAuthTokenError(int status_code, hash<auto> headers, bool body_deserialized, *string body_content_type, auto body);
317
318
320protected:
322public:
323
324
326protected:
328public:
329
330
332
337protected:
338 CdsRestClient getImpl(bool connect = True, *hash<auto> rtopts);
339public:
340
341
343protected:
344 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
345public:
346
347
349protected:
350 static hash<auto> getOptions(string url, *hash<auto> orig_opts);
351public:
352
353};
354
357
358public:
360 const ConnectionScheme = ...;
361
362
364
381 constructor(hash<auto> config, *hash<auto> attr) : CdsRestConnection(config + {"opts": CdsRestConnection::getOptions(config.url, config.opts
382 + {"api_profile": "dynamics"})}, attr) {
383 }
384
386 string getType();
387
388
390protected:
391 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
392public:
393
394};
395};
string getApi()
returns the CDS REST API version currently in use
static raiseError(string fmt,...)
throws an exception due to an error
constructor(hash< auto > opts, *softbool do_not_connect)
creates the object with the given options
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
static hash< auto > getOptions(hash< auto > opts)
returns options for the CdsRestClient::CdsRestClient::constructor()
class for Microsoft Common Data Service REST connections; returns CdsRestClient objects
Definition CdsRestClient.qm.dox.h:210
string getAuthorizationCodeRequest(hash< AuthCodeInfo > info=< AuthCodeInfo >{})
Returns a URI for an authorization code request.
string getAuthUrl(*bool allow_relative)
Returns the OAuth2 auth URL or throws an exception if not set.
setChildCapabilities()
Sets child data provider capabilities.
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
const OAuth2StandardToCdsOptionMap
Maps standard option names to CDS REST option names.
Definition CdsRestClient.qm.dox.h:226
static hash< auto > getOptions(string url, *hash< auto > orig_opts)
returns options for CdsRestConnection::constructor()
const ConnectionScheme
Connection entry info.
Definition CdsRestClient.qm.dox.h:214
const OAuth2Options
Maps CDS REST options to standard options.
Definition CdsRestClient.qm.dox.h:222
const OAuth2AuthRequestOptions
options required to support the OAuth2 authorization code grant flow
Definition CdsRestClient.qm.dox.h:218
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.
const OAuth2DifferentOptionMap
Different OAuth2 option map; standard name => extern name.
Definition CdsRestClient.qm.dox.h:229
bool hasDataProvider()
returns True as this connection returns a data provider with the getDataProvider() method
hash< auto > getOAuth2Options()
Returns OAuth2 options in a standard format.
CdsRestClient getImpl(bool connect=True, *hash< auto > rtopts)
returns a CdsRestClient object
checkAuthCodeFeature()
Sets the auth code feature if supported.
constructor(hash< auto > config, *hash< auto > attr)
creates the CdsRestConnection object
DataProvider::AbstractDataProvider getDataProvider(*hash< auto > constructor_options)
returns a data provider object for this connection
string getOAuth2OptionName(string opt)
Returns the OAuth2 option name for this connection.
string getTokenUrl(*bool allow_relative)
Returns the OAuth2 token URL or throws an exception if not set.
string getType()
returns "cdsrests"
For REST connections to Microsoft Dynamics.
Definition CdsRestClient.qm.dox.h:356
const ConnectionScheme
Connection entry info.
Definition CdsRestClient.qm.dox.h:360
string getType()
returns "dynamics"
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
constructor(hash< auto > config, *hash< auto > attr)
creates the CdsRestConnection object
Definition CdsRestClient.qm.dox.h:381
the CdsRestClient namespace contains all the objects in the CdsRestClient module
Definition CdsRestClient.qm.dox.h:89