API Guide from CA Spring Multimodule
CA Spring Multimodule tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP verbs.
Verb | Usage |
---|---|
|
Used to retrieve a resource |
|
Used to create a new resource |
|
Used to update an existing resource, including partial updates |
|
Used to delete an existing resource |
CA Spring Multimodule tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP status codes.
Status code | Usage |
---|---|
|
The request completed successfully |
|
A new resource has been created
successfully. The resource’s URI is available from the response’s
|
|
An update to an existing resource has been applied successfully |
|
The request was malformed. The response body will include an error providing further information |
|
The requested resource did not exist |
CA Spring Multimodule uses hypermedia and resources include links to
other resources in their responses. Responses are in Hypertext
Application from resource to resource. Language
(HAL) format. Links can be
found beneath the _links
key. Users of the API should not create URIs
themselves, instead they should use the above-described links to
navigate
The index provides the entry point into the service.
A GET
request is used to access the index
GET / HTTP/1.1
Host: localhost:8080
HTTP/1.1 200 OK
Content-Type: application/prs.hal-forms+json
Content-Length: 201
{
"_links" : {
"customers" : {
"href" : "http://localhost:8080/customers/id"
},
"customers:search" : {
"href" : "http://localhost:8080/customers?name=customerName"
}
}
}
Path | Type | Description |
---|---|---|
|
|
Links to resources |
$ curl 'http://localhost:8080/' -i -X GET
Relation | Description |
---|---|
|
The Customers resource |
|
The Search for Customers |
The customers
provides the entry point into the service.
A POST
request is used to access customer creation.
POST /customers HTTP/1.1
Content-Type: application/hal+json;charset=UTF-8
Content-Length: 139
Host: localhost:8080
{
"zip" : "000000-000",
"number" : "123-A",
"city" : "city",
"street" : "street",
"name" : "Foo Bar",
"email" : "foo@bar.com"
}
Path | Type | Description |
---|---|---|
|
|
The name of the customer |
|
|
The email of the customer |
|
|
The street of the customer |
|
|
The number of the customer |
|
|
The city of the customer |
|
|
The zip of the customer |
HTTP/1.1 201 Created
Location: /91f9d915-d1ea-4eb8-97d1-cfabdffc5085
Content-Type: application/prs.hal-forms+json
Content-Length: 129
{
"_links" : {
"edit" : {
"href" : "http://localhost:8080/customers/91f9d915-d1ea-4eb8-97d1-cfabdffc5085"
}
}
}
Name | Description |
---|---|
|
The location of the created resource |
$ curl 'http://localhost:8080/customers' -i -X POST \
-H 'Content-Type: application/hal+json;charset=UTF-8' \
-d '{
"zip" : "000000-000",
"number" : "123-A",
"city" : "city",
"street" : "street",
"name" : "Foo Bar",
"email" : "foo@bar.com"
}'
Relation | Description |
---|---|
|
Edit customer data |
A GET
request is used to get the customer by Id.
GET /customers/e3119506-030a-4877-a219-389ef21118a4 HTTP/1.1
Accept: application/prs.hal-forms+json
Host: localhost:8080
Parameter | Description |
---|---|
|
Customer Id |
/customers/{id}
$ curl 'http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4' -i -X GET \
-H 'Accept: application/prs.hal-forms+json'
HTTP/1.1 200 OK
Content-Type: application/prs.hal-forms+json
Content-Length: 1533
{
"id" : "e3119506-030a-4877-a219-389ef21118a4",
"name" : "Foo Bar",
"email" : "foo@bar.com",
"active" : false,
"street" : "street",
"number" : "123-A",
"city" : "city",
"zip" : "000000-000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4"
}
},
"_templates" : {
"default" : {
"method" : "PUT",
"properties" : [ {
"name" : "city",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "email",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "name",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "number",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "street",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "zip",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
} ]
},
"activate" : {
"method" : "PATCH",
"properties" : [ ],
"target" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/activate"
},
"deactivate" : {
"method" : "PATCH",
"properties" : [ ],
"target" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/deactivate"
}
}
}
A GET
request is also used to find customers by name.
GET /customers?name=Foo%20Bar HTTP/1.1
Accept: application/prs.hal-forms+json
Host: localhost:8080
Parameter | Description |
---|---|
|
Customer name to search |
$ curl 'http://localhost:8080/customers?name=Foo%20Bar' -i -X GET \
-H 'Accept: application/prs.hal-forms+json'
Path | Type | Description |
---|---|---|
|
|
The customer list |
|
|
The search made |
HTTP/1.1 200 OK
Content-Type: application/prs.hal-forms+json
Content-Length: 1942
{
"_embedded" : {
"existingCustomerModelList" : [ {
"id" : "e3119506-030a-4877-a219-389ef21118a4",
"name" : "Foo Bar",
"email" : "foo@bar.com",
"active" : false,
"street" : "street",
"number" : "123-A",
"city" : "city",
"zip" : "000000-000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4"
}
},
"_templates" : {
"default" : {
"method" : "PUT",
"properties" : [ {
"name" : "city",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "email",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "name",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "number",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "street",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "zip",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
} ]
},
"activate" : {
"method" : "PATCH",
"properties" : [ ],
"target" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/activate"
},
"deactivate" : {
"method" : "PATCH",
"properties" : [ ],
"target" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/deactivate"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/customers?name=Foo%20Bar"
}
}
}
A PUT
request is used to access customer update.
PUT /customers/e3119506-030a-4877-a219-389ef21118a4 HTTP/1.1
Content-Type: application/hal+json;charset=UTF-8
Content-Length: 139
Host: localhost:8080
{
"zip" : "000000-000",
"number" : "123-A",
"city" : "city",
"street" : "street",
"name" : "Foo Bar",
"email" : "foo@bar.com"
}
Parameter | Description |
---|---|
|
Customer Id |
/customers/{id}
Path | Type | Description |
---|---|---|
|
|
The name of the customer |
|
|
The email of the customer |
|
|
The street of the customer |
|
|
The number of the customer |
|
|
The city of the customer |
|
|
The zip of the customer |
$ curl 'http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4' -i -X PUT \
-H 'Content-Type: application/hal+json;charset=UTF-8' \
-d '{
"zip" : "000000-000",
"number" : "123-A",
"city" : "city",
"street" : "street",
"name" : "Foo Bar",
"email" : "foo@bar.com"
}'
HTTP/1.1 200 OK
Content-Type: application/prs.hal-forms+json
Content-Length: 1533
{
"id" : "e3119506-030a-4877-a219-389ef21118a4",
"name" : "Foo Bar",
"email" : "foo@bar.com",
"active" : false,
"street" : "street",
"number" : "123-A",
"city" : "city",
"zip" : "000000-000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4"
}
},
"_templates" : {
"default" : {
"method" : "PUT",
"properties" : [ {
"name" : "city",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "email",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "name",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "number",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "street",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
}, {
"name" : "zip",
"regex" : "^(?=\\s*\\S).*$",
"required" : true,
"type" : "text"
} ]
},
"activate" : {
"method" : "PATCH",
"properties" : [ ],
"target" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/activate"
},
"deactivate" : {
"method" : "PATCH",
"properties" : [ ],
"target" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/deactivate"
}
}
}
Relation | Description |
---|---|
|
Resource Self Link |
A PATCH
request can be used to activate a customer.
PATCH /customers/e3119506-030a-4877-a219-389ef21118a4/activate HTTP/1.1
Host: localhost:8080
Parameter | Description |
---|---|
|
Customer Id |
/customers/{id}/activate
$ curl 'http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/activate' -i -X PATCH
HTTP/1.1 202 Accepted
Content-Type: application/prs.hal-forms+json
Content-Length: 254
{
"_links" : {
"self" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4"
},
"deactivate" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/deactivate"
}
}
}
Relation | Description |
---|---|
|
Resource Self Link |
|
Link to deactivate the customer |
A PATCH
request can be used to deactivate a customer.
PATCH /customers/e3119506-030a-4877-a219-389ef21118a4/deactivate HTTP/1.1
Host: localhost:8080
Parameter | Description |
---|---|
|
Customer Id |
/customers/{id}/deactivate
$ curl 'http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/deactivate' -i -X PATCH
HTTP/1.1 202 Accepted
Content-Type: application/prs.hal-forms+json
Content-Length: 250
{
"_links" : {
"self" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4"
},
"activate" : {
"href" : "http://localhost:8080/customers/e3119506-030a-4877-a219-389ef21118a4/activate"
}
}
}
Relation | Description |
---|---|
|
Resource Self Link |
|
Link to activate the customer |