root/openwsman/trunk/bindings/wsman-client.i

Revision 3191, 5.8 kB (checked in by kkaempf, 7 months ago)

fix 'Client::invoke' API to accept a XmlDoc? instead of string+length+encoding
adapt tests accordingly

Line 
1 /*
2  * wsman-client.i
3  *
4  * client declarations for openwsman swig bindings
5  *
6  */
7  
8 %rename(Client) _WsManClient;
9 %nodefault _WsManClient;
10 typedef struct _WsManClient {
11 } WsManClient;
12
13 /*
14  * Instances of Client represent a connection to a client used for
15  * sending WS-Management operation requests.
16  *
17  */
18  
19 %extend WsManClient {
20   /*
21    * Create a client connection.
22    *
23    * There are two ways to connect to a client, either by specifying a
24    * URL or by passing all client parameters separately
25    *
26    * call-seq:
27    *  Client.new("http://user:pass@host.domain.com:1234/path")
28    *  Client.new(host, port, path, scheme, username, password)
29    *  Client.new("host.domain.com", 1234, "/path", "http", "user", "pass")
30    *
31    */
32   WsManClient( const char *uri ) {
33     return wsmc_create_from_uri( uri );
34   }
35   /* :nodoc: */
36   WsManClient(const char *hostname,
37               const int port, const char *path,
38               const char *scheme,
39               const char *username,
40               const char *password) {
41     return wsmc_create( hostname, port, path, scheme, username, password );
42   }
43   /* destructor */
44   ~WsManClient() {
45     wsmc_release( $self );
46   }
47   /* set dumpfile */
48 #if defined(SWIGRUBY)
49   %rename( "dumpfile=" ) set_dumpfile( FILE *f );
50 #endif
51   /*
52    * Set the dumpfile (for debugging)
53    */
54   void set_dumpfile( FILE *f ) {
55     wsmc_set_dumpfile( $self, f );
56   }
57   /*
58    * Response code of the last request
59    * call-seq:
60    *  client.reponse_code -> Integer
61    *
62    */
63   long response_code() {
64     return wsmc_get_response_code( $self );
65   }
66   /*
67    * String representation of the transport scheme ('http', 'https')
68    */
69   char *scheme() {
70     return wsmc_get_scheme( $self );
71   }
72   /*
73    * The host part of the client URL
74    */
75   char *host() {
76     return wsmc_get_hostname( $self );
77   }
78   /*
79    * The TCP port used in the connection
80    */
81   int port() {
82     return wsmc_get_port( $self );
83   }
84   /*
85    * The path of the clien URL
86    */
87   char *path() {
88     return wsmc_get_path( $self );
89   }
90   /*
91    * The user name used for authentication
92    */
93   char *user() {
94     return wsmc_get_user( $self );
95   }
96   /*
97    * The password used for authentication
98    */
99   char *password() {
100     return wsmc_get_password( $self );
101   }
102  
103   /*
104    * The Transport instance associated to the client
105    */
106   WsManTransport *transport() {
107     wsmc_transport_init($self, NULL);
108     wsmc_transport_set_auth_request_func( $self, auth_request_callback );
109
110     return (WsManTransport *)$self;
111   }
112
113   /*
114    * Send a (raw) SOAP request to the client
115    */
116   int send_request(WsXmlDocH request) {
117     return wsman_send_request($self, request);
118   }
119
120   /*
121    * Get client encoding
122    */
123   char *encoding() {
124     return wsmc_get_encoding($self);
125   }
126  
127 #if defined(SWIGRUBY)
128   %rename( "encoding=" ) set_encoding( const char *encoding );
129 #endif
130   /*
131    * Set client encoding
132    */
133   void set_encoding(const char *encoding) {
134     wsmc_set_encoding($self, encoding);
135   }
136
137 /*-----------------------------------------------------------------*/
138 /* actions */
139
140   /*
141    * WS-Identify
142    */
143   WsXmlDocH identify( client_opt_t *options ) {
144     return wsmc_action_identify( $self, options );
145   }
146  
147   /*
148    * WS-Get
149    */
150   WsXmlDocH get_from_epr( client_opt_t *options , epr_t *epr) {
151     return wsmc_action_get_from_epr( $self, epr, options);
152   }
153   /*
154    * WS-Delete
155    */
156   WsXmlDocH delete_from_epr( client_opt_t *options , epr_t *epr) {
157     return wsmc_action_delete_from_epr( $self, epr, options);
158   }
159
160   /*
161    * WS-Enumerate
162    */
163   WsXmlDocH enumerate( client_opt_t *options , filter_t *filter, char *resource_uri) {
164     return wsmc_action_enumerate( $self, resource_uri, options, filter);
165   }
166   /*
167    * WS-Transport: pull
168    */
169   WsXmlDocH pull( client_opt_t *options , filter_t *filter, char *resource_uri, char *enum_ctx) {
170     return wsmc_action_pull( $self, resource_uri, options, filter, enum_ctx);
171   }
172   /*
173    * WS-Create
174    */
175   WsXmlDocH create( client_opt_t *options, char *resource_uri, char *data, size_t size, char *encoding = "utf-8") {
176     return wsmc_action_create_fromtext( $self, resource_uri, options, data, size, encoding);
177   }
178   /*
179    * WS-Transport: put
180    */
181   WsXmlDocH put( client_opt_t *options , char *resource_uri,  char *data, size_t size, char *encoding = "utf-8") {
182     return wsmc_action_put_fromtext( $self, resource_uri, options, data, size, encoding);
183   }
184   /*
185    * WS-Release
186    */
187   WsXmlDocH release( client_opt_t *options , char *resource_uri, char *enum_ctx) {
188     return wsmc_action_release( $self, resource_uri, options, enum_ctx);
189   }
190   /*
191    * WS-Transport: get
192    */
193   WsXmlDocH get( client_opt_t *options , char *resource_uri) {
194     return wsmc_action_get( $self, resource_uri, options);
195   }
196
197   /*
198    * WS-Transport: delete
199    */
200   WsXmlDocH delete( client_opt_t *options , char *resource_uri) {
201     return wsmc_action_delete( $self, resource_uri, options);
202   }
203   /*
204    * WS-Invoke
205    */
206   WsXmlDocH invoke( client_opt_t *options , char *resource_uri, char *method, WsXmlDocH data = NULL) {
207     return wsmc_action_invoke( $self, resource_uri, options, method, data);
208   }
209
210   /*
211    * WS-Eventing: subscribe
212    */
213   WsXmlDocH subscribe(client_opt_t *options , filter_t *filter, char *resource_uri) {
214     return wsmc_action_subscribe($self,  resource_uri, options, filter);
215   }
216
217   /*
218    * WS-Eventing: unsubscribe
219    */
220   WsXmlDocH unsubscribe(client_opt_t *options , filter_t *filter, char *resource_uri, char *identifier) {
221     return wsmc_action_unsubscribe($self, resource_uri, options, identifier);
222   }
223
224   /*
225    * WS-Eventing: renew
226    */
227   WsXmlDocH renew(client_opt_t *options , char *resource_uri, char *identifier) {
228     return wsmc_action_renew($self, resource_uri, options, identifier);
229   }
230
231   /*
232    * fault string
233    */
234   char *fault_string() {
235     return wsmc_get_fault_string($self);
236   }
237  
238   /*
239    * last error
240    */
241    int last_error() {
242      return wsmc_get_last_error($self);
243    }
244 }