QueueManagerController

The second part of the URI must be qmgr to call the QueueManagerController. This controller has the following actions:

inquire

Returns all attributes of the queuemanager with the given name. This actions executes the PCF commando MQCMD_INQUIRE_Q_MGR. On success, the returned JSON object will have a data array, on failure an error object.

URL Parameters

/api/qmgr/inquire/<QueueManager>

QueueManager

The name of the queuemanager. This parameter is required.

Query Parameters

CommandScope

Specifies how the command is executed when the queue manager is a member of a queue-sharing group. This parameter applies to z/OS only.

QMgrAttrs

With the QMgrAttrs parameter you can specify which attributes must be returned from the PCF command. Multiple occurences of this parameter are possible. The value must be a (case-sensitive) valid attribute name.

Attrs is a synonym for QMgrAttrs

Example

/api/qmgr/inquire/PIGEON

<?php
	/*
	 * This sample will show the description of queuemanager PIGEON.
	 * MQWeb runs on localhost and is listening on port 8081. 
	 */
	$url = "http://localhost:8081/api/qmgr/inquire/PIGEON";

	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

	if ( ($response = curl_exec($curl)) === false )	{
		$err = curl_error($curl);
		echo 'An HTTP error occurred while inquiring queuemanager status: '
			. $err
			. PHP_EOL;
	}
	else {
		$json = json_decode($response);
		if ( isset($json->error) ) {
			echo 'An MQ error occurred while inquiring queuemanager status.'
				. PHP_EOL;
			echo 'Reason Code: '
				. $json->error->reason->code
				. ' - '
				. $json->error->reason->desc
				. PHP_EOL;
		}
		else {
			if ( isset($json->data) && count($json->data) > 0 ) {
				echo $json->data[0]->QMgrName->value
					. ' : '
					. $json->data[0]->QMgrDesc->value
					. PHP_EOL;
			}
			else {
				echo 'No qmgr found' . PHP_EOL;
			}
		}
	}

JSON Object

When using an application/json POST request you can post a JSON object with names like the query parameters.

All URL parameters and query parameters are ignored except for the URL parameter for the name of the queuemanager.

{
  'QMgrAttrs' : [
    'QMgrName',
    'QMgrDesc'
  ]
}

There are some differences between query parameters and a JSON object:

This is a Perl example that inquires a queuemanager to get the description of the queuemanager.

#!/usr/bin/perl
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use HTTP::Request::Common;
use feature qw(say);

# This sample will show the description of the queuemanager

my $qmgr = shift;
die("Please pass me the name of a queuemanager as argument") 
	unless defined($qmgr);

my $json = JSON->new;

my %input = ( 
	'QMgrAttrs' => [
		'QMgrDesc'
	],
);
my $content = $json->encode(\%input);    

my $ua = LWP::UserAgent->new;
my $req = POST 'http://localhost:8081/api/qmgr/inquire/' . $qmgr;
$req->header(
	'Content-Type' => 'application/json',
	'Content-length' => length($content)
);
$req->content($content);

my $res = $ua->request($req);
die $res->status_line unless $res->is_success;

my $mqweb = $json->decode($res->content());
if ( exists($mqweb->{error}) ) {
	say 'An MQ error occurred while inquiring queuemanager.';
	say	'Reason Code: ',
		$mqweb->{error}->{reason}->{code},
		' - ',
		$mqweb->{error}->{reason}->{desc};
}
else {
	say $mqweb->{data}->[0]->{QMgrName}->{value},
		' : ', 
		$mqweb->{data}->[0]->{QMgrDesc}->{value};
}

ping

This action executes the PCF commando MQCMD_PING_Q_MGR. On success, the returned JSON object will have an empty data array, on failure an error object.

URL Parameters

/api/qmgr/ping/<QueueManager>

QueueManager

The name of the queuemanager. This parameter is required.

Example

/api/qmgr/ping/PIGEON