代码优先还是设计优先?说说API开发技术(五)

举报
Jet Ding 发表于 2021/07/26 09:42:52 2021/07/26
【摘要】 /** * Creates list of users with given input array * * @param body List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deser...
 /**

     * Creates list of users with given input array

     * 

     * @param body List of 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> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public void createUsersWithListInput(List<User> body) throws ApiException {

        createUsersWithListInputWithHttpInfo(body);

    }

 

    /**

     * Creates list of users with given input array

     * 

     * @param body List of user object (required)

     * @return ApiResponse&lt;Void&gt;

     * @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> createUsersWithListInputWithHttpInfo(List<User> body) throws ApiException {

        okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null);

        return localVarApiClient.execute(localVarCall);

    }

 

    /**

     * Creates list of users with given input array (asynchronously)

     * 

     * @param body List of 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> 0 </td><td> successful operation </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call createUsersWithListInputAsync(List<User> body, final ApiCallback<Void> _callback) throws ApiException {

 

        okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _callback);

        localVarApiClient.executeAsync(localVarCall, _callback);

        return localVarCall;

    }

    /**

     * Build call for deleteUser

     * @param username The name that needs to be deleted (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 username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException {

        Object localVarPostBody = null;

 

        // 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, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);

    }

 

    @SuppressWarnings("rawtypes")

    private okhttp3.Call deleteUserValidateBeforeCall(String username, 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 deleteUser(Async)");

        }

        

 

        okhttp3.Call localVarCall = deleteUserCall(username, _callback);

        return localVarCall;

 

    }

 

    /**

     * Delete user

     * This can only be done by the logged in user.

     * @param username The name that needs to be deleted (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 username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public void deleteUser(String username) throws ApiException {

        deleteUserWithHttpInfo(username);

    }

 

    /**

     * Delete user

     * This can only be done by the logged in user.

     * @param username The name that needs to be deleted (required)

     * @return ApiResponse&lt;Void&gt;

     * @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 username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public ApiResponse<Void> deleteUserWithHttpInfo(String username) throws ApiException {

        okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null);

        return localVarApiClient.execute(localVarCall);

    }

 

    /**

     * Delete user (asynchronously)

     * This can only be done by the logged in user.

     * @param username The name that needs to be deleted (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 username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call deleteUserAsync(String username, final ApiCallback<Void> _callback) throws ApiException {

 

        okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _callback);

        localVarApiClient.executeAsync(localVarCall, _callback);

        return localVarCall;

    }

    /**

     * Build call for getUserByName

     * @param username The name that needs to be fetched. Use user1 for testing. (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>  -  </td></tr>

        <tr><td> 400 </td><td> Invalid username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callback) throws ApiException {

        Object localVarPostBody = null;

 

        // 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 = {

            "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 getUserByNameValidateBeforeCall(String username, 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 getUserByName(Async)");

        }

        

 

        okhttp3.Call localVarCall = getUserByNameCall(username, _callback);

        return localVarCall;

 

    }

 

    /**

     * Get user by user name

     * 

     * @param username The name that needs to be fetched. Use user1 for testing. (required)

     * @return User

     * @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>  -  </td></tr>

        <tr><td> 400 </td><td> Invalid username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public User getUserByName(String username) throws ApiException {

        ApiResponse<User> localVarResp = getUserByNameWithHttpInfo(username);

        return localVarResp.getData();

    }

 

    /**

     * Get user by user name

     * 

     * @param username The name that needs to be fetched. Use user1 for testing. (required)

     * @return ApiResponse&lt;User&gt;

     * @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>  -  </td></tr>

        <tr><td> 400 </td><td> Invalid username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public ApiResponse<User> getUserByNameWithHttpInfo(String username) throws ApiException {

        okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null);

        Type localVarReturnType = new TypeToken<User>(){}.getType();

        return localVarApiClient.execute(localVarCall, localVarReturnType);

    }

 

    /**

     * Get user by user name (asynchronously)

     * 

     * @param username The name that needs to be fetched. Use user1 for testing. (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>  -  </td></tr>

        <tr><td> 400 </td><td> Invalid username supplied </td><td>  -  </td></tr>

        <tr><td> 404 </td><td> User not found </td><td>  -  </td></tr>

     </table>

     */

    public okhttp3.Call getUserByNameAsync(String username, final ApiCallback<User> _callback) throws ApiException {

 

        okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _callback);

        Type localVarReturnType = new TypeToken<User>(){}.getType();

        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);

        return localVarCall;

    }
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。