| 55 | | /*-----------------------------------------------------------------*/ |
|---|
| 56 | | /* type definitions */ |
|---|
| 57 | | |
|---|
| 58 | | /* local definitions |
|---|
| 59 | | * |
|---|
| 60 | | * Openwsman handles some structures as 'anonymous', just declaring |
|---|
| 61 | | * them without exposing their definition. |
|---|
| 62 | | * However, SWIG need the definition in order to create bindings. |
|---|
| 63 | | */ |
|---|
| 64 | | |
|---|
| 65 | | |
|---|
| 66 | | %rename(Client) _WsManClient; |
|---|
| 67 | | %nodefault _WsManClient; |
|---|
| 68 | | typedef struct _WsManClient { |
|---|
| 69 | | } WsManClient; |
|---|
| 70 | | |
|---|
| 71 | | %rename(EndPointReference) epr_t; |
|---|
| 72 | | %nodefault epr_t; |
|---|
| 73 | | typedef struct { |
|---|
| 74 | | char * address; |
|---|
| 75 | | } epr_t; |
|---|
| 76 | | |
|---|
| 77 | | |
|---|
| 78 | | %rename(Filter) filter_t; |
|---|
| 79 | | %nodefault filter_t; |
|---|
| 80 | | typedef struct { |
|---|
| 81 | | char *resultClass; |
|---|
| 82 | | char *assocClass; |
|---|
| 83 | | } filter_t; |
|---|
| 84 | | |
|---|
| 85 | | %rename(ClientOptions) client_opt_t; |
|---|
| 86 | | %nodefault client_opt_t; |
|---|
| 87 | | typedef struct { |
|---|
| 88 | | } client_opt_t; |
|---|
| 89 | | |
|---|
| 90 | | %nodefault __WsXmlNode; /* part of WsXmlDoc */ |
|---|
| 91 | | %rename(WsXmlNode) __WsXmlNode; |
|---|
| 92 | | %ignore __WsXmlNode::__undefined; |
|---|
| 93 | | |
|---|
| 94 | | %nodefault __WsXmlAttr; /* part of WsXmlNode */ |
|---|
| 95 | | %rename(WsXmlAttr) __WsXmlAttr; |
|---|
| 96 | | %ignore __WsXmlAttr::__undefined; |
|---|
| 97 | | |
|---|
| 98 | | %nodefault __WsXmlNs; /* part of WsXmlAttr */ |
|---|
| 99 | | %rename(WsXmlNs) __WsXmlNs; |
|---|
| 100 | | %ignore __WsXmlNs::__undefined; |
|---|
| 101 | | |
|---|
| 102 | | %nodefault _WsXmlDoc; |
|---|
| 103 | | %rename(WsXmlDoc) _WsXmlDoc; |
|---|
| 104 | | struct _WsXmlDoc {}; |
|---|
| 105 | | |
|---|
| 106 | | %include "wsman-types.h" |
|---|
| 107 | | |
|---|
| 108 | | |
|---|
| 109 | | /*-----------------------------------------------------------------*/ |
|---|
| 110 | | /* constant definitions */ |
|---|
| 111 | | |
|---|
| 112 | | %include "wsman-names.h" |
|---|
| 113 | | |
|---|
| 114 | | #define FLAG_NONE 0x0000 |
|---|
| 115 | | #define FLAG_ENUMERATION_COUNT_ESTIMATION 0x0001 |
|---|
| 116 | | #define FLAG_ENUMERATION_OPTIMIZATION 0x0002 |
|---|
| 117 | | #define FLAG_ENUMERATION_ENUM_EPR 0x0004 |
|---|
| 118 | | #define FLAG_ENUMERATION_ENUM_OBJ_AND_EPR 0x0008 |
|---|
| 119 | | #define FLAG_DUMP_REQUEST 0x0010 |
|---|
| 120 | | #define FLAG_IncludeSubClassProperties 0x0020 |
|---|
| 121 | | #define FLAG_ExcludeSubClassProperties 0x0040 |
|---|
| 122 | | #define FLAG_POLYMORPHISM_NONE 0x0080 |
|---|
| 123 | | #define FLAG_MUND_MAX_ESIZE 0x0100 |
|---|
| 124 | | #define FLAG_MUND_LOCALE 0x0200 |
|---|
| 125 | | #define FLAG_MUND_OPTIONSET 0x0400 |
|---|
| 126 | | #define FLAG_MUND_FRAGMENT 0x0800 |
|---|
| 127 | | #define FLAG_CIM_EXTENSIONS 0x1000 |
|---|
| 128 | | #define FLAG_CIM_REFERENCES 0x2000 |
|---|
| 129 | | #define FLAG_CIM_ASSOCIATORS 0x4000 |
|---|
| 130 | | #define FLAG_EVENT_SENDBOOKMARK 0X8000 |
|---|
| 131 | | |
|---|
| 132 | | |
|---|
| 133 | | #define WSMAN_DELIVERY_PUSH 0 |
|---|
| 134 | | #define WSMAN_DELIVERY_PUSHWITHACK 1 |
|---|
| 135 | | #define WSMAN_DELIVERY_EVENTS 2 |
|---|
| 136 | | #define WSMAN_DELIVERY_PULL 3 |
|---|
| 137 | | |
|---|
| 138 | | |
|---|
| 139 | | /*-----------------------------------------------------------------*/ |
|---|
| 140 | | /* xml structure accessors */ |
|---|
| 141 | | |
|---|
| 142 | | %extend _WsXmlDoc { |
|---|
| 143 | | /* constructor */ |
|---|
| 144 | | _WsXmlDoc() { |
|---|
| 145 | | return ws_xml_create_soap_envelope(); |
|---|
| 146 | | } |
|---|
| 147 | | /* destructor */ |
|---|
| 148 | | ~_WsXmlDoc() { |
|---|
| 149 | | ws_xml_destroy_doc( $self ); |
|---|
| 150 | | } |
|---|
| 151 | | #if defined(SWIGRUBY) |
|---|
| 152 | | %alias dump "to_s"; |
|---|
| 153 | | #endif |
|---|
| 154 | | /* dump doc as string */ |
|---|
| 155 | | char *dump(const char *encoding="utf-8") { |
|---|
| 156 | | int size; |
|---|
| 157 | | char *buf; |
|---|
| 158 | | ws_xml_dump_memory_enc( $self, &buf, &size, encoding ); |
|---|
| 159 | | return buf; |
|---|
| 160 | | } |
|---|
| 161 | | /* dump doc to file */ |
|---|
| 162 | | void dump_file(FILE *fp) { |
|---|
| 163 | | ws_xml_dump_doc( fp, $self ); |
|---|
| 164 | | } |
|---|
| 165 | | /* get root node of doc */ |
|---|
| 166 | | WsXmlNodeH root() { |
|---|
| 167 | | return ws_xml_get_doc_root( $self ); |
|---|
| 168 | | } |
|---|
| 169 | | /* get soap envelope */ |
|---|
| 170 | | WsXmlNodeH envelope() { |
|---|
| 171 | | return ws_xml_get_soap_envelope( $self ); |
|---|
| 172 | | } |
|---|
| 173 | | /* get soap header */ |
|---|
| 174 | | WsXmlNodeH header() { |
|---|
| 175 | | return ws_xml_get_soap_header( $self ); |
|---|
| 176 | | } |
|---|
| 177 | | /* get soap body */ |
|---|
| 178 | | WsXmlNodeH body() { |
|---|
| 179 | | return ws_xml_get_soap_body( $self ); |
|---|
| 180 | | } |
|---|
| 181 | | /* get soap element by name */ |
|---|
| 182 | | WsXmlNodeH element(const char *name) { |
|---|
| 183 | | return ws_xml_get_soap_element( $self, name ); |
|---|
| 184 | | } |
|---|
| 185 | | } |
|---|
| 186 | | |
|---|
| 187 | | |
|---|
| 188 | | %extend __WsXmlNode { |
|---|
| 189 | | #if defined(SWIGRUBY) |
|---|
| 190 | | %alias text "to_s"; |
|---|
| 191 | | #endif |
|---|
| 192 | | /* dump node as string */ |
|---|
| 193 | | char *dump() { |
|---|
| 194 | | int size; |
|---|
| 195 | | char *buf; |
|---|
| 196 | | ws_xml_dump_memory_node_tree( $self, &buf, &size ); |
|---|
| 197 | | return buf; |
|---|
| 198 | | } |
|---|
| 199 | | /* dump node to file */ |
|---|
| 200 | | void dump_file(FILE *fp) { |
|---|
| 201 | | ws_xml_dump_node_tree( fp, $self ); |
|---|
| 202 | | } |
|---|
| 203 | | /* get text of node */ |
|---|
| 204 | | char *text() { |
|---|
| 205 | | return ws_xml_get_node_text( $self ); |
|---|
| 206 | | } |
|---|
| 207 | | #if defined(SWIGRUBY) |
|---|
| 208 | | %rename( "text=" ) set_text( const char *text ); |
|---|
| 209 | | #endif |
|---|
| 210 | | void set_text( const char *text ) { |
|---|
| 211 | | ws_xml_set_node_text( $self, text ); |
|---|
| 212 | | } |
|---|
| 213 | | /* get doc for node */ |
|---|
| 214 | | WsXmlDocH doc() { |
|---|
| 215 | | return ws_xml_get_node_doc( $self ); |
|---|
| 216 | | } |
|---|
| 217 | | /* get parent for node */ |
|---|
| 218 | | WsXmlNodeH parent() { |
|---|
| 219 | | return ws_xml_get_node_parent( $self ); |
|---|
| 220 | | } |
|---|
| 221 | | /* get name for node */ |
|---|
| 222 | | char *name() { |
|---|
| 223 | | return ws_xml_get_node_local_name( $self ); |
|---|
| 224 | | } |
|---|
| 225 | | /* set name of node */ |
|---|
| 226 | | void set_name( const char *nsuri, const char *name ) { |
|---|
| 227 | | ws_xml_set_node_name( $self, nsuri, name ); |
|---|
| 228 | | } |
|---|
| 229 | | /* get namespace for node */ |
|---|
| 230 | | char *ns() { |
|---|
| 231 | | return ws_xml_get_node_name_ns( $self ); |
|---|
| 232 | | } |
|---|
| 233 | | /* set namespace of node */ |
|---|
| 234 | | void set_ns( const char *ns, const char *prefix ) { |
|---|
| 235 | | ws_xml_set_ns( $self, ns, prefix ); |
|---|
| 236 | | } |
|---|
| 237 | | |
|---|
| 238 | | /* find node within tree */ |
|---|
| 239 | | WsXmlNodeH find( const char *ns, const char *name, int recursive = 1) { |
|---|
| 240 | | return ws_xml_find_in_tree( $self, ns, name, recursive ); |
|---|
| 241 | | } |
|---|
| 242 | | |
|---|
| 243 | | /* count node children */ |
|---|
| 244 | | int child_count() { |
|---|
| 245 | | return ws_xml_get_child_count( $self ); |
|---|
| 246 | | } |
|---|
| 247 | | /* add child to node */ |
|---|
| 248 | | WsXmlNodeH child_add( const char *ns, const char *name, const char *value = NULL ) { |
|---|
| 249 | | return ws_xml_add_child( $self, ns, name, value ); |
|---|
| 250 | | } |
|---|
| 251 | | #if defined(SWIGRUBY) |
|---|
| 252 | | /* enumerate children */ |
|---|
| 253 | | void each_child() { |
|---|
| 254 | | int i = 0; |
|---|
| 255 | | while ( i < ws_xml_get_child_count( $self ) ) { |
|---|
| 256 | | rb_yield( SWIG_NewPointerObj((void*) ws_xml_get_child($self, i, NULL, NULL), SWIGTYPE_p___WsXmlNode, 0)); |
|---|
| 257 | | ++i; |
|---|
| 258 | | } |
|---|
| 259 | | } |
|---|
| 260 | | #endif |
|---|
| 261 | | |
|---|
| 262 | | /* get node attribute */ |
|---|
| 263 | | WsXmlAttrH attr(int index = 0) { |
|---|
| 264 | | return ws_xml_get_node_attr( $self, index ); |
|---|
| 265 | | } |
|---|
| 266 | | /* count node attribute */ |
|---|
| 267 | | int attr_count() { |
|---|
| 268 | | return ws_xml_get_node_attr_count( $self ); |
|---|
| 269 | | } |
|---|
| 270 | | /* find node attribute by name */ |
|---|
| 271 | | WsXmlAttrH attr_find( const char *ns, const char *name ) { |
|---|
| 272 | | return ws_xml_find_node_attr( $self, ns, name ); |
|---|
| 273 | | } |
|---|
| 274 | | /* add attribute to node */ |
|---|
| 275 | | WsXmlAttrH attr_add( const char *ns, const char *name, const char *value ) { |
|---|
| 276 | | return ws_xml_add_node_attr( $self, ns, name, value ); |
|---|
| 277 | | } |
|---|
| 278 | | |
|---|
| 279 | | epr_t *epr( const char *ns, const char *epr_node_name, int embedded) { |
|---|
| 280 | | return epr_deserialize($self, ns, epr_node_name, embedded); |
|---|
| 281 | | } |
|---|
| 282 | | |
|---|
| 283 | | |
|---|
| 284 | | #if defined(SWIGRUBY) |
|---|
| 285 | | /* enumerate attributes */ |
|---|
| 286 | | void each_attr() { |
|---|
| 287 | | int i = 0; |
|---|
| 288 | | while ( i < ws_xml_get_node_attr_count( $self ) ) { |
|---|
| 289 | | rb_yield( SWIG_NewPointerObj((void*) ws_xml_get_node_attr($self, i), SWIGTYPE_p___WsXmlAttr, 0)); |
|---|
| 290 | | ++i; |
|---|
| 291 | | } |
|---|
| 292 | | } |
|---|
| 293 | | #endif |
|---|
| 294 | | } |
|---|
| 295 | | |
|---|
| 296 | | |
|---|
| 297 | | %extend __WsXmlAttr { |
|---|
| 298 | | #if defined(SWIGRUBY) |
|---|
| 299 | | %alias value "to_s"; |
|---|
| 300 | | #endif |
|---|
| 301 | | /* get name for attr */ |
|---|
| 302 | | char *name() { |
|---|
| 303 | | return ws_xml_get_attr_name( $self ); |
|---|
| 304 | | } |
|---|
| 305 | | /* get namespace for attr */ |
|---|
| 306 | | char *ns() { |
|---|
| 307 | | return ws_xml_get_attr_ns( $self ); |
|---|
| 308 | | } |
|---|
| 309 | | /* get value for attr */ |
|---|
| 310 | | char *value() { |
|---|
| 311 | | return ws_xml_get_attr_value( $self ); |
|---|
| 312 | | } |
|---|
| 313 | | /* remove note attribute */ |
|---|
| 314 | | void remove() { |
|---|
| 315 | | ws_xml_remove_node_attr( $self ); |
|---|
| 316 | | } |
|---|
| 317 | | } |
|---|
| 318 | | |
|---|
| 319 | | |
|---|
| 320 | | /*-----------------------------------------------------------------*/ |
|---|
| 321 | | /* epr */ |
|---|
| 322 | | %extend epr_t { |
|---|
| 323 | | epr_t( const char *uri, const char *address) { |
|---|
| 324 | | return epr_create( uri, NULL, address); |
|---|
| 325 | | } |
|---|
| 326 | | |
|---|
| 327 | | ~epr_t() { |
|---|
| 328 | | epr_destroy( $self ); |
|---|
| 329 | | } |
|---|
| 330 | | |
|---|
| 331 | | void add_selector(const char *name, const char *text) { |
|---|
| 332 | | epr_add_selector_text($self, name, text); |
|---|
| 333 | | } |
|---|
| 334 | | |
|---|
| 335 | | int serialize( WsXmlNodeH node, const char *ns, const char *epr_node_name, int embedded) { |
|---|
| 336 | | return epr_serialize(node, ns, epr_node_name, $self, embedded); |
|---|
| 337 | | } |
|---|
| 338 | | |
|---|
| 339 | | int cmp(epr_t *epr2) { |
|---|
| 340 | | return epr_cmp($self, epr2); |
|---|
| 341 | | } |
|---|
| 342 | | char *toxml( const char *ns, const char *epr_node_name) { |
|---|
| 343 | | return epr_to_txt($self, ns, epr_node_name); |
|---|
| 344 | | } |
|---|
| 345 | | |
|---|
| 346 | | int selector_count(void) { |
|---|
| 347 | | return epr_selector_count($self); |
|---|
| 348 | | } |
|---|
| 349 | | |
|---|
| 350 | | char *get_resource_uri(void) { |
|---|
| 351 | | return epr_get_resource_uri($self); |
|---|
| 352 | | } |
|---|
| 353 | | |
|---|
| 354 | | char *get_selector(const char* name) { |
|---|
| 355 | | return wsman_epr_selector_by_name($self, name); |
|---|
| 356 | | } |
|---|
| 357 | | |
|---|
| 358 | | |
|---|
| 359 | | } |
|---|
| 360 | | |
|---|
| 361 | | /*-----------------------------------------------------------------*/ |
|---|
| 362 | | /* filter */ |
|---|
| 363 | | %extend filter_t { |
|---|
| 364 | | filter_t() { |
|---|
| 365 | | return filter_initialize(); |
|---|
| 366 | | } |
|---|
| 367 | | ~filter_t() { |
|---|
| 368 | | filter_destroy( $self ); |
|---|
| 369 | | } |
|---|
| 370 | | |
|---|
| 371 | | int associators( epr_t *epr, const char *assocClass, const char *resultClass, |
|---|
| 372 | | const char *role, const char *resultRole, char **resultProp, const int propNum) { |
|---|
| 373 | | return filter_set_assoc($self, epr, 0, assocClass, resultClass, role, resultRole, resultProp, propNum); |
|---|
| 374 | | } |
|---|
| 375 | | int references( epr_t *epr, const char *assocClass, |
|---|
| 376 | | const char *resultClass, const char *role, const char *resultRole, char **resultProp, const int propNum) { |
|---|
| 377 | | return filter_set_assoc($self, epr, 1, assocClass, resultClass, role, resultRole, resultProp, propNum); |
|---|
| 378 | | } |
|---|
| 379 | | |
|---|
| 380 | | int simple(const char *dialect, const char *query) { |
|---|
| 381 | | return filter_set_simple($self, dialect, query ); |
|---|
| 382 | | } |
|---|
| 383 | | int xpath(const char *query) { |
|---|
| 384 | | return filter_set_simple($self, WSM_XPATH_FILTER_DIALECT, query ); |
|---|
| 385 | | } |
|---|
| 386 | | int cql(const char *query) { |
|---|
| 387 | | return filter_set_simple($self, WSM_CQL_FILTER_DIALECT, query ); |
|---|
| 388 | | } |
|---|
| 389 | | int wql(const char *query) { |
|---|
| 390 | | return filter_set_simple($self, WSM_WQL_FILTER_DIALECT, query ); |
|---|
| 391 | | } |
|---|
| 392 | | |
|---|
| 393 | | } |
|---|
| 394 | | |
|---|
| 395 | | /*-----------------------------------------------------------------*/ |
|---|
| 396 | | /* options */ |
|---|
| 397 | | |
|---|
| 398 | | %extend client_opt_t { |
|---|
| 399 | | client_opt_t() { |
|---|
| 400 | | return wsmc_options_init(); |
|---|
| 401 | | } |
|---|
| 402 | | |
|---|
| 403 | | ~client_opt_t() { |
|---|
| 404 | | wsmc_options_destroy( $self ); |
|---|
| 405 | | } |
|---|
| 406 | | |
|---|
| 407 | | |
|---|
| 408 | | void set_dump_request(void) { |
|---|
| 409 | | wsmc_set_action_option($self, FLAG_DUMP_REQUEST ); |
|---|
| 410 | | } |
|---|
| 411 | | |
|---|
| 412 | | void add_selector(char *key, char*value) { |
|---|
| 413 | | wsmc_add_selector($self, key, value); |
|---|
| 414 | | } |
|---|
| 415 | | |
|---|
| 416 | | void set_delivery_uri( const char *delivery_uri ) { |
|---|
| 417 | | wsmc_set_delivery_uri(delivery_uri, $self); |
|---|
| 418 | | } |
|---|
| 419 | | |
|---|
| 420 | | void set_sub_expiry(int event_subscription_expire) { |
|---|
| 421 | | wsmc_set_sub_expiry(event_subscription_expire, $self); |
|---|
| 422 | | } |
|---|
| 423 | | |
|---|
| 424 | | void set_heartbeat_interval(int heartbeat_interval) { |
|---|
| 425 | | wsmc_set_heartbeat_interval(heartbeat_interval, $self); |
|---|
| 426 | | } |
|---|
| 427 | | |
|---|
| 428 | | void set_delivery_mode(WsmanDeliveryMode delivery_mode) { |
|---|
| 429 | | wsmc_set_delivery_mode(delivery_mode, $self); |
|---|
| 430 | | } |
|---|
| 431 | | } |
|---|
| 432 | | |
|---|
| | 55 | %include "wsman-types.i" |
|---|
| | 56 | |
|---|
| | 57 | %include "wsman-names.i" |
|---|
| | 58 | |
|---|
| | 59 | %include "wsman-xml.i" |
|---|
| | 60 | |
|---|
| | 61 | %include "wsman-epr.i" |
|---|
| | 62 | |
|---|
| | 63 | %include "wsman-filter.i" |
|---|
| | 64 | |
|---|
| | 65 | %include "client_opt.i" |
|---|