Qore ServiceNowRestClient Module Reference 1.1.1
Loading...
Searching...
No Matches
ServiceNowRestClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* ServiceNowRestClient.qm Copyright (C) 2020 - 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
99
109
110public:
112 const OAuth2TokenUriPathSuffix = "/oauth_token.do";
113
115 const DefaultApiVersion = "now";
116
118 const RequestUriPathPrefix = "/api/now";
119
120private:
121 // for OAuth2-based access
122 string username;
123 string password;
124 string client_id;
125 string client_secret;
126 *string api;
127 string scope;
128 string token;
129 string uri_path_pfx;
130
131public:
132
134
190 constructor(hash<auto> opts, *softbool do_not_connect) ;
191
192
194
197 *string getApi();
198
199
201 *string getToken();
202
203
205
208
209
210 hash<auto> doRequest(string m, string path, auto body, *reference<hash<auto>> info, softbool decode_errors = True,
211 *hash<auto> hdr) {
212 if (client_id && !token);
213
214 return RestClient::doRequest(m, path, body, \info, decode_errors, hdr);
215 }
216
218protected:
219 loginIntern(*reference<hash<auto>> info);
220public:
221
222
224protected:
225 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors);
226public:
227
228
230 static string getString(hash<auto> opts, string key);
231
233 static error(string fmt);
234
236 static hash<auto> getOptions(hash<auto> opts);
237};
238
240
266
267public:
269 const ConnectionScheme = <ConnectionSchemeInfo>{
270 "cls": Class::forName("ServiceNowRestConnection"),
271 "options": RestConnection::ConnectionScheme.options - ("ping_method", "ping_path", "ping_headers",
272 "ping_body") + {
273 "api": <ConnectionOptionInfo>{
274 "type": "string",
275 "desc": "the API version for ServiceNow; if not set the latest version is used",
277 },
278 "client_id": <ConnectionOptionInfo>{
279 "type": "string",
280 "desc": "the ServiceNow OAuth2 client ID",
281 },
282 "client_secret": <ConnectionOptionInfo>{
283 "type": "string",
284 "desc": "the ServiceNow OAuth2 client secret",
285 "sensitive": True,
286 },
287 "password": <ConnectionOptionInfo>{
288 "type": "string",
289 "desc": "the ServiceNow password",
290 "sensitive": True,
291 },
292 "username": <ConnectionOptionInfo>{
293 "type": "string",
294 "desc": "the ServiceNow username",
295 "sensitive": False,
296 },
297 },
298 "required_options": "username,password",
299 };
300
303
305 const DefaultServiceNowPingPath = "table/sys_dictionary?sysparm_query=name=incident";
306
309 "Accept": MimeTypeJson,
310 };
311
313
323 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {})
324 ;
325
326
328 string getType();
329
330
332
337
338
340
342 DataProvider::AbstractDataProvider getDataProvider();
343
344
346
352
353
355protected:
357public:
358
359
361
366protected:
367 ServiceNowRestClient getImpl(bool connect = True, *hash<auto> rtopts);
368public:
369
370
372protected:
373 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
374public:
375
376};
377};
*string getApi()
returns the ServiceNow REST API version currently in use
const DefaultApiVersion
Default API version.
Definition: ServiceNowRestClient.qm.dox.h:115
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:265
const DefaultServiceNowPingMethod
Default ServiceNow ping method.
Definition: ServiceNowRestClient.qm.dox.h:302
Qore::AbstractPollOperation startPollConnect()
Called to start a non-blocking polling ping operation on the ServiceNow REST server.
const DefaultServiceNowPingPath
Default ServiceNow ping path (from the API root)
Definition: ServiceNowRestClient.qm.dox.h:305
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the ServiceNowRestConnection object
const DefaultServiceNowPingHeaders
Default ServiceNow ping headers.
Definition: ServiceNowRestClient.qm.dox.h:308
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:269
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:97