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