代码优先还是设计优先?说说API开发技术(六)
【摘要】 /** * Build call for loginUser * @param username The user name for login (required) * @param password The password for login in clear text (required) * @param _callback Callback for...
/**
* Build call for loginUser
* @param username The user name for login (required)
* @param password The password for login in clear text (required)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> successful operation </td><td> * X-Rate-Limit - calls per hour allowed by the user <br> * X-Expires-After - date in UTC when toekn expires <br> </td></tr>
<tr><td> 400 </td><td> Invalid username/password supplied </td><td> - </td></tr>
</table>
*/
public okhttp3.Call loginUserCall(String username, String password, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/user/login";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (username != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("username", username));
}
if (password != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("password", password));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/xml", "application/json"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'username' is set
if (username == null) {
throw new ApiException("Missing the required parameter 'username' when calling loginUser(Async)");
}
// verify the required parameter 'password' is set
if (password == null) {
throw new ApiException("Missing the required parameter 'password' when calling loginUser(Async)");
}
okhttp3.Call localVarCall = loginUserCall(username, password, _callback);
return localVarCall;
}
/**
* Logs user into the system
*
* @param username The user name for login (required)
* @param password The password for login in clear text (required)
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> successful operation </td><td> * X-Rate-Limit - calls per hour allowed by the user <br> * X-Expires-After - date in UTC when toekn expires <br> </td></tr>
<tr><td> 400 </td><td> Invalid username/password supplied </td><td> - </td></tr>
</table>
*/
public String loginUser(String username, String password) throws ApiException {
ApiResponse<String> localVarResp = loginUserWithHttpInfo(username, password);
return localVarResp.getData();
}
/**
* Logs user into the system
*
* @param username The user name for login (required)
* @param password The password for login in clear text (required)
* @return ApiResponse<String>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> successful operation </td><td> * X-Rate-Limit - calls per hour allowed by the user <br> * X-Expires-After - date in UTC when toekn expires <br> </td></tr>
<tr><td> 400 </td><td> Invalid username/password supplied </td><td> - </td></tr>
</table>
*/
public ApiResponse<String> loginUserWithHttpInfo(String username, String password) throws ApiException {
okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
/**
* Logs user into the system (asynchronously)
*
* @param username The user name for login (required)
* @param password The password for login in clear text (required)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> successful operation </td><td> * X-Rate-Limit - calls per hour allowed by the user <br> * X-Expires-After - date in UTC when toekn expires <br> </td></tr>
<tr><td> 400 </td><td> Invalid username/password supplied </td><td> - </td></tr>
</table>
*/
public okhttp3.Call loginUserAsync(String username, String password, final ApiCallback<String> _callback) throws ApiException {
okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for logoutUser
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 0 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/user/logout";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call logoutUserValidateBeforeCall(final ApiCallback _callback) throws ApiException {
okhttp3.Call localVarCall = logoutUserCall(_callback);
return localVarCall;
}
/**
* Logs out current logged in user session
*
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 0 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public void logoutUser() throws ApiException {
logoutUserWithHttpInfo();
}
/**
* Logs out current logged in user session
*
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 0 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> logoutUserWithHttpInfo() throws ApiException {
okhttp3.Call localVarCall = logoutUserValidateBeforeCall(null);
return localVarApiClient.execute(localVarCall);
}
/**
* Logs out current logged in user session (asynchronously)
*
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 0 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call logoutUserAsync(final ApiCallback<Void> _callback) throws ApiException {
okhttp3.Call localVarCall = logoutUserValidateBeforeCall(_callback);
localVarApiClient.executeAsync(localVarCall, _callback);
return localVarCall;
}
/**
* Build call for updateUser
* @param username name that need to be deleted (required)
* @param body Updated user object (required)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 400 </td><td> Invalid user supplied </td><td> - </td></tr>
<tr><td> 404 </td><td> User not found </td><td> - </td></tr>
</table>
*/
public okhttp3.Call updateUserCall(String username, User body, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = body;
// create path and map variables
String localVarPath = "/user/{username}"
.replaceAll("\\{" + "username" + "\\}", localVarApiClient.escapeString(username.toString()));
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call updateUserValidateBeforeCall(String username, User body, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'username' is set
if (username == null) {
throw new ApiException("Missing the required parameter 'username' when calling updateUser(Async)");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException("Missing the required parameter 'body' when calling updateUser(Async)");
}
okhttp3.Call localVarCall = updateUserCall(username, body, _callback);
return localVarCall;
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted (required)
* @param body Updated user object (required)
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 400 </td><td> Invalid user supplied </td><td> - </td></tr>
<tr><td> 404 </td><td> User not found </td><td> - </td></tr>
</table>
*/
public void updateUser(String username, User body) throws ApiException {
updateUserWithHttpInfo(username, body);
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted (required)
* @param body Updated user object (required)
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 400 </td><td> Invalid user supplied </td><td> - </td></tr>
<tr><td> 404 </td><td> User not found </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> updateUserWithHttpInfo(String username, User body) throws ApiException {
okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, null);
return localVarApiClient.execute(localVarCall);
}
/**
* Updated user (asynchronously)
* This can only be done by the logged in user.
* @param username name that need to be deleted (required)
* @param body Updated user object (required)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 400 </td><td> Invalid user supplied </td><td> - </td></tr>
<tr><td> 404 </td><td> User not found </td><td> - </td></tr>
</table>
*/
public okhttp3.Call updateUserAsync(String username, User body, final ApiCallback<Void> _callback) throws ApiException {
okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, body, _callback);
localVarApiClient.executeAsync(localVarCall, _callback);
return localVarCall;
}
}
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)