Qore RestClientDataProvider Module Reference 1.0
Loading...
Searching...
No Matches
RestClientDataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
26namespace RestClientDataProvider {
28class RestClientDataProvider : public AbstractDataProvider {
29
30public:
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 "proxy": <DataProviderOptionInfo>{
142 "type": AbstractDataProviderType::get(StringType),
143 "desc": "The proxy URL to use",
144 },
145 "redirect_passthru": <DataProviderOptionInfo>{
146 "type": AbstractDataProviderType::get(BoolType),
147 "desc": "if `True` then redirect responses will be passed to the caller instead of processed",
148 "default_value": False,
149 },
150 "send_encoding": <DataProviderOptionInfo>{
151 "type": AbstractDataProviderType::get(StringType),
152 "desc": "Sets the send encoding (if the `send_encoding` option is not set) and the requested response "
153 "encoding (note that only outgoing message bodies over `1024` bytes in size are compressed)",
154 "allowed_values": (
155 <AllowedValueInfo>{
156 "value": "gzip",
157 "desc": "use GNU zip encoding ([RFC 1952](https://tools.ietf.org/html/rfc1952))",
158 }, <AllowedValueInfo>{
159 "value": "bzip2",
160 "desc": "use bzip2 encoding",
161 }, <AllowedValueInfo>{
162 "value": "deflate",
163 "desc": "use the deflate algorithm ([RFC 1951](https://tools.ietf.org/html/rfc1951))",
164 }, <AllowedValueInfo>{
165 "value": "identity",
166 "desc": "use no content encoding",
167 },
168 ),
169 },
170 "ssl_cert_der": <DataProviderOptionInfo>{
171 "type": AbstractDataProviderType::get(BoolType),
172 "desc": "If `True` then the data represented by `ssl_cert_location` will be assumed to be in binary "
173 "DER format",
174 "default_value": False,
175 },
176 "ssl_cert_location": <DataProviderOptionInfo>{
177 "type": AbstractDataProviderType::get(StringType, NOTHING, {
178 DTT_FromFile: True,
179 DTT_FromLocation: True,
180 }),
181 "desc": "A path or location to an X.509 client certificate file",
182 },
183 "ssl_key_der": <DataProviderOptionInfo>{
184 "type": AbstractDataProviderType::get(BoolType),
185 "desc": "If `True` then the data represented by `ssl_key_location` will be assumed to be in binary "
186 "DER format",
187 "default_value": False,
188 },
189 "ssl_key_location": <DataProviderOptionInfo>{
190 "type": AbstractDataProviderType::get(StringType, NOTHING, {
191 DTT_FromFile: True,
192 DTT_FromLocation: True,
193 }),
194 "desc": "A path or location to a private key file for the X.509 client certificate",
195 },
196 "ssl_key_password": <DataProviderOptionInfo>{
197 "type": AbstractDataProviderType::get(StringType),
198 "desc": "The password to the private key given with `ssl_key_path` (text PEM format only)",
199 "sensitive": True,
200 },
201 "ssl_verify_cert": <DataProviderOptionInfo>{
202 "type": AbstractDataProviderType::get(BoolType),
203 "desc": "if `True` then the server's certificate will only be accepted if it's verified",
204 "default_value": False,
205 },
206 "swagger": <DataProviderOptionInfo>{
207 "type": AbstractDataProviderType::get(StringType, NOTHING, {
208 DTT_FromFile: True,
209 DTT_FromLocation: True,
210 }),
211 "desc": "A Swagger 2.0 schema location or file data for the REST connection",
212 },
213 "timeout": <DataProviderOptionInfo>{
214 "type": AbstractDataProviderType::get(IntType),
215 "desc": "Transfer timeout to use in milliseconds (default: 45 seconds)",
216 "default_value": 45000,
217 },
218 "url": <DataProviderOptionInfo>{
219 "type": AbstractDataProviderType::get(StringType),
220 "desc": "A URL for a REST or RESTS connection",
221 "required": True,
222 },
223 "validator_base_path": <DataProviderOptionInfo>{
224 "type": AbstractDataProviderType::get(StringType),
225 "desc": "In case a REST validator is used, the base path in the schema can be overridden with this "
226 "option",
227 },
228 };
229
230 RestClient rest;
231
232protected:
233 const ChildMap = {
234 "call": Class::forName("RestClientDataProvider::RestClientCallDataProvider"),
235 "delete": Class::forName("RestClientDataProvider::RestClientDeleteDataProvider"),
236 "get": Class::forName("RestClientDataProvider::RestClientGetDataProvider"),
237 "head": Class::forName("RestClientDataProvider::RestClientHeadDataProvider"),
238 "options": Class::forName("RestClientDataProvider::RestClientOptionsDataProvider"),
239 "patch": Class::forName("RestClientDataProvider::RestClientPatchDataProvider"),
240 "post": Class::forName("RestClientDataProvider::RestClientPostDataProvider"),
241 "put": Class::forName("RestClientDataProvider::RestClientPutDataProvider"),
242 };
243
244public:
245
247 constructor(*hash<auto> options);
248
249
252
253
255 string getName();
256
257
259 *string getDesc();
260
261
263 *list<hash<DataProviderSummaryInfo>> getChildProviderSummaryInfo();
264
265
267 static RestClient getRestConnection(hash<auto> options);
268
270 static hash<auto> makeRequest(RestClient rest, string meth, *data body, string path, *hash<auto> hdr);
271
273 static hash<auto> processRestOptions(hash<auto> options);
274
276
278protected:
280public:
281
282
284
288protected:
289 *AbstractDataProvider getChildProviderImpl(string name);
290public:
291
292
294protected:
295 hash<DataProviderInfo> getStaticInfoImpl();
296public:
297
298};
299};
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names, if any.
*AbstractDataProvider getChildProviderImpl(string name)
Returns the given child provider or NOTHING if the given child is unknown.
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
constructor(*hash< auto > options)
Creates the object from constructor options.
*string getDesc()
Returns the data provider description.
constructor(RestClient rest)
Creates the object from a REST connection.
string getName()
Returns the data provider name.
*list< hash< DataProviderSummaryInfo > > getChildProviderSummaryInfo()
Return data provider summary info.
static hash< auto > processRestOptions(hash< auto > options)
Processes common REST options.
static hash< auto > makeRequest(RestClient rest, string meth, *data body, string path, *hash< auto > hdr)
Makes a REST request and returns the response.
static RestClient getRestConnection(hash< auto > options)
Returns a REST connection.
Qore RestClientDataProvider module definition.
Definition: RestClientCallDataProvider.qc.dox.h:26