Qore CdsRestClient Module Reference 1.0
Loading...
Searching...
No Matches
CdsRestClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* CdsRestClient.qm Copyright (C) 2023 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}
37
88namespace CdsRestClient {
90
102
103public:
105 const OAuth2AuthUrl = "https://login.microsoftonline.com";
106
108 const OAuth2TokenUriPathSuffix = "/oauth2/v2.0/token";
109
111 const DefaultApiVersion = "9.1";
112
114 const RequestUriPathPrefix = "/api/data/v";
115
116private:
117 // for OAuth2-based access
118 string client_id;
119 string client_secret;
120 string api;
121 string tenant;
122 string scope;
123 string token;
124 string uri_path_pfx;
125
126public:
127
129
186 constructor(hash<auto> opts, *softbool do_not_connect) ;
187
188
190 string getApi();
191
192
194 *string getToken();
195
196
197 hash<auto> doRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True, *hash<auto> hdr);
198
199
201protected:
202 loginIntern(*reference<hash<auto>> info);
203public:
204
205
207protected:
208 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors);
209public:
210
211
213 static string getString(hash<auto> opts, string key);
214
216 static error(string fmt);
217
219 static hash<auto> getOptions(hash<auto> opts);
220};
221
223
251
252public:
254 const ConnectionScheme = <ConnectionSchemeInfo>{
255 "cls": Class::forName("CdsRestConnection"),
256 "options": RestConnection::ConnectionScheme.options + {
257 "api": <ConnectionOptionInfo>{
258 "type": "string",
259 "desc": "the API version for CDS",
260 "default_value": CdsRestClient::DefaultApiVersion,
261 },
262 "client_id": <ConnectionOptionInfo>{
263 "type": "string",
264 "desc": "the Microsoft Common Data Service OAuth2 client ID",
265 },
266 "client_secret": <ConnectionOptionInfo>{
267 "type": "string",
268 "desc": "the Microsoft Common Data Service OAuth2 client secret",
269 "sensitive": True,
270 },
271 "tenant": <ConnectionOptionInfo>{
272 "type": "string",
273 "desc": "the tenant ID",
274 },
275 "scope": <ConnectionOptionInfo>{
276 "type": "string",
277 "desc": "the OAuth2 scope for the login; the default it to use the target URL + `/.default`",
278 },
279 },
280 "required_options": "client_id,client_secret,tenant",
281 };
282
284
294 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {})
295 ;
296
297
299 string getType();
300
301
303
308
309
311
313 DataProvider::AbstractDataProvider getDataProvider();
314
315
317protected:
319public:
320
321
323
328protected:
329 CdsRestClient getImpl(bool connect = True, *hash<auto> rtopts);
330public:
331
332
334protected:
335 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
336public:
337
338};
339};
string getApi()
returns the CDS REST API version currently in use
const DefaultApiVersion
Default API version.
Definition: CdsRestClient.qm.dox.h:111
*string getToken()
returns the access token
constructor(hash< auto > opts, *softbool do_not_connect)
creates the object with the given options
static string getString(hash< auto > opts, string key)
gets a string option
loginIntern(*reference< hash< auto > > info)
performs authentication and authorization with SAP using the OAuth2 authorization URL
hash< auto > sendAndDecodeResponse(*data body, string m, string path, hash< auto > hdr, *reference< hash< auto > > info, *softbool decode_errors)
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()
static error(string fmt)
throws an exception due to an error
class for Microsoft Common Data Service REST connections; returns CdsRestClient objects
Definition: CdsRestClient.qm.dox.h:250
setChildCapabilities()
Sets child data provider capabilities.
DataProvider::AbstractDataProvider getDataProvider()
returns a data provider object for this connection
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
const ConnectionScheme
Connection entry info.
Definition: CdsRestClient.qm.dox.h:254
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the CdsRestConnection object
bool hasDataProvider()
returns True as this connection returns a data provider with the getDataProvider() method
CdsRestClient getImpl(bool connect=True, *hash< auto > rtopts)
returns a CdsRestClient object
string getType()
returns "cdsrest"
the CdsRestClient namespace contains all the objects in the CdsRestClient module
Definition: CdsRestClient.qm.dox.h:88