11 Replies Latest reply on Aug 21, 2013 4:10 AM by huchangchun

    Where can I find latest document of REST API

    huchangchun

      Dear RHQ Team,

      We plan to develop a web application to monitor and manage JBoss AS Server based on RHQ 4.7.0.

      We need your help to introduce where we can get the latest REST API document of RHQ 4.7.0.

      Besides, it is said the whole REST API will be finished in RHQ 4.8.0. Could you tell when the RHQ 4.8.0 will be ready?

      Many Thanks.


        • 1. Re: Where can I find latest document of REST API
          huchangchun

          I have generated the REST API document successfully. We can get it by running the command mvn -P"REST doc generation"

          at "/modules/enterprise/server/jar/".

          Could you tell when the RHQ 4.8.0 with whole REST API will be ready?

          1 of 1 people found this helpful
          • 2. Re: Where can I find latest document of REST API
            pilhuhn

            Hey,

             

            you can also run the generator via mvn -Ddocgen install.

             

            About RHQ 4.8 -- we are working hard on providing upgrade paths from RHQ 4.7 to 4.8. There was some good progress made, but there are still a few missing pieces (e.g. data migration with Oracle Databases), that need to be tied together.

             

            But (other than for the github migration), that is really real soon now

             

              Heiko

            • 3. Re: Where can I find latest document of REST API
              huchangchun

              Hello Heiko,

              Thank you very much for your answers.

              I get another problem when I try to acesss the http://hostname:7080/rest/.

              It asked for user name and password. I tried "rhqadmin/rhqadmin", it failed.

              Same problem happen when I try to access the rest example project at http://hostname:7080/rest-examples/index.html

               

              Could you tell how I can pass the authentication and access the URLs provided successfully?

              • 4. Re: Where can I find latest document of REST API
                pilhuhn

                Those urls look pretty right to me, so I guess there is another issue.

                 

                can you try

                 

                $ curl -i -u rhqadmin:rhqadmin http://localhost:7080/rest/.json

                 

                and check the return code? If it is a 40x, then authentication fails (but I'd guess it would fail for coregui too).

                If it is a 50x code, then something in the server is wrong.

                 

                When you first hit the /rest/ urls after a server start, you should see something like

                 

                10:18:13,297 INFO  [org.rhq.enterprise.rest.RHQApplication] (http-/0.0.0.0:7080-2) Starting RHQ REST interface

                10:18:13,298 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (http-/0.0.0.0:7080-2) Deploying javax.ws.rs.core.Application: class org.rhq.enterprise.rest.RHQApplication

                1

                 

                in the server log. Does that show up?

                 

                Earlier in the server startup you should see something like

                 

                10:15:13,537 INFO  [org.jboss.web] (ServerService Thread Pool -- 67) JBAS018210: Register web context: /rest

                10:15:13,546 INFO  [org.jboss.web] (ServerService Thread Pool -- 70) JBAS018210: Register web context: /rest-examples

                10:15:13,549 INFO  [org.rhq.enterprise.server.scheduler.SchedulerService] (MSC service thread 1-4) Scheduler has a default operation timeout of [600] seconds.

                10:15:13,569 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 65) HHH000206: hibernate.properties not found

                10:15:13,577 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 65) HHH000021: Bytecode provider name : javassist

                10:15:13,685 INFO  [org.jboss.web] (ServerService Thread Pool -- 74) JBAS018210: Register web context: /coregui

                 

                without errros shown.

                 

                I hope this helps

                • 5. Re: Where can I find latest document of REST API
                  huchangchun

                  I will try the curl command and check the log file tomorrow. Thanks.

                  • 6. Re: Where can I find latest document of REST API
                    huchangchun

                    Hello Heiko,

                    I checked the server.log and found the web context were registered and I find the response code of url is 401.

                     

                    • Server log

                    "

                    13:33:15,789 INFO  [org.jboss.web] (ServerService Thread Pool -- 68) JBAS018210: Register web context: /jboss-remoting-servlet-invoker

                    13:33:15,796 INFO  [org.jboss.web] (ServerService Thread Pool -- 70) JBAS018210: Register web context: /rest

                    13:33:15,804 INFO  [org.jboss.web] (ServerService Thread Pool -- 66) JBAS018210: Register web context: /rest-examples

                    13:33:15,804 INFO  [org.jboss.web] (ServerService Thread Pool -- 72) JBAS018210: Register web context: /coregui

                    13:33:15,835 DEBUG [org.rhq.enterprise.server.scheduler.SchedulerService] (MSC service thread 1-5) Scheduler Service has started - however, Quartz is not going to be starting yet

                    13:33:15,836 DEBUG [org.rhq.enterprise.server.plugin.pc.ServerPluginService] (MSC service thread 1-2) The server plugin service has been deployed (but master plugin container will not be started yet)

                    "

                    >wget.exe --user=rhqadmin --password=rhqadmin http://172.17.254.207:7080/coregui/

                    1. --2013-07-22 13:38:23--  http://172.17.254.207:7080/coregui/
                    2. Connecting to 172.17.254.207:7080... connected.
                    3. HTTP request sent, awaiting response... 200 OK
                    4. Length: 2225 (2.2K) [text/html]
                    5. Saving to: `index.html'
                    6. 100%[======================================>] 2,225       --.-K/s   in 0s
                    7. 2013-07-22 13:38:23 (123 MB/s) - `index.html' saved [2225/2225]

                     

                    1. >wget.exe --user=rhqadmin --password=rhqadmin http://172.17.254.207:7080/rest/.json
                    2. --2013-07-22 13:38:32--  http://172.17.254.207:7080/rest/.json
                    3. Connecting to 172.17.254.207:7080... connected.
                    4. HTTP request sent, awaiting response... 401 Unauthorized
                    5. Reusing existing connection to 172.17.254.207:7080.
                    6. HTTP request sent, awaiting response... 401 Unauthorized
                    7. Authorization failed.

                     

                    It seems behaviors are different from /coregui and /rest. Could you send me your standalone-full.xml?

                    Many thanks.

                    • 7. Re: Where can I find latest document of REST API
                      pilhuhn

                      Hey Changchun,

                       

                      you are right, authentication is different in coregui and rest api.

                       

                      Coregui is a GWT-app, that gets loaded ("the index.html file") and which then runs as javascript and shows a login prompt.

                       

                      The rest api does http basic auth. Not sure why you got the 401 above.

                      If you did the wget directly after the above log lines it may be that the rest-war was already deployed, but was still missing some

                      backend functionality.

                       

                      Can you perhaps try    http://localhost:7080/rest/resource/platforms.json

                       

                      $ curl -i -u rhqadmin:rhqadmin http://localhost:7080/rest/resource/platforms.json

                      HTTP/1.1 200 OK

                      Server: Apache-Coyote/1.1

                      Pragma: No-cache

                      Cache-Control: no-cache

                      Expires: Thu, 01 Jan 1970 01:00:00 CET

                      Cache-Control: max-age=300, private

                      Link: <http://localhost:7080/rest/resource/platforms.json?page=1>; rel="next"

                      Link: <http://localhost:7080/rest/resource/platforms.json>; rel="current"

                      X-collection-size: 1

                      Content-Type: application/json

                      Transfer-Encoding: chunked

                      Date: Mon, 22 Jul 2013 08:49:47 GMT

                       

                       

                      [{"resourceName":"snert","resourceId":10001,"typeName":"Mac OS X","typeId":10013,"pluginName":"Platforms","parentId":0,"status":"COMMITTED","links":[{"operationDefinitions":{"href":"http://localhost:7080/rest/operation/definitions?resourceId=10001"}},{"self":{"href":"http://localhost:7080/rest/resource/10001"}},{"schedules":{"href":"http://localhost:7080/rest/resource/10001/schedules"}},{"availability":{"href":"http://localhost:7080/rest/resource/10001/availability"}},{"children":{"href":"http://localhost:7080/rest/resource/10001/children"}},{"alerts":{"href":"http://localhost:7080/rest/resource/10001/alerts"}},{"coregui":{"href":"http://localhost:7080/coregui/#Resource/10001"}}],"ancestry":null,"location":null,"description":"Mac OS X Operating System"}]

                      • 8. Re: Where can I find latest document of REST API
                        huchangchun

                        Hello Heiko,

                        The response code is 401 when accessing http://172.17.254.207:7080/rest/rest/resource/platforms.json.

                         

                        wget --user=rhqadmin --password=rhqadmin http://172.17.254.207:7080/rest/rest/resource/platforms.json

                        1. --2013-07-22 17:35:32--  http://172.17.254.207:7080/rest/rest/resource/platforms
                        2. .json
                        3. Connecting to 172.17.254.207:7080... connected.
                        4. HTTP request sent, awaiting response... 401 Unauthorized
                        5. Reusing existing connection to 172.17.254.207:7080.
                        6. HTTP request sent, awaiting response... 401 Unauthorized
                        7. Authorization failed.

                         

                        I am working on RHQ 4.7.0, could you tell your version? It is much appreciated if you provide your standalone-full.xml and web.xml of the rhq-rest.war

                        • 9. Re: Where can I find latest document of REST API
                          huchangchun

                          Hello Heiko,

                          I download an original build of RHQ 4.7.0 and have a test in my machine. It works well.

                          So the problem I reported was due to my local change.

                          I am sorry for bringing you trouble and thank you for you message.

                          I will check the problem of my change and attach the root cause later.

                          Thanks and best regards.

                          • 10. Re: Where can I find latest document of REST API
                            huchangchun

                            Hello Heiko,

                            Finally, we found the standalone-full.xml was modified by mistake and the "RHQRESTSecurityDomain" entry was broken. As a result, the authentication didn't work normally.

                            Many thanks for support.

                            Best regards

                            • 11. Re: Where can I find latest document of REST API
                              huchangchun

                              Hello Heiko,

                              I get another problem about REST API in RHQ4.7. As I said before, we are developing a web application to monitor and manage JBoss AS Server based on RHQ 4.7.0. We have a problem on creating alert definition in our pages using REST service now.

                              We find RHQ provides API in org.rhq.enterprise.server.rest.AlertDefinitionHandlerBean class as below.

                              But we don't know how to send parameters. It seems an HTTP request with xml data should be sent to server side, so it can be interpreted to AlertDefinitionRest by JAXB. Could you give some example about the HTTP request content? Can we just convert json to string and send it to server side?

                               

                              I find the document about RestEasy on http://docs.jboss.org/resteasy/docs/1.0.0.GA/userguide/html_single, but it doen't solve our problem. I find your article about the rest on http://planet.jboss.org/post/rest_jax_rs_documentation_generation and hope you can help.

                               

                              public Response createAlertDefinition(@ApiParam("The id of the resource to attach the definition to") @QueryParam("resourceId") Integer resourceId,

                                                                        @ApiParam("The id of the group to attach the definition to") @QueryParam("groupId") Integer groupId,

                                                                        @ApiParam("The id of the resource type to attach the definition to") @QueryParam("resourceTypeId") Integer resourceTypeId,

                                                                        @ApiParam("The data for the new definition") AlertDefinitionRest adr,

                                      @Context UriInfo uriInfo) {

                              ...

                              }

                               

                              Thanks.