ServerList

From Hostway API Documentation
(Difference between revisions)
Jump to: navigation, search
(Examples)
m (1 revision: Release 98)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This operation will list all servers.
+
This operation returns a list of all [[Server|servers]].
  
'''GET''' /servers?''name=serverName&status=serverStatus&image=imageRef''
+
='''GET''' /accounts/''{accountId}''/flexcloud/servers?''name=serverName&status=serverStatus&image=imageRef&zone=zoneTextKey&region=regionTextKey''=
  
 
== Parameters ==
 
== Parameters ==
 +
; accountId - ''string''
 +
: The selected account Id.
 +
 
; name - ''string''
 
; name - ''string''
 
: ''Optional'' Server name to search for.
 
: ''Optional'' Server name to search for.
  
 
; status - ''string''
 
; status - ''string''
: ''Optional'' Server status to search for. Values: '''BUILD''', '''ACTIVE''', '''SUSPENDED''', '''DELETED''', '''UNKNOWN'''
+
: Server status to search for. Values: '''BUILD''', '''ACTIVE''', '''SUSPENDED''', '''DELETED''', '''STOPPED''', '''PROCESSING'''
 +
: without status filtering, return servers with '''ACTIVE''', '''PROCESSING''' or '''STOPPED'''
  
 
; image - ''string''
 
; image - ''string''
: ''Optional'' Absolute URL of the image to filter servers by. ''e.g. <nowiki>http(s)://{api_server}/images/{image_id}/</nowiki>''
+
: ''Optional'' Absolute URL of the image to filter servers by. ''e.g. http(s)://{api_server}/images/{image_id}/''
 +
 
 +
; zone - ''string''
 +
: ''Optional'' Zone textkey
 +
 
 +
; region - ''string''
 +
: ''Optional'' Region textkey
  
 
== Result ==
 
== Result ==
 
=== JSON ===
 
=== JSON ===
<big><source lang="javascript">
+
<nowiki>
 
{
 
{
 
   "servers":[
 
   "servers":[
 
       {
 
       {
 
         "id":"{server_id}",
 
         "id":"{server_id}",
 +
        "zone": "{zone_textkey}",
 
         "links":[
 
         "links":[
 
             {
 
             {
               "href":"http://{api_server}/servers/{server_id}/",
+
               "href":"http://{api_server}/accounts/{accountId}/flexcloud/servers/{server_id}/",
 
               "rel":"self"
 
               "rel":"self"
 
             }
 
             }
Line 29: Line 40:
 
       {
 
       {
 
         "id":"{server_id}",
 
         "id":"{server_id}",
 +
        "zone": "{zone_textkey}",
 
         "links":[
 
         "links":[
 
             {
 
             {
               "href":"http://{api_server}/servers/{server_id}/",
+
               "href":"http://{api_server}/accounts/{accountId}/flexcloud/servers/{server_id}/",
 
               "rel":"self"
 
               "rel":"self"
 
             }
 
             }
Line 37: Line 49:
 
       }
 
       }
 
   ]
 
   ]
}
+
}</nowiki>
</source></big>
+
 
+
  
 
; id - ''string''
 
; id - ''string''
 
: Unique identifier for this server.
 
: Unique identifier for this server.
 +
 +
; zone
 +
: Zone text key
  
 
; links - ''array''
 
; links - ''array''
Line 50: Line 63:
 
; Success:
 
; Success:
 
:''HTTP/1.1 200 OK''
 
:''HTTP/1.1 200 OK''
 +
 
; Failure:
 
; Failure:
:''HTTP/1.1 200 OK Unauthorized'' - This server could not verify that you are authorized to access the document you requested.  Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.
+
:''HTTP/1.1 401 Unauthorized'' : This server could not verify that you are authorized to access the document you requested.  Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.
 +
:''HTTP/1.1 404 Not Found'' : Resource does not exist
  
 
== Examples ==
 
== Examples ==
 
+
'''Successfully list servers'''
'''List servers'''
+
:'''GET''' http(s)://{api_server}/accounts/{accountId}/flexcloud/servers
:'''GET''' <nowiki>http(s)://{api_server}/servers</nowiki>
+
  
  
Line 69: Line 83:
 
''Response Body:''
 
''Response Body:''
 
  <nowiki>
 
  <nowiki>
{
+
{
 
     "servers" : [
 
     "servers" : [
 
       {
 
       {
           "id": "test_server_0001",  
+
           "id": "test_server_0001",
 +
          "zone": "AUS001",
 
           "links": [
 
           "links": [
 
             {
 
             {
                 "href": "http://{api_server}/servers/test_server_0001/",  
+
                 "href": "http://{api_server}/accounts/{accountId}/flexcloud/servers/test_server_0001/",  
 
                 "rel": "self"
 
                 "rel": "self"
 
             }
 
             }
Line 81: Line 96:
 
       },
 
       },
 
       {
 
       {
           "id": "test_server_0013",  
+
           "id": "test_server_0013",
 +
          "zone": "zone",
 
           "links": [
 
           "links": [
 
             {
 
             {
                 "href": "http://{api_server}/servers/test_server_0013/",  
+
                 "href": "http://{api_server}/accounts/{accountId}/flexcloud/servers/test_server_0013/",  
 
                 "rel": "self"
 
                 "rel": "self"
 
             }
 
             }
Line 90: Line 106:
 
       },
 
       },
 
       {
 
       {
           "id": "test_server_0015",  
+
           "id": "test_server_0015",
 +
          "zone": "AUS001",
 
           "links": [
 
           "links": [
 
             {
 
             {
                 "href": "http://{api_server}/servers/test_server_0015/",  
+
                 "href": "http://{api_server}/accounts/{accountId}/flexcloud/servers/test_server_0015/",  
 
                 "rel": "self"
 
                 "rel": "self"
 
             }
 
             }
Line 99: Line 116:
 
       }
 
       }
 
     ]
 
     ]
}
+
}</nowiki>
</nowiki>
+
'''Unauthorized access'''
+
:'''GET''' <nowiki>http://{api_server}/servers</nowiki>
+
  
 +
'''Failure while trying to make unauthorized access'''
 +
:'''GET''' <nowiki>http://{api_server}/accounts/{accountId}/flexcloud/servers</nowiki>
  
 
''Request Headers:''
 
''Request Headers:''
 
     Content-Type:application/json
 
     Content-Type:application/json
 
     Charset=UTF-8
 
     Charset=UTF-8
     Authorization:Base64-encoded fake_authentication_string
+
     Authorization:Base64-encoded <span style="color:red">fake_authentication_string</span>
  
 
''Response Code:''
 
''Response Code:''
Line 120: Line 136:
 
     does not understand how to supply the credentials required.
 
     does not understand how to supply the credentials required.
  
 +
'''Failure while trying to pass invalid account number'''
 +
:'''GET''' http(s)://{api_server}/accounts/{accountId}/flexcloud/servers
 +
 +
 +
''Request Headers:''
 +
    Content-Type:application/json
 +
    Charset=UTF-8
 +
    Authorization:Base64-encoded username & password string
 +
 +
''Response Code:''
 +
<pre>HTTP/1.1 404 Not Found</pre>
 +
 +
''Response Body:''
 +
<nowiki>
 +
{
 +
    "itemNotFound" : {
 +
      "message": "Resource not found",
 +
      "code": 404,
 +
      "details": "",
 +
      "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf"
 +
    }
 +
}</nowiki>
  
<!--  THIS CODE ENABLES DISQUS COMMENTS ON THE PAGE - DELETE TO DISABLE COMMENTING-->
+
== Alternative URI /servers ==
 +
An alternative way to execute this call is to omit the ''accountId'' portion of the URI. In this case the system assumes the request is executed for the account identified in the [[Authentication|authorization header]].
  
{{#widget:DISQUS
+
<code>GET /servers</code>
|id=hostway
+
|uniqid={{PAGENAME}}
+
|url={{fullurl:{{PAGENAME}}}}
+
}}
+
  
<!--  ########################################################################### -->
+
[[Category:Hostway API]]
 +
[[Category:FlexCloud Server API]]

Latest revision as of 07:52, 15 September 2014

This operation returns a list of all servers.

Contents

[edit] GET /accounts/{accountId}/flexcloud/servers?name=serverName&status=serverStatus&image=imageRef&zone=zoneTextKey&region=regionTextKey

[edit] Parameters

accountId - string
The selected account Id.
name - string
Optional Server name to search for.
status - string
Server status to search for. Values: BUILD, ACTIVE, SUSPENDED, DELETED, STOPPED, PROCESSING
without status filtering, return servers with ACTIVE, PROCESSING or STOPPED
image - string
Optional Absolute URL of the image to filter servers by. e.g. http(s)://{api_server}/images/{image_id}/
zone - string
Optional Zone textkey
region - string
Optional Region textkey

[edit] Result

[edit] JSON

{
   "servers":[
      {
         "id":"{server_id}",
         "zone": "{zone_textkey}",
         "links":[
            {
               "href":"http://{api_server}/accounts/{accountId}/flexcloud/servers/{server_id}/",
               "rel":"self"
            }
         ]
      },
      {
         "id":"{server_id}",
         "zone": "{zone_textkey}",
         "links":[
            {
               "href":"http://{api_server}/accounts/{accountId}/flexcloud/servers/{server_id}/",
               "rel":"self"
            }
         ]
      }
   ]
}
id - string
Unique identifier for this server.
zone
Zone text key
links - array
Hypermedia for this resource.

[edit] Response Codes

Success
HTTP/1.1 200 OK
Failure
HTTP/1.1 401 Unauthorized : This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.
HTTP/1.1 404 Not Found : Resource does not exist

[edit] Examples

Successfully list servers

GET http(s)://{api_server}/accounts/{accountId}/flexcloud/servers


Request Headers:

   Content-Type:application/json
   Charset=UTF-8
   Authorization:Base64-encoded username & password string

Response Code:

HTTP/1.1 200 OK

Response Body:

{
    "servers" : [
       {
          "id": "test_server_0001",
          "zone": "AUS001",
          "links": [
             {
                "href": "http://{api_server}/accounts/{accountId}/flexcloud/servers/test_server_0001/", 
                "rel": "self"
             }
          ]
       },
       {
          "id": "test_server_0013",
          "zone": "zone",
          "links": [
             {
                "href": "http://{api_server}/accounts/{accountId}/flexcloud/servers/test_server_0013/", 
                "rel": "self"
             }
           ]
       },
       {
          "id": "test_server_0015",
          "zone": "AUS001",
          "links": [
             {
                "href": "http://{api_server}/accounts/{accountId}/flexcloud/servers/test_server_0015/", 
                "rel": "self"
             }
          ]
       }
    ]
}

Failure while trying to make unauthorized access

GET http://{api_server}/accounts/{accountId}/flexcloud/servers

Request Headers:

   Content-Type:application/json
   Charset=UTF-8
   Authorization:Base64-encoded fake_authentication_string

Response Code:

HTTP/1.1 401 Unauthorized

Response Body:

    401 Unauthorized
    This server could not verify that you are authorized to
    access the document you requested.  Either you supplied the
    wrong credentials (e.g., bad password), or your browser
    does not understand how to supply the credentials required.

Failure while trying to pass invalid account number

GET http(s)://{api_server}/accounts/{accountId}/flexcloud/servers


Request Headers:

   Content-Type:application/json
   Charset=UTF-8
   Authorization:Base64-encoded username & password string

Response Code:

HTTP/1.1 404 Not Found

Response Body:

 {
    "itemNotFound" : {
       "message": "Resource not found", 
       "code": 404, 
       "details": "",
       "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf"
    }
 }

[edit] Alternative URI /servers

An alternative way to execute this call is to omit the accountId portion of the URI. In this case the system assumes the request is executed for the account identified in the authorization header.

GET /servers

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox