Qore ServiceNowRestClient Module Reference 1.2
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
104
114
115public:
117 const OAuth2DefaultGrantType = "authorization_code";
118
120 const OAuth2AuthUriPathSuffix = "/oauth_auth.do";
121
123 const OAuth2TokenUriPathSuffix = "/oauth_token.do";
124
126 const DefaultApiVersion = "now";
127
129 const RequestUriPathPrefix = "/api/";
130
131private:
132 *string api;
133 string uri_path_pfx;
134
135public:
136
138
194 constructor(hash<auto> opts, *softbool do_not_connect) ;
195
196
198
200 string getApi();
201
202
204protected:
205 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors);
206public:
207
208
210 static string getString(hash<auto> opts, string key);
211
213 static raiseError(string fmt);
214
216 static hash<auto> getOptions(hash<auto> opts);
217};
218
220
229
230public:
232 const ConnectionScheme = <ConnectionSchemeInfo>{
233 "cls": Class::forName("ServiceNowRestConnection"),
234 "options": RestConnection::ConnectionScheme.options - (keys OAuth2DifferentOptionMap) + {
235 "api": <ConnectionOptionInfo>{
236 "type": "string",
237 "desc": "the API version for ServiceNow; if not set the latest version is used",
239 },
240 "client_id": RestConnection::ConnectionScheme.options.oauth2_client_id + <ConnectionOptionInfo>{
241 "desc": "the ServiceNow OAuth2 client ID",
242 },
243 "client_secret": RestConnection::ConnectionScheme.options.oauth2_client_secret + <ConnectionOptionInfo>{
244 "desc": "the ServiceNow OAuth2 client secret",
245 "sensitive": True,
246 },
247 "oauth2_auth_url": RestConnection::ConnectionScheme.options.oauth2_auth_url + <ConnectionOptionInfo>{
249 },
250 "oauth2_grant_type": RestConnection::ConnectionScheme.options.oauth2_grant_type + <ConnectionOptionInfo>{
252 },
253 "oauth2_token_url": RestConnection::ConnectionScheme.options.oauth2_token_url + <ConnectionOptionInfo>{
255 },
256 "password": RestConnection::ConnectionScheme.options.password + <ConnectionOptionInfo>{
257 "desc": "the ServiceNow password",
258 "sensitive": True,
259 },
260 "ping_headers": RestConnection::ConnectionScheme.options."ping_headers" + <ConnectionOptionInfo>{
261 "default_value": DefaultServiceNowPingHeaders,
262 },
263 "ping_method": RestConnection::ConnectionScheme.options."ping_method" + <ConnectionOptionInfo>{
264 "default_value": DefaultServiceNowPingMethod,
265 },
266 "ping_path": RestConnection::ConnectionScheme.options."ping_path" + <ConnectionOptionInfo>{
267 "default_value": DefaultServiceNowPingPath,
268 },
269 "username": RestConnection::ConnectionScheme.options.username + <ConnectionOptionInfo>{
270 "desc": "the ServiceNow username",
271 },
272 },
273 "required_options": "username,password|token|client_id,client_secret",
274 };
275
278
281
282
285 "Accept": MimeTypeJson,
286 };
287
290
291
294 "oauth2_auto_refresh": "oauth2_auto_refresh",
295 "oauth2_auth_args": "oauth2_auth_args",
296 "oauth2_auth_url": "oauth2_auth_url",
297 "client_id": "oauth2_client_id",
298 "client_secret": "oauth2_client_secret",
299 "oauth2_redirect_url": "oauth2_redirect_url",
300 "oauth2_refresh_token": "oauth2_refresh_token",
301 "oauth2_scopes": "oauth2_scopes",
302 "oauth2_token_url": "oauth2_token_url",
303 "password": "password",
304 "username": "username",
305 };
306
308 const OAuth2StandardToServiceNowOptionMap = map {$1.value: $1.key}, OAuth2Options.pairIterator();
309
311 const OAuth2DifferentOptionMap = map {$1.value: $1.key}, OAuth2Options.pairIterator(), $1.key != $1.value;
312
314
324 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {})
325 ;
326
327
329 string getType();
330
331
333
338
339
341
343 DataProvider::AbstractDataProvider getDataProvider();
344
345
347
349 string getOAuth2OptionName(string opt);
350
351
353
355 hash<auto> getOAuth2Options();
356
357
359
365
366
368protected:
370public:
371
372
374protected:
376public:
377
378
380
385protected:
386 ServiceNowRestClient getImpl(bool connect = True, *hash<auto> rtopts);
387public:
388
389
391protected:
392 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
393public:
394
395};
396};
const OAuth2DefaultGrantType
OAuth2 default grant type.
Definition: ServiceNowRestClient.qm.dox.h:117
const DefaultApiVersion
Default API version.
Definition: ServiceNowRestClient.qm.dox.h:126
constructor(hash< auto > opts, *softbool do_not_connect)
creates the object with the given options
static hash< auto > getOptions(hash< auto > opts)
returns options for ServiceNowRestClient::ServiceNowRestClient::constructor()
string getApi()
returns the ServiceNow REST API version currently in use
const OAuth2TokenUriPathSuffix
OAuth2 token URI path suffix.
Definition: ServiceNowRestClient.qm.dox.h:123
const OAuth2AuthUriPathSuffix
OAuth2 auth URL.
Definition: ServiceNowRestClient.qm.dox.h:120
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 string getString(hash< auto > opts, string key)
gets a string option
static raiseError(string fmt)
throws an exception due to an error
Class for ServiceNow REST connections; returns ServiceNowRestClient objects.
Definition: ServiceNowRestClient.qm.dox.h:228
const DefaultServiceNowPingMethod
Default ServiceNow ping method.
Definition: ServiceNowRestClient.qm.dox.h:277
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:280
const OAuth2Options
Maps ServiceNow REST options to standard options.
Definition: ServiceNowRestClient.qm.dox.h:293
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the ServiceNowRestConnection object
hash< auto > getOAuth2Options()
Returns OAuth2 options in a standard format.
checkAuthCodeFeature()
Sets the auth code feature if supported.
const DefaultServiceNowPingHeaders
Default ServiceNow ping headers.
Definition: ServiceNowRestClient.qm.dox.h:284
string getOAuth2OptionName(string opt)
Returns the OAuth2 option name for this connection.
DataProvider::AbstractDataProvider getDataProvider()
returns a data provider object for this connection
const OAuth2AuthRequestOptions
options required to support the OAuth2 authorization code grant flow
Definition: ServiceNowRestClient.qm.dox.h:289
setChildCapabilities()
Sets child data provider capabilities.
const OAuth2StandardToServiceNowOptionMap
Maps standard option names to ServiceNow REST option names.
Definition: ServiceNowRestClient.qm.dox.h:308
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:232
const OAuth2DifferentOptionMap
Different OAuth2 option map; standard name => extern name.
Definition: ServiceNowRestClient.qm.dox.h:311
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:102