#!/usr/bin/perl

# USAGE: updateProperties <objid> <propname> <propval>

use strict;
use warnings;

use lib "/opt/sarch/common/lib"; # service API
use lib "/opt/sarch/om/bin/perl/OMIface";
use lib "/opt/sarch/imp/lib/perl"; # thrift api

use ObjectManagementService;
use NextCAM::Servicing::Client;
use Time::HiRes qw(gettimeofday sleep);

my $service_client = NextCAM::Servicing::Client->new("s_master", 10000);
my $om_client = ObjectManagementServiceClient->new($service_client->getProtocol("skm.om"));
my $objid = shift @ARGV;

sub prop_update {
    my ($propname, $val) = @_;
    eval {
	$om_client->updateProperties({ $objid => {$propname => $val}});
    };
    if ($@)
    {
	die "FwIface::FwException: ". $@->{errorId}.": ".$@->{what}. "\n" if $@->UNIVERSAL::isa("OMIface::FwException");
        die "Bad: $@\n"; 
    }
    else
    {
      print("Action performed successfully\n");
    }
}

prop_update(@ARGV);