Adding new application to a CLM infrastructure might require registering it as a friend to existing applications. Unfortunately, no public API to command line utility is available to automate this process.
Nevertheless, it can be done using undocumented administrative REST services. In order to add new friend, we need to create OAuth consumer key on the remote server first (or request provisional key if we do not have administrative access to the server). Then, CLM application friend could be registered using the following REST service:
https://server:port/context/service/com.ibm.team.repository.service.internal.discovery.IFriendsAdminRestService/newFriend
This service accepts the following parameters (URL-encoded):
title – friend’s name;
oauthConsumerKey – consumer key unique ID;
oauthConsumerSecret – consumer secret string;
rootServices – new application root services URL.
Perl code sample:
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Headers;
...
my $app = 'https://server:port/context';
my $register_friend = 'service/com.ibm.team.repository.service.internal.discovery.IFriendsAdminRestService/newFriend';
# Create user agent
my $ua = LWP::UserAgent->new( cookie_jar => {}, default_headers => HTTP::Headers->new( Accept => 'text/xml'));
...
# login to the CLM application
...
# set referrer header
$ua->default_header('Referer' => "$app/admin");
# Register new friend
my $response = $ua->request( POST "$app/$register_friend",
[
title => 'Friend Name',
rootServices => 'https://remote_application:port/context/rootservices',
oauthConsumerKey => 'consumer key id',
oauthConsumerSecret => 'consumer secret'
]
);