Table Of Contents

Application Instance

../../../../_images/step-project2.png ../../../../_images/step-meta2.png ../../../../_images/step-provision-b.png ../../../../_images/step-presentation1.png ../../../../_images/step-deploy2.png ../../../../_images/step-provisioning2.png

The APS type used for creating an APS application instance must declare some system-wide properties to be used for operating the original cloud application and optionally operations for the product initialization.

../../../../_images/step-provision-app-b.png ../../../../_images/step-provision-lic.png ../../../../_images/step-provision-tenant.png

Service and Type Definition

Complete the following steps to define the app service and the app APS type in the scripts/app.php file:

  1. Define the properties to connect to the cloud application on behalf of the provider. Those properties are: URL, login name, and password.

    /**
     * @type(string)
     * @title("BaseURL")
     * @required
     * @description("Base endpoint on the external system. Note: The final slash is required.")
     */
    public $baseURL = "https://api.github.com/";
    
    /**
     * @type(string)
     * @title("Login")
     * @required
     * @description("Login name of the provider on the external system, e.g., providerOne")
     */
    public $login;
    
    /**
     * @type(string)
     * @title("Password")
     * @required
     * @encrypted
     * @description("Password of the provider on the external system")
     */
    public $passwd;
    

    Key:

    • The declared properties will appear in the provider control panel when setting up an APS application instance.

    • A required property will be marked with an asterisk in the provider control panel.

    • The encrypted``attribute of the ``passwd property will make the user panel hide that property by replacing every character with an asterisk.

    • This sample APS application will not establish a connection with the cloud application during creation (provisioning) of an APS application instance. A connection will be established every time the tenant provisioning logic generates a new security token (described more in the following documents).

  2. Define a standard method for returning the default data for the product configuration wizard. This helps the provider to quickly configure service plans and other related components. The typical definition looks as follows:

    /**
     * @verb(GET)
     * @path("/getInitWizardConfig")
     * @access(admin, true)
      * @access(owner, true)
     * @access(referrer, true)
    */
    public function getInitWizardConfig()
    {
       $myfile = fopen("./wizard_data.json", "r") or die("Unable to open file!");
       $data = fread($myfile,filesize("./wizard_data.json"));
       fclose($myfile);
       return json_decode($data);
    }
    

    The method returns the contents of the scripts/wizard_data.json file that we will consider in the Deployment document.

  3. Define a standard method that verifies a connection with the cloud application by a request from the product configuration wizard. The following simplified method always returns OK:

    /**
     * @verb(GET)
     * @path("/testConnection")
     * @param(object,body)
     * @access(admin, true)
     * @access(owner, true)
     * @access(referrer, true)
     */
    public function testConnection($body)
    {
       return "";
    }
    

Conclusion

You have completed the configuration of the app service and the app APS type in scripts/app.php. If there are any problems, compare it with the sample app.php file:

<?php

	define('APS_DEVELOPMENT_MODE', true);
	require "aps/2/runtime.php";	

	/**
	* @type("http://aps-standard.org/samples/github/app/1.0")
	* @implements("http://aps-standard.org/types/core/application/1.0","http://odin.com/init-wizard/config/1.0")
	*/

	class app extends \APS\ResourceBase
	{
        /**
         * @link("http://aps-standard.org/samples/github/tenant/1.0[]")
         */
        public $tenants;

        /**
         * @link("http://aps-standard.org/samples/github/license/1.0[]")
         */
        public $licenses;

        /**
         * @link("http://aps-standard.org/samples/github/reseller/1.0[]")
         */
        public $resellers;

        /**
         * @type(string)
         * @title("BaseURL")
         * @required
         * @description("Base endpoint in the external system. Note: The final slash is required.")
         */
        public $baseURL = "https://api.github.com/";

        /**
         * @verb(GET)
         * @path("/getInitWizardConfig")
         * @access(admin, true)
         * @access(owner, true)
         * @access(referrer, true)
         */
        public function getInitWizardConfig()
        {
            $myfile = fopen("./wizard_data.json", "r") or die("Unable to open file!");
            $data = fread($myfile,filesize("./wizard_data.json"));
            fclose($myfile);
            return json_decode($data);
        }

        /**
         * @verb(GET)
         * @path("/testConnection")
         * @param(object,body)
         * @access(admin, true)
         * @access(owner, true)
         * @access(referrer, true)
         */
        public function testConnection($body)
        {
            return "";
        }

    }
?>