$darkmode
Qore RestClientDataProvider Module Reference 1.1
RestClientDataProvider.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
26 namespace RestClientDataProvider {
29 
30 public:
32  const ProviderInfo = <DataProviderInfo>{
33  "type": "RestClientDataProvider",
34  "constructor_options": ConstructorOptions,
35  "supports_children": True,
36  "children_can_support_apis": True,
37  "children_can_support_records": False,
38  "children_can_support_observers": False,
39  };
40 
42  const ConstructorOptions = {
43  "assume_encoding": <DataProviderOptionInfo>{
44  "type": AbstractDataProviderType::get(StringType),
45  "desc": "Assumes the given encoding if the server does not send a `charset` value",
46  },
47  "connect_timeout": <DataProviderOptionInfo>{
48  "type": AbstractDataProviderType::get(IntType),
49  "desc": "The connection timeout to use in milliseconds (default: 45 seconds)",
50  "default_value": 45000,
51  },
52  "content_encoding": <DataProviderOptionInfo>{
53  "type": AbstractDataProviderType::get(StringType),
54  "desc": "Sets the send encoding (if the `send_encoding` option is not set) and the "
55  "response encoding to request"
56  "Sets the send encoding (if the `send_encoding` option is not set) and the requested response "
57  "encoding (note that only outgoing message bodies over `1024` bytes in size are compressed)",
58  "default_value": "gzip",
59  "allowed_values": (
60  <AllowedValueInfo>{
61  "value": "gzip",
62  "desc": "use GNU zip encoding ([RFC 1952](https://tools.ietf.org/html/rfc1952))",
63  }, <AllowedValueInfo>{
64  "value": "bzip2",
65  "desc": "use bzip2 encoding",
66  }, <AllowedValueInfo>{
67  "value": "deflate",
68  "desc": "use the deflate algorithm ([RFC 1951](https://tools.ietf.org/html/rfc1951))",
69  }, <AllowedValueInfo>{
70  "value": "identity",
71  "desc": "use no content encoding",
72  },
73  ),
74  },
75  "data": <DataProviderOptionInfo>{
76  "type": AbstractDataProviderType::get(StringType),
77  "desc": "Determines how message bodies are serialized",
78  "default_value": "auto",
79  "allowed_values": (
80  <AllowedValueInfo>{
81  "value": "auto",
82  "desc": "Prefers in this order: `json`, `yaml`, `rawxml`, `xml`, `url`, and `text`",
83  }, <AllowedValueInfo>{
84  "value": "bin",
85  "desc": "For binary message bodies without data serialization",
86  }, <AllowedValueInfo>{
87  "value": "json",
88  "desc": "Use JSON serialization",
89  }, <AllowedValueInfo>{
90  "value": "rawxml",
91  "desc": "Message bodies are encoded with XML without any data type encodings",
92  }, <AllowedValueInfo>{
93  "value": "text",
94  "desc": "Use only plain text; no serialization is used",
95  }, <AllowedValueInfo>{
96  "value": "url",
97  "desc": "For URL-encoded message bodies "
98  "(see [RFC 2738 2.2](https://tools.ietf.org/html/rfc1738))",
99  }, <AllowedValueInfo>{
100  "value": "xml",
101  "desc": "Use only XML-RPC value serialization",
102  }, <AllowedValueInfo>{
103  "value": "yaml",
104  "desc": "Use only YAML serialization",
105  },
106  ),
107  },
108  "error_passthru": <DataProviderOptionInfo>{
109  "type": AbstractDataProviderType::get(BoolType),
110  "desc": "If `True` then REST status codes indicating errors will not cause an "
111  "`REST-CLIENT-RECEIVE-ERROR` exception to be raised, rather such responses will be "
112  "passed through to the caller like any other response",
113  "default_value": False,
114  },
115  "headers": <DataProviderOptionInfo>{
116  "type": AbstractDataProviderType::get(HashType),
117  "desc": "An optional hash of headers to send with every request"
118  },
119  "http_version": <DataProviderOptionInfo>{
120  "type": AbstractDataProviderType::get(StringType),
121  "desc": "HTTP version to use (`1.0` or `1.1`, defaults to `1.1`)",
122  "default_value": "1.1",
123  "allowed_values": (
124  <AllowedValueInfo>{
125  "value": "1.0",
126  "desc": "Use HTTP version \"1.0\"",
127  }, <AllowedValueInfo>{
128  "value": "1.1",
129  "desc": "Use HTTP version \"1.1\" (the default)",
130  },
131  ),
132  },
133  "max_redirects": <DataProviderOptionInfo>{
134  "type": AbstractDataProviderType::get(IntType),
135  "desc": "Maximum redirects to support",
136  },
137  "no_charset": <DataProviderOptionInfo>{
138  "type": AbstractDataProviderType::get(BoolType),
139  "desc": "If `True` no charset will be added to the `Content-Type` header",
140  },
141  "pre_encoded_urls": <DataProviderOptionInfo>{
142  "type": AbstractDataProviderType::get(BoolType),
143  "desc": "if `true` then all URI paths in URLs are assumed to be already "
144  "[percent encoded](https://en.wikipedia.org/wiki/Percent-encoding); if this flag is set and "
145  "any unencoded characters are sent in a URL with a new request, an exception is raised",
146  "default_value": False,
147  },
148  "proxy": <DataProviderOptionInfo>{
149  "type": AbstractDataProviderType::get(StringType),
150  "desc": "The proxy URL to use",
151  },
152  "redirect_passthru": <DataProviderOptionInfo>{
153  "type": AbstractDataProviderType::get(BoolType),
154  "desc": "if `True` then redirect responses will be passed to the caller instead of processed",
155  "default_value": False,
156  },
157  "send_encoding": <DataProviderOptionInfo>{
158  "type": AbstractDataProviderType::get(StringType),
159  "desc": "Sets the send encoding (if the `send_encoding` option is not set) and the requested response "
160  "encoding (note that only outgoing message bodies over `1024` bytes in size are compressed)",
161  "allowed_values": (
162  <AllowedValueInfo>{
163  "value": "gzip",
164  "desc": "use GNU zip encoding ([RFC 1952](https://tools.ietf.org/html/rfc1952))",
165  }, <AllowedValueInfo>{
166  "value": "bzip2",
167  "desc": "use bzip2 encoding",
168  }, <AllowedValueInfo>{
169  "value": "deflate",
170  "desc": "use the deflate algorithm ([RFC 1951](https://tools.ietf.org/html/rfc1951))",
171  }, <AllowedValueInfo>{
172  "value": "identity",
173  "desc": "use no content encoding",
174  },
175  ),
176  },
177  "ssl_cert_der": <DataProviderOptionInfo>{
178  "type": AbstractDataProviderType::get(BoolType),
179  "desc": "If `True` then the data represented by `ssl_cert_location` will be assumed to be in binary "
180  "DER format",
181  "default_value": False,
182  },
183  "ssl_cert_location": <DataProviderOptionInfo>{
184  "type": AbstractDataProviderType::get(StringType, NOTHING, {
187  }),
188  "desc": "A path or location to an X.509 client certificate file",
189  },
190  "ssl_key_der": <DataProviderOptionInfo>{
191  "type": AbstractDataProviderType::get(BoolType),
192  "desc": "If `True` then the data represented by `ssl_key_location` will be assumed to be in binary "
193  "DER format",
194  "default_value": False,
195  },
196  "ssl_key_location": <DataProviderOptionInfo>{
197  "type": AbstractDataProviderType::get(StringType, NOTHING, {
200  }),
201  "desc": "A path or location to a private key file for the X.509 client certificate",
202  },
203  "ssl_key_password": <DataProviderOptionInfo>{
204  "type": AbstractDataProviderType::get(StringType),
205  "desc": "The password to the private key given with `ssl_key_path` (text PEM format only)",
206  "sensitive": True,
207  },
208  "ssl_verify_cert": <DataProviderOptionInfo>{
209  "type": AbstractDataProviderType::get(BoolType),
210  "desc": "if `True` then the server's certificate will only be accepted if it's verified",
211  "default_value": False,
212  },
213  "swagger": <DataProviderOptionInfo>{
214  "type": AbstractDataProviderType::get(StringType, NOTHING, {
217  }),
218  "desc": "A Swagger 2.0 schema location or file data for the REST connection",
219  },
220  "swagger_lax_parsing": <DataProviderOptionInfo>{
221  "type": AbstractDataProviderTypeMap."bool",
222  "desc": "try to parse invalid Swagger schemas",
223  },
224  "timeout": <DataProviderOptionInfo>{
225  "type": AbstractDataProviderType::get(IntType),
226  "desc": "Transfer timeout to use in milliseconds (default: 45 seconds)",
227  "default_value": 45000,
228  },
229  "url": <DataProviderOptionInfo>{
230  "type": AbstractDataProviderType::get(StringType),
231  "desc": "A URL for a REST or RESTS connection",
232  "required": True,
233  },
234  "validator_base_path": <DataProviderOptionInfo>{
235  "type": AbstractDataProviderType::get(StringType),
236  "desc": "In case a REST validator is used, the base path in the schema can be overridden with this "
237  "option",
238  },
239  };
240 
241 protected:
242  const ChildMap = {
243  "call": Class::forName("RestClientDataProvider::RestClientCallDataProvider"),
244  "delete": Class::forName("RestClientDataProvider::RestClientDeleteDataProvider"),
245  "get": Class::forName("RestClientDataProvider::RestClientGetDataProvider"),
246  "head": Class::forName("RestClientDataProvider::RestClientHeadDataProvider"),
247  "options": Class::forName("RestClientDataProvider::RestClientOptionsDataProvider"),
248  "patch": Class::forName("RestClientDataProvider::RestClientPatchDataProvider"),
249  "post": Class::forName("RestClientDataProvider::RestClientPostDataProvider"),
250  "put": Class::forName("RestClientDataProvider::RestClientPutDataProvider"),
251  };
252 
253 public:
254 
256  constructor(*hash<auto> options);
257 
258 
261 
262 
264  string getName();
265 
266 
268  *string getDesc();
269 
270 
272  *list<hash<DataProviderSummaryInfo>> getChildProviderSummaryInfo();
273 
274 
276  setLogger(*LoggerInterface logger);
277 
278 
280  static RestClient getRestConnection(hash<auto> options);
281 
283  static hash<auto> makeRequest(RestClient rest, string meth, *data body, string path, *hash<auto> hdr);
284 
286  static hash<auto> processRestOptions(hash<auto> options);
287 
289 
291 protected:
292  *list<string> getChildProviderNamesImpl();
293 public:
294 
295 
297 
301 protected:
302  *AbstractDataProvider getChildProviderImpl(string name);
303 public:
304 
305 
307 protected:
308  hash<DataProviderInfo> getStaticInfoImpl();
309 public:
310 
311 };
312 };
The REST client data provider class, provides API classes as children.
Definition: RestClientDataProviderBase.qc.dox.h:28
*AbstractDataProvider getChildProviderImpl(string name)
Returns the given child provider or NOTHING if the given child is unknown.
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names, if any.
constructor(*hash< auto > options)
Creates the object from constructor options.
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
static hash< auto > processRestOptions(hash< auto > options)
Processes common REST options.
*string getDesc()
Returns the data provider description.
*list< hash< DataProviderSummaryInfo > > getChildProviderSummaryInfo()
Return data provider summary info.
constructor(RestClient rest)
Creates the object from a REST connection.
string getName()
Returns the data provider name.
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
static RestClient getRestConnection(hash< auto > options)
Returns a REST connection.
static hash< auto > makeRequest(RestClient rest, string meth, *data body, string path, *hash< auto > hdr)
Makes a REST request and returns the response.
const True
const False
const DTT_FromLocation
const DTT_FromFile
const NOTHING
Qore RestClientDataProvider module definition.
Definition: RestClientCallDataProvider.qc.dox.h:26