use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class PetApi method addPet.
/**
* Add a new pet to the store
*
* <p><b>405</b> - Invalid input
* @param body Pet object that needs to be added to the store
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void addPet(Pet body) throws RestClientException {
Object postBody = body;
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling addPet");
}
String path = UriComponentsBuilder.fromPath("/pet").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>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = { "application/json", "application/xml" };
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "petstore_auth" };
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class UserApi method updateUser.
/**
* Updated user
* This can only be done by the logged in user.
* <p><b>400</b> - Invalid user supplied
* <p><b>404</b> - User not found
* @param username name that need to be updated
* @param body Updated user object
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void updateUser(String username, User body) throws RestClientException {
Object postBody = body;
// verify the required parameter 'username' is set
if (username == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'username' when calling updateUser");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling updateUser");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("username", username);
String path = UriComponentsBuilder.fromPath("/user/{username}").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.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class UserApi method deleteUser.
/**
* Delete user
* This can only be done by the logged in user.
* <p><b>400</b> - Invalid username supplied
* <p><b>404</b> - User not found
* @param username The name that needs to be deleted
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void deleteUser(String username) throws RestClientException {
Object postBody = null;
// verify the required parameter 'username' is set
if (username == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'username' when calling deleteUser");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("username", username);
String path = UriComponentsBuilder.fromPath("/user/{username}").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);
}
use of org.springframework.web.client.HttpClientErrorException in project tutorials by eugenp.
the class UserApi method getUserByName.
/**
* Get user by user name
*
* <p><b>200</b> - successful operation
* <p><b>400</b> - Invalid username supplied
* <p><b>404</b> - User not found
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public User getUserByName(String username) throws RestClientException {
Object postBody = null;
// verify the required parameter 'username' is set
if (username == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'username' when calling getUserByName");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("username", username);
String path = UriComponentsBuilder.fromPath("/user/{username}").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<User> returnType = new ParameterizedTypeReference<User>() {
};
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 UserApi method createUsersWithArrayInput.
/**
* Creates list of users with given input array
*
* <p><b>0</b> - successful operation
* @param body List of user object
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void createUsersWithArrayInput(List<User> body) throws RestClientException {
Object postBody = body;
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUsersWithArrayInput");
}
String path = UriComponentsBuilder.fromPath("/user/createWithArray").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>();
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.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Aggregations