use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class PetApi method deletePet.
/**
* Deletes a pet
*
* <p><b>400</b> - Invalid ID supplied
* <p><b>404</b> - Pet not found
* @param petId Pet id to delete
* @param apiKey The apiKey parameter
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void deletePet(Long petId, String apiKey) throws RestClientException {
Object postBody = null;
// verify the required parameter 'petId' is set
if (petId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'petId' when calling deletePet");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("petId", petId);
String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
if (apiKey != null)
headerParams.add("api_key", apiClient.parameterToString(apiKey));
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "petstore_auth" };
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class PetApi method findPetsByTags.
/**
* Finds Pets by tags
* Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* <p><b>200</b> - successful operation
* <p><b>400</b> - Invalid tag value
* @param tags Tags to filter by
* @return List<Pet>
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public List<Pet> findPetsByTags(List<String> tags) throws RestClientException {
Object postBody = null;
// verify the required parameter 'tags' is set
if (tags == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'tags' when calling findPetsByTags");
}
String path = UriComponentsBuilder.fromPath("/pet/findByTags").build().toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("multi".toUpperCase()), "tags", tags));
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "petstore_auth" };
ParameterizedTypeReference<List<Pet>> returnType = new ParameterizedTypeReference<List<Pet>>() {
};
return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class PetApi method getPetById.
/**
* Find pet by ID
* Returns a single pet
* <p><b>200</b> - successful operation
* <p><b>400</b> - Invalid ID supplied
* <p><b>404</b> - Pet not found
* @param petId ID of pet to return
* @return Pet
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public Pet getPetById(Long petId) throws RestClientException {
Object postBody = null;
// verify the required parameter 'petId' is set
if (petId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'petId' when calling getPetById");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("petId", petId);
String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "api_key" };
ParameterizedTypeReference<Pet> returnType = new ParameterizedTypeReference<Pet>() {
};
return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class StoreApi method getOrderById.
/**
* Find purchase order by ID
* For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
* <p><b>200</b> - successful operation
* <p><b>400</b> - Invalid ID supplied
* <p><b>404</b> - Order not found
* @param orderId ID of pet that needs to be fetched
* @return Order
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public Order getOrderById(Long orderId) throws RestClientException {
Object postBody = null;
// verify the required parameter 'orderId' is set
if (orderId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'orderId' when calling getOrderById");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("orderId", orderId);
String path = UriComponentsBuilder.fromPath("/store/order/{orderId}").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] {};
ParameterizedTypeReference<Order> returnType = new ParameterizedTypeReference<Order>() {
};
return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class StoreApi method deleteOrder.
/**
* Delete purchase order by ID
* For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors
* <p><b>400</b> - Invalid ID supplied
* <p><b>404</b> - Order not found
* @param orderId ID of the order that needs to be deleted
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void deleteOrder(Long orderId) throws RestClientException {
Object postBody = null;
// verify the required parameter 'orderId' is set
if (orderId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'orderId' when calling deleteOrder");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("orderId", orderId);
String path = UriComponentsBuilder.fromPath("/store/order/{orderId}").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] {};
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Aggregations