Bug 805960 - [REST API] Inadequate response when creating or querying domains
[REST API] Inadequate response when creating or querying domains
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Pod (Show other bugs)
2.x
Unspecified Unspecified
high Severity high
: ---
: ---
Assigned To: Lili Nader
libra bugs
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-22 10:49 EDT by Xavier Coulon
Modified: 2015-05-14 21:48 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-04-13 14:30:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Xavier Coulon 2012-03-22 10:49:19 EDT
when creating, updating or querying for an existing domain, the response contains a link within the domain to create a new one. This link should be a sibbling element to the domain one, not one of its children:

<response>
  <domain>
    <links>
      <link>
        <rel>Get domain</rel>
        <href>/domains/foobar</href>
        <optional-params/>
        <method>GET</method>
        <required-params/>
      </link>
      <link>
        <rel>Update domain</rel>
        <href>/domains/foobar</href>
        <optional-params/>
        <method>PUT</method>
        <required-params>
          <param>
            <name>namespace</name>
            <description>Name of the domain</description>
            <valid-options/>
            <type>string</type>
          </param>
        </required-params>
      </link>
      <link>
        <rel>Delete domain</rel>
        <href>/domains/foobar</href>
        <optional-params>
          <optional-param>
            <default-value>false</default-value>
            <name>force</name>
            <description>Force delete domain.  i.e. delete any applications under this domain</description>
            <valid-options>true or false</valid-options>
            <type>boolean</type>
          </optional-param>
        </optional-params>
        <method>DELETE</method>
        <required-params/>
      </link>
      <link>
        <rel>Create new domain</rel>
        <href>/domains</href>
        <optional-params/>
        <method>POST</method>
        <required-params>
          <param>
            <name>namespace</name>
            <description>Name of the domain</description>
            <valid-options/>
            <type>string</type>
          </param>
        </required-params>
      </link>
      <link>
        <rel>Create new application</rel>
        <href>/domains/foobar/applications</href>
        <optional-params/>
        <method>POST</method>
        <required-params>
          <param>
            <name>name</name>
            <description>Name of the application</description>
            <valid-options/>
            <type>string</type>
          </param>
          <param>
            <name>template</name>
            <description>UUID of the application template</description>
            <valid-options/>
            <type>string</type>
          </param>
        </required-params>
      </link>
      <link>
        <rel>Create new application</rel>
        <href>/domains/foobar/applications</href>
        <optional-params/>
        <method>POST</method>
        <required-params>
          <param>
            <name>name</name>
            <description>Name of the application</description>
            <valid-options/>
            <type>string</type>
          </param>
          <param>
            <name>cartridge</name>
            <description>framework-type, e.g: php-5.3</description>
            <valid-options>
              <valid-option>raw-0.1</valid-option>
              <valid-option>php-5.3</valid-option>
              <valid-option>jenkins-1.4</valid-option>
              <valid-option>jbossas-7</valid-option>
              <valid-option>nodejs-0.6</valid-option>
              <valid-option>python-2.6</valid-option>
              <valid-option>perl-5.10</valid-option>
              <valid-option>ruby-1.8</valid-option>
            </valid-options>
            <type>string</type>
          </param>
        </required-params>
      </link>
      <link>
        <rel>List applications</rel>
        <href>/domains/foobar/applications</href>
        <optional-params/>
        <method>GET</method>
        <required-params/>
      </link>
    </links>
    <namespace>foobar</namespace>
  </domain>
  <version>1.0</version>
  <type>domain</type>
  <status>created</status>
  <messages/>
</response>
Comment 1 Xavier Coulon 2012-03-22 10:51:33 EDT
Also, the response misses the <data> element to embed the <domain> element.
Having a consistent <data> element accross all types of responses makes the parsing easier
Comment 2 Xavier Coulon 2012-03-22 12:39:18 EDT
Same behavior when querying the user:

<response>
  <messages/>
  <type>user</type>
  <user>
    <login>xcoulon+test@redhat.com</login>
    <links>
      <link>
        <rel>Add new SSH key</rel>
        <method>POST</method>
        <href>/user/keys</href>
        <optional-params/>
        <required-params>
          <param>
            <description>Name of the application</description>
            <type>string</type>
            <name>name</name>
            <valid-options/>
          </param>
          <param>
            <description>Type of Key</description>
            <type>string</type>
            <name>type</name>
            <valid-options>
              <valid-option>ssh-rsa</valid-option>
              <valid-option>ssh-dss</valid-option>
            </valid-options>
          </param>
          <param>
            <description>The key portion of an rsa key (excluding ssh-rsa and comment)</description>
            <type>string</type>
            <name>content</name>
            <valid-options/>
          </param>
        </required-params>
      </link>
      <link>
        <rel>Get SSH keys</rel>
        <method>GET</method>
        <href>/user/keys</href>
        <optional-params/>
        <required-params/>
      </link>
      <link>
        <rel>Get user information</rel>
        <method>GET</method>
        <href>/user</href>
        <optional-params/>
        <required-params/>
      </link>
    </links>
  </user>
  <status>ok</status>
  <version>1.0</version>
</response>
Comment 3 Xavier Coulon 2012-03-26 10:06:38 EDT
Marking as URGENT, like for issue #806382
Comment 4 Johnny Liu 2012-03-29 05:41:29 EDT
Verified this bug with devenv_1679, and PASS.

When creating, updating or querying for an existing domain, link to create new domain has been removed, and <data> element is shown up now, and <domain> element is embedded into <data> element.

$ curl -k -X POST -H 'Accept: application/xml' -H 'Content-type: application/json' -d '{'\''namespace'\'':jialiu}' --user jialiu@redhat.com:214214 https://ec2-23-20-46-167.compute-1.amazonaws.com/broker/rest/domains
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>created</status>
  <version>1.0</version>
  <type>domain</type>
  <data>
    <domain>
      <links>
        <link>
          <method>POST</method>
          <rel>Create new application</rel>
          <href>/domains/jialiu/applications</href>
          <optional-params/>
          <required-params>
            <param>
              <type>string</type>
              <description>Name of the application</description>
              <valid-options/>
              <name>name</name>
            </param>
            <param>
              <type>string</type>
              <description>UUID of the application template</description>
              <valid-options/>
              <name>template</name>
            </param>
          </required-params>
        </link>
        <link>
          <method>GET</method>
          <rel>List applications</rel>
          <href>/domains/jialiu/applications</href>
          <optional-params/>
          <required-params/>
        </link>
        <link>
          <method>PUT</method>
          <rel>Update domain</rel>
          <href>/domains/jialiu</href>
          <optional-params/>
          <required-params>
            <param>
              <type>string</type>
              <description>Name of the domain</description>
              <valid-options/>
              <name>namespace</name>
            </param>
          </required-params>
        </link>
        <link>
          <method>GET</method>
          <rel>Get domain</rel>
          <href>/domains/jialiu</href>
          <optional-params/>
          <required-params/>
        </link>
        <link>
          <method>POST</method>
          <rel>Create new application</rel>
          <href>/domains/jialiu/applications</href>
          <optional-params>
            <optional-param>
              <type>boolean</type>
              <description>Mark application as scalable</description>
              <valid-options>
                <valid-option>true</valid-option>
                <valid-option>false</valid-option>
              </valid-options>
              <default-value>false</default-value>
              <name>scale</name>
            </optional-param>
            <optional-param>
              <type>string</type>
              <description>The size of the gear</description>
              <valid-options>
                <valid-option>small</valid-option>
                <valid-option>micro</valid-option>
                <valid-option>medium</valid-option>
                <valid-option>large</valid-option>
                <valid-option>exlarge</valid-option>
                <valid-option>jumbo</valid-option>
              </valid-options>
              <default-value>small</default-value>
              <name>node_profile</name>
            </optional-param>
          </optional-params>
          <required-params>
            <param>
              <type>string</type>
              <description>Name of the application</description>
              <valid-options/>
              <name>name</name>
            </param>
            <param>
              <type>string</type>
              <description>framework-type, e.g: php-5.3</description>
              <valid-options>
                <valid-option>nodejs-0.6</valid-option>
                <valid-option>jbossas-7</valid-option>
                <valid-option>python-2.6</valid-option>
                <valid-option>jenkins-1.4</valid-option>
                <valid-option>ruby-1.8</valid-option>
                <valid-option>diy-0.1</valid-option>
                <valid-option>php-5.3</valid-option>
                <valid-option>perl-5.10</valid-option>
              </valid-options>
              <name>cartridge</name>
            </param>
          </required-params>
        </link>
        <link>
          <method>DELETE</method>
          <rel>Delete domain</rel>
          <href>/domains/jialiu</href>
          <optional-params>
            <optional-param>
              <type>boolean</type>
              <description>Force delete domain.  i.e. delete any applications under this domain</description>
              <valid-options>
                <valid-option>true</valid-option>
                <valid-option>false</valid-option>
              </valid-options>
              <default-value>false</default-value>
              <name>force</name>
            </optional-param>
          </optional-params>
          <required-params/>
        </link>
      </links>
      <suffix>dev.rhcloud.com</suffix>
      <namespace>jialiu</namespace>
    </domain>
  </data>
  <messages/>
</response>


user resource is also fixed. link for "Get user information" is removed, and <data> element is shown up now, and <user> element is embedded into <data> element.

curl -k -X GET -H 'Accept: application/xml' --user jialiu@redhat.com:214214 https://ec2-23-20-46-167.compute-1.amazonaws.com/broker/rest/user
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>ok</status>
  <version>1.0</version>
  <type>user</type>
  <data>
    <user>
      <login>jialiu@redhat.com</login>
      <links>
        <link>
          <method>POST</method>
          <rel>Add new SSH key</rel>
          <href>/user/keys</href>
          <optional-params/>
          <required-params>
            <param>
              <type>string</type>
              <description>Name of the application</description>
              <valid-options/>
              <name>name</name>
            </param>
            <param>
              <type>string</type>
              <description>Type of Key</description>
              <valid-options>
                <valid-option>ssh-rsa</valid-option>
                <valid-option>ssh-dss</valid-option>
              </valid-options>
              <name>type</name>
            </param>
            <param>
              <type>string</type>
              <description>The key portion of an rsa key (excluding ssh-rsa and comment)</description>
              <valid-options/>
              <name>content</name>
            </param>
          </required-params>
        </link>
        <link>
          <method>GET</method>
          <rel>Get SSH keys</rel>
          <href>/user/keys</href>
          <optional-params/>
          <required-params/>
        </link>
      </links>
    </user>
  </data>
  <messages/>
</response>
Comment 5 Johnny Liu 2012-03-29 05:43:38 EDT
During testing, I found some other issue, open Bug 807977 to track it.

Note You need to log in before you can comment on or make changes to this bug.