class Openwsman::EndPointReference
The EndPointReference
is a stub to proxy server-side operations
Each WS-Management operation (Get, Enumerate, Invoke, …) has an associated end point reference, providing the actual implementation of the operation.
Public Instance Methods
Add selector as key/value pair
void add_selector(const char *name, const char *text) { epr_add_selector_text($self, name, text); } /* * Serialization * * XML-serialize EndPointReference as child (with namespace and name) of node * */ int serialize( WsXmlNodeH node, const char *ns, const char *epr_node_name, int embedded) { return epr_serialize(node, ns, epr_node_name, $self, embedded); } %alias cmp "=="; %typemap(out) int cmp "$result = ($1 == 0) ? Qtrue : Qfalse;"; /* * Compare two EndPointReferences * */ int cmp(const epr_t *epr2) { return epr_cmp($self, epr2); } /* * String representation (XML syntax) * */ char *to_xml( const char *ns = NULL, const char *epr_node_name = NULL) { return epr_to_txt($self, ns?ns:XML_NS_ADDRESSING, epr_node_name?epr_node_name:WSA_EPR); } %rename("to_s") string(); %newobject string; /* * String representation (<uri>?<selector>,<selector>,...) * */ char *string() { return epr_to_string($self); } /* * Number of selectors */ int selector_count(void) { return epr_selector_count($self); } /* * The resource URI associated to this EndPointReference * */ char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Classname of EPR
char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
clone the EndPointReference
instance
epr_t *clone(const epr_t *epr) { return epr_copy(epr); } /* * Add selector as key/value pair * */ void add_selector(const char *name, const char *text) { epr_add_selector_text($self, name, text); } /* * Serialization * * XML-serialize EndPointReference as child (with namespace and name) of node * */ int serialize( WsXmlNodeH node, const char *ns, const char *epr_node_name, int embedded) { return epr_serialize(node, ns, epr_node_name, $self, embedded); } %alias cmp "=="; %typemap(out) int cmp "$result = ($1 == 0) ? Qtrue : Qfalse;"; /* * Compare two EndPointReferences * */ int cmp(const epr_t *epr2) { return epr_cmp($self, epr2); } /* * String representation (XML syntax) * */ char *to_xml( const char *ns = NULL, const char *epr_node_name = NULL) { return epr_to_txt($self, ns?ns:XML_NS_ADDRESSING, epr_node_name?epr_node_name:WSA_EPR); } %rename("to_s") string(); %newobject string; /* * String representation (<uri>?<selector>,<selector>,...) * */ char *string() { return epr_to_string($self); } /* * Number of selectors */ int selector_count(void) { return epr_selector_count($self); } /* * The resource URI associated to this EndPointReference * */ char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Compare two EndPointReferences
int cmp(const epr_t *epr2) { return epr_cmp($self, epr2); } /* * String representation (XML syntax) * */ char *to_xml( const char *ns = NULL, const char *epr_node_name = NULL) { return epr_to_txt($self, ns?ns:XML_NS_ADDRESSING, epr_node_name?epr_node_name:WSA_EPR); } %rename("to_s") string(); %newobject string; /* * String representation (<uri>?<selector>,<selector>,...) * */ char *string() { return epr_to_string($self); } /* * Number of selectors */ int selector_count(void) { return epr_selector_count($self); } /* * The resource URI associated to this EndPointReference * */ char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
enumerate over selectors as key,value pairs
void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Namespace of EPR
char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Prefix of EPR
char *prefix(void) { return epr_prefix($self->refparams.uri); } }
The resource URI associated to this EndPointReference
char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Get value of selector by name epr#selector converts any value passed to String
Shortcut¶ ↑
epr.selector(“name”) can also be abbreviated as epr.name
Examples¶ ↑
epr.selector("name") epr.selector(value) epr.name
char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Number of selectors
int selector_count(void) { return epr_selector_count($self); } /* * The resource URI associated to this EndPointReference * */ char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Return list of selector names
VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
Serialization
XML-serialize EndPointReference
as child (with namespace and name) of node
int serialize( WsXmlNodeH node, const char *ns, const char *epr_node_name, int embedded) { return epr_serialize(node, ns, epr_node_name, $self, embedded); } %alias cmp "=="; %typemap(out) int cmp "$result = ($1 == 0) ? Qtrue : Qfalse;"; /* * Compare two EndPointReferences * */ int cmp(const epr_t *epr2) { return epr_cmp($self, epr2); } /* * String representation (XML syntax) * */ char *to_xml( const char *ns = NULL, const char *epr_node_name = NULL) { return epr_to_txt($self, ns?ns:XML_NS_ADDRESSING, epr_node_name?epr_node_name:WSA_EPR); } %rename("to_s") string(); %newobject string; /* * String representation (<uri>?<selector>,<selector>,...) * */ char *string() { return epr_to_string($self); } /* * Number of selectors */ int selector_count(void) { return epr_selector_count($self); } /* * The resource URI associated to this EndPointReference * */ char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }
String representation (<uri>?<selector>,<selector>,…)
char *string() { return epr_to_string($self); } /* * Number of selectors */ int selector_count(void) { return epr_selector_count($self); } /* * The resource URI associated to this EndPointReference * */ char *resource_uri(void) { return epr_get_resource_uri($self); } /* * Get value of selector by name * epr#selector converts any value passed to String * * ==== Shortcut * epr.selector("name") can also be abbreviated as epr.name * * ==== Examples * epr.selector("name") * epr.selector(value) * epr.name */ char *selector(VALUE v) { const char *name = as_string(v); return wsman_epr_selector_by_name($self, name); } #if !defined(SWIGJAVA) /* Target_* undefined for Java in openwsman.i */ /* * Return list of selector names */ VALUE selector_names(void) { int i; Target_Type ary = Target_SizedArray($self->refparams.selectorset.count); key_value_t *p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { Target_ListSet(ary, i, SWIG_FromCharPtr(p->key)); ++p; } return ary; } #endif /* * enumerate over selectors as key,value pairs * * call-seq: * epr.each { |key,value| ... } * */ void each() { int i; key_value_t *p = NULL; VALUE value, ary; p = $self->refparams.selectorset.selectors; for (i = 0; i < $self->refparams.selectorset.count; i++) { ary = rb_ary_new2(2); rb_ary_store(ary, 0, SWIG_FromCharPtr(p->key)); if (p->type == 0) { value = SWIG_FromCharPtr(p->v.text); } else { value = SWIG_NewPointerObj((void*) p->v.epr, SWIGTYPE_p_epr_t, 0); } rb_ary_store(ary, 1, value); rb_yield(ary); p++; } } %newobject classname; /* * Classname of EPR */ char *classname(void) { return uri_classname($self->refparams.uri); } %newobject namespace; /* * Namespace of EPR */ char *namespace(void) { char *classname; int classnamelen, namespacelen; const char *prefix; const char *uri; /* try to get namespace from selectors (WS-Management style) */ char *ns = get_cimnamespace_from_selectorset(&($self->refparams.selectorset)); if (ns) { return strdup(ns); } /* WMI style? - extract namespace from uri */ uri = $self->refparams.uri; prefix = epr_prefix(uri); if (prefix == NULL) { return NULL; /* bad classname in URI */ } classname = uri_classname(uri); if (classname == NULL) return NULL; /* bad URI */ classnamelen = strlen(classname); free(classname); namespacelen = strlen(uri) - classnamelen - strlen(prefix) - 2; /* drop enclosing slashes */ if (namespacelen <= 0) return strdup(""); /* copy after prefix slash (+ 1) */ return strndup(uri + strlen(prefix) + 1, namespacelen); } %newobject prefix; /* * Prefix of EPR */ char *prefix(void) { return epr_prefix($self->refparams.uri); } }