Orders-orderId-account-products-productId-services:POST

(Difference between revisions)
Jump to: navigation, search
m (1 revision: Release 97)
Line 62: Line 62:
  
 
=== Status Code ===
 
=== Status Code ===
;201 Created
+
{| class="wikitable"
: The product was successfully added to the order.
+
! Status Code
 +
! Error Message
 +
! Description
 +
|-
 +
| 201 Created
 +
| -
 +
| The service was successfully added to the order.
 +
|-
 +
| rowspan="6"| 400 Bad Request
 +
| POST data error
 +
| Trying to create a service without passing all the required attributes.
 +
|-
 +
| Invalid service specification
 +
| Malformed serviceSpecification was passed or the service is not found in the backend
 +
|-
 +
| Invalid cycle
 +
| Trying to add service with wrong billingCycle
 +
|-
 +
| Invalid relatedTo service ID provided: fake.service
 +
| Trying to add a service with invalid relatedTo
 +
|-
 +
| Product does not support this service
 +
| Trying to add service to a product, which doesn't support the service.
 +
|-
 +
| Current service requires being a child service.
 +
| The service that can be added only as a child is added as a service
 +
|-
 +
| 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.
 +
| The ''OwnerId'' cookie was not specified or is incorrect.
 +
|-
 +
| 403 Unauthorized
 +
| -
 +
| The client does not have permissions to add products.
 +
|-
 +
| 404 Not Found
 +
| Resource not found
 +
|  An account has not been added to the given order or the order does not exist.
 +
|-
 +
|}
  
;400 Bad Request
 
: The request body contains invalid JSON or the values do not adhere to the restrictions set for them.
 
  
;401 Unauthorized
+
=== Response Headers ===
: The ''OwnerId'' cookie was not specified or is incorrect.
+
; Location
 +
: Returned with successful response. Contains the URI of the newly added service.
  
;403 Forbidden
+
=== Response Body ===
: The client does not have permissions to add services.
+
==== Successful response ====
 +
<nowiki>
 +
201 Created
 +
{
 +
    "url": "</nowiki>{{APIBaseURL}}<nowiki>/order/account/products/00000140728b013c52e249a4007f000000010001/services/00000140735d43640f62c50f007f000000010001/"
 +
} </nowiki>
  
;404 Not Found
+
==== Error responses ====
: An account has not been added to the given order or the order does not exist.
+
<nowiki>
 +
400 Bad Request - request body is missing some of the required attributes
 +
{
 +
    "badRequest": {
 +
        "guid": "23bf964e-fb93-4bd6-816e-3dcb31b82755",
 +
        "message": "POST data error",
 +
        "code": 400,
 +
        "details": {
 +
            "serviceSpecification": "Required",
 +
            "billingCycle": "Required"
 +
        }
 +
    }
 +
}
  
;409 Conflict
+
400 - malformed serviceSpecification was passed or the service is not found in the backend
: A conflict has occurred preventing attributes creation to particular service. There are different conflict situations for different products/services
+
{
:; Domain-dependent services:
+
    "computeFault": {
:: One of the domains to be ordered is already owned by another account or is blacklisted.
+
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
 +
        "message": "Invalid service specification",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
  
:; Email domain alias service:
+
400 - wrong billingCycle
:: A domain alias would produce impossible to delivery loops namely:
+
{
:: - There is an email forwarder from the target domain name to a mailbox of the domain alias with the same username, OR
+
    "computeFault": {
:: - There is an email forwarder from the domain alias to a mailbox of the target domain name with the same username
+
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
 +
        "message": "Invalid cycle",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
  
=== Response Headers ===
+
400 - invalid service was passed as relatedTo
; Location
+
{
: Returned with successful response. Contains the URI of the newly added service.
+
    "computeFault": {
 +
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
 +
        "message": "Invalid relatedTo service ID provided: fake.service",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
  
=== Response Body ===
+
400 - the service is not supported by the product
None.
+
{
 +
    "computeFault": {
 +
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
 +
        "message": "Product does not support this service",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
 +
 
 +
400 - the service that can be added only as a child is added as a service
 +
{
 +
    "computeFault": {
 +
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
 +
        "message": "Current service requires being a child service.",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}</nowiki>
  
 
== Examples ==
 
== Examples ==
Line 107: Line 195:
 
         "serverLocation": "Tampa"
 
         "serverLocation": "Tampa"
 
     }
 
     }
}
+
}</nowiki>
</nowiki>
+
 
  
'''Response'''
 
<nowiki>
 
{
 
    "url": "</nowiki>{{APIBaseURL}}<nowiki>/order/account/products/00000140728b013c52e249a4007f000000010001/services/00000140735d43640f62c50f007f000000010001/"
 
}
 
</nowiki>
 
  
 
== See also ==
 
== See also ==

Revision as of 04:36, 11 September 2014

POST /orders/{orderId}/account/products/{productId}/services

Adds a new service to a product in the order.

Contents


Request

POST /orders/{orderId}/account/products/{productId}/services

Request Parameters

orderId - string
The unique order Id. The URI of the order is returned by the POST /orders call.
productId - string
UUID specifying the product

URI Parameters

None.

Request Headers

Content-Type
Required. Set this header to application/json; charset=UTF-8
Cookie
A cookie named OwnerId to identify the client (for most browser clients, the browser will do this automatically, depending on the browser configuration). The value of the cookie would come from the response to the create order request in the Set-Cookie response header.

Request Body

{
  "name": "john.smith1",
  "relatedTo": [ "https://api.hostway.com/orders/{orderId}/account/products/{productId}/services/{serviceId}" ],
  "serviceSpecification": "https://api.hostway.com/serviceSpecifications/{serviceSpecificationId}",
  "billingCycle": 1,
  "attributes": {
    "{attribute-name}": "{attribute-value}",
    ....
  }
}
 

Parameters

name - string
The name of the new service
relatedTo - list
(OPTIONAL)
A list containing other services related in some way to the newly created service. The relatedTo may be omitted, but relationships between some types of services have to be established for the order to be validated or submitted.
serviceSpecification - string
Link to the product catalog specification describing the new service
billingCycle - integer
Billing cycle (length of billing period in months) of the service. Allowed values are from 1 to 120
attributes - dictionary
(OPTIONAL)
a dictionary of the new service's attributes values. Each (attribute-name, attribute-value) pair present the service attribute name and its relevant value to be set. The allowed attribute names depends on the serviceSpecification field value. See Service Attributes Structure.

Validation Rules

  1. The service specification URL ( https://api.hostway.com/serviceSpecifications/{serviceSpecificationId} ) should point to an existing service.
  2. Each service URL ( https://api.hostway.com/orders/{orderId}/account/products/{productId}/services/{serviceId} ) from the related services list should point to a valid service already added to the product.
  3. The service billing cycle should be allowed for the product.
  4. The product should support adding the service.

Response

Status Code

Status Code Error Message Description
201 Created - The service was successfully added to the order.
400 Bad Request POST data error Trying to create a service without passing all the required attributes.
Invalid service specification Malformed serviceSpecification was passed or the service is not found in the backend
Invalid cycle Trying to add service with wrong billingCycle
Invalid relatedTo service ID provided: fake.service Trying to add a service with invalid relatedTo
Product does not support this service Trying to add service to a product, which doesn't support the service.
Current service requires being a child service. The service that can be added only as a child is added as a service
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. The OwnerId cookie was not specified or is incorrect.
403 Unauthorized - The client does not have permissions to add products.
404 Not Found Resource not found An account has not been added to the given order or the order does not exist.


Response Headers

Location
Returned with successful response. Contains the URI of the newly added service.

Response Body

Successful response

201 Created
{
    "url": "https://api.hostway.com/order/account/products/00000140728b013c52e249a4007f000000010001/services/00000140735d43640f62c50f007f000000010001/"
} 

Error responses

400 Bad Request - request body is missing some of the required attributes
{
    "badRequest": {
        "guid": "23bf964e-fb93-4bd6-816e-3dcb31b82755",
        "message": "POST data error",
        "code": 400,
        "details": {
            "serviceSpecification": "Required",
            "billingCycle": "Required"
        }
    }
}

400 - malformed serviceSpecification was passed or the service is not found in the backend
{
    "computeFault": {
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
        "message": "Invalid service specification",
        "code": 400,
        "details": ""
    }
}

400 - wrong billingCycle
{
    "computeFault": {
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
        "message": "Invalid cycle",
        "code": 400,
        "details": ""
    }
}

400 - invalid service was passed as relatedTo
{
    "computeFault": {
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
        "message": "Invalid relatedTo service ID provided: fake.service",
        "code": 400,
        "details": ""
    }
}

400 - the service is not supported by the product
{
    "computeFault": {
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
        "message": "Product does not support this service",
        "code": 400,
        "details": ""
    }
}

400 - the service that can be added only as a child is added as a service
{
    "computeFault": {
        "guid": "e4443fe7-1139-4078-b407-39d868c02d26",
        "message": "Current service requires being a child service.",
        "code": 400,
        "details": ""
    }
}

Examples

Create a service with attributes

Request

{
    "name": "ng-test-hwus-test.com",
    "serviceSpecification": "https://api.hostway.com/serviceSpecifications/core.dedserver",
    "billingCycle": 1,
    "attributes": { 
        "serverName": "sampleServerName",
        "serverLocation": "Tampa"
    }
}


See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox