Class: Sfcc::Cim::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sfcc/client.rb,
ext/sfcc/cim_client.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.connect(args = {}) ⇒ Object

Client.connect(:host => “localhost”,

             :scheme => "http",
             :port => 5988,
             :user => "root",
             :password => "foo"
             :verify => true,
             :trust_store => "/path/to/trust/store",
             :cert_file => "/path/to/cert_file",
             :key_file => "/path/to/key_file") do |client|
# do something with client

end

client is both returned and passed to a given block.

:verify, :trust_store, :cert_file, and :key_file are only evaluated if :scheme is 'https' and verify != false

If :verify=>false, :trust_store, :cert_file and :key_file are unused If :verify is ommitted, it defaults to true

Alternatively you can pass a uri:

client = Client.connect(uri)

or a mix like

client = Client.connect(:uri => uri, :verify => false)

Explicit parameters (like :user) always override :uri data


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sfcc/client.rb', line 46

def self.connect(args={})
  params = {}
  uri = nil
  case args
  when Hash
    params.merge!(args)
    uri = params[:uri]
    case uri
    when URI
      self.uri_to_params(uri, params)
    else
      self.uri_to_params(URI.parse(uri.to_s), params)
    end
  when ::String
    uri = URI.parse(args)
	  return Client.connect uri
  when URI
    self.uri_to_params(args, params)
	else
	  raise "Bad argument #{args.inspect}:#{args.class}"
  end

  verify = params[:verify]
  trust_store = params[:trust_store]
  cert_file = params[:cert_file]
  key_file = params[:key_file]

  case params[:scheme]
  when "http"
  when "https"
    unless verify == false
      raise "Must either specify :verify=>false or :cert_file for https URLs."
    end
  else
    raise "Unsupported connection scheme #{scheme.inspect}"
  end

  native_connect(params[:host],
                 params[:scheme],
                 params[:port].to_s,
                 params[:user],
                 params[:password],
                 verify,
                 trust_store,
                 cert_file,
                 key_file)
end

.native_connectObject


1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
# File 'ext/sfcc/cim_client.c', line 1207

static VALUE connect(VALUE klass, VALUE host, VALUE scheme, VALUE port, VALUE user, VALUE pwd,
                     VALUE verify, VALUE trust_store, VALUE cert_file, VALUE key_file)
{
  CIMCClient *client;
  CIMCStatus status = {CIMC_RC_OK, NULL};
  /*
   * CIMCClient* (*connect2)
   * (CIMCEnv *ce, const char *hn, const char *scheme, const char *port, const char *user, const char *pwd,
   * int verifyMode, const char * trustStore,
   * const char * certFile, const char * keyFile,
   * CIMCStatus *rc);
   */

  client = cimcEnv->ft->connect2(cimcEnv,
                       to_charptr(host),
                       to_charptr(scheme),
                       to_charptr(port),
                       to_charptr(user),
                       to_charptr(pwd),
                       (verify == Qfalse)?0:1,
                       to_charptr(trust_store),
                       to_charptr(cert_file),
                       to_charptr(key_file),
                       &status);
  if ( !status.rc )
    return Sfcc_wrap_cim_client(client);
  sfcc_rb_raise_if_error(status, "Can't create CIM client");
  return Qnil;
}

Instance Method Details

#associator_names(object_path, association_class = nil) ⇒ Object #result_class=Object #properties=Object

Enumerate object paths associated with the Instance defined by the object_path

object_path Source ObjectPath containing nameSpace, classname and key components.

association_class If not nil, MUST be a valid Association Class name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Instance of this Class or one of its subclasses.

result_class If not nil, MUST be a valid Class name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be either an Instance of this Class (or one of its subclasses).

role If not nil, MUST be a valid Property name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Association in which the source Object plays the specified role (i.e. the name of the Property in the Association Class that refers to the source Object MUST match the value of this parameter).

result_role If not nil, MUST be a valid Property name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Association in which the returned Object plays the specified role (i.e. the name of the Property in the Association Class that refers to the returned Object MUST match the value of this parameter).

returns enumeration of object paths


851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
# File 'ext/sfcc/cim_client.c', line 851

static VALUE associator_names(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE assoc_class;
  VALUE result_class;
  VALUE role;
  VALUE result_role;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  CIMCString *ops;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "14", &object_path,
               &assoc_class, &result_class,
               &role, &result_role);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.assoc_class = to_charptr(assoc_class);
  args.result_class = to_charptr(result_class);
  args.role = to_charptr(role);
  args.result_role = to_charptr(result_role);
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_associator_names, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->associatorNames(client,
                                    rso->op,
                                    to_charptr(assoc_class),
                                    to_charptr(result_class),
                                    to_charptr(role),
                                    to_charptr(result_role),
                                    &status);
#endif
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }
  ops = rso->op->ft->toString(rso->op, NULL);
  sfcc_rb_raise_if_error(status, "Can't get associator names for '%s'", ops->ft->getCharPtr(ops, NULL));
  return Qnil;
}

#associators(object_path, association_class = nil) ⇒ Object #result_class=Object #properties=Object

Enumerate instances associated with the Instance defined by the object_path

object_path Source ObjectPath containing nameSpace, classname and key components.

association_class If not nil, MUST be a valid Association Class name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Instance of this Class or one of its subclasses.

result_class If not nil, MUST be a valid Class name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be either an Instance of this Class (or one of its subclasses).

role If not nil, MUST be a valid Property name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Association in which the source Object plays the specified role (i.e. the name of the Property in the Association Class that refers to the source Object MUST match the value of this parameter).

result_role If not nil, MUST be a valid Property name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Association in which the returned Object plays the specified role (i.e. the name of the Property in the Association Class that refers to the returned Object MUST match the value of this parameter).

flags Any combination of the following flags are supported: Flags::IncludeQualifiers and Flags::IncludeClassOrigin.

properties If not nil, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list

returns enumeration of instances


753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'ext/sfcc/cim_client.c', line 753

static VALUE associators(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE assoc_class;
  VALUE result_class;
  VALUE role;
  VALUE result_role;
  VALUE flags;
  VALUE properties;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCString *ops;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
  char **props;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "16", &object_path,
               &assoc_class, &result_class,
               &role, &result_role, &flags, &properties);

  if (NIL_P(flags)) flags = INT2NUM(0);
  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  props = sfcc_value_array_to_string_array(properties);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.assoc_class = to_charptr(assoc_class);
  args.result_class = to_charptr(result_class);
  args.role = to_charptr(role);
  args.result_role = to_charptr(result_role);
  args.flags = NUM2INT(flags);
  args.props = props;
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_associators, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->associators(client,
                                rso->op,
                                to_charptr(assoc_class),
                                to_charptr(result_class),
                                to_charptr(role),
                                to_charptr(result_role),
                                NUM2INT(flags), props, &status);
#endif
  free(props);
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }

  ops = rso->op->ft->toString(rso->op, NULL);
  sfcc_rb_raise_if_error(status, "Can't get associators for '%s'", ops->ft->getCharPtr(ops, NULL));
  return Qnil;
}

#class_names(object_path, flags = 0) ⇒ Object

return the available class names for the given object_path and flags

The following flag is supported: Flags::DeepInheritance.


282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'ext/sfcc/cim_client.c', line 282

static VALUE class_names(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE flags;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "11", &object_path, &flags);
  if (NIL_P(flags)) flags = INT2NUM(0);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.flags = NUM2INT(flags);
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_enum_class_names, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->enumClassNames(client, rso->op, NUM2INT(flags), &status);
#endif
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }

  sfcc_rb_raise_if_error(status, "Can't get class names");
  return Qnil;
}

#classes(object_path, flags = 0) ⇒ Object

classes and subclasses in the namespace defined by object_path.

Class structure and inheritance scope can be controled using the flags parameter Any combination of the following flags are supported: Flags::LocalOnly, Flags::IncludeQualifiers and Flags::IncludeClassOrigin.


328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'ext/sfcc/cim_client.c', line 328

static VALUE classes(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE flags;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "11", &object_path, &flags);
  if (NIL_P(flags)) flags = INT2NUM(0);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.flags = NUM2INT(flags);
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_enum_classes, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->enumClasses(client, rso->op, NUM2INT(flags), &status);
#endif
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }

  sfcc_rb_raise_if_error(status, "Can't get classes, try increasing maxMsgLen in sfcb.cfg ?");
  return Qnil;
}

#create_instance(object_path, instance) ⇒ Object

Create Instance from object_path as reference.

object_path ObjectPath containing nameSpace, classname and key components.

instance Complete instance.

returns the assigned instance reference (object path)


435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'ext/sfcc/cim_client.c', line 435

static VALUE create_instance(VALUE self, VALUE object_path, VALUE instance)
{
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCObjectPath *new_op;
  rb_sfcc_object_path *rso;
  rb_sfcc_instance *inst;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);
  Data_Get_Struct(instance, rb_sfcc_instance, inst);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.instance = inst->inst;
  args.status = &status;
  new_op = (CIMCObjectPath *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_create_instance, &args, RUBY_UBF_IO, 0);
#else
  new_op = client->ft->createInstance(client, rso->op, inst->inst, &status);
#endif

  if (!status.rc)
    return Sfcc_wrap_cim_object_path(new_op, self);

  sfcc_rb_raise_if_error(status, "Can't create instance");
  return Qnil;
}

#delete_instance(object_path) ⇒ Object

Delete an existing Instance using object_path as reference. object_path ObjectPath containing nameSpace, classname and key components.


531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'ext/sfcc/cim_client.c', line 531

static VALUE delete_instance(VALUE self, VALUE object_path)
{
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCString *ops;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.status = &status;
  rb_thread_blocking_region((rb_blocking_function_t*)threaded_delete_instance, &args, RUBY_UBF_IO, 0);
#else
  status = client->ft->deleteInstance(client, rso->op);
#endif
  if (status.rc) {
    ops = rso->op->ft->toString(rso->op, NULL);
    sfcc_rb_raise_if_error(status, "Can't delete instance '%s'", ops->ft->getCharPtr(ops, NULL));
  }
  return Qnil;
}

#get_class(object_path, flags = 0, properties = nil) ⇒ Object

Get Class using object_path as reference. Class structure can be controled using the flags parameter.

object_path ObjectPath containing nameSpace and classname components.

flags Any combination of the following flags are supported:

Flags::LocalOnly, Flags::IncludeQualifiers and Flags::IncludeClassOrigin.

properties If not nil, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list


229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'ext/sfcc/cim_client.c', line 229

static VALUE get_class(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE flags;
  VALUE properties;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCClass *cimclass;
  CIMCString *ops;
  rb_sfcc_object_path *rso;
  char **props;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "12", &object_path, &flags, &properties);

  if (NIL_P(flags)) flags = INT2NUM(0);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  props = sfcc_value_array_to_string_array(properties);
#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.flags = NUM2INT(flags);
  args.props = props;
  args.status = &status;
  cimclass = (CIMCClass *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_get_class, &args, RUBY_UBF_IO, 0);
#else
  cimclass = client->ft->getClass(client, rso->op, NUM2INT(flags), props, &status);
 #endif
  free(props);

  if (!status.rc) {
      return Sfcc_wrap_cim_class(cimclass);
  }
  ops = rso->op->ft->toString(rso->op, NULL);
  sfcc_rb_raise_if_error(status, "Can't get class at %s", ops->ft->getCharPtr(ops, NULL));
  return Qnil;
}

#get_instance(object_path, flags = 0, properties = nil) ⇒ Object

get instance using object_path as reference. Instance structure can be controlled using the flags parameter.

object_path an ObjectPath containing namespace, class name and key components.

flags Any combination of the following flags are supported: Flags::LocalOnly, Flags::IncludeQualifiers and Flags::IncludeClassOrigin.

properties If not nil, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list


381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'ext/sfcc/cim_client.c', line 381

static VALUE get_instance(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE flags;
  VALUE properties;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCInstance *ciminstance;
  rb_sfcc_object_path *rso;
  char **props;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "12", &object_path, &flags, &properties);
  if (NIL_P(flags)) flags = INT2NUM(0);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  props = sfcc_value_array_to_string_array(properties);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.flags = NUM2INT(flags);
  args.props = props;
  args.status = &status;
  ciminstance = (CIMCInstance *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_get_instance, &args, RUBY_UBF_IO, 0);
#else
  ciminstance = client->ft->getInstance(client, rso->op, NUM2INT(flags), props, &status);
#endif
  free(props);

  if (!status.rc)
    return Sfcc_wrap_cim_instance(ciminstance, self);

  sfcc_rb_raise_if_error(status, "Can't get instance");
  return Qnil;
}

#instance_names(object_path, flags) ⇒ Object

instance names of the class defined by object_path


618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
# File 'ext/sfcc/cim_client.c', line 618

static VALUE instance_names(VALUE self, VALUE object_path)
{
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_enum_instance_names, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->enumInstanceNames(client, rso->op, &status);
#endif

  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }
  sfcc_rb_raise_if_error(status, "Can't get instance names");
  return Qnil;
}

#instances(object_path, flags = 0, properties = nil) ⇒ Object

Enumerate the instance names of the class defined by object_path

object_path ObjectPath containing nameSpace and classname components.

flags Any combination of the following flags are supported: Flags::LocalOnly, Flags::DeepInheritance, Flags::IncludeQualifiers and Flags::IncludeClassOrigin.

properties If not NULL, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list


665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'ext/sfcc/cim_client.c', line 665

static VALUE instances(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE flags;
  VALUE properties;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
  char **props;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "12", &object_path, &flags, &properties);
  if (NIL_P(flags)) flags = INT2NUM(0);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  props = sfcc_value_array_to_string_array(properties);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.flags = NUM2INT(flags);
  args.props = props;
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_enum_instances, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->enumInstances(client, rso->op, NUM2INT(flags), props, &status);
#endif

  free(props);

  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }

  sfcc_rb_raise_if_error(status, "Can't get instances");
  return Qnil;
}

#invoke_method(object_path, method_name, argin, argout) ⇒ Object

Invoke a named, extrinsic method of an instance defined by object_path

object_path containing namespace, classname, and key components.

argin hash containing the input parameters (keys can be symbols) or strings.

argout hash where output parameters will be returned


1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# File 'ext/sfcc/cim_client.c', line 1063

static VALUE invoke_method(VALUE self,
                           VALUE object_path,
                           VALUE method_name,
                           VALUE argin,
                           VALUE argout)
{
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCArgs *cimcargsout;
  const char *method_name_cstr;
  CIMCData ret;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Check_Type(argin, T_HASH);

  cimcargsout = cimcEnv->ft->newArgs(cimcEnv, NULL);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  method_name_cstr = to_charptr(method_name);
#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.name = method_name_cstr;
  args.argsin = sfcc_hash_to_cimargs(argin);
  args.argsout = cimcargsout;
  args.status = &status;
  args.data = &ret;
  (void)rb_thread_blocking_region((rb_blocking_function_t*)threaded_invoke_method, &args, RUBY_UBF_IO, 0);
#else
  ret = client->ft->invokeMethod(client,
                              rso->op,
                              method_name_cstr,
                              sfcc_hash_to_cimargs(argin),
                              cimcargsout,
                              &status);
#endif
  if (!status.rc) {
    if (cimcargsout && ! NIL_P(argout)) {
      Check_Type(argout, T_HASH);
      rb_funcall(argout, rb_intern("merge!"), 1, sfcc_cimargs_to_hash(cimcargsout, self));
    }
    return sfcc_cimdata_to_value(&ret, self);
  }
  sfcc_rb_raise_if_error(status, "Can't invoke method '%s'", method_name_cstr);
  return Qnil;
}

#property(object_path, name) ⇒ Object

Gets the named property value of an instance defined by object_path

object_path containing namespace, classname, and key components.


1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
# File 'ext/sfcc/cim_client.c', line 1170

static VALUE property(VALUE self, VALUE object_path, VALUE name)
{
  CIMCClient *client;
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCData data;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.name = to_charptr(name);
  args.status = &status;
  args.data = &data;
  (void)rb_thread_blocking_region((rb_blocking_function_t*)threaded_get_property, &args, RUBY_UBF_IO, 0);
#else
  data = client->ft->getProperty(client, rso->op, to_charptr(name), &status);
#endif
  if ( !status.rc )
    return sfcc_cimdata_to_value(&data, self);

  sfcc_rb_raise_if_error(status, "Can't retrieve property '%s'", to_charptr(name));
  return Qnil;
}

#query(object_path, query, lang) ⇒ Object

Query the enumeration of instances of the class (and subclasses) defined by object_path using query expression.

object_path ObjectPath containing nameSpace and classname components.

query Query expression

lang Query Language

returns resulting eumeration of instances


574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'ext/sfcc/cim_client.c', line 574

static VALUE query(VALUE self,
                   VALUE object_path,
                   VALUE query,
                   VALUE lang)
{
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.query = to_charptr(query);
  args.lang = to_charptr(lang);
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_exec_query, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->execQuery(client,
                              rso->op,
                              to_charptr(query),
                              to_charptr(lang),
                              &status);
#endif
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }

  sfcc_rb_raise_if_error(status, "Can't get instances from query");
  return Qnil;
}

#reference_names(object_path, result_class = nil, role = nil, flags = 0, properties = nil) ⇒ Object

Enumerates the association instances that refer to the instance defined by object_path

object_path Source ObjectPath containing nameSpace, classname and key components.

result_class If not nil, MUST be a valid Class name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be either an Instance of this Class (or one of its subclasses).

role If not nil, MUST be a valid Property name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Association in which the source Object plays the specified role (i.e. the name of the Property in the Association Class that refers to the source Object MUST match the value of this parameter).

returns enumeration of ObjectPaths


1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
# File 'ext/sfcc/cim_client.c', line 1007

static VALUE reference_names(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path = Qnil;
  VALUE result_class = Qnil;
  VALUE role = Qnil;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCEnumeration *enm;
  CIMCString *ops;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif
  rb_scan_args(argc, argv, "12", &object_path,
               &result_class, &role);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.result_class = to_charptr(result_class);
  args.role = to_charptr(role);
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_reference_names, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->referenceNames(client,
                                   rso->op,
                                   to_charptr(result_class),
                                   to_charptr(role),
                                   &status);
#endif
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }
  ops = rso->op->ft->toString(rso->op, NULL);
  sfcc_rb_raise_if_error(status, "Can't get reference names for '%s'", ops->ft->getCharPtr(ops, NULL));
  return Qnil;
}

#references(object_path, result_class = nil, role = nil, flags = 0, properties = nil) ⇒ Object

Enumerates the association instances that refer to the instance defined by object_path

object_path Source ObjectPath containing nameSpace, classname and key components.

result_class If not nil, MUST be a valid Class name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be either an Instance of this Class (or one of its subclasses).

role If not nil, MUST be a valid Property name. It acts as a filter on the returned set of Objects by mandating that each returned Object MUST be associated to the source Object via an Association in which the source Object plays the specified role (i.e. the name of the Property in the Association Class that refers to the source Object MUST match the value of this parameter).

flags Any combination of the following flags are supported: Flags::IncludeQualifiers and Flags::IncludeClassOrigin.

properties If not nil, the members of the array define one or more Property names. Each returned Object MUST NOT include elements for any Properties missing from this list

returns enumeration of ObjectPaths


931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
# File 'ext/sfcc/cim_client.c', line 931

static VALUE references(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE result_class;
  VALUE role;
  VALUE flags;
  VALUE properties;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCString *ops;
  CIMCEnumeration *enm;
  rb_sfcc_object_path *rso;
  char **props;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "14", &object_path,
               &result_class, &role,
               &flags, &properties);

  if (NIL_P(flags)) flags = INT2NUM(0);
  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  props = sfcc_value_array_to_string_array(properties);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.result_class = to_charptr(result_class);
  args.role = to_charptr(role);
  args.flags = NUM2INT(flags);
  args.props = props;
  args.status = &status;
  enm = (CIMCEnumeration *)rb_thread_blocking_region((rb_blocking_function_t*)threaded_references, &args, RUBY_UBF_IO, 0);
#else
  enm = client->ft->references(client,
                               rso->op,
                               to_charptr(result_class),
                               to_charptr(role),
                               NUM2INT(flags), props, &status);
#endif
  free(props);
  if (enm && !status.rc ) {
    return Sfcc_wrap_cim_enumeration(enm, self);
  }
  ops = rso->op->ft->toString(rso->op, NULL);
  sfcc_rb_raise_if_error(status, "Can't get references for '%s'", ops->ft->getCharPtr(ops, NULL));
  return Qnil;
}

#set_instance(object_path, instance, flags = 0, properties = nil) ⇒ Object

Replace an existing Instance from instance, using object_path as reference.

object_path ObjectPath containing nameSpace, classname and key components.

instance Complete instance.

flags The following flag is supported: Flags::IncludeQualifiers.

+ properties+ If not nil, the members of the array define one or more Property names, only those properties will be updated. Else, all properties will be updated.


482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'ext/sfcc/cim_client.c', line 482

static VALUE set_instance(int argc, VALUE *argv, VALUE self)
{
  VALUE object_path;
  VALUE instance;
  VALUE flags;
  VALUE properties;

  CIMCStatus status = {CIMC_RC_OK, NULL};
  rb_sfcc_object_path *rso;
  rb_sfcc_instance *inst;
  CIMCClient *client;
  char **props;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  rb_scan_args(argc, argv, "22", &object_path, &instance, &flags, &properties);
  if (NIL_P(flags)) flags = INT2NUM(0);

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);
  Data_Get_Struct(instance, rb_sfcc_instance, inst);

  props = sfcc_value_array_to_string_array(properties);

#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.instance = inst->inst;
  args.flags = NUM2INT(flags);
  args.props = props;
  args.status = &status;
  rb_thread_blocking_region((rb_blocking_function_t*)threaded_set_instance, &args, RUBY_UBF_IO, 0);
#else
  status = client->ft->setInstance(client, rso->op, inst->inst, NUM2INT(flags), props);
#endif
  free(props);

  sfcc_rb_raise_if_error(status, "Can't set instance");
  return instance;
}

#set_property(object_path, name, value) ⇒ Object

Sets the named property value of an instance defined by object_path

object_path containing namespace, classname, and key components.


1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'ext/sfcc/cim_client.c', line 1125

static VALUE set_property(VALUE self,
                          VALUE object_path,
                          VALUE name,
                          VALUE value)
{
  CIMCStatus status = {CIMC_RC_OK, NULL};
  CIMCClient *client;
  CIMCData data;
  rb_sfcc_object_path *rso;
#if THREAD_MIGHT_BLOCK
  ruby_thread_args_t args;
#endif

  Data_Get_Struct(self, CIMCClient, client);
  Data_Get_Struct(object_path, rb_sfcc_object_path, rso);

  data = sfcc_value_to_cimdata(value);
#if THREAD_MIGHT_BLOCK
  args.client = client;
  args.op = rso->op;
  args.name = to_charptr(name);
  args.value = &data.value;
  args.type = data.type;
  args.status = &status;
  (void)rb_thread_blocking_region((rb_blocking_function_t*)threaded_set_property, &args, RUBY_UBF_IO, 0);
#else
  status = client->ft->setProperty(client, rso->op, to_charptr(name), &data.value, data.type);
#endif

  if ( !status.rc )
    return value;
  sfcc_rb_raise_if_error(status, "Can't set property '%s'", to_charptr(name));
  return Qnil;
}