Qore ServiceNowRestClient Module Reference 1.1
Loading...
Searching...
No Matches
ServiceNowRestClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* ServiceNowRestClient.qm Copyright (C) 2020 - 2022 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
95
105
106public:
108 const OAuth2TokenUriPathSuffix = "/oauth_token.do";
109
111 const DefaultApiVersion = "now";
112
114 const RequestUriPathPrefix = "/api/now";
115
116private:
117 // for OAuth2-based access
118 string username;
119 string password;
120 string client_id;
121 string client_secret;
122 *string api;
123 string scope;
124 string token;
125 string uri_path_pfx;
126
127public:
128
130
186 constructor(hash<auto> opts, *softbool do_not_connect) ;
187
188
190
193 *string getApi();
194
195
197 *string getToken();
198
199
201
204
205
206 hash<auto> doRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True,
207 *hash<auto> hdr) {
208 if (client_id && !token);
209
210 return RestClient::doRequest(m, path, body, \info, decode_errors, hdr);
211 }
212
214protected:
215 loginIntern(*reference<hash<auto>> info);
216public:
217
218
220protected:
221 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors);
222public:
223
224
226 static string getString(hash<auto> opts, string key);
227
229 static error(string fmt);
230
232 static hash<auto> getOptions(hash<auto> opts);
233};
234
236
262
263public:
265 const ConnectionScheme = <ConnectionSchemeInfo>{
266 "cls": Class::forName("ServiceNowRestConnection"),
267 "options": RestConnection::ConnectionScheme.options + {
268 "api": <ConnectionOptionInfo>{
269 "type": "string",
270 "desc": "the API version for ServiceNow; if not set the latest version is used",
272 },
273 "client_id": <ConnectionOptionInfo>{
274 "type": "string",
275 "desc": "the ServiceNow OAuth2 client ID",
276 },
277 "client_secret": <ConnectionOptionInfo>{
278 "type": "string",
279 "desc": "the ServiceNow OAuth2 client secret",
280 "sensitive": True,
281 },
282 "password": <ConnectionOptionInfo>{
283 "type": "string",
284 "desc": "the ServiceNow password",
285 "sensitive": True,
286 },
287 "username": <ConnectionOptionInfo>{
288 "type": "string",
289 "desc": "the ServiceNow username",
290 "sensitive": False,
291 },
292 },
293 "required_options": "username,password",
294 };
295
297
307 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {})
308 ;
309
310
312 string getType();
313
314
316
321
322
324
326 DataProvider::AbstractDataProvider getDataProvider();
327
328
330protected:
332public:
333
334
336
341protected:
342 ServiceNowRestClient getImpl(bool connect = True, *hash<auto> rtopts);
343public:
344
345
347protected:
348 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
349public:
350
351};
352};
*string getApi()
returns the ServiceNow REST API version currently in use
const DefaultApiVersion
Default API version.
Definition: ServiceNowRestClient.qm.dox.h:111
constructor(hash< auto > opts, *softbool do_not_connect)
creates the object with the given options
*string getToken()
returns the access token, if any
static error(string fmt)
throws an exception due to an error
static hash< auto > getOptions(hash< auto > opts)
returns options for ServiceNowRestClient::ServiceNowRestClient::constructor()
static string getString(hash< auto > opts, string key)
gets a string option
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
bool usingOAuth2()
Returns True if the client is using OAuth2 authentication.
loginIntern(*reference< hash< auto > > info)
performs authentication and authorization with SAP using the OAuth2 authorization URL
class for ServiceNow REST connections; returns ServiceNowRestClient objects
Definition: ServiceNowRestClient.qm.dox.h:261
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the ServiceNowRestConnection object
DataProvider::AbstractDataProvider getDataProvider()
returns a data provider object for this connection
setChildCapabilities()
Sets child data provider capabilities.
ServiceNowRestClient getImpl(bool connect=True, *hash< auto > rtopts)
returns a ServiceNowRestClient object
bool hasDataProvider()
returns True as this connection returns a data provider with the getDataProvider() method
const ConnectionScheme
Connection entry info.
Definition: ServiceNowRestClient.qm.dox.h:265
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
the ServiceNowRestClient namespace contains all the objects in the ServiceNowRestClient module
Definition: ServiceNowRestClient.qm.dox.h:93