/*
 * Daytona
 * Daytona AI platform API Docs
 *
 * The version of the OpenAPI document: 1.0
 * Contact: support@daytona.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package io.daytona.api.client.api;

import io.daytona.api.client.ApiCallback;
import io.daytona.api.client.ApiClient;
import io.daytona.api.client.ApiException;
import io.daytona.api.client.ApiResponse;
import io.daytona.api.client.Configuration;
import io.daytona.api.client.Pair;
import io.daytona.api.client.ProgressRequestBody;
import io.daytona.api.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import io.daytona.api.client.model.ApiKeyList;
import io.daytona.api.client.model.ApiKeyResponse;
import io.daytona.api.client.model.CreateApiKey;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ApiKeysApi {
    private ApiClient localVarApiClient;
    private int localHostIndex;
    private String localCustomBaseUrl;

    public ApiKeysApi() {
        this(Configuration.getDefaultApiClient());
    }

    public ApiKeysApi(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return localVarApiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public int getHostIndex() {
        return localHostIndex;
    }

    public void setHostIndex(int hostIndex) {
        this.localHostIndex = hostIndex;
    }

    public String getCustomBaseUrl() {
        return localCustomBaseUrl;
    }

    public void setCustomBaseUrl(String customBaseUrl) {
        this.localCustomBaseUrl = customBaseUrl;
    }

    /**
     * Build call for createApiKey
     * @param createApiKey  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> API key created successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createApiKeyCall(@javax.annotation.Nonnull CreateApiKey createApiKey, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = createApiKey;

        // create path and map variables
        String localVarPath = "/api-keys";

        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/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        if (xDaytonaOrganizationID != null) {
            localVarHeaderParams.put("X-Daytona-Organization-ID", localVarApiClient.parameterToString(xDaytonaOrganizationID));
        }


        String[] localVarAuthNames = new String[] { "bearer", "oauth2" };
        return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call createApiKeyValidateBeforeCall(@javax.annotation.Nonnull CreateApiKey createApiKey, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        // verify the required parameter 'createApiKey' is set
        if (createApiKey == null) {
            throw new ApiException("Missing the required parameter 'createApiKey' when calling createApiKey(Async)");
        }

        return createApiKeyCall(createApiKey, xDaytonaOrganizationID, _callback);

    }

    /**
     * Create API key
     * 
     * @param createApiKey  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiKeyResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> API key created successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiKeyResponse createApiKey(@javax.annotation.Nonnull CreateApiKey createApiKey, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        ApiResponse<ApiKeyResponse> localVarResp = createApiKeyWithHttpInfo(createApiKey, xDaytonaOrganizationID);
        return localVarResp.getData();
    }

    /**
     * Create API key
     * 
     * @param createApiKey  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiResponse&lt;ApiKeyResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> API key created successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<ApiKeyResponse> createApiKeyWithHttpInfo(@javax.annotation.Nonnull CreateApiKey createApiKey, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        okhttp3.Call localVarCall = createApiKeyValidateBeforeCall(createApiKey, xDaytonaOrganizationID, null);
        Type localVarReturnType = new TypeToken<ApiKeyResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Create API key (asynchronously)
     * 
     * @param createApiKey  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> API key created successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createApiKeyAsync(@javax.annotation.Nonnull CreateApiKey createApiKey, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback<ApiKeyResponse> _callback) throws ApiException {

        okhttp3.Call localVarCall = createApiKeyValidateBeforeCall(createApiKey, xDaytonaOrganizationID, _callback);
        Type localVarReturnType = new TypeToken<ApiKeyResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for deleteApiKey
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteApiKeyCall(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api-keys/{name}"
            .replace("{" + "name" + "}", localVarApiClient.escapeString(name.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);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        if (xDaytonaOrganizationID != null) {
            localVarHeaderParams.put("X-Daytona-Organization-ID", localVarApiClient.parameterToString(xDaytonaOrganizationID));
        }


        String[] localVarAuthNames = new String[] { "bearer", "oauth2" };
        return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call deleteApiKeyValidateBeforeCall(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling deleteApiKey(Async)");
        }

        return deleteApiKeyCall(name, xDaytonaOrganizationID, _callback);

    }

    /**
     * Delete API key
     * 
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public void deleteApiKey(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        deleteApiKeyWithHttpInfo(name, xDaytonaOrganizationID);
    }

    /**
     * Delete API key
     * 
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Void> deleteApiKeyWithHttpInfo(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        okhttp3.Call localVarCall = deleteApiKeyValidateBeforeCall(name, xDaytonaOrganizationID, null);
        return localVarApiClient.execute(localVarCall);
    }

    /**
     * Delete API key (asynchronously)
     * 
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteApiKeyAsync(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback<Void> _callback) throws ApiException {

        okhttp3.Call localVarCall = deleteApiKeyValidateBeforeCall(name, xDaytonaOrganizationID, _callback);
        localVarApiClient.executeAsync(localVarCall, _callback);
        return localVarCall;
    }
    /**
     * Build call for deleteApiKeyForUser
     * @param userId  (required)
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteApiKeyForUserCall(@javax.annotation.Nonnull String userId, @javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api-keys/{userId}/{name}"
            .replace("{" + "userId" + "}", localVarApiClient.escapeString(userId.toString()))
            .replace("{" + "name" + "}", localVarApiClient.escapeString(name.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);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        if (xDaytonaOrganizationID != null) {
            localVarHeaderParams.put("X-Daytona-Organization-ID", localVarApiClient.parameterToString(xDaytonaOrganizationID));
        }


        String[] localVarAuthNames = new String[] { "bearer", "oauth2" };
        return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call deleteApiKeyForUserValidateBeforeCall(@javax.annotation.Nonnull String userId, @javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        // verify the required parameter 'userId' is set
        if (userId == null) {
            throw new ApiException("Missing the required parameter 'userId' when calling deleteApiKeyForUser(Async)");
        }

        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling deleteApiKeyForUser(Async)");
        }

        return deleteApiKeyForUserCall(userId, name, xDaytonaOrganizationID, _callback);

    }

    /**
     * Delete API key for user
     * 
     * @param userId  (required)
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public void deleteApiKeyForUser(@javax.annotation.Nonnull String userId, @javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        deleteApiKeyForUserWithHttpInfo(userId, name, xDaytonaOrganizationID);
    }

    /**
     * Delete API key for user
     * 
     * @param userId  (required)
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Void> deleteApiKeyForUserWithHttpInfo(@javax.annotation.Nonnull String userId, @javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        okhttp3.Call localVarCall = deleteApiKeyForUserValidateBeforeCall(userId, name, xDaytonaOrganizationID, null);
        return localVarApiClient.execute(localVarCall);
    }

    /**
     * Delete API key for user (asynchronously)
     * 
     * @param userId  (required)
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> API key deleted successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteApiKeyForUserAsync(@javax.annotation.Nonnull String userId, @javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback<Void> _callback) throws ApiException {

        okhttp3.Call localVarCall = deleteApiKeyForUserValidateBeforeCall(userId, name, xDaytonaOrganizationID, _callback);
        localVarApiClient.executeAsync(localVarCall, _callback);
        return localVarCall;
    }
    /**
     * Build call for getApiKey
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getApiKeyCall(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api-keys/{name}"
            .replace("{" + "name" + "}", localVarApiClient.escapeString(name.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/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        if (xDaytonaOrganizationID != null) {
            localVarHeaderParams.put("X-Daytona-Organization-ID", localVarApiClient.parameterToString(xDaytonaOrganizationID));
        }


        String[] localVarAuthNames = new String[] { "bearer", "oauth2" };
        return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getApiKeyValidateBeforeCall(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling getApiKey(Async)");
        }

        return getApiKeyCall(name, xDaytonaOrganizationID, _callback);

    }

    /**
     * Get API key
     * 
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiKeyList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiKeyList getApiKey(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        ApiResponse<ApiKeyList> localVarResp = getApiKeyWithHttpInfo(name, xDaytonaOrganizationID);
        return localVarResp.getData();
    }

    /**
     * Get API key
     * 
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiResponse&lt;ApiKeyList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<ApiKeyList> getApiKeyWithHttpInfo(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        okhttp3.Call localVarCall = getApiKeyValidateBeforeCall(name, xDaytonaOrganizationID, null);
        Type localVarReturnType = new TypeToken<ApiKeyList>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get API key (asynchronously)
     * 
     * @param name  (required)
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getApiKeyAsync(@javax.annotation.Nonnull String name, @javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback<ApiKeyList> _callback) throws ApiException {

        okhttp3.Call localVarCall = getApiKeyValidateBeforeCall(name, xDaytonaOrganizationID, _callback);
        Type localVarReturnType = new TypeToken<ApiKeyList>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getCurrentApiKey
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getCurrentApiKeyCall(@javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api-keys/current";

        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/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        if (xDaytonaOrganizationID != null) {
            localVarHeaderParams.put("X-Daytona-Organization-ID", localVarApiClient.parameterToString(xDaytonaOrganizationID));
        }


        String[] localVarAuthNames = new String[] { "bearer", "oauth2" };
        return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getCurrentApiKeyValidateBeforeCall(@javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        return getCurrentApiKeyCall(xDaytonaOrganizationID, _callback);

    }

    /**
     * Get current API key&#39;s details
     * 
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiKeyList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiKeyList getCurrentApiKey(@javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        ApiResponse<ApiKeyList> localVarResp = getCurrentApiKeyWithHttpInfo(xDaytonaOrganizationID);
        return localVarResp.getData();
    }

    /**
     * Get current API key&#39;s details
     * 
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiResponse&lt;ApiKeyList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<ApiKeyList> getCurrentApiKeyWithHttpInfo(@javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        okhttp3.Call localVarCall = getCurrentApiKeyValidateBeforeCall(xDaytonaOrganizationID, null);
        Type localVarReturnType = new TypeToken<ApiKeyList>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get current API key&#39;s details (asynchronously)
     * 
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API key retrieved successfully. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getCurrentApiKeyAsync(@javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback<ApiKeyList> _callback) throws ApiException {

        okhttp3.Call localVarCall = getCurrentApiKeyValidateBeforeCall(xDaytonaOrganizationID, _callback);
        Type localVarReturnType = new TypeToken<ApiKeyList>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for listApiKeys
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API keys retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Error fetching API keys. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call listApiKeysCall(@javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        String basePath = null;
        // Operation Servers
        String[] localBasePaths = new String[] {  };

        // Determine Base Path to Use
        if (localCustomBaseUrl != null){
            basePath = localCustomBaseUrl;
        } else if ( localBasePaths.length > 0 ) {
            basePath = localBasePaths[localHostIndex];
        } else {
            basePath = null;
        }

        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api-keys";

        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/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        if (xDaytonaOrganizationID != null) {
            localVarHeaderParams.put("X-Daytona-Organization-ID", localVarApiClient.parameterToString(xDaytonaOrganizationID));
        }


        String[] localVarAuthNames = new String[] { "bearer", "oauth2" };
        return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call listApiKeysValidateBeforeCall(@javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback _callback) throws ApiException {
        return listApiKeysCall(xDaytonaOrganizationID, _callback);

    }

    /**
     * List API keys
     * 
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return List&lt;ApiKeyList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API keys retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Error fetching API keys. </td><td>  -  </td></tr>
     </table>
     */
    public List<ApiKeyList> listApiKeys(@javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        ApiResponse<List<ApiKeyList>> localVarResp = listApiKeysWithHttpInfo(xDaytonaOrganizationID);
        return localVarResp.getData();
    }

    /**
     * List API keys
     * 
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @return ApiResponse&lt;List&lt;ApiKeyList&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API keys retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Error fetching API keys. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<List<ApiKeyList>> listApiKeysWithHttpInfo(@javax.annotation.Nullable String xDaytonaOrganizationID) throws ApiException {
        okhttp3.Call localVarCall = listApiKeysValidateBeforeCall(xDaytonaOrganizationID, null);
        Type localVarReturnType = new TypeToken<List<ApiKeyList>>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * List API keys (asynchronously)
     * 
     * @param xDaytonaOrganizationID Use with JWT to specify the organization ID (optional)
     * @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 border="1">
       <caption>Response Details</caption>
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> API keys retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Error fetching API keys. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call listApiKeysAsync(@javax.annotation.Nullable String xDaytonaOrganizationID, final ApiCallback<List<ApiKeyList>> _callback) throws ApiException {

        okhttp3.Call localVarCall = listApiKeysValidateBeforeCall(xDaytonaOrganizationID, _callback);
        Type localVarReturnType = new TypeToken<List<ApiKeyList>>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
