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
90namespace CdsRestClient {
92
104
105public:
107 const OAuth2BaseUrl = "https://login.microsoftonline.com/";
108
110 const OAuth2AuthUriPathSuffix = "/oauth2/v2.0/authorize";
111
113 const OAuth2TokenUriPathSuffix = "/oauth2/v2.0/token";
114
116 const DefaultApiVersion = "9.2";
117
119 const RequestUriPathPrefix = "/api/data/v";
120
122 const DefaultBusinessCentralBaseUri = "https://api.businesscentral.dynamics.com/";
123
125 const DefaultDynamicsPingMethod = "GET";
126
128 const DefaultDynamicsPingPath = "{api_uri_path}/systemusers?$top=1&$select=identityid";
129
131 const DefaultDynamicsPingHeaders = ...;
132
133
135 const ApiProfiles = ...;
136
137
138private:
139 string api;
140 string tenant;
141 string uri_path_pfx;
142
143public:
144
146
175 constructor(hash<auto> opts, *softbool do_not_connect) ;
176
177
179 string getApi();
180
181
183 static raiseError(string fmt, ...);
184
186 static hash<auto> getOptions(hash<auto> opts);
187
189protected:
190 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);
191public:
192
193};
194
196
212
213public:
215 const ConnectionScheme = ...;
216
217
220
221
223 const OAuth2Options = ...;
224
225
227 const OAuth2StandardToCdsOptionMap = map {$1.value: $1.key}, OAuth2Options.pairIterator();
228
230 const OAuth2DifferentOptionMap = map {$1.value: $1.key}, OAuth2Options.pairIterator(), $1.key != $1.value;
231
233
250 constructor(hash<auto> config, *hash<auto> attr) ;
251
252
254 string getType();
255
256
258
263
264
266
270 DataProvider::AbstractDataProvider getDataProvider(*hash<auto> constructor_options);
271
272
274
281 string getAuthorizationCodeRequest(hash<AuthCodeInfo> info = <AuthCodeInfo>{});
282
283
285
287 string getOAuth2OptionName(string opt);
288
289
291
293 hash<auto> getOAuth2Options();
294
295
297 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
298 is to return a full URL
299
300 @since %CdsRestClient 2.0
301 */
302 string getAuthUrl(*bool allow_relative);
303
304
306 /* @param allow_relative if @ref True then a relative URL (path only) can be returned; the default (@ref False)
307 is to return a full URL
308
309 @since %CdsRestClient 2.0
310 */
311 string getTokenUrl(*bool allow_relative);
312
313
315
317 bool isAuthTokenError(int status_code, hash<auto> headers, bool body_deserialized, *string body_content_type, auto body);
318
319
321protected:
323public:
324
325
327protected:
329public:
330
331
333
338protected:
339 CdsRestClient getImpl(bool connect = True, *hash<auto> rtopts);
340public:
341
342
344protected:
345 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
346public:
347
348
350protected:
351 static hash<auto> getOptions(string url, *hash<auto> orig_opts);
352public:
353
354};
355
358
359public:
361 const ConnectionScheme = ...;
362
363
365
382 constructor(hash<auto> config, *hash<auto> attr) : CdsRestConnection(config + {"opts": CdsRestConnection::getOptions(config.url, config.opts
383 + {"api_profile": "dynamics"})}, attr) {
384 }
385
387 string getType();
388
389
391protected:
392 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
393public:
394
395};
396};
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:211
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:227
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:215
const OAuth2Options
Maps CDS REST options to standard options.
Definition CdsRestClient.qm.dox.h:223
const OAuth2AuthRequestOptions
options required to support the OAuth2 authorization code grant flow
Definition CdsRestClient.qm.dox.h:219
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:230
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:357
const ConnectionScheme
Connection entry info.
Definition CdsRestClient.qm.dox.h:361
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:382
the CdsRestClient namespace contains all the objects in the CdsRestClient module
Definition CdsRestClient.qm.dox.h:90