Symptoms

As Provider I want to send OpenAPI request to POA.

Resolution

One way is to use console utility like curl to send OpenAPI requests to POA.

Create a file with XML request and save it on POA Management Node, e.g. /root/pemActivateSubscription.xml Send request using curl:

# curl -d@/root/pemActivateSubscription.xml http://localhost:8440

POA for Windows Management Node does not have the curl utility installed out of the box, one may download curl for Windows and install it manually.

Another way is to use API calls from Python shell scripts. Here is some example of such script:

[root@poa ~]# cat getapsinstance.py:
from poaupdater import openapi, uLogging

uLogging.log_to_console = False

api = openapi.OpenAPI()
ii = input("Enter POA Application subscription_id: ")
result = api.pem.APS.getSubscriptionApplicationInstances(subscription_id=ii)

if (isinstance(result,list)):
  for i in range(len(result)):
    print result[i]
else:
  print result

and run it as:

[root@poa ~]# python getapsinstance.py
Enter POA Application subscription_id: 1011471
{'status': 'Ready', 'application_id': 112, 'rt_id': 0, 'url': 'http://domain.com/wordpress', 'package_version': '3.5.1-4', 'application_instance_id': 6665}
{'status': 'Ready', 'application_id': 113, 'rt_id': 0, 'url': 'http://domain.com/joomla', 'package_version': '2.5.9-4', 'application_instance_id': 6666}
{'status': 'Ready', 'application_id': 118, 'rt_id': 1000672, 'url': 'http://domain.com/drupal', 'package_version': '7.21-1', 'application_instance_id': 7968}

As you can see, you just need to provide the name of the API method from the POA Integration guide with appropriate parameters name. The parameter names can be obtained from the API method description.

In the example, the parameter for the API call would be asked from user to prompt. Here is the another example of script. which takes parameter from the command line:

[root@poa API]# cat getMemberSubscriptionRestrictions.py
import sys
from poaupdater import openapi, uLogging

uLogging.log_to_console = False

api = openapi.OpenAPI()
result = api.pem.getMemberSubscriptionRestrictions(member_id=int(sys.argv[1]))

if (isinstance(result,list)):
  for i in range(len(result)):
    print result[i]
else:
  print result


[root@poa API]# python getMemberSubscriptionRestrictions.py 206
{'access_all_subscriptions': False, 'subscriptions': [23, 32]}
[root@poa API]#

The int(sys.argv[1]) call contains the first parameter passed to the script. The numeration of the parameters is the same as in the Bash itself.

Additional Information

Refer to the Parallels Knowledgebase #116506 for instruction how to send OpenAPI request to POA for Windows Management Node using PowerShell.

Internal content

Link on internal Article