Methods of Calling for REST


Last Update: 2017/03/22


The following is an example of hicloud CaaS / CVPC API calling (take runInstances for example):

 

    https://hws.hicloud.hinet.net/cloud_hws/api/hws/?action=runInstances&version=2013-03-29
    &chtAuthType=hwspass&imageId=hi-olajtpss&instanceType=HC1.S.LINUX&monitoringEnabled=false
    &instanceName=myInstance&count=1&accessKey=U0U0MU5UQXhNREF3TVRFek5qSTVPRFkxTURneU1UWT0
    &expires=2013-03-13T17%3A50%3A04%Z&signature=VGMS-tWF3Xa2ixBhwvzgi7Aplhc
    

 

  1. Related information on hicloud CaaS / CVPC API
    1. Server: hws.hicloud.hinet.net
    2. Port: 443
    3. HTTP protocol: HTTPS
    4. Action: /cboss-hws-web/api/hws/
  2. Go to hicloud user platform to acquire Access Key and Secret KeyFor example:
    1. Access Key: U0U0MU5UQXhNREF3TVRFek5qSTVPRFkxTURneU1UWT0
    2. Secret key: WWpJNU16a3pOV1JsWWpNeU5HVXdOMkkxTURNd1lUbG1OMlEwTXpSaFptST0
  3. Go to the Common Parameterpage at right side of Developer Center > hicloud CaaS >VM > Welcome, To prepare for the following parameters :
    1. chtAuthType=hwspass
    2. version=2013-03-29 (Varies in different versions.)
    3. expires=2013-03-17T17%3A50%3A04Z (It is suggested to add 15 minutes to the current system time in ISO 8601 format. During URL transmission, some special characters would be replaced, such as “:”, “+” …Therefore, the original 2013-03-17T17:50:04Z would be replaced with 2013-03-17T17%3A50%3A04Z)

    4. accessKey=U0U0MU5UQXhNREF3TVRFek5qSTVPRFkxTURneU1UWT0
    5. action=runInstances
  4. See description of Request Parameter at Developer Center > hicloud CaaS > VM > Actions > runInstances,To prepare for the following parameters :
    1. imageId=hi-olajtpss
    2. instanceType=HC1.S.LINUX
    3. monitoringEnabled=false
    4. instanceName=myInstance
    5. count=1
  5. The transmitted Request Parameter value should undergo URL encoding
    1. Example
      Original Value
      URL Encode
      Description
      noun phrase noun%20phrase Empty Space
      vm!@#$%^&*()-=_+[]{};':",./<>?999 vm!%40%23%24%25%5E%26*()-%
      3D_%2B%5B%5D%7B%7D%3B%27
      %3A%22%2C.%2F%3C%3E%3F999
    2. References
      1. Wikipedia-Encoding of Percent-encoding
        (http://en.wikipedia.org/wiki/Percent-encoding)
      2. URL Encode and Decode Tool (http://www.url-encode-decode.com/)
      3. Wikipedia - UTF-8 (http://en.wikipedia.org/wiki/UTF-8)
  6. 3. With the abovementioned information, the following url can be produced.
  7.   https://hws.hicloud.hinet.net/cloud_hws/api/hws/?action=runInstances&version=2013-03-29&
      chtAuthType=hwspass&imageId=hi-olajtpss&instanceType=HC1.S.LINUX&monitoringEnabled=false&
      instanceName=myInstance&count=1&accessKey=U0U0MU5UQXhNREF3TVRFek5qSTVPRFkxTURneU1UWT0&
      expires=2013-03-13T17%3A50%3A04%Z
  8. According to Signature code example, along with Secret Key and url at the last step, a website with signature can be produced.
      https://hws.hicloud.hinet.net/cloud_hws/api/hws/?action=runInstances&version=2013-03-29&chtAuthType=hwspass&
      imageId=hi-olajtpss&instanceType=HC1.S.LINUX&monitoringEnabled=false&instanceName=myInstance&count=1&
      accessKey=U0U0MU5UQXhNREF3TVRFek5qSTVPRFkxTURneU1UWT0&expires=2013-03-13T17%3A50%3A04%Z&
      signature=VGMS-tWF3Xa2ixBhwvzgi7Aplhc 
  9. Execute the action through REST. Take Firefox + RESTClient for example.
    1. Fill in GET in Method.
    2. Fill in a website with Signature in URL.
    3. Press “SEND”
    4. The result of the execution can be found in Response section.