diff --git a/clients/java/pom.xml b/clients/java/pom.xml index f5f7958..eaa6c9a 100644 --- a/clients/java/pom.xml +++ b/clients/java/pom.xml @@ -200,6 +200,59 @@ ${junit-version} test + + + io.grpc + grpc-netty-shaded + ${grpc.version} + + + io.grpc + grpc-protobuf + ${grpc.version} + + + io.grpc + grpc-stub + ${grpc.version} + + + io.grpc + grpc-api + ${grpc.version} + + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + org.apache.httpcomponents + httpclient + 4.5.14 + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.17.2 + + + org.openapitools + jackson-databind-nullable + 0.2.6 + + + javax.ws.rs + javax.ws.rs-api + 2.1.1 + + @@ -210,6 +263,8 @@ 1.5.15 2.8.1 2.9.9 + 1.60.0 + 4.34.0 1.0.0 4.13.1 UTF-8 diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiCallback.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiCallback.java new file mode 100644 index 0000000..1cb9717 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiCallback.java @@ -0,0 +1,62 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiClient.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiClient.java new file mode 100644 index 0000000..7a33449 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiClient.java @@ -0,0 +1,1570 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.openkruise.agents.client.e2b.api.invoker.auth.Authentication; +import io.openkruise.agents.client.e2b.api.invoker.auth.HttpBasicAuth; +import io.openkruise.agents.client.e2b.api.invoker.auth.HttpBearerAuth; +import io.openkruise.agents.client.e2b.api.invoker.auth.ApiKeyAuth; + +/** + *

ApiClient class.

+ */ +public class ApiClient { + + private String basePath = "https://api.e2b.app"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + "https://api.e2b.app", + "No description provided", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("ApiKeyAuth", new ApiKeyAuth("header", "X-API-Key")); + authentications.put("AccessTokenAuth", new HttpBearerAuth("bearer")); + authentications.put("Supabase1TokenAuth", new ApiKeyAuth("header", "X-Supabase-Token")); + authentications.put("Supabase2TeamAuth", new ApiKeyAuth("header", "X-Supabase-Team")); + authentications.put("AdminTokenAuth", new ApiKeyAuth("header", "X-Admin-Token")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("ApiKeyAuth", new ApiKeyAuth("header", "X-API-Key")); + authentications.put("AccessTokenAuth", new HttpBearerAuth("bearer")); + authentications.put("Supabase1TokenAuth", new ApiKeyAuth("header", "X-Supabase-Token")); + authentications.put("Supabase2TeamAuth", new ApiKeyAuth("header", "X-Supabase-Team")); + authentications.put("AdminTokenAuth", new ApiKeyAuth("header", "X-Admin-Token")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + private void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor: interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + private void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/0.1.0/java"); + + authentications = new HashMap(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://api.e2b.app + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link DateFormat} object + * @return a {@link ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + JSON.setDateFormat(dateFormat); + return this; + } + + /** + *

Set SqlDateFormat.

+ * + * @param dateFormat a {@link DateFormat} object + * @return a {@link ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

Set OffsetDateTimeFormat.

+ * + * @param dateFormat a {@link DateTimeFormatter} object + * @return a {@link ApiClient} object + */ + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setOffsetDateTimeFormat(dateFormat); + return this; + } + + /** + *

Set LocalDateFormat.

+ * + * @param dateFormat a {@link DateTimeFormatter} object + * @return a {@link ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set access token for the first Bearer authentication. + * @param bearerToken Bearer token + */ + public void setBearerToken(String bearerToken) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBearerAuth) { + ((HttpBearerAuth) auth).setBearerToken(bearerToken); + return; + } + } + throw new RuntimeException("No Bearer authentication configured!"); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(".*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * returns null. If it matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws ApiException If fail to read file content from response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) + prefix = "download-"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. + * @throws ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws ApiException If the response has an unsuccessful status code or + * fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws ApiException If fail to serialize the request body object + */ + public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws ApiException If fail to serialize the request body object + */ + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentType)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentType)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create("", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + FormBody.Builder formBuilder = new FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + private Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws ApiException If fail to serialize the request body object into a string + */ + private String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiException.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiException.java new file mode 100644 index 0000000..7935ad1 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiException.java @@ -0,0 +1,166 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import java.util.Map; +import java.util.List; + +import javax.ws.rs.core.GenericType; + +/** + *

ApiException class.

+ */ +@SuppressWarnings("serial") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class ApiException extends Exception { + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

+ */ + public ApiException() {} + + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this("Response Code: " + code + " Response Body: " + responseBody, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiResponse.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiResponse.java new file mode 100644 index 0000000..7cfbbf0 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ApiResponse.java @@ -0,0 +1,76 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + /** + *

Get the status code.

+ * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + *

Get the headers.

+ * + * @return a {@link Map} of headers + */ + public Map> getHeaders() { + return headers; + } + + /** + *

Get the data.

+ * + * @return the data + */ + public T getData() { + return data; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/Configuration.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/Configuration.java new file mode 100644 index 0000000..18ade6d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/Configuration.java @@ -0,0 +1,41 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Configuration { + public static final String VERSION = "0.1.0"; + + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/GzipRequestInterceptor.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/GzipRequestInterceptor.java new file mode 100644 index 0000000..ee348f8 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/GzipRequestInterceptor.java @@ -0,0 +1,85 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/JSON.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/JSON.java new file mode 100644 index 0000000..b130f5c --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/JSON.java @@ -0,0 +1,485 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + +import okio.ByteString; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + .registerTypeSelector(io.openkruise.agents.client.e2b.api.models.FromImageRegistry.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("AWSRegistry", io.openkruise.agents.client.e2b.api.models.AWSRegistry.class); + classByDiscriminatorValue.put("GCPRegistry", io.openkruise.agents.client.e2b.api.models.GCPRegistry.class); + classByDiscriminatorValue.put("GeneralRegistry", io.openkruise.agents.client.e2b.api.models.GeneralRegistry.class); + classByDiscriminatorValue.put("aws", io.openkruise.agents.client.e2b.api.models.AWSRegistry.class); + classByDiscriminatorValue.put("gcp", io.openkruise.agents.client.e2b.api.models.GCPRegistry.class); + classByDiscriminatorValue.put("registry", io.openkruise.agents.client.e2b.api.models.GeneralRegistry.class); + classByDiscriminatorValue.put("FromImageRegistry", io.openkruise.agents.client.e2b.api.models.FromImageRegistry.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "type")); + } + }) + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.AWSRegistry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.AdminSandboxKillResult.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.AssignTemplateTagsRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.AssignedTemplateTags.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.BuildLogEntry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.BuildStatusReason.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.ConnectSandbox.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.CreatedAccessToken.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.CreatedTeamAPIKey.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.DeleteTemplateTagsRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.DiskMetrics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.Error.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.FromImageRegistry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.GCPRegistry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.GeneralRegistry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.IdentifierMaskingDetails.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.ListedSandbox.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.MachineInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.MaxTeamMetric.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NewAccessToken.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NewSandbox.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NewTeamAPIKey.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NewVolume.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.Node.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NodeDetail.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NodeMetrics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NodeStatusChange.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.NodesGet200ResponseInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.ResumedSandbox.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.Sandbox.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxAutoResumeConfig.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxDetail.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxLog.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxLogEntry.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxLogs.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxLogsV2Response.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxMetric.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxNetworkConfig.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxVolumeMount.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxesGet200ResponseInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxesSandboxIDRefreshesPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxesSandboxIDSnapshotsPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxesSandboxIDTimeoutPostRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SandboxesWithMetrics.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.SnapshotInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.Team.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TeamAPIKey.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TeamMetric.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TeamUser.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TeamsGet200ResponseInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.Template.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateAliasResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuild.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildFileUpload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildInfo.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildLogsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildRequestV2.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildRequestV3.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateBuildStartV2.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateLegacy.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateRequestResponseV3.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateStep.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateTag.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateUpdateRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateUpdateResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplateWithBuilds.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.TemplatesGet200ResponseInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.UpdateTeamAPIKey.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.openkruise.agents.client.e2b.api.models.Volume.CustomTypeAdapterFactory()); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/Pair.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/Pair.java new file mode 100644 index 0000000..daf8c54 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/Pair.java @@ -0,0 +1,57 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ProgressRequestBody.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ProgressRequestBody.java new file mode 100644 index 0000000..60c8d83 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ProgressRequestBody.java @@ -0,0 +1,73 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ProgressResponseBody.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ProgressResponseBody.java new file mode 100644 index 0000000..fa126cd --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ProgressResponseBody.java @@ -0,0 +1,70 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ServerConfiguration.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ServerConfiguration.java new file mode 100644 index 0000000..5ce1af1 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ServerConfiguration.java @@ -0,0 +1,58 @@ +package io.openkruise.agents.client.e2b.api.invoker; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ServerVariable.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ServerVariable.java new file mode 100644 index 0000000..1c49f75 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/ServerVariable.java @@ -0,0 +1,23 @@ +package io.openkruise.agents.client.e2b.api.invoker; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/StringUtil.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/StringUtil.java new file mode 100644 index 0000000..d989c0d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/StringUtil.java @@ -0,0 +1,83 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/ApiKeyAuth.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/ApiKeyAuth.java new file mode 100644 index 0000000..ee65c94 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/ApiKeyAuth.java @@ -0,0 +1,80 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker.auth; + +import io.openkruise.agents.client.e2b.api.invoker.ApiException; +import io.openkruise.agents.client.e2b.api.invoker.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/Authentication.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/Authentication.java new file mode 100644 index 0000000..8abe0d6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/Authentication.java @@ -0,0 +1,36 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker.auth; + +import io.openkruise.agents.client.e2b.api.invoker.Pair; +import io.openkruise.agents.client.e2b.api.invoker.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/HttpBasicAuth.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/HttpBasicAuth.java new file mode 100644 index 0000000..d6b12ab --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/HttpBasicAuth.java @@ -0,0 +1,57 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker.auth; + +import io.openkruise.agents.client.e2b.api.invoker.Pair; +import io.openkruise.agents.client.e2b.api.invoker.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/HttpBearerAuth.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/HttpBearerAuth.java new file mode 100644 index 0000000..ae64b7a --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/invoker/auth/HttpBearerAuth.java @@ -0,0 +1,63 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.invoker.auth; + +import io.openkruise.agents.client.e2b.api.invoker.ApiException; +import io.openkruise.agents.client.e2b.api.invoker.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AWSRegistry.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AWSRegistry.java new file mode 100644 index 0000000..736ae23 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AWSRegistry.java @@ -0,0 +1,432 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * AWSRegistry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class AWSRegistry { + /** + * Type of registry authentication + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + AWS("aws"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_AWS_ACCESS_KEY_ID = "awsAccessKeyId"; + @SerializedName(SERIALIZED_NAME_AWS_ACCESS_KEY_ID) + private String awsAccessKeyId; + + public static final String SERIALIZED_NAME_AWS_SECRET_ACCESS_KEY = "awsSecretAccessKey"; + @SerializedName(SERIALIZED_NAME_AWS_SECRET_ACCESS_KEY) + private String awsSecretAccessKey; + + public static final String SERIALIZED_NAME_AWS_REGION = "awsRegion"; + @SerializedName(SERIALIZED_NAME_AWS_REGION) + private String awsRegion; + + public AWSRegistry() { + } + + public AWSRegistry type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Type of registry authentication + * @return type + **/ + @javax.annotation.Nonnull + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public AWSRegistry awsAccessKeyId(String awsAccessKeyId) { + + this.awsAccessKeyId = awsAccessKeyId; + return this; + } + + /** + * AWS Access Key ID for ECR authentication + * @return awsAccessKeyId + **/ + @javax.annotation.Nonnull + public String getAwsAccessKeyId() { + return awsAccessKeyId; + } + + + public void setAwsAccessKeyId(String awsAccessKeyId) { + this.awsAccessKeyId = awsAccessKeyId; + } + + + public AWSRegistry awsSecretAccessKey(String awsSecretAccessKey) { + + this.awsSecretAccessKey = awsSecretAccessKey; + return this; + } + + /** + * AWS Secret Access Key for ECR authentication + * @return awsSecretAccessKey + **/ + @javax.annotation.Nonnull + public String getAwsSecretAccessKey() { + return awsSecretAccessKey; + } + + + public void setAwsSecretAccessKey(String awsSecretAccessKey) { + this.awsSecretAccessKey = awsSecretAccessKey; + } + + + public AWSRegistry awsRegion(String awsRegion) { + + this.awsRegion = awsRegion; + return this; + } + + /** + * AWS Region where the ECR registry is located + * @return awsRegion + **/ + @javax.annotation.Nonnull + public String getAwsRegion() { + return awsRegion; + } + + + public void setAwsRegion(String awsRegion) { + this.awsRegion = awsRegion; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AWSRegistry instance itself + */ + public AWSRegistry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AWSRegistry awSRegistry = (AWSRegistry) o; + return Objects.equals(this.type, awSRegistry.type) && + Objects.equals(this.awsAccessKeyId, awSRegistry.awsAccessKeyId) && + Objects.equals(this.awsSecretAccessKey, awSRegistry.awsSecretAccessKey) && + Objects.equals(this.awsRegion, awSRegistry.awsRegion)&& + Objects.equals(this.additionalProperties, awSRegistry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, awsAccessKeyId, awsSecretAccessKey, awsRegion, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AWSRegistry {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" awsAccessKeyId: ").append(toIndentedString(awsAccessKeyId)).append("\n"); + sb.append(" awsSecretAccessKey: ").append(toIndentedString(awsSecretAccessKey)).append("\n"); + sb.append(" awsRegion: ").append(toIndentedString(awsRegion)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("awsAccessKeyId"); + openapiFields.add("awsSecretAccessKey"); + openapiFields.add("awsRegion"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("awsAccessKeyId"); + openapiRequiredFields.add("awsSecretAccessKey"); + openapiRequiredFields.add("awsRegion"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AWSRegistry + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AWSRegistry.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AWSRegistry is not found in the empty JSON string", AWSRegistry.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AWSRegistry.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("awsAccessKeyId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `awsAccessKeyId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("awsAccessKeyId").toString())); + } + if (!jsonObj.get("awsSecretAccessKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `awsSecretAccessKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("awsSecretAccessKey").toString())); + } + if (!jsonObj.get("awsRegion").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `awsRegion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("awsRegion").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AWSRegistry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AWSRegistry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AWSRegistry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AWSRegistry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public AWSRegistry read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + AWSRegistry instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AWSRegistry given an JSON string + * + * @param jsonString JSON string + * @return An instance of AWSRegistry + * @throws IOException if the JSON string is invalid with respect to AWSRegistry + */ + public static AWSRegistry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AWSRegistry.class); + } + + /** + * Convert an instance of AWSRegistry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AbstractOpenApiSchema.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AbstractOpenApiSchema.java new file mode 100644 index 0000000..2a2b5fa --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AbstractOpenApiSchema.java @@ -0,0 +1,149 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import io.openkruise.agents.client.e2b.api.invoker.ApiException; +import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; +import javax.ws.rs.core.GenericType; + +//import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + //@JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AdminSandboxKillResult.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AdminSandboxKillResult.java new file mode 100644 index 0000000..6f81994 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AdminSandboxKillResult.java @@ -0,0 +1,317 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * AdminSandboxKillResult + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class AdminSandboxKillResult { + public static final String SERIALIZED_NAME_KILLED_COUNT = "killedCount"; + @SerializedName(SERIALIZED_NAME_KILLED_COUNT) + private Integer killedCount; + + public static final String SERIALIZED_NAME_FAILED_COUNT = "failedCount"; + @SerializedName(SERIALIZED_NAME_FAILED_COUNT) + private Integer failedCount; + + public AdminSandboxKillResult() { + } + + public AdminSandboxKillResult killedCount(Integer killedCount) { + + this.killedCount = killedCount; + return this; + } + + /** + * Number of sandboxes successfully killed + * @return killedCount + **/ + @javax.annotation.Nonnull + public Integer getKilledCount() { + return killedCount; + } + + + public void setKilledCount(Integer killedCount) { + this.killedCount = killedCount; + } + + + public AdminSandboxKillResult failedCount(Integer failedCount) { + + this.failedCount = failedCount; + return this; + } + + /** + * Number of sandboxes that failed to kill + * @return failedCount + **/ + @javax.annotation.Nonnull + public Integer getFailedCount() { + return failedCount; + } + + + public void setFailedCount(Integer failedCount) { + this.failedCount = failedCount; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdminSandboxKillResult instance itself + */ + public AdminSandboxKillResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdminSandboxKillResult adminSandboxKillResult = (AdminSandboxKillResult) o; + return Objects.equals(this.killedCount, adminSandboxKillResult.killedCount) && + Objects.equals(this.failedCount, adminSandboxKillResult.failedCount)&& + Objects.equals(this.additionalProperties, adminSandboxKillResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(killedCount, failedCount, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdminSandboxKillResult {\n"); + sb.append(" killedCount: ").append(toIndentedString(killedCount)).append("\n"); + sb.append(" failedCount: ").append(toIndentedString(failedCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("killedCount"); + openapiFields.add("failedCount"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("killedCount"); + openapiRequiredFields.add("failedCount"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdminSandboxKillResult + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdminSandboxKillResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdminSandboxKillResult is not found in the empty JSON string", AdminSandboxKillResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AdminSandboxKillResult.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdminSandboxKillResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdminSandboxKillResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdminSandboxKillResult.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdminSandboxKillResult value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public AdminSandboxKillResult read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + AdminSandboxKillResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AdminSandboxKillResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdminSandboxKillResult + * @throws IOException if the JSON string is invalid with respect to AdminSandboxKillResult + */ + public static AdminSandboxKillResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdminSandboxKillResult.class); + } + + /** + * Convert an instance of AdminSandboxKillResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AssignTemplateTagsRequest.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AssignTemplateTagsRequest.java new file mode 100644 index 0000000..f22fea7 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AssignTemplateTagsRequest.java @@ -0,0 +1,336 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * AssignTemplateTagsRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class AssignTemplateTagsRequest { + public static final String SERIALIZED_NAME_TARGET = "target"; + @SerializedName(SERIALIZED_NAME_TARGET) + private String target; + + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) + private List tags = new ArrayList<>(); + + public AssignTemplateTagsRequest() { + } + + public AssignTemplateTagsRequest target(String target) { + + this.target = target; + return this; + } + + /** + * Target template in \"name:tag\" format + * @return target + **/ + @javax.annotation.Nonnull + public String getTarget() { + return target; + } + + + public void setTarget(String target) { + this.target = target; + } + + + public AssignTemplateTagsRequest tags(List tags) { + + this.tags = tags; + return this; + } + + public AssignTemplateTagsRequest addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Tags to assign to the template + * @return tags + **/ + @javax.annotation.Nonnull + public List getTags() { + return tags; + } + + + public void setTags(List tags) { + this.tags = tags; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AssignTemplateTagsRequest instance itself + */ + public AssignTemplateTagsRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AssignTemplateTagsRequest assignTemplateTagsRequest = (AssignTemplateTagsRequest) o; + return Objects.equals(this.target, assignTemplateTagsRequest.target) && + Objects.equals(this.tags, assignTemplateTagsRequest.tags)&& + Objects.equals(this.additionalProperties, assignTemplateTagsRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(target, tags, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AssignTemplateTagsRequest {\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("target"); + openapiFields.add("tags"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("target"); + openapiRequiredFields.add("tags"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AssignTemplateTagsRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AssignTemplateTagsRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AssignTemplateTagsRequest is not found in the empty JSON string", AssignTemplateTagsRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AssignTemplateTagsRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("target").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); + } + // ensure the required json array is present + if (jsonObj.get("tags") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AssignTemplateTagsRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AssignTemplateTagsRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AssignTemplateTagsRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AssignTemplateTagsRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public AssignTemplateTagsRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + AssignTemplateTagsRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AssignTemplateTagsRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of AssignTemplateTagsRequest + * @throws IOException if the JSON string is invalid with respect to AssignTemplateTagsRequest + */ + public static AssignTemplateTagsRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AssignTemplateTagsRequest.class); + } + + /** + * Convert an instance of AssignTemplateTagsRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AssignedTemplateTags.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AssignedTemplateTags.java new file mode 100644 index 0000000..8be3a11 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/AssignedTemplateTags.java @@ -0,0 +1,337 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * AssignedTemplateTags + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class AssignedTemplateTags { + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) + private List tags = new ArrayList<>(); + + public static final String SERIALIZED_NAME_BUILD_I_D = "buildID"; + @SerializedName(SERIALIZED_NAME_BUILD_I_D) + private UUID buildID; + + public AssignedTemplateTags() { + } + + public AssignedTemplateTags tags(List tags) { + + this.tags = tags; + return this; + } + + public AssignedTemplateTags addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Assigned tags of the template + * @return tags + **/ + @javax.annotation.Nonnull + public List getTags() { + return tags; + } + + + public void setTags(List tags) { + this.tags = tags; + } + + + public AssignedTemplateTags buildID(UUID buildID) { + + this.buildID = buildID; + return this; + } + + /** + * Identifier of the build associated with these tags + * @return buildID + **/ + @javax.annotation.Nonnull + public UUID getBuildID() { + return buildID; + } + + + public void setBuildID(UUID buildID) { + this.buildID = buildID; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AssignedTemplateTags instance itself + */ + public AssignedTemplateTags putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AssignedTemplateTags assignedTemplateTags = (AssignedTemplateTags) o; + return Objects.equals(this.tags, assignedTemplateTags.tags) && + Objects.equals(this.buildID, assignedTemplateTags.buildID)&& + Objects.equals(this.additionalProperties, assignedTemplateTags.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(tags, buildID, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AssignedTemplateTags {\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" buildID: ").append(toIndentedString(buildID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("tags"); + openapiFields.add("buildID"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("tags"); + openapiRequiredFields.add("buildID"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AssignedTemplateTags + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AssignedTemplateTags.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AssignedTemplateTags is not found in the empty JSON string", AssignedTemplateTags.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AssignedTemplateTags.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the required json array is present + if (jsonObj.get("tags") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + if (!jsonObj.get("buildID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `buildID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("buildID").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AssignedTemplateTags.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AssignedTemplateTags' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AssignedTemplateTags.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AssignedTemplateTags value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public AssignedTemplateTags read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + AssignedTemplateTags instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of AssignedTemplateTags given an JSON string + * + * @param jsonString JSON string + * @return An instance of AssignedTemplateTags + * @throws IOException if the JSON string is invalid with respect to AssignedTemplateTags + */ + public static AssignedTemplateTags fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AssignedTemplateTags.class); + } + + /** + * Convert an instance of AssignedTemplateTags to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/BuildLogEntry.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/BuildLogEntry.java new file mode 100644 index 0000000..3b3336f --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/BuildLogEntry.java @@ -0,0 +1,382 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.LogLevel; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * BuildLogEntry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class BuildLogEntry { + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + private OffsetDateTime timestamp; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_LEVEL = "level"; + @SerializedName(SERIALIZED_NAME_LEVEL) + private LogLevel level; + + public static final String SERIALIZED_NAME_STEP = "step"; + @SerializedName(SERIALIZED_NAME_STEP) + private String step; + + public BuildLogEntry() { + } + + public BuildLogEntry timestamp(OffsetDateTime timestamp) { + + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp of the log entry + * @return timestamp + **/ + @javax.annotation.Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + + public BuildLogEntry message(String message) { + + this.message = message; + return this; + } + + /** + * Log message content + * @return message + **/ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public BuildLogEntry level(LogLevel level) { + + this.level = level; + return this; + } + + /** + * Get level + * @return level + **/ + @javax.annotation.Nonnull + public LogLevel getLevel() { + return level; + } + + + public void setLevel(LogLevel level) { + this.level = level; + } + + + public BuildLogEntry step(String step) { + + this.step = step; + return this; + } + + /** + * Step in the build process related to the log entry + * @return step + **/ + @javax.annotation.Nullable + public String getStep() { + return step; + } + + + public void setStep(String step) { + this.step = step; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BuildLogEntry instance itself + */ + public BuildLogEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BuildLogEntry buildLogEntry = (BuildLogEntry) o; + return Objects.equals(this.timestamp, buildLogEntry.timestamp) && + Objects.equals(this.message, buildLogEntry.message) && + Objects.equals(this.level, buildLogEntry.level) && + Objects.equals(this.step, buildLogEntry.step)&& + Objects.equals(this.additionalProperties, buildLogEntry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, message, level, step, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BuildLogEntry {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" level: ").append(toIndentedString(level)).append("\n"); + sb.append(" step: ").append(toIndentedString(step)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timestamp"); + openapiFields.add("message"); + openapiFields.add("level"); + openapiFields.add("step"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timestamp"); + openapiRequiredFields.add("message"); + openapiRequiredFields.add("level"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BuildLogEntry + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!BuildLogEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in BuildLogEntry is not found in the empty JSON string", BuildLogEntry.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BuildLogEntry.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + if ((jsonObj.get("step") != null && !jsonObj.get("step").isJsonNull()) && !jsonObj.get("step").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BuildLogEntry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BuildLogEntry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BuildLogEntry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BuildLogEntry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public BuildLogEntry read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + BuildLogEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BuildLogEntry given an JSON string + * + * @param jsonString JSON string + * @return An instance of BuildLogEntry + * @throws IOException if the JSON string is invalid with respect to BuildLogEntry + */ + public static BuildLogEntry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BuildLogEntry.class); + } + + /** + * Convert an instance of BuildLogEntry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/BuildStatusReason.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/BuildStatusReason.java new file mode 100644 index 0000000..a0cf89a --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/BuildStatusReason.java @@ -0,0 +1,375 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.BuildLogEntry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * BuildStatusReason + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class BuildStatusReason { + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_STEP = "step"; + @SerializedName(SERIALIZED_NAME_STEP) + private String step; + + public static final String SERIALIZED_NAME_LOG_ENTRIES = "logEntries"; + @SerializedName(SERIALIZED_NAME_LOG_ENTRIES) + private List logEntries = null; + + public BuildStatusReason() { + } + + public BuildStatusReason message(String message) { + + this.message = message; + return this; + } + + /** + * Message with the status reason, currently reporting only for error status + * @return message + **/ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public BuildStatusReason step(String step) { + + this.step = step; + return this; + } + + /** + * Step that failed + * @return step + **/ + @javax.annotation.Nullable + public String getStep() { + return step; + } + + + public void setStep(String step) { + this.step = step; + } + + + public BuildStatusReason logEntries(List logEntries) { + + this.logEntries = logEntries; + return this; + } + + public BuildStatusReason addLogEntriesItem(BuildLogEntry logEntriesItem) { + if (this.logEntries == null) { + this.logEntries = null; + } + this.logEntries.add(logEntriesItem); + return this; + } + + /** + * Log entries related to the status reason + * @return logEntries + **/ + @javax.annotation.Nullable + public List getLogEntries() { + return logEntries; + } + + + public void setLogEntries(List logEntries) { + this.logEntries = logEntries; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BuildStatusReason instance itself + */ + public BuildStatusReason putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BuildStatusReason buildStatusReason = (BuildStatusReason) o; + return Objects.equals(this.message, buildStatusReason.message) && + Objects.equals(this.step, buildStatusReason.step) && + Objects.equals(this.logEntries, buildStatusReason.logEntries)&& + Objects.equals(this.additionalProperties, buildStatusReason.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(message, step, logEntries, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BuildStatusReason {\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" step: ").append(toIndentedString(step)).append("\n"); + sb.append(" logEntries: ").append(toIndentedString(logEntries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("message"); + openapiFields.add("step"); + openapiFields.add("logEntries"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("message"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to BuildStatusReason + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!BuildStatusReason.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in BuildStatusReason is not found in the empty JSON string", BuildStatusReason.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BuildStatusReason.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + if ((jsonObj.get("step") != null && !jsonObj.get("step").isJsonNull()) && !jsonObj.get("step").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); + } + if (jsonObj.get("logEntries") != null && !jsonObj.get("logEntries").isJsonNull()) { + JsonArray jsonArraylogEntries = jsonObj.getAsJsonArray("logEntries"); + if (jsonArraylogEntries != null) { + // ensure the json data is an array + if (!jsonObj.get("logEntries").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `logEntries` to be an array in the JSON string but got `%s`", jsonObj.get("logEntries").toString())); + } + + // validate the optional field `logEntries` (array) + for (int i = 0; i < jsonArraylogEntries.size(); i++) { + BuildLogEntry.validateJsonObject(jsonArraylogEntries.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BuildStatusReason.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BuildStatusReason' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BuildStatusReason.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BuildStatusReason value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public BuildStatusReason read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + BuildStatusReason instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BuildStatusReason given an JSON string + * + * @param jsonString JSON string + * @return An instance of BuildStatusReason + * @throws IOException if the JSON string is invalid with respect to BuildStatusReason + */ + public static BuildStatusReason fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BuildStatusReason.class); + } + + /** + * Convert an instance of BuildStatusReason to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ConnectSandbox.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ConnectSandbox.java new file mode 100644 index 0000000..2abc6fa --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ConnectSandbox.java @@ -0,0 +1,289 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * ConnectSandbox + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class ConnectSandbox { + public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; + @SerializedName(SERIALIZED_NAME_TIMEOUT) + private Integer timeout; + + public ConnectSandbox() { + } + + public ConnectSandbox timeout(Integer timeout) { + + this.timeout = timeout; + return this; + } + + /** + * Timeout in seconds from the current time after which the sandbox should expire + * minimum: 0 + * @return timeout + **/ + @javax.annotation.Nonnull + public Integer getTimeout() { + return timeout; + } + + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ConnectSandbox instance itself + */ + public ConnectSandbox putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConnectSandbox connectSandbox = (ConnectSandbox) o; + return Objects.equals(this.timeout, connectSandbox.timeout)&& + Objects.equals(this.additionalProperties, connectSandbox.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timeout, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConnectSandbox {\n"); + sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timeout"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timeout"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ConnectSandbox + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ConnectSandbox.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ConnectSandbox is not found in the empty JSON string", ConnectSandbox.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ConnectSandbox.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConnectSandbox.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConnectSandbox' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ConnectSandbox.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ConnectSandbox value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ConnectSandbox read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + ConnectSandbox instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ConnectSandbox given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConnectSandbox + * @throws IOException if the JSON string is invalid with respect to ConnectSandbox + */ + public static ConnectSandbox fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConnectSandbox.class); + } + + /** + * Convert an instance of ConnectSandbox to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/CreatedAccessToken.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/CreatedAccessToken.java new file mode 100644 index 0000000..583803f --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/CreatedAccessToken.java @@ -0,0 +1,418 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.IdentifierMaskingDetails; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * CreatedAccessToken + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class CreatedAccessToken { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_TOKEN = "token"; + @SerializedName(SERIALIZED_NAME_TOKEN) + private String token; + + public static final String SERIALIZED_NAME_MASK = "mask"; + @SerializedName(SERIALIZED_NAME_MASK) + private IdentifierMaskingDetails mask; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public CreatedAccessToken() { + } + + public CreatedAccessToken id(UUID id) { + + this.id = id; + return this; + } + + /** + * Identifier of the access token + * @return id + **/ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + + public void setId(UUID id) { + this.id = id; + } + + + public CreatedAccessToken name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the access token + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public CreatedAccessToken token(String token) { + + this.token = token; + return this; + } + + /** + * The fully created access token + * @return token + **/ + @javax.annotation.Nonnull + public String getToken() { + return token; + } + + + public void setToken(String token) { + this.token = token; + } + + + public CreatedAccessToken mask(IdentifierMaskingDetails mask) { + + this.mask = mask; + return this; + } + + /** + * Get mask + * @return mask + **/ + @javax.annotation.Nonnull + public IdentifierMaskingDetails getMask() { + return mask; + } + + + public void setMask(IdentifierMaskingDetails mask) { + this.mask = mask; + } + + + public CreatedAccessToken createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * Timestamp of access token creation + * @return createdAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreatedAccessToken instance itself + */ + public CreatedAccessToken putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreatedAccessToken createdAccessToken = (CreatedAccessToken) o; + return Objects.equals(this.id, createdAccessToken.id) && + Objects.equals(this.name, createdAccessToken.name) && + Objects.equals(this.token, createdAccessToken.token) && + Objects.equals(this.mask, createdAccessToken.mask) && + Objects.equals(this.createdAt, createdAccessToken.createdAt)&& + Objects.equals(this.additionalProperties, createdAccessToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, token, mask, createdAt, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreatedAccessToken {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" mask: ").append(toIndentedString(mask)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("token"); + openapiFields.add("mask"); + openapiFields.add("createdAt"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("token"); + openapiRequiredFields.add("mask"); + openapiRequiredFields.add("createdAt"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatedAccessToken + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatedAccessToken.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatedAccessToken is not found in the empty JSON string", CreatedAccessToken.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatedAccessToken.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("token").toString())); + } + // validate the required field `mask` + IdentifierMaskingDetails.validateJsonObject(jsonObj.getAsJsonObject("mask")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatedAccessToken.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatedAccessToken' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatedAccessToken.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatedAccessToken value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreatedAccessToken read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + CreatedAccessToken instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatedAccessToken given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatedAccessToken + * @throws IOException if the JSON string is invalid with respect to CreatedAccessToken + */ + public static CreatedAccessToken fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatedAccessToken.class); + } + + /** + * Convert an instance of CreatedAccessToken to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/CreatedTeamAPIKey.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/CreatedTeamAPIKey.java new file mode 100644 index 0000000..3fe0125 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/CreatedTeamAPIKey.java @@ -0,0 +1,491 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.IdentifierMaskingDetails; +import io.openkruise.agents.client.e2b.api.models.TeamUser; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * CreatedTeamAPIKey + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class CreatedTeamAPIKey { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; + + public static final String SERIALIZED_NAME_KEY = "key"; + @SerializedName(SERIALIZED_NAME_KEY) + private String key; + + public static final String SERIALIZED_NAME_MASK = "mask"; + @SerializedName(SERIALIZED_NAME_MASK) + private IdentifierMaskingDetails mask; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_CREATED_BY = "createdBy"; + @SerializedName(SERIALIZED_NAME_CREATED_BY) + private TeamUser createdBy; + + public static final String SERIALIZED_NAME_LAST_USED = "lastUsed"; + @SerializedName(SERIALIZED_NAME_LAST_USED) + private OffsetDateTime lastUsed; + + public CreatedTeamAPIKey() { + } + + public CreatedTeamAPIKey id(UUID id) { + + this.id = id; + return this; + } + + /** + * Identifier of the API key + * @return id + **/ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + + public void setId(UUID id) { + this.id = id; + } + + + public CreatedTeamAPIKey key(String key) { + + this.key = key; + return this; + } + + /** + * Raw value of the API key + * @return key + **/ + @javax.annotation.Nonnull + public String getKey() { + return key; + } + + + public void setKey(String key) { + this.key = key; + } + + + public CreatedTeamAPIKey mask(IdentifierMaskingDetails mask) { + + this.mask = mask; + return this; + } + + /** + * Get mask + * @return mask + **/ + @javax.annotation.Nonnull + public IdentifierMaskingDetails getMask() { + return mask; + } + + + public void setMask(IdentifierMaskingDetails mask) { + this.mask = mask; + } + + + public CreatedTeamAPIKey name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the API key + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public CreatedTeamAPIKey createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * Timestamp of API key creation + * @return createdAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public CreatedTeamAPIKey createdBy(TeamUser createdBy) { + + this.createdBy = createdBy; + return this; + } + + /** + * Get createdBy + * @return createdBy + **/ + @javax.annotation.Nullable + public TeamUser getCreatedBy() { + return createdBy; + } + + + public void setCreatedBy(TeamUser createdBy) { + this.createdBy = createdBy; + } + + + public CreatedTeamAPIKey lastUsed(OffsetDateTime lastUsed) { + + this.lastUsed = lastUsed; + return this; + } + + /** + * Last time this API key was used + * @return lastUsed + **/ + @javax.annotation.Nullable + public OffsetDateTime getLastUsed() { + return lastUsed; + } + + + public void setLastUsed(OffsetDateTime lastUsed) { + this.lastUsed = lastUsed; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreatedTeamAPIKey instance itself + */ + public CreatedTeamAPIKey putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreatedTeamAPIKey createdTeamAPIKey = (CreatedTeamAPIKey) o; + return Objects.equals(this.id, createdTeamAPIKey.id) && + Objects.equals(this.key, createdTeamAPIKey.key) && + Objects.equals(this.mask, createdTeamAPIKey.mask) && + Objects.equals(this.name, createdTeamAPIKey.name) && + Objects.equals(this.createdAt, createdTeamAPIKey.createdAt) && + Objects.equals(this.createdBy, createdTeamAPIKey.createdBy) && + Objects.equals(this.lastUsed, createdTeamAPIKey.lastUsed)&& + Objects.equals(this.additionalProperties, createdTeamAPIKey.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(id, key, mask, name, createdAt, createdBy, lastUsed, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreatedTeamAPIKey {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" mask: ").append(toIndentedString(mask)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" lastUsed: ").append(toIndentedString(lastUsed)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("key"); + openapiFields.add("mask"); + openapiFields.add("name"); + openapiFields.add("createdAt"); + openapiFields.add("createdBy"); + openapiFields.add("lastUsed"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("key"); + openapiRequiredFields.add("mask"); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("createdAt"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to CreatedTeamAPIKey + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!CreatedTeamAPIKey.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreatedTeamAPIKey is not found in the empty JSON string", CreatedTeamAPIKey.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreatedTeamAPIKey.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("key").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); + } + // validate the required field `mask` + IdentifierMaskingDetails.validateJsonObject(jsonObj.getAsJsonObject("mask")); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the optional field `createdBy` + if (jsonObj.get("createdBy") != null && !jsonObj.get("createdBy").isJsonNull()) { + TeamUser.validateJsonObject(jsonObj.getAsJsonObject("createdBy")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreatedTeamAPIKey.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreatedTeamAPIKey' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreatedTeamAPIKey.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreatedTeamAPIKey value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreatedTeamAPIKey read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + CreatedTeamAPIKey instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreatedTeamAPIKey given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreatedTeamAPIKey + * @throws IOException if the JSON string is invalid with respect to CreatedTeamAPIKey + */ + public static CreatedTeamAPIKey fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreatedTeamAPIKey.class); + } + + /** + * Convert an instance of CreatedTeamAPIKey to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/DeleteTemplateTagsRequest.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/DeleteTemplateTagsRequest.java new file mode 100644 index 0000000..6a9eb8f --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/DeleteTemplateTagsRequest.java @@ -0,0 +1,336 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * DeleteTemplateTagsRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class DeleteTemplateTagsRequest { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) + private List tags = new ArrayList<>(); + + public DeleteTemplateTagsRequest() { + } + + public DeleteTemplateTagsRequest name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the template + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public DeleteTemplateTagsRequest tags(List tags) { + + this.tags = tags; + return this; + } + + public DeleteTemplateTagsRequest addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Tags to delete + * @return tags + **/ + @javax.annotation.Nonnull + public List getTags() { + return tags; + } + + + public void setTags(List tags) { + this.tags = tags; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DeleteTemplateTagsRequest instance itself + */ + public DeleteTemplateTagsRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteTemplateTagsRequest deleteTemplateTagsRequest = (DeleteTemplateTagsRequest) o; + return Objects.equals(this.name, deleteTemplateTagsRequest.name) && + Objects.equals(this.tags, deleteTemplateTagsRequest.tags)&& + Objects.equals(this.additionalProperties, deleteTemplateTagsRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, tags, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeleteTemplateTagsRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("tags"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("tags"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DeleteTemplateTagsRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!DeleteTemplateTagsRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in DeleteTemplateTagsRequest is not found in the empty JSON string", DeleteTemplateTagsRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DeleteTemplateTagsRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // ensure the required json array is present + if (jsonObj.get("tags") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DeleteTemplateTagsRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DeleteTemplateTagsRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DeleteTemplateTagsRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DeleteTemplateTagsRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DeleteTemplateTagsRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + DeleteTemplateTagsRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DeleteTemplateTagsRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of DeleteTemplateTagsRequest + * @throws IOException if the JSON string is invalid with respect to DeleteTemplateTagsRequest + */ + public static DeleteTemplateTagsRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DeleteTemplateTagsRequest.class); + } + + /** + * Convert an instance of DeleteTemplateTagsRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/DiskMetrics.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/DiskMetrics.java new file mode 100644 index 0000000..8deab9b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/DiskMetrics.java @@ -0,0 +1,413 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * DiskMetrics + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class DiskMetrics { + public static final String SERIALIZED_NAME_MOUNT_POINT = "mountPoint"; + @SerializedName(SERIALIZED_NAME_MOUNT_POINT) + private String mountPoint; + + public static final String SERIALIZED_NAME_DEVICE = "device"; + @SerializedName(SERIALIZED_NAME_DEVICE) + private String device; + + public static final String SERIALIZED_NAME_FILESYSTEM_TYPE = "filesystemType"; + @SerializedName(SERIALIZED_NAME_FILESYSTEM_TYPE) + private String filesystemType; + + public static final String SERIALIZED_NAME_USED_BYTES = "usedBytes"; + @SerializedName(SERIALIZED_NAME_USED_BYTES) + private Integer usedBytes; + + public static final String SERIALIZED_NAME_TOTAL_BYTES = "totalBytes"; + @SerializedName(SERIALIZED_NAME_TOTAL_BYTES) + private Integer totalBytes; + + public DiskMetrics() { + } + + public DiskMetrics mountPoint(String mountPoint) { + + this.mountPoint = mountPoint; + return this; + } + + /** + * Mount point of the disk + * @return mountPoint + **/ + @javax.annotation.Nonnull + public String getMountPoint() { + return mountPoint; + } + + + public void setMountPoint(String mountPoint) { + this.mountPoint = mountPoint; + } + + + public DiskMetrics device(String device) { + + this.device = device; + return this; + } + + /** + * Device name + * @return device + **/ + @javax.annotation.Nonnull + public String getDevice() { + return device; + } + + + public void setDevice(String device) { + this.device = device; + } + + + public DiskMetrics filesystemType(String filesystemType) { + + this.filesystemType = filesystemType; + return this; + } + + /** + * Filesystem type (e.g., ext4, xfs) + * @return filesystemType + **/ + @javax.annotation.Nonnull + public String getFilesystemType() { + return filesystemType; + } + + + public void setFilesystemType(String filesystemType) { + this.filesystemType = filesystemType; + } + + + public DiskMetrics usedBytes(Integer usedBytes) { + + this.usedBytes = usedBytes; + return this; + } + + /** + * Used space in bytes + * @return usedBytes + **/ + @javax.annotation.Nonnull + public Integer getUsedBytes() { + return usedBytes; + } + + + public void setUsedBytes(Integer usedBytes) { + this.usedBytes = usedBytes; + } + + + public DiskMetrics totalBytes(Integer totalBytes) { + + this.totalBytes = totalBytes; + return this; + } + + /** + * Total space in bytes + * @return totalBytes + **/ + @javax.annotation.Nonnull + public Integer getTotalBytes() { + return totalBytes; + } + + + public void setTotalBytes(Integer totalBytes) { + this.totalBytes = totalBytes; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DiskMetrics instance itself + */ + public DiskMetrics putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DiskMetrics diskMetrics = (DiskMetrics) o; + return Objects.equals(this.mountPoint, diskMetrics.mountPoint) && + Objects.equals(this.device, diskMetrics.device) && + Objects.equals(this.filesystemType, diskMetrics.filesystemType) && + Objects.equals(this.usedBytes, diskMetrics.usedBytes) && + Objects.equals(this.totalBytes, diskMetrics.totalBytes)&& + Objects.equals(this.additionalProperties, diskMetrics.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(mountPoint, device, filesystemType, usedBytes, totalBytes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DiskMetrics {\n"); + sb.append(" mountPoint: ").append(toIndentedString(mountPoint)).append("\n"); + sb.append(" device: ").append(toIndentedString(device)).append("\n"); + sb.append(" filesystemType: ").append(toIndentedString(filesystemType)).append("\n"); + sb.append(" usedBytes: ").append(toIndentedString(usedBytes)).append("\n"); + sb.append(" totalBytes: ").append(toIndentedString(totalBytes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("mountPoint"); + openapiFields.add("device"); + openapiFields.add("filesystemType"); + openapiFields.add("usedBytes"); + openapiFields.add("totalBytes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("mountPoint"); + openapiRequiredFields.add("device"); + openapiRequiredFields.add("filesystemType"); + openapiRequiredFields.add("usedBytes"); + openapiRequiredFields.add("totalBytes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DiskMetrics + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!DiskMetrics.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in DiskMetrics is not found in the empty JSON string", DiskMetrics.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DiskMetrics.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("mountPoint").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `mountPoint` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mountPoint").toString())); + } + if (!jsonObj.get("device").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `device` to be a primitive type in the JSON string but got `%s`", jsonObj.get("device").toString())); + } + if (!jsonObj.get("filesystemType").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `filesystemType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filesystemType").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DiskMetrics.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DiskMetrics' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DiskMetrics.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DiskMetrics value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DiskMetrics read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + DiskMetrics instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DiskMetrics given an JSON string + * + * @param jsonString JSON string + * @return An instance of DiskMetrics + * @throws IOException if the JSON string is invalid with respect to DiskMetrics + */ + public static DiskMetrics fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DiskMetrics.class); + } + + /** + * Convert an instance of DiskMetrics to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Error.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Error.java new file mode 100644 index 0000000..571f374 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Error.java @@ -0,0 +1,320 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Error + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Error { + public static final String SERIALIZED_NAME_CODE = "code"; + @SerializedName(SERIALIZED_NAME_CODE) + private Integer code; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public Error() { + } + + public Error code(Integer code) { + + this.code = code; + return this; + } + + /** + * Error code + * @return code + **/ + @javax.annotation.Nonnull + public Integer getCode() { + return code; + } + + + public void setCode(Integer code) { + this.code = code; + } + + + public Error message(String message) { + + this.message = message; + return this; + } + + /** + * Error + * @return message + **/ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Error instance itself + */ + public Error putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message)&& + Objects.equals(this.additionalProperties, error.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("code"); + openapiFields.add("message"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("code"); + openapiRequiredFields.add("message"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Error + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Error.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Error is not found in the empty JSON string", Error.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Error.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Error.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Error' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Error.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Error value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Error read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + Error instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Error given an JSON string + * + * @param jsonString JSON string + * @return An instance of Error + * @throws IOException if the JSON string is invalid with respect to Error + */ + public static Error fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Error.class); + } + + /** + * Convert an instance of Error to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/FromImageRegistry.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/FromImageRegistry.java new file mode 100644 index 0000000..219b7cf --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/FromImageRegistry.java @@ -0,0 +1,337 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.AWSRegistry; +import io.openkruise.agents.client.e2b.api.models.GCPRegistry; +import io.openkruise.agents.client.e2b.api.models.GeneralRegistry; +import java.io.IOException; + +import javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class FromImageRegistry extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(FromImageRegistry.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FromImageRegistry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FromImageRegistry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterAWSRegistry = gson.getDelegateAdapter(this, TypeToken.get(AWSRegistry.class)); + final TypeAdapter adapterGCPRegistry = gson.getDelegateAdapter(this, TypeToken.get(GCPRegistry.class)); + final TypeAdapter adapterGeneralRegistry = gson.getDelegateAdapter(this, TypeToken.get(GeneralRegistry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FromImageRegistry value) throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `AWSRegistry` + if (value.getActualInstance() instanceof AWSRegistry) { + JsonObject obj = adapterAWSRegistry.toJsonTree((AWSRegistry)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `GCPRegistry` + if (value.getActualInstance() instanceof GCPRegistry) { + JsonObject obj = adapterGCPRegistry.toJsonTree((GCPRegistry)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + // check if the actual instance is of the type `GeneralRegistry` + if (value.getActualInstance() instanceof GeneralRegistry) { + JsonObject obj = adapterGeneralRegistry.toJsonTree((GeneralRegistry)value.getActualInstance()).getAsJsonObject(); + elementAdapter.write(out, obj); + return; + } + + throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: AWSRegistry, GCPRegistry, GeneralRegistry"); + } + + @Override + public FromImageRegistry read(JsonReader in) throws IOException { + Object deserialized = null; + JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject(); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize AWSRegistry + try { + // validate the JSON object to see if any exception is thrown + AWSRegistry.validateJsonObject(jsonObject); + actualAdapter = adapterAWSRegistry; + match++; + log.log(Level.FINER, "Input data matches schema 'AWSRegistry'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for AWSRegistry failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'AWSRegistry'", e); + } + + // deserialize GCPRegistry + try { + // validate the JSON object to see if any exception is thrown + GCPRegistry.validateJsonObject(jsonObject); + actualAdapter = adapterGCPRegistry; + match++; + log.log(Level.FINER, "Input data matches schema 'GCPRegistry'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for GCPRegistry failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'GCPRegistry'", e); + } + + // deserialize GeneralRegistry + try { + // validate the JSON object to see if any exception is thrown + GeneralRegistry.validateJsonObject(jsonObject); + actualAdapter = adapterGeneralRegistry; + match++; + log.log(Level.FINER, "Input data matches schema 'GeneralRegistry'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add(String.format("Deserialization for GeneralRegistry failed with `%s`.", e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'GeneralRegistry'", e); + } + + if (match == 1) { + FromImageRegistry ret = new FromImageRegistry(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject)); + return ret; + } + + throw new IOException(String.format("Failed deserialization for FromImageRegistry: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FromImageRegistry() { + super("oneOf", Boolean.FALSE); + } + + public FromImageRegistry(AWSRegistry o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FromImageRegistry(GCPRegistry o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FromImageRegistry(GeneralRegistry o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("AWSRegistry", new GenericType() { + }); + schemas.put("GCPRegistry", new GenericType() { + }); + schemas.put("GeneralRegistry", new GenericType() { + }); + } + + @Override + public Map getSchemas() { + return FromImageRegistry.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * AWSRegistry, GCPRegistry, GeneralRegistry + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof AWSRegistry) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof GCPRegistry) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof GeneralRegistry) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be AWSRegistry, GCPRegistry, GeneralRegistry"); + } + + /** + * Get the actual instance, which can be the following: + * AWSRegistry, GCPRegistry, GeneralRegistry + * + * @return The actual instance (AWSRegistry, GCPRegistry, GeneralRegistry) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `AWSRegistry`. If the actual instance is not `AWSRegistry`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `AWSRegistry` + * @throws ClassCastException if the instance is not `AWSRegistry` + */ + public AWSRegistry getAWSRegistry() throws ClassCastException { + return (AWSRegistry)super.getActualInstance(); + } + + /** + * Get the actual instance of `GCPRegistry`. If the actual instance is not `GCPRegistry`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `GCPRegistry` + * @throws ClassCastException if the instance is not `GCPRegistry` + */ + public GCPRegistry getGCPRegistry() throws ClassCastException { + return (GCPRegistry)super.getActualInstance(); + } + + /** + * Get the actual instance of `GeneralRegistry`. If the actual instance is not `GeneralRegistry`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `GeneralRegistry` + * @throws ClassCastException if the instance is not `GeneralRegistry` + */ + public GeneralRegistry getGeneralRegistry() throws ClassCastException { + return (GeneralRegistry)super.getActualInstance(); + } + + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to FromImageRegistry + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with AWSRegistry + try { + AWSRegistry.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for AWSRegistry failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with GCPRegistry + try { + GCPRegistry.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for GCPRegistry failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with GeneralRegistry + try { + GeneralRegistry.validateJsonObject(jsonObj); + validCount++; + } catch (Exception e) { + errorMessages.add(String.format("Deserialization for GeneralRegistry failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException(String.format("The JSON string is invalid for FromImageRegistry with oneOf schemas: AWSRegistry, GCPRegistry, GeneralRegistry. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString())); + } + } + + /** + * Create an instance of FromImageRegistry given an JSON string + * + * @param jsonString JSON string + * @return An instance of FromImageRegistry + * @throws IOException if the JSON string is invalid with respect to FromImageRegistry + */ + public static FromImageRegistry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FromImageRegistry.class); + } + + /** + * Convert an instance of FromImageRegistry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/GCPRegistry.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/GCPRegistry.java new file mode 100644 index 0000000..8e19b1f --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/GCPRegistry.java @@ -0,0 +1,368 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * GCPRegistry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class GCPRegistry { + /** + * Type of registry authentication + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + GCP("gcp"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_SERVICE_ACCOUNT_JSON = "serviceAccountJson"; + @SerializedName(SERIALIZED_NAME_SERVICE_ACCOUNT_JSON) + private String serviceAccountJson; + + public GCPRegistry() { + } + + public GCPRegistry type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Type of registry authentication + * @return type + **/ + @javax.annotation.Nonnull + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public GCPRegistry serviceAccountJson(String serviceAccountJson) { + + this.serviceAccountJson = serviceAccountJson; + return this; + } + + /** + * Service Account JSON for GCP authentication + * @return serviceAccountJson + **/ + @javax.annotation.Nonnull + public String getServiceAccountJson() { + return serviceAccountJson; + } + + + public void setServiceAccountJson(String serviceAccountJson) { + this.serviceAccountJson = serviceAccountJson; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GCPRegistry instance itself + */ + public GCPRegistry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GCPRegistry gcPRegistry = (GCPRegistry) o; + return Objects.equals(this.type, gcPRegistry.type) && + Objects.equals(this.serviceAccountJson, gcPRegistry.serviceAccountJson)&& + Objects.equals(this.additionalProperties, gcPRegistry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, serviceAccountJson, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GCPRegistry {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" serviceAccountJson: ").append(toIndentedString(serviceAccountJson)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("serviceAccountJson"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("serviceAccountJson"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GCPRegistry + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GCPRegistry.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GCPRegistry is not found in the empty JSON string", GCPRegistry.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GCPRegistry.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("serviceAccountJson").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `serviceAccountJson` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serviceAccountJson").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GCPRegistry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GCPRegistry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GCPRegistry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GCPRegistry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GCPRegistry read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + GCPRegistry instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GCPRegistry given an JSON string + * + * @param jsonString JSON string + * @return An instance of GCPRegistry + * @throws IOException if the JSON string is invalid with respect to GCPRegistry + */ + public static GCPRegistry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GCPRegistry.class); + } + + /** + * Convert an instance of GCPRegistry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/GeneralRegistry.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/GeneralRegistry.java new file mode 100644 index 0000000..5cee369 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/GeneralRegistry.java @@ -0,0 +1,400 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * GeneralRegistry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class GeneralRegistry { + /** + * Type of registry authentication + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + REGISTRY("registry"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; + + public static final String SERIALIZED_NAME_PASSWORD = "password"; + @SerializedName(SERIALIZED_NAME_PASSWORD) + private String password; + + public GeneralRegistry() { + } + + public GeneralRegistry type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Type of registry authentication + * @return type + **/ + @javax.annotation.Nonnull + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public GeneralRegistry username(String username) { + + this.username = username; + return this; + } + + /** + * Username to use for the registry + * @return username + **/ + @javax.annotation.Nonnull + public String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + public GeneralRegistry password(String password) { + + this.password = password; + return this; + } + + /** + * Password to use for the registry + * @return password + **/ + @javax.annotation.Nonnull + public String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GeneralRegistry instance itself + */ + public GeneralRegistry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GeneralRegistry generalRegistry = (GeneralRegistry) o; + return Objects.equals(this.type, generalRegistry.type) && + Objects.equals(this.username, generalRegistry.username) && + Objects.equals(this.password, generalRegistry.password)&& + Objects.equals(this.additionalProperties, generalRegistry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, username, password, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GeneralRegistry {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("type"); + openapiFields.add("username"); + openapiFields.add("password"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("type"); + openapiRequiredFields.add("username"); + openapiRequiredFields.add("password"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GeneralRegistry + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GeneralRegistry.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GeneralRegistry is not found in the empty JSON string", GeneralRegistry.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GeneralRegistry.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if (!jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GeneralRegistry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GeneralRegistry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GeneralRegistry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GeneralRegistry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GeneralRegistry read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + GeneralRegistry instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GeneralRegistry given an JSON string + * + * @param jsonString JSON string + * @return An instance of GeneralRegistry + * @throws IOException if the JSON string is invalid with respect to GeneralRegistry + */ + public static GeneralRegistry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GeneralRegistry.class); + } + + /** + * Convert an instance of GeneralRegistry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/IdentifierMaskingDetails.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/IdentifierMaskingDetails.java new file mode 100644 index 0000000..998ac56 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/IdentifierMaskingDetails.java @@ -0,0 +1,384 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * IdentifierMaskingDetails + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class IdentifierMaskingDetails { + public static final String SERIALIZED_NAME_PREFIX = "prefix"; + @SerializedName(SERIALIZED_NAME_PREFIX) + private String prefix; + + public static final String SERIALIZED_NAME_VALUE_LENGTH = "valueLength"; + @SerializedName(SERIALIZED_NAME_VALUE_LENGTH) + private Integer valueLength; + + public static final String SERIALIZED_NAME_MASKED_VALUE_PREFIX = "maskedValuePrefix"; + @SerializedName(SERIALIZED_NAME_MASKED_VALUE_PREFIX) + private String maskedValuePrefix; + + public static final String SERIALIZED_NAME_MASKED_VALUE_SUFFIX = "maskedValueSuffix"; + @SerializedName(SERIALIZED_NAME_MASKED_VALUE_SUFFIX) + private String maskedValueSuffix; + + public IdentifierMaskingDetails() { + } + + public IdentifierMaskingDetails prefix(String prefix) { + + this.prefix = prefix; + return this; + } + + /** + * Prefix that identifies the token or key type + * @return prefix + **/ + @javax.annotation.Nonnull + public String getPrefix() { + return prefix; + } + + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + + public IdentifierMaskingDetails valueLength(Integer valueLength) { + + this.valueLength = valueLength; + return this; + } + + /** + * Length of the token or key + * @return valueLength + **/ + @javax.annotation.Nonnull + public Integer getValueLength() { + return valueLength; + } + + + public void setValueLength(Integer valueLength) { + this.valueLength = valueLength; + } + + + public IdentifierMaskingDetails maskedValuePrefix(String maskedValuePrefix) { + + this.maskedValuePrefix = maskedValuePrefix; + return this; + } + + /** + * Prefix used in masked version of the token or key + * @return maskedValuePrefix + **/ + @javax.annotation.Nonnull + public String getMaskedValuePrefix() { + return maskedValuePrefix; + } + + + public void setMaskedValuePrefix(String maskedValuePrefix) { + this.maskedValuePrefix = maskedValuePrefix; + } + + + public IdentifierMaskingDetails maskedValueSuffix(String maskedValueSuffix) { + + this.maskedValueSuffix = maskedValueSuffix; + return this; + } + + /** + * Suffix used in masked version of the token or key + * @return maskedValueSuffix + **/ + @javax.annotation.Nonnull + public String getMaskedValueSuffix() { + return maskedValueSuffix; + } + + + public void setMaskedValueSuffix(String maskedValueSuffix) { + this.maskedValueSuffix = maskedValueSuffix; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the IdentifierMaskingDetails instance itself + */ + public IdentifierMaskingDetails putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdentifierMaskingDetails identifierMaskingDetails = (IdentifierMaskingDetails) o; + return Objects.equals(this.prefix, identifierMaskingDetails.prefix) && + Objects.equals(this.valueLength, identifierMaskingDetails.valueLength) && + Objects.equals(this.maskedValuePrefix, identifierMaskingDetails.maskedValuePrefix) && + Objects.equals(this.maskedValueSuffix, identifierMaskingDetails.maskedValueSuffix)&& + Objects.equals(this.additionalProperties, identifierMaskingDetails.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(prefix, valueLength, maskedValuePrefix, maskedValueSuffix, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IdentifierMaskingDetails {\n"); + sb.append(" prefix: ").append(toIndentedString(prefix)).append("\n"); + sb.append(" valueLength: ").append(toIndentedString(valueLength)).append("\n"); + sb.append(" maskedValuePrefix: ").append(toIndentedString(maskedValuePrefix)).append("\n"); + sb.append(" maskedValueSuffix: ").append(toIndentedString(maskedValueSuffix)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("prefix"); + openapiFields.add("valueLength"); + openapiFields.add("maskedValuePrefix"); + openapiFields.add("maskedValueSuffix"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("prefix"); + openapiRequiredFields.add("valueLength"); + openapiRequiredFields.add("maskedValuePrefix"); + openapiRequiredFields.add("maskedValueSuffix"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to IdentifierMaskingDetails + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!IdentifierMaskingDetails.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in IdentifierMaskingDetails is not found in the empty JSON string", IdentifierMaskingDetails.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : IdentifierMaskingDetails.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("prefix").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `prefix` to be a primitive type in the JSON string but got `%s`", jsonObj.get("prefix").toString())); + } + if (!jsonObj.get("maskedValuePrefix").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `maskedValuePrefix` to be a primitive type in the JSON string but got `%s`", jsonObj.get("maskedValuePrefix").toString())); + } + if (!jsonObj.get("maskedValueSuffix").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `maskedValueSuffix` to be a primitive type in the JSON string but got `%s`", jsonObj.get("maskedValueSuffix").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!IdentifierMaskingDetails.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'IdentifierMaskingDetails' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(IdentifierMaskingDetails.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, IdentifierMaskingDetails value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public IdentifierMaskingDetails read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + IdentifierMaskingDetails instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of IdentifierMaskingDetails given an JSON string + * + * @param jsonString JSON string + * @return An instance of IdentifierMaskingDetails + * @throws IOException if the JSON string is invalid with respect to IdentifierMaskingDetails + */ + public static IdentifierMaskingDetails fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, IdentifierMaskingDetails.class); + } + + /** + * Convert an instance of IdentifierMaskingDetails to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ListedSandbox.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ListedSandbox.java new file mode 100644 index 0000000..757c85b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ListedSandbox.java @@ -0,0 +1,693 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxState; +import io.openkruise.agents.client.e2b.api.models.SandboxVolumeMount; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * ListedSandbox + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class ListedSandbox { + public static final String SERIALIZED_NAME_TEMPLATE_I_D = "templateID"; + @SerializedName(SERIALIZED_NAME_TEMPLATE_I_D) + private String templateID; + + public static final String SERIALIZED_NAME_ALIAS = "alias"; + @SerializedName(SERIALIZED_NAME_ALIAS) + private String alias; + + public static final String SERIALIZED_NAME_SANDBOX_I_D = "sandboxID"; + @SerializedName(SERIALIZED_NAME_SANDBOX_I_D) + private String sandboxID; + + public static final String SERIALIZED_NAME_CLIENT_I_D = "clientID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_CLIENT_I_D) + private String clientID; + + public static final String SERIALIZED_NAME_STARTED_AT = "startedAt"; + @SerializedName(SERIALIZED_NAME_STARTED_AT) + private OffsetDateTime startedAt; + + public static final String SERIALIZED_NAME_END_AT = "endAt"; + @SerializedName(SERIALIZED_NAME_END_AT) + private OffsetDateTime endAt; + + public static final String SERIALIZED_NAME_CPU_COUNT = "cpuCount"; + @SerializedName(SERIALIZED_NAME_CPU_COUNT) + private Integer cpuCount; + + public static final String SERIALIZED_NAME_MEMORY_M_B = "memoryMB"; + @SerializedName(SERIALIZED_NAME_MEMORY_M_B) + private Integer memoryMB; + + public static final String SERIALIZED_NAME_DISK_SIZE_M_B = "diskSizeMB"; + @SerializedName(SERIALIZED_NAME_DISK_SIZE_M_B) + private Integer diskSizeMB; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private Map metadata = new HashMap<>(); + + public static final String SERIALIZED_NAME_STATE = "state"; + @SerializedName(SERIALIZED_NAME_STATE) + private SandboxState state; + + public static final String SERIALIZED_NAME_ENVD_VERSION = "envdVersion"; + @SerializedName(SERIALIZED_NAME_ENVD_VERSION) + private String envdVersion; + + public static final String SERIALIZED_NAME_VOLUME_MOUNTS = "volumeMounts"; + @SerializedName(SERIALIZED_NAME_VOLUME_MOUNTS) + private List volumeMounts; + + public ListedSandbox() { + } + + public ListedSandbox templateID(String templateID) { + + this.templateID = templateID; + return this; + } + + /** + * Identifier of the template from which is the sandbox created + * @return templateID + **/ + @javax.annotation.Nonnull + public String getTemplateID() { + return templateID; + } + + + public void setTemplateID(String templateID) { + this.templateID = templateID; + } + + + public ListedSandbox alias(String alias) { + + this.alias = alias; + return this; + } + + /** + * Alias of the template + * @return alias + **/ + @javax.annotation.Nullable + public String getAlias() { + return alias; + } + + + public void setAlias(String alias) { + this.alias = alias; + } + + + public ListedSandbox sandboxID(String sandboxID) { + + this.sandboxID = sandboxID; + return this; + } + + /** + * Identifier of the sandbox + * @return sandboxID + **/ + @javax.annotation.Nonnull + public String getSandboxID() { + return sandboxID; + } + + + public void setSandboxID(String sandboxID) { + this.sandboxID = sandboxID; + } + + + @Deprecated + public ListedSandbox clientID(String clientID) { + + this.clientID = clientID; + return this; + } + + /** + * Identifier of the client + * @return clientID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getClientID() { + return clientID; + } + + + @Deprecated + public void setClientID(String clientID) { + this.clientID = clientID; + } + + + public ListedSandbox startedAt(OffsetDateTime startedAt) { + + this.startedAt = startedAt; + return this; + } + + /** + * Time when the sandbox was started + * @return startedAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getStartedAt() { + return startedAt; + } + + + public void setStartedAt(OffsetDateTime startedAt) { + this.startedAt = startedAt; + } + + + public ListedSandbox endAt(OffsetDateTime endAt) { + + this.endAt = endAt; + return this; + } + + /** + * Time when the sandbox will expire + * @return endAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getEndAt() { + return endAt; + } + + + public void setEndAt(OffsetDateTime endAt) { + this.endAt = endAt; + } + + + public ListedSandbox cpuCount(Integer cpuCount) { + + this.cpuCount = cpuCount; + return this; + } + + /** + * CPU cores for the sandbox + * minimum: 1 + * @return cpuCount + **/ + @javax.annotation.Nonnull + public Integer getCpuCount() { + return cpuCount; + } + + + public void setCpuCount(Integer cpuCount) { + this.cpuCount = cpuCount; + } + + + public ListedSandbox memoryMB(Integer memoryMB) { + + this.memoryMB = memoryMB; + return this; + } + + /** + * Memory for the sandbox in MiB + * minimum: 128 + * @return memoryMB + **/ + @javax.annotation.Nonnull + public Integer getMemoryMB() { + return memoryMB; + } + + + public void setMemoryMB(Integer memoryMB) { + this.memoryMB = memoryMB; + } + + + public ListedSandbox diskSizeMB(Integer diskSizeMB) { + + this.diskSizeMB = diskSizeMB; + return this; + } + + /** + * Disk size for the sandbox in MiB + * minimum: 0 + * @return diskSizeMB + **/ + @javax.annotation.Nonnull + public Integer getDiskSizeMB() { + return diskSizeMB; + } + + + public void setDiskSizeMB(Integer diskSizeMB) { + this.diskSizeMB = diskSizeMB; + } + + + public ListedSandbox metadata(Map metadata) { + + this.metadata = metadata; + return this; + } + + public ListedSandbox putMetadataItem(String key, String metadataItem) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.put(key, metadataItem); + return this; + } + + /** + * Get metadata + * @return metadata + **/ + @javax.annotation.Nullable + public Map getMetadata() { + return metadata; + } + + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + + public ListedSandbox state(SandboxState state) { + + this.state = state; + return this; + } + + /** + * Get state + * @return state + **/ + @javax.annotation.Nonnull + public SandboxState getState() { + return state; + } + + + public void setState(SandboxState state) { + this.state = state; + } + + + public ListedSandbox envdVersion(String envdVersion) { + + this.envdVersion = envdVersion; + return this; + } + + /** + * Version of the envd running in the sandbox + * @return envdVersion + **/ + @javax.annotation.Nonnull + public String getEnvdVersion() { + return envdVersion; + } + + + public void setEnvdVersion(String envdVersion) { + this.envdVersion = envdVersion; + } + + + public ListedSandbox volumeMounts(List volumeMounts) { + + this.volumeMounts = volumeMounts; + return this; + } + + public ListedSandbox addVolumeMountsItem(SandboxVolumeMount volumeMountsItem) { + if (this.volumeMounts == null) { + this.volumeMounts = new ArrayList<>(); + } + this.volumeMounts.add(volumeMountsItem); + return this; + } + + /** + * Get volumeMounts + * @return volumeMounts + **/ + @javax.annotation.Nullable + public List getVolumeMounts() { + return volumeMounts; + } + + + public void setVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListedSandbox instance itself + */ + public ListedSandbox putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListedSandbox listedSandbox = (ListedSandbox) o; + return Objects.equals(this.templateID, listedSandbox.templateID) && + Objects.equals(this.alias, listedSandbox.alias) && + Objects.equals(this.sandboxID, listedSandbox.sandboxID) && + Objects.equals(this.clientID, listedSandbox.clientID) && + Objects.equals(this.startedAt, listedSandbox.startedAt) && + Objects.equals(this.endAt, listedSandbox.endAt) && + Objects.equals(this.cpuCount, listedSandbox.cpuCount) && + Objects.equals(this.memoryMB, listedSandbox.memoryMB) && + Objects.equals(this.diskSizeMB, listedSandbox.diskSizeMB) && + Objects.equals(this.metadata, listedSandbox.metadata) && + Objects.equals(this.state, listedSandbox.state) && + Objects.equals(this.envdVersion, listedSandbox.envdVersion) && + Objects.equals(this.volumeMounts, listedSandbox.volumeMounts)&& + Objects.equals(this.additionalProperties, listedSandbox.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(templateID, alias, sandboxID, clientID, startedAt, endAt, cpuCount, memoryMB, diskSizeMB, metadata, state, envdVersion, volumeMounts, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListedSandbox {\n"); + sb.append(" templateID: ").append(toIndentedString(templateID)).append("\n"); + sb.append(" alias: ").append(toIndentedString(alias)).append("\n"); + sb.append(" sandboxID: ").append(toIndentedString(sandboxID)).append("\n"); + sb.append(" clientID: ").append(toIndentedString(clientID)).append("\n"); + sb.append(" startedAt: ").append(toIndentedString(startedAt)).append("\n"); + sb.append(" endAt: ").append(toIndentedString(endAt)).append("\n"); + sb.append(" cpuCount: ").append(toIndentedString(cpuCount)).append("\n"); + sb.append(" memoryMB: ").append(toIndentedString(memoryMB)).append("\n"); + sb.append(" diskSizeMB: ").append(toIndentedString(diskSizeMB)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).append("\n"); + sb.append(" envdVersion: ").append(toIndentedString(envdVersion)).append("\n"); + sb.append(" volumeMounts: ").append(toIndentedString(volumeMounts)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("templateID"); + openapiFields.add("alias"); + openapiFields.add("sandboxID"); + openapiFields.add("clientID"); + openapiFields.add("startedAt"); + openapiFields.add("endAt"); + openapiFields.add("cpuCount"); + openapiFields.add("memoryMB"); + openapiFields.add("diskSizeMB"); + openapiFields.add("metadata"); + openapiFields.add("state"); + openapiFields.add("envdVersion"); + openapiFields.add("volumeMounts"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("templateID"); + openapiRequiredFields.add("sandboxID"); + openapiRequiredFields.add("clientID"); + openapiRequiredFields.add("startedAt"); + openapiRequiredFields.add("endAt"); + openapiRequiredFields.add("cpuCount"); + openapiRequiredFields.add("memoryMB"); + openapiRequiredFields.add("diskSizeMB"); + openapiRequiredFields.add("state"); + openapiRequiredFields.add("envdVersion"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ListedSandbox + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ListedSandbox.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ListedSandbox is not found in the empty JSON string", ListedSandbox.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListedSandbox.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("templateID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `templateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateID").toString())); + } + if ((jsonObj.get("alias") != null && !jsonObj.get("alias").isJsonNull()) && !jsonObj.get("alias").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `alias` to be a primitive type in the JSON string but got `%s`", jsonObj.get("alias").toString())); + } + if (!jsonObj.get("sandboxID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `sandboxID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sandboxID").toString())); + } + if (!jsonObj.get("clientID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clientID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clientID").toString())); + } + if (!jsonObj.get("envdVersion").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdVersion").toString())); + } + if (jsonObj.get("volumeMounts") != null && !jsonObj.get("volumeMounts").isJsonNull()) { + JsonArray jsonArrayvolumeMounts = jsonObj.getAsJsonArray("volumeMounts"); + if (jsonArrayvolumeMounts != null) { + // ensure the json data is an array + if (!jsonObj.get("volumeMounts").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `volumeMounts` to be an array in the JSON string but got `%s`", jsonObj.get("volumeMounts").toString())); + } + + // validate the optional field `volumeMounts` (array) + for (int i = 0; i < jsonArrayvolumeMounts.size(); i++) { + SandboxVolumeMount.validateJsonObject(jsonArrayvolumeMounts.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListedSandbox.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListedSandbox' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListedSandbox.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListedSandbox value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ListedSandbox read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + ListedSandbox instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListedSandbox given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListedSandbox + * @throws IOException if the JSON string is invalid with respect to ListedSandbox + */ + public static ListedSandbox fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListedSandbox.class); + } + + /** + * Convert an instance of ListedSandbox to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogLevel.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogLevel.java new file mode 100644 index 0000000..e9ce8e0 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogLevel.java @@ -0,0 +1,77 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * State of the sandbox + */ +@JsonAdapter(LogLevel.Adapter.class) +public enum LogLevel { + + DEBUG("debug"), + + INFO("info"), + + WARN("warn"), + + ERROR("error"); + + private String value; + + LogLevel(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LogLevel fromValue(String value) { + for (LogLevel b : LogLevel.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LogLevel enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LogLevel read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LogLevel.fromValue(value); + } + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogsDirection.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogsDirection.java new file mode 100644 index 0000000..28718e1 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogsDirection.java @@ -0,0 +1,73 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Direction of the logs that should be returned + */ +@JsonAdapter(LogsDirection.Adapter.class) +public enum LogsDirection { + + LogsDirectionForward("forward"), + + LogsDirectionBackward("backward"); + + private String value; + + LogsDirection(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LogsDirection fromValue(String value) { + for (LogsDirection b : LogsDirection.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LogsDirection enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LogsDirection read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LogsDirection.fromValue(value); + } + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogsSource.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogsSource.java new file mode 100644 index 0000000..39635d7 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/LogsSource.java @@ -0,0 +1,73 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Source of the logs that should be returned + */ +@JsonAdapter(LogsSource.Adapter.class) +public enum LogsSource { + + LogsSourceTemporary("temporary"), + + LogsSourcePersistent("persistent"); + + private String value; + + LogsSource(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LogsSource fromValue(String value) { + for (LogsSource b : LogsSource.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LogsSource enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LogsSource read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LogsSource.fromValue(value); + } + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/MachineInfo.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/MachineInfo.java new file mode 100644 index 0000000..f139605 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/MachineInfo.java @@ -0,0 +1,387 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * MachineInfo + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class MachineInfo { + public static final String SERIALIZED_NAME_CPU_FAMILY = "cpuFamily"; + @SerializedName(SERIALIZED_NAME_CPU_FAMILY) + private String cpuFamily; + + public static final String SERIALIZED_NAME_CPU_MODEL = "cpuModel"; + @SerializedName(SERIALIZED_NAME_CPU_MODEL) + private String cpuModel; + + public static final String SERIALIZED_NAME_CPU_MODEL_NAME = "cpuModelName"; + @SerializedName(SERIALIZED_NAME_CPU_MODEL_NAME) + private String cpuModelName; + + public static final String SERIALIZED_NAME_CPU_ARCHITECTURE = "cpuArchitecture"; + @SerializedName(SERIALIZED_NAME_CPU_ARCHITECTURE) + private String cpuArchitecture; + + public MachineInfo() { + } + + public MachineInfo cpuFamily(String cpuFamily) { + + this.cpuFamily = cpuFamily; + return this; + } + + /** + * CPU family of the node + * @return cpuFamily + **/ + @javax.annotation.Nonnull + public String getCpuFamily() { + return cpuFamily; + } + + + public void setCpuFamily(String cpuFamily) { + this.cpuFamily = cpuFamily; + } + + + public MachineInfo cpuModel(String cpuModel) { + + this.cpuModel = cpuModel; + return this; + } + + /** + * CPU model of the node + * @return cpuModel + **/ + @javax.annotation.Nonnull + public String getCpuModel() { + return cpuModel; + } + + + public void setCpuModel(String cpuModel) { + this.cpuModel = cpuModel; + } + + + public MachineInfo cpuModelName(String cpuModelName) { + + this.cpuModelName = cpuModelName; + return this; + } + + /** + * CPU model name of the node + * @return cpuModelName + **/ + @javax.annotation.Nonnull + public String getCpuModelName() { + return cpuModelName; + } + + + public void setCpuModelName(String cpuModelName) { + this.cpuModelName = cpuModelName; + } + + + public MachineInfo cpuArchitecture(String cpuArchitecture) { + + this.cpuArchitecture = cpuArchitecture; + return this; + } + + /** + * CPU architecture of the node + * @return cpuArchitecture + **/ + @javax.annotation.Nonnull + public String getCpuArchitecture() { + return cpuArchitecture; + } + + + public void setCpuArchitecture(String cpuArchitecture) { + this.cpuArchitecture = cpuArchitecture; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MachineInfo instance itself + */ + public MachineInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MachineInfo machineInfo = (MachineInfo) o; + return Objects.equals(this.cpuFamily, machineInfo.cpuFamily) && + Objects.equals(this.cpuModel, machineInfo.cpuModel) && + Objects.equals(this.cpuModelName, machineInfo.cpuModelName) && + Objects.equals(this.cpuArchitecture, machineInfo.cpuArchitecture)&& + Objects.equals(this.additionalProperties, machineInfo.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(cpuFamily, cpuModel, cpuModelName, cpuArchitecture, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MachineInfo {\n"); + sb.append(" cpuFamily: ").append(toIndentedString(cpuFamily)).append("\n"); + sb.append(" cpuModel: ").append(toIndentedString(cpuModel)).append("\n"); + sb.append(" cpuModelName: ").append(toIndentedString(cpuModelName)).append("\n"); + sb.append(" cpuArchitecture: ").append(toIndentedString(cpuArchitecture)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("cpuFamily"); + openapiFields.add("cpuModel"); + openapiFields.add("cpuModelName"); + openapiFields.add("cpuArchitecture"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("cpuFamily"); + openapiRequiredFields.add("cpuModel"); + openapiRequiredFields.add("cpuModelName"); + openapiRequiredFields.add("cpuArchitecture"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MachineInfo + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MachineInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MachineInfo is not found in the empty JSON string", MachineInfo.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MachineInfo.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("cpuFamily").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cpuFamily` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cpuFamily").toString())); + } + if (!jsonObj.get("cpuModel").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cpuModel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cpuModel").toString())); + } + if (!jsonObj.get("cpuModelName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cpuModelName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cpuModelName").toString())); + } + if (!jsonObj.get("cpuArchitecture").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cpuArchitecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cpuArchitecture").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MachineInfo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MachineInfo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MachineInfo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MachineInfo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MachineInfo read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + MachineInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MachineInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of MachineInfo + * @throws IOException if the JSON string is invalid with respect to MachineInfo + */ + public static MachineInfo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MachineInfo.class); + } + + /** + * Convert an instance of MachineInfo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/MaxTeamMetric.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/MaxTeamMetric.java new file mode 100644 index 0000000..799e3cf --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/MaxTeamMetric.java @@ -0,0 +1,353 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Team metric with timestamp + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class MaxTeamMetric { + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + @Deprecated + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + private OffsetDateTime timestamp; + + public static final String SERIALIZED_NAME_TIMESTAMP_UNIX = "timestampUnix"; + @SerializedName(SERIALIZED_NAME_TIMESTAMP_UNIX) + private Long timestampUnix; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private BigDecimal value; + + public MaxTeamMetric() { + } + + @Deprecated + public MaxTeamMetric timestamp(OffsetDateTime timestamp) { + + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp of the metric entry + * @return timestamp + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + + @Deprecated + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + + public MaxTeamMetric timestampUnix(Long timestampUnix) { + + this.timestampUnix = timestampUnix; + return this; + } + + /** + * Timestamp of the metric entry in Unix time (seconds since epoch) + * @return timestampUnix + **/ + @javax.annotation.Nonnull + public Long getTimestampUnix() { + return timestampUnix; + } + + + public void setTimestampUnix(Long timestampUnix) { + this.timestampUnix = timestampUnix; + } + + + public MaxTeamMetric value(BigDecimal value) { + + this.value = value; + return this; + } + + /** + * The maximum value of the requested metric in the given interval + * @return value + **/ + @javax.annotation.Nonnull + public BigDecimal getValue() { + return value; + } + + + public void setValue(BigDecimal value) { + this.value = value; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MaxTeamMetric instance itself + */ + public MaxTeamMetric putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MaxTeamMetric maxTeamMetric = (MaxTeamMetric) o; + return Objects.equals(this.timestamp, maxTeamMetric.timestamp) && + Objects.equals(this.timestampUnix, maxTeamMetric.timestampUnix) && + Objects.equals(this.value, maxTeamMetric.value)&& + Objects.equals(this.additionalProperties, maxTeamMetric.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, timestampUnix, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MaxTeamMetric {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" timestampUnix: ").append(toIndentedString(timestampUnix)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timestamp"); + openapiFields.add("timestampUnix"); + openapiFields.add("value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timestamp"); + openapiRequiredFields.add("timestampUnix"); + openapiRequiredFields.add("value"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to MaxTeamMetric + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!MaxTeamMetric.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MaxTeamMetric is not found in the empty JSON string", MaxTeamMetric.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : MaxTeamMetric.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MaxTeamMetric.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MaxTeamMetric' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MaxTeamMetric.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MaxTeamMetric value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MaxTeamMetric read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + MaxTeamMetric instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MaxTeamMetric given an JSON string + * + * @param jsonString JSON string + * @return An instance of MaxTeamMetric + * @throws IOException if the JSON string is invalid with respect to MaxTeamMetric + */ + public static MaxTeamMetric fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MaxTeamMetric.class); + } + + /** + * Convert an instance of MaxTeamMetric to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewAccessToken.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewAccessToken.java new file mode 100644 index 0000000..3836b3d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewAccessToken.java @@ -0,0 +1,291 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NewAccessToken + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NewAccessToken { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public NewAccessToken() { + } + + public NewAccessToken name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the access token + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NewAccessToken instance itself + */ + public NewAccessToken putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NewAccessToken newAccessToken = (NewAccessToken) o; + return Objects.equals(this.name, newAccessToken.name)&& + Objects.equals(this.additionalProperties, newAccessToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NewAccessToken {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NewAccessToken + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NewAccessToken.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NewAccessToken is not found in the empty JSON string", NewAccessToken.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NewAccessToken.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NewAccessToken.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NewAccessToken' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NewAccessToken.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NewAccessToken value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NewAccessToken read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NewAccessToken instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NewAccessToken given an JSON string + * + * @param jsonString JSON string + * @return An instance of NewAccessToken + * @throws IOException if the JSON string is invalid with respect to NewAccessToken + */ + public static NewAccessToken fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NewAccessToken.class); + } + + /** + * Convert an instance of NewAccessToken to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewSandbox.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewSandbox.java new file mode 100644 index 0000000..3435e43 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewSandbox.java @@ -0,0 +1,645 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxAutoResumeConfig; +import io.openkruise.agents.client.e2b.api.models.SandboxNetworkConfig; +import io.openkruise.agents.client.e2b.api.models.SandboxVolumeMount; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NewSandbox + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NewSandbox { + public static final String SERIALIZED_NAME_TEMPLATE_I_D = "templateID"; + @SerializedName(SERIALIZED_NAME_TEMPLATE_I_D) + private String templateID; + + public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; + @SerializedName(SERIALIZED_NAME_TIMEOUT) + private Integer timeout = 15; + + public static final String SERIALIZED_NAME_AUTO_PAUSE = "autoPause"; + @SerializedName(SERIALIZED_NAME_AUTO_PAUSE) + private Boolean autoPause = false; + + public static final String SERIALIZED_NAME_AUTO_RESUME = "autoResume"; + @SerializedName(SERIALIZED_NAME_AUTO_RESUME) + private SandboxAutoResumeConfig autoResume; + + public static final String SERIALIZED_NAME_SECURE = "secure"; + @SerializedName(SERIALIZED_NAME_SECURE) + private Boolean secure; + + public static final String SERIALIZED_NAME_ALLOW_INTERNET_ACCESS = "allow_internet_access"; + @SerializedName(SERIALIZED_NAME_ALLOW_INTERNET_ACCESS) + private Boolean allowInternetAccess; + + public static final String SERIALIZED_NAME_NETWORK = "network"; + @SerializedName(SERIALIZED_NAME_NETWORK) + private SandboxNetworkConfig network; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private Map metadata = new HashMap<>(); + + public static final String SERIALIZED_NAME_ENV_VARS = "envVars"; + @SerializedName(SERIALIZED_NAME_ENV_VARS) + private Map envVars = new HashMap<>(); + + public static final String SERIALIZED_NAME_MCP = "mcp"; + @SerializedName(SERIALIZED_NAME_MCP) + private Map mcp; + + public static final String SERIALIZED_NAME_VOLUME_MOUNTS = "volumeMounts"; + @SerializedName(SERIALIZED_NAME_VOLUME_MOUNTS) + private List volumeMounts; + + public NewSandbox() { + } + + public NewSandbox templateID(String templateID) { + + this.templateID = templateID; + return this; + } + + /** + * Identifier of the required template + * @return templateID + **/ + @javax.annotation.Nonnull + public String getTemplateID() { + return templateID; + } + + + public void setTemplateID(String templateID) { + this.templateID = templateID; + } + + + public NewSandbox timeout(Integer timeout) { + + this.timeout = timeout; + return this; + } + + /** + * Time to live for the sandbox in seconds. + * minimum: 0 + * @return timeout + **/ + @javax.annotation.Nullable + public Integer getTimeout() { + return timeout; + } + + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + + public NewSandbox autoPause(Boolean autoPause) { + + this.autoPause = autoPause; + return this; + } + + /** + * Automatically pauses the sandbox after the timeout + * @return autoPause + **/ + @javax.annotation.Nullable + public Boolean getAutoPause() { + return autoPause; + } + + + public void setAutoPause(Boolean autoPause) { + this.autoPause = autoPause; + } + + + public NewSandbox autoResume(SandboxAutoResumeConfig autoResume) { + + this.autoResume = autoResume; + return this; + } + + /** + * Get autoResume + * @return autoResume + **/ + @javax.annotation.Nullable + public SandboxAutoResumeConfig getAutoResume() { + return autoResume; + } + + + public void setAutoResume(SandboxAutoResumeConfig autoResume) { + this.autoResume = autoResume; + } + + + public NewSandbox secure(Boolean secure) { + + this.secure = secure; + return this; + } + + /** + * Secure all system communication with sandbox + * @return secure + **/ + @javax.annotation.Nullable + public Boolean getSecure() { + return secure; + } + + + public void setSecure(Boolean secure) { + this.secure = secure; + } + + + public NewSandbox allowInternetAccess(Boolean allowInternetAccess) { + + this.allowInternetAccess = allowInternetAccess; + return this; + } + + /** + * Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config. + * @return allowInternetAccess + **/ + @javax.annotation.Nullable + public Boolean getAllowInternetAccess() { + return allowInternetAccess; + } + + + public void setAllowInternetAccess(Boolean allowInternetAccess) { + this.allowInternetAccess = allowInternetAccess; + } + + + public NewSandbox network(SandboxNetworkConfig network) { + + this.network = network; + return this; + } + + /** + * Get network + * @return network + **/ + @javax.annotation.Nullable + public SandboxNetworkConfig getNetwork() { + return network; + } + + + public void setNetwork(SandboxNetworkConfig network) { + this.network = network; + } + + + public NewSandbox metadata(Map metadata) { + + this.metadata = metadata; + return this; + } + + public NewSandbox putMetadataItem(String key, String metadataItem) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.put(key, metadataItem); + return this; + } + + /** + * Get metadata + * @return metadata + **/ + @javax.annotation.Nullable + public Map getMetadata() { + return metadata; + } + + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + + public NewSandbox envVars(Map envVars) { + + this.envVars = envVars; + return this; + } + + public NewSandbox putEnvVarsItem(String key, String envVarsItem) { + if (this.envVars == null) { + this.envVars = new HashMap<>(); + } + this.envVars.put(key, envVarsItem); + return this; + } + + /** + * Get envVars + * @return envVars + **/ + @javax.annotation.Nullable + public Map getEnvVars() { + return envVars; + } + + + public void setEnvVars(Map envVars) { + this.envVars = envVars; + } + + + public NewSandbox mcp(Map mcp) { + + this.mcp = mcp; + return this; + } + + public NewSandbox putMcpItem(String key, Object mcpItem) { + if (this.mcp == null) { + this.mcp = new HashMap<>(); + } + this.mcp.put(key, mcpItem); + return this; + } + + /** + * MCP configuration for the sandbox + * @return mcp + **/ + @javax.annotation.Nullable + public Map getMcp() { + return mcp; + } + + + public void setMcp(Map mcp) { + this.mcp = mcp; + } + + + public NewSandbox volumeMounts(List volumeMounts) { + + this.volumeMounts = volumeMounts; + return this; + } + + public NewSandbox addVolumeMountsItem(SandboxVolumeMount volumeMountsItem) { + if (this.volumeMounts == null) { + this.volumeMounts = new ArrayList<>(); + } + this.volumeMounts.add(volumeMountsItem); + return this; + } + + /** + * Get volumeMounts + * @return volumeMounts + **/ + @javax.annotation.Nullable + public List getVolumeMounts() { + return volumeMounts; + } + + + public void setVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NewSandbox instance itself + */ + public NewSandbox putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NewSandbox newSandbox = (NewSandbox) o; + return Objects.equals(this.templateID, newSandbox.templateID) && + Objects.equals(this.timeout, newSandbox.timeout) && + Objects.equals(this.autoPause, newSandbox.autoPause) && + Objects.equals(this.autoResume, newSandbox.autoResume) && + Objects.equals(this.secure, newSandbox.secure) && + Objects.equals(this.allowInternetAccess, newSandbox.allowInternetAccess) && + Objects.equals(this.network, newSandbox.network) && + Objects.equals(this.metadata, newSandbox.metadata) && + Objects.equals(this.envVars, newSandbox.envVars) && + Objects.equals(this.mcp, newSandbox.mcp) && + Objects.equals(this.volumeMounts, newSandbox.volumeMounts)&& + Objects.equals(this.additionalProperties, newSandbox.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(templateID, timeout, autoPause, autoResume, secure, allowInternetAccess, network, metadata, envVars, mcp, volumeMounts, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NewSandbox {\n"); + sb.append(" templateID: ").append(toIndentedString(templateID)).append("\n"); + sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" autoPause: ").append(toIndentedString(autoPause)).append("\n"); + sb.append(" autoResume: ").append(toIndentedString(autoResume)).append("\n"); + sb.append(" secure: ").append(toIndentedString(secure)).append("\n"); + sb.append(" allowInternetAccess: ").append(toIndentedString(allowInternetAccess)).append("\n"); + sb.append(" network: ").append(toIndentedString(network)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" envVars: ").append(toIndentedString(envVars)).append("\n"); + sb.append(" mcp: ").append(toIndentedString(mcp)).append("\n"); + sb.append(" volumeMounts: ").append(toIndentedString(volumeMounts)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("templateID"); + openapiFields.add("timeout"); + openapiFields.add("autoPause"); + openapiFields.add("autoResume"); + openapiFields.add("secure"); + openapiFields.add("allow_internet_access"); + openapiFields.add("network"); + openapiFields.add("metadata"); + openapiFields.add("envVars"); + openapiFields.add("mcp"); + openapiFields.add("volumeMounts"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("templateID"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NewSandbox + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NewSandbox.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NewSandbox is not found in the empty JSON string", NewSandbox.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NewSandbox.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("templateID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `templateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateID").toString())); + } + // validate the optional field `autoResume` + if (jsonObj.get("autoResume") != null && !jsonObj.get("autoResume").isJsonNull()) { + SandboxAutoResumeConfig.validateJsonObject(jsonObj.getAsJsonObject("autoResume")); + } + // validate the optional field `network` + if (jsonObj.get("network") != null && !jsonObj.get("network").isJsonNull()) { + SandboxNetworkConfig.validateJsonObject(jsonObj.getAsJsonObject("network")); + } + if (jsonObj.get("volumeMounts") != null && !jsonObj.get("volumeMounts").isJsonNull()) { + JsonArray jsonArrayvolumeMounts = jsonObj.getAsJsonArray("volumeMounts"); + if (jsonArrayvolumeMounts != null) { + // ensure the json data is an array + if (!jsonObj.get("volumeMounts").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `volumeMounts` to be an array in the JSON string but got `%s`", jsonObj.get("volumeMounts").toString())); + } + + // validate the optional field `volumeMounts` (array) + for (int i = 0; i < jsonArrayvolumeMounts.size(); i++) { + SandboxVolumeMount.validateJsonObject(jsonArrayvolumeMounts.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NewSandbox.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NewSandbox' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NewSandbox.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NewSandbox value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NewSandbox read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NewSandbox instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NewSandbox given an JSON string + * + * @param jsonString JSON string + * @return An instance of NewSandbox + * @throws IOException if the JSON string is invalid with respect to NewSandbox + */ + public static NewSandbox fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NewSandbox.class); + } + + /** + * Convert an instance of NewSandbox to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewTeamAPIKey.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewTeamAPIKey.java new file mode 100644 index 0000000..0c31cf9 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewTeamAPIKey.java @@ -0,0 +1,291 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NewTeamAPIKey + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NewTeamAPIKey { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public NewTeamAPIKey() { + } + + public NewTeamAPIKey name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the API key + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NewTeamAPIKey instance itself + */ + public NewTeamAPIKey putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NewTeamAPIKey newTeamAPIKey = (NewTeamAPIKey) o; + return Objects.equals(this.name, newTeamAPIKey.name)&& + Objects.equals(this.additionalProperties, newTeamAPIKey.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NewTeamAPIKey {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NewTeamAPIKey + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NewTeamAPIKey.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NewTeamAPIKey is not found in the empty JSON string", NewTeamAPIKey.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NewTeamAPIKey.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NewTeamAPIKey.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NewTeamAPIKey' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NewTeamAPIKey.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NewTeamAPIKey value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NewTeamAPIKey read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NewTeamAPIKey instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NewTeamAPIKey given an JSON string + * + * @param jsonString JSON string + * @return An instance of NewTeamAPIKey + * @throws IOException if the JSON string is invalid with respect to NewTeamAPIKey + */ + public static NewTeamAPIKey fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NewTeamAPIKey.class); + } + + /** + * Convert an instance of NewTeamAPIKey to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewVolume.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewVolume.java new file mode 100644 index 0000000..8bb2b11 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NewVolume.java @@ -0,0 +1,291 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NewVolume + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NewVolume { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public NewVolume() { + } + + public NewVolume name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the volume + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NewVolume instance itself + */ + public NewVolume putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NewVolume newVolume = (NewVolume) o; + return Objects.equals(this.name, newVolume.name)&& + Objects.equals(this.additionalProperties, newVolume.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NewVolume {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NewVolume + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NewVolume.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NewVolume is not found in the empty JSON string", NewVolume.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NewVolume.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NewVolume.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NewVolume' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NewVolume.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NewVolume value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NewVolume read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NewVolume instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NewVolume given an JSON string + * + * @param jsonString JSON string + * @return An instance of NewVolume + * @throws IOException if the JSON string is invalid with respect to NewVolume + */ + public static NewVolume fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NewVolume.class); + } + + /** + * Convert an instance of NewVolume to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Node.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Node.java new file mode 100644 index 0000000..bc8d0a6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Node.java @@ -0,0 +1,666 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.MachineInfo; +import io.openkruise.agents.client.e2b.api.models.NodeMetrics; +import io.openkruise.agents.client.e2b.api.models.NodeStatus; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Node + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Node { + public static final String SERIALIZED_NAME_VERSION = "version"; + @SerializedName(SERIALIZED_NAME_VERSION) + private String version; + + public static final String SERIALIZED_NAME_COMMIT = "commit"; + @SerializedName(SERIALIZED_NAME_COMMIT) + private String commit; + + public static final String SERIALIZED_NAME_NODE_I_D = "nodeID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_NODE_I_D) + private String nodeID; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_SERVICE_INSTANCE_I_D = "serviceInstanceID"; + @SerializedName(SERIALIZED_NAME_SERVICE_INSTANCE_I_D) + private String serviceInstanceID; + + public static final String SERIALIZED_NAME_CLUSTER_I_D = "clusterID"; + @SerializedName(SERIALIZED_NAME_CLUSTER_I_D) + private String clusterID; + + public static final String SERIALIZED_NAME_MACHINE_INFO = "machineInfo"; + @SerializedName(SERIALIZED_NAME_MACHINE_INFO) + private MachineInfo machineInfo; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private NodeStatus status; + + public static final String SERIALIZED_NAME_SANDBOX_COUNT = "sandboxCount"; + @SerializedName(SERIALIZED_NAME_SANDBOX_COUNT) + private Integer sandboxCount; + + public static final String SERIALIZED_NAME_METRICS = "metrics"; + @SerializedName(SERIALIZED_NAME_METRICS) + private NodeMetrics metrics; + + public static final String SERIALIZED_NAME_CREATE_SUCCESSES = "createSuccesses"; + @SerializedName(SERIALIZED_NAME_CREATE_SUCCESSES) + private Integer createSuccesses; + + public static final String SERIALIZED_NAME_CREATE_FAILS = "createFails"; + @SerializedName(SERIALIZED_NAME_CREATE_FAILS) + private Integer createFails; + + public static final String SERIALIZED_NAME_SANDBOX_STARTING_COUNT = "sandboxStartingCount"; + @SerializedName(SERIALIZED_NAME_SANDBOX_STARTING_COUNT) + private Integer sandboxStartingCount; + + public Node() { + } + + public Node version(String version) { + + this.version = version; + return this; + } + + /** + * Version of the orchestrator + * @return version + **/ + @javax.annotation.Nonnull + public String getVersion() { + return version; + } + + + public void setVersion(String version) { + this.version = version; + } + + + public Node commit(String commit) { + + this.commit = commit; + return this; + } + + /** + * Commit of the orchestrator + * @return commit + **/ + @javax.annotation.Nonnull + public String getCommit() { + return commit; + } + + + public void setCommit(String commit) { + this.commit = commit; + } + + + @Deprecated + public Node nodeID(String nodeID) { + + this.nodeID = nodeID; + return this; + } + + /** + * Identifier of the nomad node + * @return nodeID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getNodeID() { + return nodeID; + } + + + @Deprecated + public void setNodeID(String nodeID) { + this.nodeID = nodeID; + } + + + public Node id(String id) { + + this.id = id; + return this; + } + + /** + * Identifier of the node + * @return id + **/ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public Node serviceInstanceID(String serviceInstanceID) { + + this.serviceInstanceID = serviceInstanceID; + return this; + } + + /** + * Service instance identifier of the node + * @return serviceInstanceID + **/ + @javax.annotation.Nonnull + public String getServiceInstanceID() { + return serviceInstanceID; + } + + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + + public Node clusterID(String clusterID) { + + this.clusterID = clusterID; + return this; + } + + /** + * Identifier of the cluster + * @return clusterID + **/ + @javax.annotation.Nonnull + public String getClusterID() { + return clusterID; + } + + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + + public Node machineInfo(MachineInfo machineInfo) { + + this.machineInfo = machineInfo; + return this; + } + + /** + * Get machineInfo + * @return machineInfo + **/ + @javax.annotation.Nonnull + public MachineInfo getMachineInfo() { + return machineInfo; + } + + + public void setMachineInfo(MachineInfo machineInfo) { + this.machineInfo = machineInfo; + } + + + public Node status(NodeStatus status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + public NodeStatus getStatus() { + return status; + } + + + public void setStatus(NodeStatus status) { + this.status = status; + } + + + public Node sandboxCount(Integer sandboxCount) { + + this.sandboxCount = sandboxCount; + return this; + } + + /** + * Number of sandboxes running on the node + * @return sandboxCount + **/ + @javax.annotation.Nonnull + public Integer getSandboxCount() { + return sandboxCount; + } + + + public void setSandboxCount(Integer sandboxCount) { + this.sandboxCount = sandboxCount; + } + + + public Node metrics(NodeMetrics metrics) { + + this.metrics = metrics; + return this; + } + + /** + * Get metrics + * @return metrics + **/ + @javax.annotation.Nonnull + public NodeMetrics getMetrics() { + return metrics; + } + + + public void setMetrics(NodeMetrics metrics) { + this.metrics = metrics; + } + + + public Node createSuccesses(Integer createSuccesses) { + + this.createSuccesses = createSuccesses; + return this; + } + + /** + * Number of sandbox create successes + * @return createSuccesses + **/ + @javax.annotation.Nonnull + public Integer getCreateSuccesses() { + return createSuccesses; + } + + + public void setCreateSuccesses(Integer createSuccesses) { + this.createSuccesses = createSuccesses; + } + + + public Node createFails(Integer createFails) { + + this.createFails = createFails; + return this; + } + + /** + * Number of sandbox create fails + * @return createFails + **/ + @javax.annotation.Nonnull + public Integer getCreateFails() { + return createFails; + } + + + public void setCreateFails(Integer createFails) { + this.createFails = createFails; + } + + + public Node sandboxStartingCount(Integer sandboxStartingCount) { + + this.sandboxStartingCount = sandboxStartingCount; + return this; + } + + /** + * Number of starting Sandboxes + * @return sandboxStartingCount + **/ + @javax.annotation.Nonnull + public Integer getSandboxStartingCount() { + return sandboxStartingCount; + } + + + public void setSandboxStartingCount(Integer sandboxStartingCount) { + this.sandboxStartingCount = sandboxStartingCount; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Node instance itself + */ + public Node putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Node node = (Node) o; + return Objects.equals(this.version, node.version) && + Objects.equals(this.commit, node.commit) && + Objects.equals(this.nodeID, node.nodeID) && + Objects.equals(this.id, node.id) && + Objects.equals(this.serviceInstanceID, node.serviceInstanceID) && + Objects.equals(this.clusterID, node.clusterID) && + Objects.equals(this.machineInfo, node.machineInfo) && + Objects.equals(this.status, node.status) && + Objects.equals(this.sandboxCount, node.sandboxCount) && + Objects.equals(this.metrics, node.metrics) && + Objects.equals(this.createSuccesses, node.createSuccesses) && + Objects.equals(this.createFails, node.createFails) && + Objects.equals(this.sandboxStartingCount, node.sandboxStartingCount)&& + Objects.equals(this.additionalProperties, node.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(version, commit, nodeID, id, serviceInstanceID, clusterID, machineInfo, status, sandboxCount, metrics, createSuccesses, createFails, sandboxStartingCount, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Node {\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" commit: ").append(toIndentedString(commit)).append("\n"); + sb.append(" nodeID: ").append(toIndentedString(nodeID)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" serviceInstanceID: ").append(toIndentedString(serviceInstanceID)).append("\n"); + sb.append(" clusterID: ").append(toIndentedString(clusterID)).append("\n"); + sb.append(" machineInfo: ").append(toIndentedString(machineInfo)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" sandboxCount: ").append(toIndentedString(sandboxCount)).append("\n"); + sb.append(" metrics: ").append(toIndentedString(metrics)).append("\n"); + sb.append(" createSuccesses: ").append(toIndentedString(createSuccesses)).append("\n"); + sb.append(" createFails: ").append(toIndentedString(createFails)).append("\n"); + sb.append(" sandboxStartingCount: ").append(toIndentedString(sandboxStartingCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("version"); + openapiFields.add("commit"); + openapiFields.add("nodeID"); + openapiFields.add("id"); + openapiFields.add("serviceInstanceID"); + openapiFields.add("clusterID"); + openapiFields.add("machineInfo"); + openapiFields.add("status"); + openapiFields.add("sandboxCount"); + openapiFields.add("metrics"); + openapiFields.add("createSuccesses"); + openapiFields.add("createFails"); + openapiFields.add("sandboxStartingCount"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("version"); + openapiRequiredFields.add("commit"); + openapiRequiredFields.add("nodeID"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("serviceInstanceID"); + openapiRequiredFields.add("clusterID"); + openapiRequiredFields.add("machineInfo"); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("sandboxCount"); + openapiRequiredFields.add("metrics"); + openapiRequiredFields.add("createSuccesses"); + openapiRequiredFields.add("createFails"); + openapiRequiredFields.add("sandboxStartingCount"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Node + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Node.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Node is not found in the empty JSON string", Node.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Node.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("version").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + } + if (!jsonObj.get("commit").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `commit` to be a primitive type in the JSON string but got `%s`", jsonObj.get("commit").toString())); + } + if (!jsonObj.get("nodeID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `nodeID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nodeID").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("serviceInstanceID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `serviceInstanceID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serviceInstanceID").toString())); + } + if (!jsonObj.get("clusterID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clusterID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clusterID").toString())); + } + // validate the required field `machineInfo` + MachineInfo.validateJsonObject(jsonObj.getAsJsonObject("machineInfo")); + // validate the required field `metrics` + NodeMetrics.validateJsonObject(jsonObj.getAsJsonObject("metrics")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Node.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Node' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Node.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Node value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Node read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + Node instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Node given an JSON string + * + * @param jsonString JSON string + * @return An instance of Node + * @throws IOException if the JSON string is invalid with respect to Node + */ + public static Node fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Node.class); + } + + /** + * Convert an instance of Node to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeDetail.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeDetail.java new file mode 100644 index 0000000..64a0453 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeDetail.java @@ -0,0 +1,701 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.ListedSandbox; +import io.openkruise.agents.client.e2b.api.models.MachineInfo; +import io.openkruise.agents.client.e2b.api.models.NodeMetrics; +import io.openkruise.agents.client.e2b.api.models.NodeStatus; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NodeDetail + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NodeDetail { + public static final String SERIALIZED_NAME_CLUSTER_I_D = "clusterID"; + @SerializedName(SERIALIZED_NAME_CLUSTER_I_D) + private String clusterID; + + public static final String SERIALIZED_NAME_VERSION = "version"; + @SerializedName(SERIALIZED_NAME_VERSION) + private String version; + + public static final String SERIALIZED_NAME_COMMIT = "commit"; + @SerializedName(SERIALIZED_NAME_COMMIT) + private String commit; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_SERVICE_INSTANCE_I_D = "serviceInstanceID"; + @SerializedName(SERIALIZED_NAME_SERVICE_INSTANCE_I_D) + private String serviceInstanceID; + + public static final String SERIALIZED_NAME_NODE_I_D = "nodeID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_NODE_I_D) + private String nodeID; + + public static final String SERIALIZED_NAME_MACHINE_INFO = "machineInfo"; + @SerializedName(SERIALIZED_NAME_MACHINE_INFO) + private MachineInfo machineInfo; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private NodeStatus status; + + public static final String SERIALIZED_NAME_SANDBOXES = "sandboxes"; + @SerializedName(SERIALIZED_NAME_SANDBOXES) + private List sandboxes = new ArrayList<>(); + + public static final String SERIALIZED_NAME_METRICS = "metrics"; + @SerializedName(SERIALIZED_NAME_METRICS) + private NodeMetrics metrics; + + public static final String SERIALIZED_NAME_CACHED_BUILDS = "cachedBuilds"; + @SerializedName(SERIALIZED_NAME_CACHED_BUILDS) + private List cachedBuilds = new ArrayList<>(); + + public static final String SERIALIZED_NAME_CREATE_SUCCESSES = "createSuccesses"; + @SerializedName(SERIALIZED_NAME_CREATE_SUCCESSES) + private Integer createSuccesses; + + public static final String SERIALIZED_NAME_CREATE_FAILS = "createFails"; + @SerializedName(SERIALIZED_NAME_CREATE_FAILS) + private Integer createFails; + + public NodeDetail() { + } + + public NodeDetail clusterID(String clusterID) { + + this.clusterID = clusterID; + return this; + } + + /** + * Identifier of the cluster + * @return clusterID + **/ + @javax.annotation.Nonnull + public String getClusterID() { + return clusterID; + } + + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + + public NodeDetail version(String version) { + + this.version = version; + return this; + } + + /** + * Version of the orchestrator + * @return version + **/ + @javax.annotation.Nonnull + public String getVersion() { + return version; + } + + + public void setVersion(String version) { + this.version = version; + } + + + public NodeDetail commit(String commit) { + + this.commit = commit; + return this; + } + + /** + * Commit of the orchestrator + * @return commit + **/ + @javax.annotation.Nonnull + public String getCommit() { + return commit; + } + + + public void setCommit(String commit) { + this.commit = commit; + } + + + public NodeDetail id(String id) { + + this.id = id; + return this; + } + + /** + * Identifier of the node + * @return id + **/ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public NodeDetail serviceInstanceID(String serviceInstanceID) { + + this.serviceInstanceID = serviceInstanceID; + return this; + } + + /** + * Service instance identifier of the node + * @return serviceInstanceID + **/ + @javax.annotation.Nonnull + public String getServiceInstanceID() { + return serviceInstanceID; + } + + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + + @Deprecated + public NodeDetail nodeID(String nodeID) { + + this.nodeID = nodeID; + return this; + } + + /** + * Identifier of the nomad node + * @return nodeID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getNodeID() { + return nodeID; + } + + + @Deprecated + public void setNodeID(String nodeID) { + this.nodeID = nodeID; + } + + + public NodeDetail machineInfo(MachineInfo machineInfo) { + + this.machineInfo = machineInfo; + return this; + } + + /** + * Get machineInfo + * @return machineInfo + **/ + @javax.annotation.Nonnull + public MachineInfo getMachineInfo() { + return machineInfo; + } + + + public void setMachineInfo(MachineInfo machineInfo) { + this.machineInfo = machineInfo; + } + + + public NodeDetail status(NodeStatus status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + public NodeStatus getStatus() { + return status; + } + + + public void setStatus(NodeStatus status) { + this.status = status; + } + + + public NodeDetail sandboxes(List sandboxes) { + + this.sandboxes = sandboxes; + return this; + } + + public NodeDetail addSandboxesItem(ListedSandbox sandboxesItem) { + if (this.sandboxes == null) { + this.sandboxes = new ArrayList<>(); + } + this.sandboxes.add(sandboxesItem); + return this; + } + + /** + * List of sandboxes running on the node + * @return sandboxes + **/ + @javax.annotation.Nonnull + public List getSandboxes() { + return sandboxes; + } + + + public void setSandboxes(List sandboxes) { + this.sandboxes = sandboxes; + } + + + public NodeDetail metrics(NodeMetrics metrics) { + + this.metrics = metrics; + return this; + } + + /** + * Get metrics + * @return metrics + **/ + @javax.annotation.Nonnull + public NodeMetrics getMetrics() { + return metrics; + } + + + public void setMetrics(NodeMetrics metrics) { + this.metrics = metrics; + } + + + public NodeDetail cachedBuilds(List cachedBuilds) { + + this.cachedBuilds = cachedBuilds; + return this; + } + + public NodeDetail addCachedBuildsItem(String cachedBuildsItem) { + if (this.cachedBuilds == null) { + this.cachedBuilds = new ArrayList<>(); + } + this.cachedBuilds.add(cachedBuildsItem); + return this; + } + + /** + * List of cached builds id on the node + * @return cachedBuilds + **/ + @javax.annotation.Nonnull + public List getCachedBuilds() { + return cachedBuilds; + } + + + public void setCachedBuilds(List cachedBuilds) { + this.cachedBuilds = cachedBuilds; + } + + + public NodeDetail createSuccesses(Integer createSuccesses) { + + this.createSuccesses = createSuccesses; + return this; + } + + /** + * Number of sandbox create successes + * @return createSuccesses + **/ + @javax.annotation.Nonnull + public Integer getCreateSuccesses() { + return createSuccesses; + } + + + public void setCreateSuccesses(Integer createSuccesses) { + this.createSuccesses = createSuccesses; + } + + + public NodeDetail createFails(Integer createFails) { + + this.createFails = createFails; + return this; + } + + /** + * Number of sandbox create fails + * @return createFails + **/ + @javax.annotation.Nonnull + public Integer getCreateFails() { + return createFails; + } + + + public void setCreateFails(Integer createFails) { + this.createFails = createFails; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NodeDetail instance itself + */ + public NodeDetail putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NodeDetail nodeDetail = (NodeDetail) o; + return Objects.equals(this.clusterID, nodeDetail.clusterID) && + Objects.equals(this.version, nodeDetail.version) && + Objects.equals(this.commit, nodeDetail.commit) && + Objects.equals(this.id, nodeDetail.id) && + Objects.equals(this.serviceInstanceID, nodeDetail.serviceInstanceID) && + Objects.equals(this.nodeID, nodeDetail.nodeID) && + Objects.equals(this.machineInfo, nodeDetail.machineInfo) && + Objects.equals(this.status, nodeDetail.status) && + Objects.equals(this.sandboxes, nodeDetail.sandboxes) && + Objects.equals(this.metrics, nodeDetail.metrics) && + Objects.equals(this.cachedBuilds, nodeDetail.cachedBuilds) && + Objects.equals(this.createSuccesses, nodeDetail.createSuccesses) && + Objects.equals(this.createFails, nodeDetail.createFails)&& + Objects.equals(this.additionalProperties, nodeDetail.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(clusterID, version, commit, id, serviceInstanceID, nodeID, machineInfo, status, sandboxes, metrics, cachedBuilds, createSuccesses, createFails, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NodeDetail {\n"); + sb.append(" clusterID: ").append(toIndentedString(clusterID)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" commit: ").append(toIndentedString(commit)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" serviceInstanceID: ").append(toIndentedString(serviceInstanceID)).append("\n"); + sb.append(" nodeID: ").append(toIndentedString(nodeID)).append("\n"); + sb.append(" machineInfo: ").append(toIndentedString(machineInfo)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" sandboxes: ").append(toIndentedString(sandboxes)).append("\n"); + sb.append(" metrics: ").append(toIndentedString(metrics)).append("\n"); + sb.append(" cachedBuilds: ").append(toIndentedString(cachedBuilds)).append("\n"); + sb.append(" createSuccesses: ").append(toIndentedString(createSuccesses)).append("\n"); + sb.append(" createFails: ").append(toIndentedString(createFails)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("clusterID"); + openapiFields.add("version"); + openapiFields.add("commit"); + openapiFields.add("id"); + openapiFields.add("serviceInstanceID"); + openapiFields.add("nodeID"); + openapiFields.add("machineInfo"); + openapiFields.add("status"); + openapiFields.add("sandboxes"); + openapiFields.add("metrics"); + openapiFields.add("cachedBuilds"); + openapiFields.add("createSuccesses"); + openapiFields.add("createFails"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("clusterID"); + openapiRequiredFields.add("version"); + openapiRequiredFields.add("commit"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("serviceInstanceID"); + openapiRequiredFields.add("nodeID"); + openapiRequiredFields.add("machineInfo"); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("sandboxes"); + openapiRequiredFields.add("metrics"); + openapiRequiredFields.add("cachedBuilds"); + openapiRequiredFields.add("createSuccesses"); + openapiRequiredFields.add("createFails"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NodeDetail + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NodeDetail.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NodeDetail is not found in the empty JSON string", NodeDetail.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NodeDetail.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("clusterID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clusterID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clusterID").toString())); + } + if (!jsonObj.get("version").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + } + if (!jsonObj.get("commit").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `commit` to be a primitive type in the JSON string but got `%s`", jsonObj.get("commit").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("serviceInstanceID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `serviceInstanceID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serviceInstanceID").toString())); + } + if (!jsonObj.get("nodeID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `nodeID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nodeID").toString())); + } + // validate the required field `machineInfo` + MachineInfo.validateJsonObject(jsonObj.getAsJsonObject("machineInfo")); + // ensure the json data is an array + if (!jsonObj.get("sandboxes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `sandboxes` to be an array in the JSON string but got `%s`", jsonObj.get("sandboxes").toString())); + } + + JsonArray jsonArraysandboxes = jsonObj.getAsJsonArray("sandboxes"); + // validate the required field `sandboxes` (array) + for (int i = 0; i < jsonArraysandboxes.size(); i++) { + ListedSandbox.validateJsonObject(jsonArraysandboxes.get(i).getAsJsonObject()); + }; + // validate the required field `metrics` + NodeMetrics.validateJsonObject(jsonObj.getAsJsonObject("metrics")); + // ensure the required json array is present + if (jsonObj.get("cachedBuilds") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("cachedBuilds").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `cachedBuilds` to be an array in the JSON string but got `%s`", jsonObj.get("cachedBuilds").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NodeDetail.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NodeDetail' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NodeDetail.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NodeDetail value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NodeDetail read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NodeDetail instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NodeDetail given an JSON string + * + * @param jsonString JSON string + * @return An instance of NodeDetail + * @throws IOException if the JSON string is invalid with respect to NodeDetail + */ + public static NodeDetail fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NodeDetail.class); + } + + /** + * Convert an instance of NodeDetail to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeMetrics.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeMetrics.java new file mode 100644 index 0000000..38c079f --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeMetrics.java @@ -0,0 +1,483 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.DiskMetrics; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Node metrics + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NodeMetrics { + public static final String SERIALIZED_NAME_ALLOCATED_C_P_U = "allocatedCPU"; + @SerializedName(SERIALIZED_NAME_ALLOCATED_C_P_U) + private Integer allocatedCPU; + + public static final String SERIALIZED_NAME_CPU_PERCENT = "cpuPercent"; + @SerializedName(SERIALIZED_NAME_CPU_PERCENT) + private Integer cpuPercent; + + public static final String SERIALIZED_NAME_CPU_COUNT = "cpuCount"; + @SerializedName(SERIALIZED_NAME_CPU_COUNT) + private Integer cpuCount; + + public static final String SERIALIZED_NAME_ALLOCATED_MEMORY_BYTES = "allocatedMemoryBytes"; + @SerializedName(SERIALIZED_NAME_ALLOCATED_MEMORY_BYTES) + private Integer allocatedMemoryBytes; + + public static final String SERIALIZED_NAME_MEMORY_USED_BYTES = "memoryUsedBytes"; + @SerializedName(SERIALIZED_NAME_MEMORY_USED_BYTES) + private Integer memoryUsedBytes; + + public static final String SERIALIZED_NAME_MEMORY_TOTAL_BYTES = "memoryTotalBytes"; + @SerializedName(SERIALIZED_NAME_MEMORY_TOTAL_BYTES) + private Integer memoryTotalBytes; + + public static final String SERIALIZED_NAME_DISKS = "disks"; + @SerializedName(SERIALIZED_NAME_DISKS) + private List disks = new ArrayList<>(); + + public NodeMetrics() { + } + + public NodeMetrics allocatedCPU(Integer allocatedCPU) { + + this.allocatedCPU = allocatedCPU; + return this; + } + + /** + * Number of allocated CPU cores + * @return allocatedCPU + **/ + @javax.annotation.Nonnull + public Integer getAllocatedCPU() { + return allocatedCPU; + } + + + public void setAllocatedCPU(Integer allocatedCPU) { + this.allocatedCPU = allocatedCPU; + } + + + public NodeMetrics cpuPercent(Integer cpuPercent) { + + this.cpuPercent = cpuPercent; + return this; + } + + /** + * Node CPU usage percentage + * @return cpuPercent + **/ + @javax.annotation.Nonnull + public Integer getCpuPercent() { + return cpuPercent; + } + + + public void setCpuPercent(Integer cpuPercent) { + this.cpuPercent = cpuPercent; + } + + + public NodeMetrics cpuCount(Integer cpuCount) { + + this.cpuCount = cpuCount; + return this; + } + + /** + * Total number of CPU cores on the node + * @return cpuCount + **/ + @javax.annotation.Nonnull + public Integer getCpuCount() { + return cpuCount; + } + + + public void setCpuCount(Integer cpuCount) { + this.cpuCount = cpuCount; + } + + + public NodeMetrics allocatedMemoryBytes(Integer allocatedMemoryBytes) { + + this.allocatedMemoryBytes = allocatedMemoryBytes; + return this; + } + + /** + * Amount of allocated memory in bytes + * @return allocatedMemoryBytes + **/ + @javax.annotation.Nonnull + public Integer getAllocatedMemoryBytes() { + return allocatedMemoryBytes; + } + + + public void setAllocatedMemoryBytes(Integer allocatedMemoryBytes) { + this.allocatedMemoryBytes = allocatedMemoryBytes; + } + + + public NodeMetrics memoryUsedBytes(Integer memoryUsedBytes) { + + this.memoryUsedBytes = memoryUsedBytes; + return this; + } + + /** + * Node memory used in bytes + * @return memoryUsedBytes + **/ + @javax.annotation.Nonnull + public Integer getMemoryUsedBytes() { + return memoryUsedBytes; + } + + + public void setMemoryUsedBytes(Integer memoryUsedBytes) { + this.memoryUsedBytes = memoryUsedBytes; + } + + + public NodeMetrics memoryTotalBytes(Integer memoryTotalBytes) { + + this.memoryTotalBytes = memoryTotalBytes; + return this; + } + + /** + * Total node memory in bytes + * @return memoryTotalBytes + **/ + @javax.annotation.Nonnull + public Integer getMemoryTotalBytes() { + return memoryTotalBytes; + } + + + public void setMemoryTotalBytes(Integer memoryTotalBytes) { + this.memoryTotalBytes = memoryTotalBytes; + } + + + public NodeMetrics disks(List disks) { + + this.disks = disks; + return this; + } + + public NodeMetrics addDisksItem(DiskMetrics disksItem) { + if (this.disks == null) { + this.disks = new ArrayList<>(); + } + this.disks.add(disksItem); + return this; + } + + /** + * Detailed metrics for each disk/mount point + * @return disks + **/ + @javax.annotation.Nonnull + public List getDisks() { + return disks; + } + + + public void setDisks(List disks) { + this.disks = disks; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NodeMetrics instance itself + */ + public NodeMetrics putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NodeMetrics nodeMetrics = (NodeMetrics) o; + return Objects.equals(this.allocatedCPU, nodeMetrics.allocatedCPU) && + Objects.equals(this.cpuPercent, nodeMetrics.cpuPercent) && + Objects.equals(this.cpuCount, nodeMetrics.cpuCount) && + Objects.equals(this.allocatedMemoryBytes, nodeMetrics.allocatedMemoryBytes) && + Objects.equals(this.memoryUsedBytes, nodeMetrics.memoryUsedBytes) && + Objects.equals(this.memoryTotalBytes, nodeMetrics.memoryTotalBytes) && + Objects.equals(this.disks, nodeMetrics.disks)&& + Objects.equals(this.additionalProperties, nodeMetrics.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(allocatedCPU, cpuPercent, cpuCount, allocatedMemoryBytes, memoryUsedBytes, memoryTotalBytes, disks, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NodeMetrics {\n"); + sb.append(" allocatedCPU: ").append(toIndentedString(allocatedCPU)).append("\n"); + sb.append(" cpuPercent: ").append(toIndentedString(cpuPercent)).append("\n"); + sb.append(" cpuCount: ").append(toIndentedString(cpuCount)).append("\n"); + sb.append(" allocatedMemoryBytes: ").append(toIndentedString(allocatedMemoryBytes)).append("\n"); + sb.append(" memoryUsedBytes: ").append(toIndentedString(memoryUsedBytes)).append("\n"); + sb.append(" memoryTotalBytes: ").append(toIndentedString(memoryTotalBytes)).append("\n"); + sb.append(" disks: ").append(toIndentedString(disks)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("allocatedCPU"); + openapiFields.add("cpuPercent"); + openapiFields.add("cpuCount"); + openapiFields.add("allocatedMemoryBytes"); + openapiFields.add("memoryUsedBytes"); + openapiFields.add("memoryTotalBytes"); + openapiFields.add("disks"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("allocatedCPU"); + openapiRequiredFields.add("cpuPercent"); + openapiRequiredFields.add("cpuCount"); + openapiRequiredFields.add("allocatedMemoryBytes"); + openapiRequiredFields.add("memoryUsedBytes"); + openapiRequiredFields.add("memoryTotalBytes"); + openapiRequiredFields.add("disks"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NodeMetrics + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NodeMetrics.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NodeMetrics is not found in the empty JSON string", NodeMetrics.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NodeMetrics.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("disks").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `disks` to be an array in the JSON string but got `%s`", jsonObj.get("disks").toString())); + } + + JsonArray jsonArraydisks = jsonObj.getAsJsonArray("disks"); + // validate the required field `disks` (array) + for (int i = 0; i < jsonArraydisks.size(); i++) { + DiskMetrics.validateJsonObject(jsonArraydisks.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NodeMetrics.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NodeMetrics' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NodeMetrics.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NodeMetrics value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NodeMetrics read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NodeMetrics instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NodeMetrics given an JSON string + * + * @param jsonString JSON string + * @return An instance of NodeMetrics + * @throws IOException if the JSON string is invalid with respect to NodeMetrics + */ + public static NodeMetrics fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NodeMetrics.class); + } + + /** + * Convert an instance of NodeMetrics to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeStatus.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeStatus.java new file mode 100644 index 0000000..4b422d7 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeStatus.java @@ -0,0 +1,77 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Status of the node + */ +@JsonAdapter(NodeStatus.Adapter.class) +public enum NodeStatus { + + NodeStatusReady("ready"), + + NodeStatusDraining("draining"), + + NodeStatusConnecting("connecting"), + + NodeStatusUnhealthy("unhealthy"); + + private String value; + + NodeStatus(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static NodeStatus fromValue(String value) { + for (NodeStatus b : NodeStatus.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final NodeStatus enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public NodeStatus read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return NodeStatus.fromValue(value); + } + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeStatusChange.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeStatusChange.java new file mode 100644 index 0000000..2c7e94d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodeStatusChange.java @@ -0,0 +1,321 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.NodeStatus; +import java.io.IOException; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NodeStatusChange + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NodeStatusChange { + public static final String SERIALIZED_NAME_CLUSTER_I_D = "clusterID"; + @SerializedName(SERIALIZED_NAME_CLUSTER_I_D) + private UUID clusterID; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private NodeStatus status; + + public NodeStatusChange() { + } + + public NodeStatusChange clusterID(UUID clusterID) { + + this.clusterID = clusterID; + return this; + } + + /** + * Identifier of the cluster + * @return clusterID + **/ + @javax.annotation.Nullable + public UUID getClusterID() { + return clusterID; + } + + + public void setClusterID(UUID clusterID) { + this.clusterID = clusterID; + } + + + public NodeStatusChange status(NodeStatus status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + public NodeStatus getStatus() { + return status; + } + + + public void setStatus(NodeStatus status) { + this.status = status; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NodeStatusChange instance itself + */ + public NodeStatusChange putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NodeStatusChange nodeStatusChange = (NodeStatusChange) o; + return Objects.equals(this.clusterID, nodeStatusChange.clusterID) && + Objects.equals(this.status, nodeStatusChange.status)&& + Objects.equals(this.additionalProperties, nodeStatusChange.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(clusterID, status, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NodeStatusChange {\n"); + sb.append(" clusterID: ").append(toIndentedString(clusterID)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("clusterID"); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("status"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NodeStatusChange + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NodeStatusChange.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NodeStatusChange is not found in the empty JSON string", NodeStatusChange.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NodeStatusChange.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if ((jsonObj.get("clusterID") != null && !jsonObj.get("clusterID").isJsonNull()) && !jsonObj.get("clusterID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clusterID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clusterID").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NodeStatusChange.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NodeStatusChange' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NodeStatusChange.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NodeStatusChange value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NodeStatusChange read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NodeStatusChange instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NodeStatusChange given an JSON string + * + * @param jsonString JSON string + * @return An instance of NodeStatusChange + * @throws IOException if the JSON string is invalid with respect to NodeStatusChange + */ + public static NodeStatusChange fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NodeStatusChange.class); + } + + /** + * Convert an instance of NodeStatusChange to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodesGet200ResponseInner.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodesGet200ResponseInner.java new file mode 100644 index 0000000..72196d6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/NodesGet200ResponseInner.java @@ -0,0 +1,666 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.MachineInfo; +import io.openkruise.agents.client.e2b.api.models.NodeMetrics; +import io.openkruise.agents.client.e2b.api.models.NodeStatus; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * NodesGet200ResponseInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class NodesGet200ResponseInner { + public static final String SERIALIZED_NAME_VERSION = "version"; + @SerializedName(SERIALIZED_NAME_VERSION) + private String version; + + public static final String SERIALIZED_NAME_COMMIT = "commit"; + @SerializedName(SERIALIZED_NAME_COMMIT) + private String commit; + + public static final String SERIALIZED_NAME_NODE_I_D = "nodeID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_NODE_I_D) + private String nodeID; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_SERVICE_INSTANCE_I_D = "serviceInstanceID"; + @SerializedName(SERIALIZED_NAME_SERVICE_INSTANCE_I_D) + private String serviceInstanceID; + + public static final String SERIALIZED_NAME_CLUSTER_I_D = "clusterID"; + @SerializedName(SERIALIZED_NAME_CLUSTER_I_D) + private String clusterID; + + public static final String SERIALIZED_NAME_MACHINE_INFO = "machineInfo"; + @SerializedName(SERIALIZED_NAME_MACHINE_INFO) + private MachineInfo machineInfo; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private NodeStatus status; + + public static final String SERIALIZED_NAME_SANDBOX_COUNT = "sandboxCount"; + @SerializedName(SERIALIZED_NAME_SANDBOX_COUNT) + private Integer sandboxCount; + + public static final String SERIALIZED_NAME_METRICS = "metrics"; + @SerializedName(SERIALIZED_NAME_METRICS) + private NodeMetrics metrics; + + public static final String SERIALIZED_NAME_CREATE_SUCCESSES = "createSuccesses"; + @SerializedName(SERIALIZED_NAME_CREATE_SUCCESSES) + private Integer createSuccesses; + + public static final String SERIALIZED_NAME_CREATE_FAILS = "createFails"; + @SerializedName(SERIALIZED_NAME_CREATE_FAILS) + private Integer createFails; + + public static final String SERIALIZED_NAME_SANDBOX_STARTING_COUNT = "sandboxStartingCount"; + @SerializedName(SERIALIZED_NAME_SANDBOX_STARTING_COUNT) + private Integer sandboxStartingCount; + + public NodesGet200ResponseInner() { + } + + public NodesGet200ResponseInner version(String version) { + + this.version = version; + return this; + } + + /** + * Version of the orchestrator + * @return version + **/ + @javax.annotation.Nonnull + public String getVersion() { + return version; + } + + + public void setVersion(String version) { + this.version = version; + } + + + public NodesGet200ResponseInner commit(String commit) { + + this.commit = commit; + return this; + } + + /** + * Commit of the orchestrator + * @return commit + **/ + @javax.annotation.Nonnull + public String getCommit() { + return commit; + } + + + public void setCommit(String commit) { + this.commit = commit; + } + + + @Deprecated + public NodesGet200ResponseInner nodeID(String nodeID) { + + this.nodeID = nodeID; + return this; + } + + /** + * Identifier of the nomad node + * @return nodeID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getNodeID() { + return nodeID; + } + + + @Deprecated + public void setNodeID(String nodeID) { + this.nodeID = nodeID; + } + + + public NodesGet200ResponseInner id(String id) { + + this.id = id; + return this; + } + + /** + * Identifier of the node + * @return id + **/ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public NodesGet200ResponseInner serviceInstanceID(String serviceInstanceID) { + + this.serviceInstanceID = serviceInstanceID; + return this; + } + + /** + * Service instance identifier of the node + * @return serviceInstanceID + **/ + @javax.annotation.Nonnull + public String getServiceInstanceID() { + return serviceInstanceID; + } + + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + + public NodesGet200ResponseInner clusterID(String clusterID) { + + this.clusterID = clusterID; + return this; + } + + /** + * Identifier of the cluster + * @return clusterID + **/ + @javax.annotation.Nonnull + public String getClusterID() { + return clusterID; + } + + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + + public NodesGet200ResponseInner machineInfo(MachineInfo machineInfo) { + + this.machineInfo = machineInfo; + return this; + } + + /** + * Get machineInfo + * @return machineInfo + **/ + @javax.annotation.Nonnull + public MachineInfo getMachineInfo() { + return machineInfo; + } + + + public void setMachineInfo(MachineInfo machineInfo) { + this.machineInfo = machineInfo; + } + + + public NodesGet200ResponseInner status(NodeStatus status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + public NodeStatus getStatus() { + return status; + } + + + public void setStatus(NodeStatus status) { + this.status = status; + } + + + public NodesGet200ResponseInner sandboxCount(Integer sandboxCount) { + + this.sandboxCount = sandboxCount; + return this; + } + + /** + * Number of sandboxes running on the node + * @return sandboxCount + **/ + @javax.annotation.Nonnull + public Integer getSandboxCount() { + return sandboxCount; + } + + + public void setSandboxCount(Integer sandboxCount) { + this.sandboxCount = sandboxCount; + } + + + public NodesGet200ResponseInner metrics(NodeMetrics metrics) { + + this.metrics = metrics; + return this; + } + + /** + * Get metrics + * @return metrics + **/ + @javax.annotation.Nonnull + public NodeMetrics getMetrics() { + return metrics; + } + + + public void setMetrics(NodeMetrics metrics) { + this.metrics = metrics; + } + + + public NodesGet200ResponseInner createSuccesses(Integer createSuccesses) { + + this.createSuccesses = createSuccesses; + return this; + } + + /** + * Number of sandbox create successes + * @return createSuccesses + **/ + @javax.annotation.Nonnull + public Integer getCreateSuccesses() { + return createSuccesses; + } + + + public void setCreateSuccesses(Integer createSuccesses) { + this.createSuccesses = createSuccesses; + } + + + public NodesGet200ResponseInner createFails(Integer createFails) { + + this.createFails = createFails; + return this; + } + + /** + * Number of sandbox create fails + * @return createFails + **/ + @javax.annotation.Nonnull + public Integer getCreateFails() { + return createFails; + } + + + public void setCreateFails(Integer createFails) { + this.createFails = createFails; + } + + + public NodesGet200ResponseInner sandboxStartingCount(Integer sandboxStartingCount) { + + this.sandboxStartingCount = sandboxStartingCount; + return this; + } + + /** + * Number of starting Sandboxes + * @return sandboxStartingCount + **/ + @javax.annotation.Nonnull + public Integer getSandboxStartingCount() { + return sandboxStartingCount; + } + + + public void setSandboxStartingCount(Integer sandboxStartingCount) { + this.sandboxStartingCount = sandboxStartingCount; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NodesGet200ResponseInner instance itself + */ + public NodesGet200ResponseInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NodesGet200ResponseInner nodesGet200ResponseInner = (NodesGet200ResponseInner) o; + return Objects.equals(this.version, nodesGet200ResponseInner.version) && + Objects.equals(this.commit, nodesGet200ResponseInner.commit) && + Objects.equals(this.nodeID, nodesGet200ResponseInner.nodeID) && + Objects.equals(this.id, nodesGet200ResponseInner.id) && + Objects.equals(this.serviceInstanceID, nodesGet200ResponseInner.serviceInstanceID) && + Objects.equals(this.clusterID, nodesGet200ResponseInner.clusterID) && + Objects.equals(this.machineInfo, nodesGet200ResponseInner.machineInfo) && + Objects.equals(this.status, nodesGet200ResponseInner.status) && + Objects.equals(this.sandboxCount, nodesGet200ResponseInner.sandboxCount) && + Objects.equals(this.metrics, nodesGet200ResponseInner.metrics) && + Objects.equals(this.createSuccesses, nodesGet200ResponseInner.createSuccesses) && + Objects.equals(this.createFails, nodesGet200ResponseInner.createFails) && + Objects.equals(this.sandboxStartingCount, nodesGet200ResponseInner.sandboxStartingCount)&& + Objects.equals(this.additionalProperties, nodesGet200ResponseInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(version, commit, nodeID, id, serviceInstanceID, clusterID, machineInfo, status, sandboxCount, metrics, createSuccesses, createFails, sandboxStartingCount, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NodesGet200ResponseInner {\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" commit: ").append(toIndentedString(commit)).append("\n"); + sb.append(" nodeID: ").append(toIndentedString(nodeID)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" serviceInstanceID: ").append(toIndentedString(serviceInstanceID)).append("\n"); + sb.append(" clusterID: ").append(toIndentedString(clusterID)).append("\n"); + sb.append(" machineInfo: ").append(toIndentedString(machineInfo)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" sandboxCount: ").append(toIndentedString(sandboxCount)).append("\n"); + sb.append(" metrics: ").append(toIndentedString(metrics)).append("\n"); + sb.append(" createSuccesses: ").append(toIndentedString(createSuccesses)).append("\n"); + sb.append(" createFails: ").append(toIndentedString(createFails)).append("\n"); + sb.append(" sandboxStartingCount: ").append(toIndentedString(sandboxStartingCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("version"); + openapiFields.add("commit"); + openapiFields.add("nodeID"); + openapiFields.add("id"); + openapiFields.add("serviceInstanceID"); + openapiFields.add("clusterID"); + openapiFields.add("machineInfo"); + openapiFields.add("status"); + openapiFields.add("sandboxCount"); + openapiFields.add("metrics"); + openapiFields.add("createSuccesses"); + openapiFields.add("createFails"); + openapiFields.add("sandboxStartingCount"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("version"); + openapiRequiredFields.add("commit"); + openapiRequiredFields.add("nodeID"); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("serviceInstanceID"); + openapiRequiredFields.add("clusterID"); + openapiRequiredFields.add("machineInfo"); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("sandboxCount"); + openapiRequiredFields.add("metrics"); + openapiRequiredFields.add("createSuccesses"); + openapiRequiredFields.add("createFails"); + openapiRequiredFields.add("sandboxStartingCount"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NodesGet200ResponseInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NodesGet200ResponseInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NodesGet200ResponseInner is not found in the empty JSON string", NodesGet200ResponseInner.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : NodesGet200ResponseInner.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("version").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + } + if (!jsonObj.get("commit").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `commit` to be a primitive type in the JSON string but got `%s`", jsonObj.get("commit").toString())); + } + if (!jsonObj.get("nodeID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `nodeID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nodeID").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("serviceInstanceID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `serviceInstanceID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serviceInstanceID").toString())); + } + if (!jsonObj.get("clusterID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clusterID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clusterID").toString())); + } + // validate the required field `machineInfo` + MachineInfo.validateJsonObject(jsonObj.getAsJsonObject("machineInfo")); + // validate the required field `metrics` + NodeMetrics.validateJsonObject(jsonObj.getAsJsonObject("metrics")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NodesGet200ResponseInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NodesGet200ResponseInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NodesGet200ResponseInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NodesGet200ResponseInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public NodesGet200ResponseInner read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + NodesGet200ResponseInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NodesGet200ResponseInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of NodesGet200ResponseInner + * @throws IOException if the JSON string is invalid with respect to NodesGet200ResponseInner + */ + public static NodesGet200ResponseInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NodesGet200ResponseInner.class); + } + + /** + * Convert an instance of NodesGet200ResponseInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ResumedSandbox.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ResumedSandbox.java new file mode 100644 index 0000000..0bbf976 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/ResumedSandbox.java @@ -0,0 +1,314 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * ResumedSandbox + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class ResumedSandbox { + public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; + @SerializedName(SERIALIZED_NAME_TIMEOUT) + private Integer timeout = 15; + + public static final String SERIALIZED_NAME_AUTO_PAUSE = "autoPause"; + @Deprecated + @SerializedName(SERIALIZED_NAME_AUTO_PAUSE) + private Boolean autoPause; + + public ResumedSandbox() { + } + + public ResumedSandbox timeout(Integer timeout) { + + this.timeout = timeout; + return this; + } + + /** + * Time to live for the sandbox in seconds. + * minimum: 0 + * @return timeout + **/ + @javax.annotation.Nullable + public Integer getTimeout() { + return timeout; + } + + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + + @Deprecated + public ResumedSandbox autoPause(Boolean autoPause) { + + this.autoPause = autoPause; + return this; + } + + /** + * Automatically pauses the sandbox after the timeout + * @return autoPause + * @deprecated + **/ + @Deprecated + @javax.annotation.Nullable + public Boolean getAutoPause() { + return autoPause; + } + + + @Deprecated + public void setAutoPause(Boolean autoPause) { + this.autoPause = autoPause; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ResumedSandbox instance itself + */ + public ResumedSandbox putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResumedSandbox resumedSandbox = (ResumedSandbox) o; + return Objects.equals(this.timeout, resumedSandbox.timeout) && + Objects.equals(this.autoPause, resumedSandbox.autoPause)&& + Objects.equals(this.additionalProperties, resumedSandbox.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timeout, autoPause, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResumedSandbox {\n"); + sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" autoPause: ").append(toIndentedString(autoPause)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timeout"); + openapiFields.add("autoPause"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ResumedSandbox + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ResumedSandbox.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ResumedSandbox is not found in the empty JSON string", ResumedSandbox.openapiRequiredFields.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ResumedSandbox.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ResumedSandbox' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ResumedSandbox.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ResumedSandbox value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ResumedSandbox read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + ResumedSandbox instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ResumedSandbox given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResumedSandbox + * @throws IOException if the JSON string is invalid with respect to ResumedSandbox + */ + public static ResumedSandbox fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ResumedSandbox.class); + } + + /** + * Convert an instance of ResumedSandbox to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Sandbox.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Sandbox.java new file mode 100644 index 0000000..f6a0eb8 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Sandbox.java @@ -0,0 +1,528 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Sandbox + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Sandbox { + public static final String SERIALIZED_NAME_TEMPLATE_I_D = "templateID"; + @SerializedName(SERIALIZED_NAME_TEMPLATE_I_D) + private String templateID; + + public static final String SERIALIZED_NAME_SANDBOX_I_D = "sandboxID"; + @SerializedName(SERIALIZED_NAME_SANDBOX_I_D) + private String sandboxID; + + public static final String SERIALIZED_NAME_ALIAS = "alias"; + @SerializedName(SERIALIZED_NAME_ALIAS) + private String alias; + + public static final String SERIALIZED_NAME_CLIENT_I_D = "clientID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_CLIENT_I_D) + private String clientID; + + public static final String SERIALIZED_NAME_ENVD_VERSION = "envdVersion"; + @SerializedName(SERIALIZED_NAME_ENVD_VERSION) + private String envdVersion; + + public static final String SERIALIZED_NAME_ENVD_ACCESS_TOKEN = "envdAccessToken"; + @SerializedName(SERIALIZED_NAME_ENVD_ACCESS_TOKEN) + private String envdAccessToken; + + public static final String SERIALIZED_NAME_TRAFFIC_ACCESS_TOKEN = "trafficAccessToken"; + @SerializedName(SERIALIZED_NAME_TRAFFIC_ACCESS_TOKEN) + private String trafficAccessToken; + + public static final String SERIALIZED_NAME_DOMAIN = "domain"; + @SerializedName(SERIALIZED_NAME_DOMAIN) + private String domain; + + public Sandbox() { + } + + public Sandbox templateID(String templateID) { + + this.templateID = templateID; + return this; + } + + /** + * Identifier of the template from which is the sandbox created + * @return templateID + **/ + @javax.annotation.Nonnull + public String getTemplateID() { + return templateID; + } + + + public void setTemplateID(String templateID) { + this.templateID = templateID; + } + + + public Sandbox sandboxID(String sandboxID) { + + this.sandboxID = sandboxID; + return this; + } + + /** + * Identifier of the sandbox + * @return sandboxID + **/ + @javax.annotation.Nonnull + public String getSandboxID() { + return sandboxID; + } + + + public void setSandboxID(String sandboxID) { + this.sandboxID = sandboxID; + } + + + public Sandbox alias(String alias) { + + this.alias = alias; + return this; + } + + /** + * Alias of the template + * @return alias + **/ + @javax.annotation.Nullable + public String getAlias() { + return alias; + } + + + public void setAlias(String alias) { + this.alias = alias; + } + + + @Deprecated + public Sandbox clientID(String clientID) { + + this.clientID = clientID; + return this; + } + + /** + * Identifier of the client + * @return clientID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getClientID() { + return clientID; + } + + + @Deprecated + public void setClientID(String clientID) { + this.clientID = clientID; + } + + + public Sandbox envdVersion(String envdVersion) { + + this.envdVersion = envdVersion; + return this; + } + + /** + * Version of the envd running in the sandbox + * @return envdVersion + **/ + @javax.annotation.Nonnull + public String getEnvdVersion() { + return envdVersion; + } + + + public void setEnvdVersion(String envdVersion) { + this.envdVersion = envdVersion; + } + + + public Sandbox envdAccessToken(String envdAccessToken) { + + this.envdAccessToken = envdAccessToken; + return this; + } + + /** + * Access token used for envd communication + * @return envdAccessToken + **/ + @javax.annotation.Nullable + public String getEnvdAccessToken() { + return envdAccessToken; + } + + + public void setEnvdAccessToken(String envdAccessToken) { + this.envdAccessToken = envdAccessToken; + } + + + public Sandbox trafficAccessToken(String trafficAccessToken) { + + this.trafficAccessToken = trafficAccessToken; + return this; + } + + /** + * Token required for accessing sandbox via proxy. + * @return trafficAccessToken + **/ + @javax.annotation.Nullable + public String getTrafficAccessToken() { + return trafficAccessToken; + } + + + public void setTrafficAccessToken(String trafficAccessToken) { + this.trafficAccessToken = trafficAccessToken; + } + + + public Sandbox domain(String domain) { + + this.domain = domain; + return this; + } + + /** + * Base domain where the sandbox traffic is accessible + * @return domain + **/ + @javax.annotation.Nullable + public String getDomain() { + return domain; + } + + + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Sandbox instance itself + */ + public Sandbox putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Sandbox sandbox = (Sandbox) o; + return Objects.equals(this.templateID, sandbox.templateID) && + Objects.equals(this.sandboxID, sandbox.sandboxID) && + Objects.equals(this.alias, sandbox.alias) && + Objects.equals(this.clientID, sandbox.clientID) && + Objects.equals(this.envdVersion, sandbox.envdVersion) && + Objects.equals(this.envdAccessToken, sandbox.envdAccessToken) && + Objects.equals(this.trafficAccessToken, sandbox.trafficAccessToken) && + Objects.equals(this.domain, sandbox.domain)&& + Objects.equals(this.additionalProperties, sandbox.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(templateID, sandboxID, alias, clientID, envdVersion, envdAccessToken, trafficAccessToken, domain, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Sandbox {\n"); + sb.append(" templateID: ").append(toIndentedString(templateID)).append("\n"); + sb.append(" sandboxID: ").append(toIndentedString(sandboxID)).append("\n"); + sb.append(" alias: ").append(toIndentedString(alias)).append("\n"); + sb.append(" clientID: ").append(toIndentedString(clientID)).append("\n"); + sb.append(" envdVersion: ").append(toIndentedString(envdVersion)).append("\n"); + sb.append(" envdAccessToken: ").append(toIndentedString(envdAccessToken)).append("\n"); + sb.append(" trafficAccessToken: ").append(toIndentedString(trafficAccessToken)).append("\n"); + sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("templateID"); + openapiFields.add("sandboxID"); + openapiFields.add("alias"); + openapiFields.add("clientID"); + openapiFields.add("envdVersion"); + openapiFields.add("envdAccessToken"); + openapiFields.add("trafficAccessToken"); + openapiFields.add("domain"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("templateID"); + openapiRequiredFields.add("sandboxID"); + openapiRequiredFields.add("clientID"); + openapiRequiredFields.add("envdVersion"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Sandbox + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Sandbox.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Sandbox is not found in the empty JSON string", Sandbox.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Sandbox.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("templateID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `templateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateID").toString())); + } + if (!jsonObj.get("sandboxID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `sandboxID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sandboxID").toString())); + } + if ((jsonObj.get("alias") != null && !jsonObj.get("alias").isJsonNull()) && !jsonObj.get("alias").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `alias` to be a primitive type in the JSON string but got `%s`", jsonObj.get("alias").toString())); + } + if (!jsonObj.get("clientID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clientID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clientID").toString())); + } + if (!jsonObj.get("envdVersion").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdVersion").toString())); + } + if ((jsonObj.get("envdAccessToken") != null && !jsonObj.get("envdAccessToken").isJsonNull()) && !jsonObj.get("envdAccessToken").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdAccessToken` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdAccessToken").toString())); + } + if ((jsonObj.get("trafficAccessToken") != null && !jsonObj.get("trafficAccessToken").isJsonNull()) && !jsonObj.get("trafficAccessToken").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `trafficAccessToken` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trafficAccessToken").toString())); + } + if ((jsonObj.get("domain") != null && !jsonObj.get("domain").isJsonNull()) && !jsonObj.get("domain").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Sandbox.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Sandbox' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Sandbox.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Sandbox value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Sandbox read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + Sandbox instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Sandbox given an JSON string + * + * @param jsonString JSON string + * @return An instance of Sandbox + * @throws IOException if the JSON string is invalid with respect to Sandbox + */ + public static Sandbox fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Sandbox.class); + } + + /** + * Convert an instance of Sandbox to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxAutoResumeConfig.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxAutoResumeConfig.java new file mode 100644 index 0000000..104efa8 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxAutoResumeConfig.java @@ -0,0 +1,288 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Auto-resume configuration for paused sandboxes. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxAutoResumeConfig { + public static final String SERIALIZED_NAME_ENABLED = "enabled"; + @SerializedName(SERIALIZED_NAME_ENABLED) + private Boolean enabled = false; + + public SandboxAutoResumeConfig() { + } + + public SandboxAutoResumeConfig enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + /** + * Auto-resume enabled flag for paused sandboxes. Default false. + * @return enabled + **/ + @javax.annotation.Nonnull + public Boolean getEnabled() { + return enabled; + } + + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxAutoResumeConfig instance itself + */ + public SandboxAutoResumeConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxAutoResumeConfig sandboxAutoResumeConfig = (SandboxAutoResumeConfig) o; + return Objects.equals(this.enabled, sandboxAutoResumeConfig.enabled)&& + Objects.equals(this.additionalProperties, sandboxAutoResumeConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxAutoResumeConfig {\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("enabled"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("enabled"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxAutoResumeConfig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxAutoResumeConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxAutoResumeConfig is not found in the empty JSON string", SandboxAutoResumeConfig.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxAutoResumeConfig.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxAutoResumeConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxAutoResumeConfig' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxAutoResumeConfig.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxAutoResumeConfig value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxAutoResumeConfig read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxAutoResumeConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxAutoResumeConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxAutoResumeConfig + * @throws IOException if the JSON string is invalid with respect to SandboxAutoResumeConfig + */ + public static SandboxAutoResumeConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxAutoResumeConfig.class); + } + + /** + * Convert an instance of SandboxAutoResumeConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxDetail.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxDetail.java new file mode 100644 index 0000000..fa4098e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxDetail.java @@ -0,0 +1,767 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxState; +import io.openkruise.agents.client.e2b.api.models.SandboxVolumeMount; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxDetail + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxDetail { + public static final String SERIALIZED_NAME_TEMPLATE_I_D = "templateID"; + @SerializedName(SERIALIZED_NAME_TEMPLATE_I_D) + private String templateID; + + public static final String SERIALIZED_NAME_ALIAS = "alias"; + @SerializedName(SERIALIZED_NAME_ALIAS) + private String alias; + + public static final String SERIALIZED_NAME_SANDBOX_I_D = "sandboxID"; + @SerializedName(SERIALIZED_NAME_SANDBOX_I_D) + private String sandboxID; + + public static final String SERIALIZED_NAME_CLIENT_I_D = "clientID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_CLIENT_I_D) + private String clientID; + + public static final String SERIALIZED_NAME_STARTED_AT = "startedAt"; + @SerializedName(SERIALIZED_NAME_STARTED_AT) + private OffsetDateTime startedAt; + + public static final String SERIALIZED_NAME_END_AT = "endAt"; + @SerializedName(SERIALIZED_NAME_END_AT) + private OffsetDateTime endAt; + + public static final String SERIALIZED_NAME_ENVD_VERSION = "envdVersion"; + @SerializedName(SERIALIZED_NAME_ENVD_VERSION) + private String envdVersion; + + public static final String SERIALIZED_NAME_ENVD_ACCESS_TOKEN = "envdAccessToken"; + @SerializedName(SERIALIZED_NAME_ENVD_ACCESS_TOKEN) + private String envdAccessToken; + + public static final String SERIALIZED_NAME_DOMAIN = "domain"; + @SerializedName(SERIALIZED_NAME_DOMAIN) + private String domain; + + public static final String SERIALIZED_NAME_CPU_COUNT = "cpuCount"; + @SerializedName(SERIALIZED_NAME_CPU_COUNT) + private Integer cpuCount; + + public static final String SERIALIZED_NAME_MEMORY_M_B = "memoryMB"; + @SerializedName(SERIALIZED_NAME_MEMORY_M_B) + private Integer memoryMB; + + public static final String SERIALIZED_NAME_DISK_SIZE_M_B = "diskSizeMB"; + @SerializedName(SERIALIZED_NAME_DISK_SIZE_M_B) + private Integer diskSizeMB; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private Map metadata = new HashMap<>(); + + public static final String SERIALIZED_NAME_STATE = "state"; + @SerializedName(SERIALIZED_NAME_STATE) + private SandboxState state; + + public static final String SERIALIZED_NAME_VOLUME_MOUNTS = "volumeMounts"; + @SerializedName(SERIALIZED_NAME_VOLUME_MOUNTS) + private List volumeMounts; + + public SandboxDetail() { + } + + public SandboxDetail templateID(String templateID) { + + this.templateID = templateID; + return this; + } + + /** + * Identifier of the template from which is the sandbox created + * @return templateID + **/ + @javax.annotation.Nonnull + public String getTemplateID() { + return templateID; + } + + + public void setTemplateID(String templateID) { + this.templateID = templateID; + } + + + public SandboxDetail alias(String alias) { + + this.alias = alias; + return this; + } + + /** + * Alias of the template + * @return alias + **/ + @javax.annotation.Nullable + public String getAlias() { + return alias; + } + + + public void setAlias(String alias) { + this.alias = alias; + } + + + public SandboxDetail sandboxID(String sandboxID) { + + this.sandboxID = sandboxID; + return this; + } + + /** + * Identifier of the sandbox + * @return sandboxID + **/ + @javax.annotation.Nonnull + public String getSandboxID() { + return sandboxID; + } + + + public void setSandboxID(String sandboxID) { + this.sandboxID = sandboxID; + } + + + @Deprecated + public SandboxDetail clientID(String clientID) { + + this.clientID = clientID; + return this; + } + + /** + * Identifier of the client + * @return clientID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getClientID() { + return clientID; + } + + + @Deprecated + public void setClientID(String clientID) { + this.clientID = clientID; + } + + + public SandboxDetail startedAt(OffsetDateTime startedAt) { + + this.startedAt = startedAt; + return this; + } + + /** + * Time when the sandbox was started + * @return startedAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getStartedAt() { + return startedAt; + } + + + public void setStartedAt(OffsetDateTime startedAt) { + this.startedAt = startedAt; + } + + + public SandboxDetail endAt(OffsetDateTime endAt) { + + this.endAt = endAt; + return this; + } + + /** + * Time when the sandbox will expire + * @return endAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getEndAt() { + return endAt; + } + + + public void setEndAt(OffsetDateTime endAt) { + this.endAt = endAt; + } + + + public SandboxDetail envdVersion(String envdVersion) { + + this.envdVersion = envdVersion; + return this; + } + + /** + * Version of the envd running in the sandbox + * @return envdVersion + **/ + @javax.annotation.Nonnull + public String getEnvdVersion() { + return envdVersion; + } + + + public void setEnvdVersion(String envdVersion) { + this.envdVersion = envdVersion; + } + + + public SandboxDetail envdAccessToken(String envdAccessToken) { + + this.envdAccessToken = envdAccessToken; + return this; + } + + /** + * Access token used for envd communication + * @return envdAccessToken + **/ + @javax.annotation.Nullable + public String getEnvdAccessToken() { + return envdAccessToken; + } + + + public void setEnvdAccessToken(String envdAccessToken) { + this.envdAccessToken = envdAccessToken; + } + + + public SandboxDetail domain(String domain) { + + this.domain = domain; + return this; + } + + /** + * Base domain where the sandbox traffic is accessible + * @return domain + **/ + @javax.annotation.Nullable + public String getDomain() { + return domain; + } + + + public void setDomain(String domain) { + this.domain = domain; + } + + + public SandboxDetail cpuCount(Integer cpuCount) { + + this.cpuCount = cpuCount; + return this; + } + + /** + * CPU cores for the sandbox + * minimum: 1 + * @return cpuCount + **/ + @javax.annotation.Nonnull + public Integer getCpuCount() { + return cpuCount; + } + + + public void setCpuCount(Integer cpuCount) { + this.cpuCount = cpuCount; + } + + + public SandboxDetail memoryMB(Integer memoryMB) { + + this.memoryMB = memoryMB; + return this; + } + + /** + * Memory for the sandbox in MiB + * minimum: 128 + * @return memoryMB + **/ + @javax.annotation.Nonnull + public Integer getMemoryMB() { + return memoryMB; + } + + + public void setMemoryMB(Integer memoryMB) { + this.memoryMB = memoryMB; + } + + + public SandboxDetail diskSizeMB(Integer diskSizeMB) { + + this.diskSizeMB = diskSizeMB; + return this; + } + + /** + * Disk size for the sandbox in MiB + * minimum: 0 + * @return diskSizeMB + **/ + @javax.annotation.Nonnull + public Integer getDiskSizeMB() { + return diskSizeMB; + } + + + public void setDiskSizeMB(Integer diskSizeMB) { + this.diskSizeMB = diskSizeMB; + } + + + public SandboxDetail metadata(Map metadata) { + + this.metadata = metadata; + return this; + } + + public SandboxDetail putMetadataItem(String key, String metadataItem) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.put(key, metadataItem); + return this; + } + + /** + * Get metadata + * @return metadata + **/ + @javax.annotation.Nullable + public Map getMetadata() { + return metadata; + } + + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + + public SandboxDetail state(SandboxState state) { + + this.state = state; + return this; + } + + /** + * Get state + * @return state + **/ + @javax.annotation.Nonnull + public SandboxState getState() { + return state; + } + + + public void setState(SandboxState state) { + this.state = state; + } + + + public SandboxDetail volumeMounts(List volumeMounts) { + + this.volumeMounts = volumeMounts; + return this; + } + + public SandboxDetail addVolumeMountsItem(SandboxVolumeMount volumeMountsItem) { + if (this.volumeMounts == null) { + this.volumeMounts = new ArrayList<>(); + } + this.volumeMounts.add(volumeMountsItem); + return this; + } + + /** + * Get volumeMounts + * @return volumeMounts + **/ + @javax.annotation.Nullable + public List getVolumeMounts() { + return volumeMounts; + } + + + public void setVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxDetail instance itself + */ + public SandboxDetail putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxDetail sandboxDetail = (SandboxDetail) o; + return Objects.equals(this.templateID, sandboxDetail.templateID) && + Objects.equals(this.alias, sandboxDetail.alias) && + Objects.equals(this.sandboxID, sandboxDetail.sandboxID) && + Objects.equals(this.clientID, sandboxDetail.clientID) && + Objects.equals(this.startedAt, sandboxDetail.startedAt) && + Objects.equals(this.endAt, sandboxDetail.endAt) && + Objects.equals(this.envdVersion, sandboxDetail.envdVersion) && + Objects.equals(this.envdAccessToken, sandboxDetail.envdAccessToken) && + Objects.equals(this.domain, sandboxDetail.domain) && + Objects.equals(this.cpuCount, sandboxDetail.cpuCount) && + Objects.equals(this.memoryMB, sandboxDetail.memoryMB) && + Objects.equals(this.diskSizeMB, sandboxDetail.diskSizeMB) && + Objects.equals(this.metadata, sandboxDetail.metadata) && + Objects.equals(this.state, sandboxDetail.state) && + Objects.equals(this.volumeMounts, sandboxDetail.volumeMounts)&& + Objects.equals(this.additionalProperties, sandboxDetail.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(templateID, alias, sandboxID, clientID, startedAt, endAt, envdVersion, envdAccessToken, domain, cpuCount, memoryMB, diskSizeMB, metadata, state, volumeMounts, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxDetail {\n"); + sb.append(" templateID: ").append(toIndentedString(templateID)).append("\n"); + sb.append(" alias: ").append(toIndentedString(alias)).append("\n"); + sb.append(" sandboxID: ").append(toIndentedString(sandboxID)).append("\n"); + sb.append(" clientID: ").append(toIndentedString(clientID)).append("\n"); + sb.append(" startedAt: ").append(toIndentedString(startedAt)).append("\n"); + sb.append(" endAt: ").append(toIndentedString(endAt)).append("\n"); + sb.append(" envdVersion: ").append(toIndentedString(envdVersion)).append("\n"); + sb.append(" envdAccessToken: ").append(toIndentedString(envdAccessToken)).append("\n"); + sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); + sb.append(" cpuCount: ").append(toIndentedString(cpuCount)).append("\n"); + sb.append(" memoryMB: ").append(toIndentedString(memoryMB)).append("\n"); + sb.append(" diskSizeMB: ").append(toIndentedString(diskSizeMB)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).append("\n"); + sb.append(" volumeMounts: ").append(toIndentedString(volumeMounts)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("templateID"); + openapiFields.add("alias"); + openapiFields.add("sandboxID"); + openapiFields.add("clientID"); + openapiFields.add("startedAt"); + openapiFields.add("endAt"); + openapiFields.add("envdVersion"); + openapiFields.add("envdAccessToken"); + openapiFields.add("domain"); + openapiFields.add("cpuCount"); + openapiFields.add("memoryMB"); + openapiFields.add("diskSizeMB"); + openapiFields.add("metadata"); + openapiFields.add("state"); + openapiFields.add("volumeMounts"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("templateID"); + openapiRequiredFields.add("sandboxID"); + openapiRequiredFields.add("clientID"); + openapiRequiredFields.add("startedAt"); + openapiRequiredFields.add("endAt"); + openapiRequiredFields.add("envdVersion"); + openapiRequiredFields.add("cpuCount"); + openapiRequiredFields.add("memoryMB"); + openapiRequiredFields.add("diskSizeMB"); + openapiRequiredFields.add("state"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxDetail + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxDetail.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxDetail is not found in the empty JSON string", SandboxDetail.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxDetail.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("templateID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `templateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateID").toString())); + } + if ((jsonObj.get("alias") != null && !jsonObj.get("alias").isJsonNull()) && !jsonObj.get("alias").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `alias` to be a primitive type in the JSON string but got `%s`", jsonObj.get("alias").toString())); + } + if (!jsonObj.get("sandboxID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `sandboxID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sandboxID").toString())); + } + if (!jsonObj.get("clientID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clientID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clientID").toString())); + } + if (!jsonObj.get("envdVersion").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdVersion").toString())); + } + if ((jsonObj.get("envdAccessToken") != null && !jsonObj.get("envdAccessToken").isJsonNull()) && !jsonObj.get("envdAccessToken").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdAccessToken` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdAccessToken").toString())); + } + if ((jsonObj.get("domain") != null && !jsonObj.get("domain").isJsonNull()) && !jsonObj.get("domain").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString())); + } + if (jsonObj.get("volumeMounts") != null && !jsonObj.get("volumeMounts").isJsonNull()) { + JsonArray jsonArrayvolumeMounts = jsonObj.getAsJsonArray("volumeMounts"); + if (jsonArrayvolumeMounts != null) { + // ensure the json data is an array + if (!jsonObj.get("volumeMounts").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `volumeMounts` to be an array in the JSON string but got `%s`", jsonObj.get("volumeMounts").toString())); + } + + // validate the optional field `volumeMounts` (array) + for (int i = 0; i < jsonArrayvolumeMounts.size(); i++) { + SandboxVolumeMount.validateJsonObject(jsonArrayvolumeMounts.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxDetail.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxDetail' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxDetail.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxDetail value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxDetail read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxDetail instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxDetail given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxDetail + * @throws IOException if the JSON string is invalid with respect to SandboxDetail + */ + public static SandboxDetail fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxDetail.class); + } + + /** + * Convert an instance of SandboxDetail to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLog.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLog.java new file mode 100644 index 0000000..e440f2a --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLog.java @@ -0,0 +1,321 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Log entry with timestamp and line + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxLog { + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + private OffsetDateTime timestamp; + + public static final String SERIALIZED_NAME_LINE = "line"; + @SerializedName(SERIALIZED_NAME_LINE) + private String line; + + public SandboxLog() { + } + + public SandboxLog timestamp(OffsetDateTime timestamp) { + + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp of the log entry + * @return timestamp + **/ + @javax.annotation.Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + + public SandboxLog line(String line) { + + this.line = line; + return this; + } + + /** + * Log line content + * @return line + **/ + @javax.annotation.Nonnull + public String getLine() { + return line; + } + + + public void setLine(String line) { + this.line = line; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxLog instance itself + */ + public SandboxLog putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxLog sandboxLog = (SandboxLog) o; + return Objects.equals(this.timestamp, sandboxLog.timestamp) && + Objects.equals(this.line, sandboxLog.line)&& + Objects.equals(this.additionalProperties, sandboxLog.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, line, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxLog {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" line: ").append(toIndentedString(line)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timestamp"); + openapiFields.add("line"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timestamp"); + openapiRequiredFields.add("line"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxLog + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxLog.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxLog is not found in the empty JSON string", SandboxLog.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxLog.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("line").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `line` to be a primitive type in the JSON string but got `%s`", jsonObj.get("line").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxLog.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxLog' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxLog.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxLog value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxLog read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxLog instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxLog given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxLog + * @throws IOException if the JSON string is invalid with respect to SandboxLog + */ + public static SandboxLog fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxLog.class); + } + + /** + * Convert an instance of SandboxLog to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogEntry.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogEntry.java new file mode 100644 index 0000000..31944a3 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogEntry.java @@ -0,0 +1,390 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.LogLevel; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxLogEntry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxLogEntry { + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + private OffsetDateTime timestamp; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_LEVEL = "level"; + @SerializedName(SERIALIZED_NAME_LEVEL) + private LogLevel level; + + public static final String SERIALIZED_NAME_FIELDS = "fields"; + @SerializedName(SERIALIZED_NAME_FIELDS) + private Map fields = new HashMap<>(); + + public SandboxLogEntry() { + } + + public SandboxLogEntry timestamp(OffsetDateTime timestamp) { + + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp of the log entry + * @return timestamp + **/ + @javax.annotation.Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + + public SandboxLogEntry message(String message) { + + this.message = message; + return this; + } + + /** + * Log message content + * @return message + **/ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public SandboxLogEntry level(LogLevel level) { + + this.level = level; + return this; + } + + /** + * Get level + * @return level + **/ + @javax.annotation.Nonnull + public LogLevel getLevel() { + return level; + } + + + public void setLevel(LogLevel level) { + this.level = level; + } + + + public SandboxLogEntry fields(Map fields) { + + this.fields = fields; + return this; + } + + public SandboxLogEntry putFieldsItem(String key, String fieldsItem) { + if (this.fields == null) { + this.fields = new HashMap<>(); + } + this.fields.put(key, fieldsItem); + return this; + } + + /** + * Get fields + * @return fields + **/ + @javax.annotation.Nonnull + public Map getFields() { + return fields; + } + + + public void setFields(Map fields) { + this.fields = fields; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxLogEntry instance itself + */ + public SandboxLogEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxLogEntry sandboxLogEntry = (SandboxLogEntry) o; + return Objects.equals(this.timestamp, sandboxLogEntry.timestamp) && + Objects.equals(this.message, sandboxLogEntry.message) && + Objects.equals(this.level, sandboxLogEntry.level) && + Objects.equals(this.fields, sandboxLogEntry.fields)&& + Objects.equals(this.additionalProperties, sandboxLogEntry.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, message, level, fields, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxLogEntry {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" level: ").append(toIndentedString(level)).append("\n"); + sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timestamp"); + openapiFields.add("message"); + openapiFields.add("level"); + openapiFields.add("fields"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timestamp"); + openapiRequiredFields.add("message"); + openapiRequiredFields.add("level"); + openapiRequiredFields.add("fields"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxLogEntry + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxLogEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxLogEntry is not found in the empty JSON string", SandboxLogEntry.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxLogEntry.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxLogEntry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxLogEntry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxLogEntry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxLogEntry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxLogEntry read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxLogEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxLogEntry given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxLogEntry + * @throws IOException if the JSON string is invalid with respect to SandboxLogEntry + */ + public static SandboxLogEntry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxLogEntry.class); + } + + /** + * Convert an instance of SandboxLogEntry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogs.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogs.java new file mode 100644 index 0000000..b61bb02 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogs.java @@ -0,0 +1,357 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxLog; +import io.openkruise.agents.client.e2b.api.models.SandboxLogEntry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxLogs + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxLogs { + public static final String SERIALIZED_NAME_LOGS = "logs"; + @SerializedName(SERIALIZED_NAME_LOGS) + private List logs = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LOG_ENTRIES = "logEntries"; + @SerializedName(SERIALIZED_NAME_LOG_ENTRIES) + private List logEntries = new ArrayList<>(); + + public SandboxLogs() { + } + + public SandboxLogs logs(List logs) { + + this.logs = logs; + return this; + } + + public SandboxLogs addLogsItem(SandboxLog logsItem) { + if (this.logs == null) { + this.logs = new ArrayList<>(); + } + this.logs.add(logsItem); + return this; + } + + /** + * Logs of the sandbox + * @return logs + **/ + @javax.annotation.Nonnull + public List getLogs() { + return logs; + } + + + public void setLogs(List logs) { + this.logs = logs; + } + + + public SandboxLogs logEntries(List logEntries) { + + this.logEntries = logEntries; + return this; + } + + public SandboxLogs addLogEntriesItem(SandboxLogEntry logEntriesItem) { + if (this.logEntries == null) { + this.logEntries = new ArrayList<>(); + } + this.logEntries.add(logEntriesItem); + return this; + } + + /** + * Structured logs of the sandbox + * @return logEntries + **/ + @javax.annotation.Nonnull + public List getLogEntries() { + return logEntries; + } + + + public void setLogEntries(List logEntries) { + this.logEntries = logEntries; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxLogs instance itself + */ + public SandboxLogs putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxLogs sandboxLogs = (SandboxLogs) o; + return Objects.equals(this.logs, sandboxLogs.logs) && + Objects.equals(this.logEntries, sandboxLogs.logEntries)&& + Objects.equals(this.additionalProperties, sandboxLogs.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(logs, logEntries, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxLogs {\n"); + sb.append(" logs: ").append(toIndentedString(logs)).append("\n"); + sb.append(" logEntries: ").append(toIndentedString(logEntries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("logs"); + openapiFields.add("logEntries"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("logs"); + openapiRequiredFields.add("logEntries"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxLogs + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxLogs.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxLogs is not found in the empty JSON string", SandboxLogs.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxLogs.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("logs").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `logs` to be an array in the JSON string but got `%s`", jsonObj.get("logs").toString())); + } + + JsonArray jsonArraylogs = jsonObj.getAsJsonArray("logs"); + // validate the required field `logs` (array) + for (int i = 0; i < jsonArraylogs.size(); i++) { + SandboxLog.validateJsonObject(jsonArraylogs.get(i).getAsJsonObject()); + }; + // ensure the json data is an array + if (!jsonObj.get("logEntries").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `logEntries` to be an array in the JSON string but got `%s`", jsonObj.get("logEntries").toString())); + } + + JsonArray jsonArraylogEntries = jsonObj.getAsJsonArray("logEntries"); + // validate the required field `logEntries` (array) + for (int i = 0; i < jsonArraylogEntries.size(); i++) { + SandboxLogEntry.validateJsonObject(jsonArraylogEntries.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxLogs.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxLogs' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxLogs.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxLogs value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxLogs read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxLogs instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxLogs given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxLogs + * @throws IOException if the JSON string is invalid with respect to SandboxLogs + */ + public static SandboxLogs fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxLogs.class); + } + + /** + * Convert an instance of SandboxLogs to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogsV2Response.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogsV2Response.java new file mode 100644 index 0000000..ba57207 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxLogsV2Response.java @@ -0,0 +1,309 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxLogEntry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxLogsV2Response + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxLogsV2Response { + public static final String SERIALIZED_NAME_LOGS = "logs"; + @SerializedName(SERIALIZED_NAME_LOGS) + private List logs = null; + + public SandboxLogsV2Response() { + } + + public SandboxLogsV2Response logs(List logs) { + + this.logs = logs; + return this; + } + + public SandboxLogsV2Response addLogsItem(SandboxLogEntry logsItem) { + if (this.logs == null) { + this.logs = null; + } + this.logs.add(logsItem); + return this; + } + + /** + * Sandbox logs structured + * @return logs + **/ + @javax.annotation.Nonnull + public List getLogs() { + return logs; + } + + + public void setLogs(List logs) { + this.logs = logs; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxLogsV2Response instance itself + */ + public SandboxLogsV2Response putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxLogsV2Response sandboxLogsV2Response = (SandboxLogsV2Response) o; + return Objects.equals(this.logs, sandboxLogsV2Response.logs)&& + Objects.equals(this.additionalProperties, sandboxLogsV2Response.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(logs, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxLogsV2Response {\n"); + sb.append(" logs: ").append(toIndentedString(logs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("logs"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("logs"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxLogsV2Response + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxLogsV2Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxLogsV2Response is not found in the empty JSON string", SandboxLogsV2Response.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxLogsV2Response.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + // ensure the json data is an array + if (!jsonObj.get("logs").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `logs` to be an array in the JSON string but got `%s`", jsonObj.get("logs").toString())); + } + + JsonArray jsonArraylogs = jsonObj.getAsJsonArray("logs"); + // validate the required field `logs` (array) + for (int i = 0; i < jsonArraylogs.size(); i++) { + SandboxLogEntry.validateJsonObject(jsonArraylogs.get(i).getAsJsonObject()); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxLogsV2Response.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxLogsV2Response' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxLogsV2Response.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxLogsV2Response value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxLogsV2Response read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxLogsV2Response instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxLogsV2Response given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxLogsV2Response + * @throws IOException if the JSON string is invalid with respect to SandboxLogsV2Response + */ + public static SandboxLogsV2Response fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxLogsV2Response.class); + } + + /** + * Convert an instance of SandboxLogsV2Response to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxMetric.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxMetric.java new file mode 100644 index 0000000..269444b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxMetric.java @@ -0,0 +1,497 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Metric entry with timestamp and line + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxMetric { + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + @Deprecated + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + private OffsetDateTime timestamp; + + public static final String SERIALIZED_NAME_TIMESTAMP_UNIX = "timestampUnix"; + @SerializedName(SERIALIZED_NAME_TIMESTAMP_UNIX) + private Long timestampUnix; + + public static final String SERIALIZED_NAME_CPU_COUNT = "cpuCount"; + @SerializedName(SERIALIZED_NAME_CPU_COUNT) + private Integer cpuCount; + + public static final String SERIALIZED_NAME_CPU_USED_PCT = "cpuUsedPct"; + @SerializedName(SERIALIZED_NAME_CPU_USED_PCT) + private Float cpuUsedPct; + + public static final String SERIALIZED_NAME_MEM_USED = "memUsed"; + @SerializedName(SERIALIZED_NAME_MEM_USED) + private Long memUsed; + + public static final String SERIALIZED_NAME_MEM_TOTAL = "memTotal"; + @SerializedName(SERIALIZED_NAME_MEM_TOTAL) + private Long memTotal; + + public static final String SERIALIZED_NAME_DISK_USED = "diskUsed"; + @SerializedName(SERIALIZED_NAME_DISK_USED) + private Long diskUsed; + + public static final String SERIALIZED_NAME_DISK_TOTAL = "diskTotal"; + @SerializedName(SERIALIZED_NAME_DISK_TOTAL) + private Long diskTotal; + + public SandboxMetric() { + } + + @Deprecated + public SandboxMetric timestamp(OffsetDateTime timestamp) { + + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp of the metric entry + * @return timestamp + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + + @Deprecated + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + + public SandboxMetric timestampUnix(Long timestampUnix) { + + this.timestampUnix = timestampUnix; + return this; + } + + /** + * Timestamp of the metric entry in Unix time (seconds since epoch) + * @return timestampUnix + **/ + @javax.annotation.Nonnull + public Long getTimestampUnix() { + return timestampUnix; + } + + + public void setTimestampUnix(Long timestampUnix) { + this.timestampUnix = timestampUnix; + } + + + public SandboxMetric cpuCount(Integer cpuCount) { + + this.cpuCount = cpuCount; + return this; + } + + /** + * Number of CPU cores + * @return cpuCount + **/ + @javax.annotation.Nonnull + public Integer getCpuCount() { + return cpuCount; + } + + + public void setCpuCount(Integer cpuCount) { + this.cpuCount = cpuCount; + } + + + public SandboxMetric cpuUsedPct(Float cpuUsedPct) { + + this.cpuUsedPct = cpuUsedPct; + return this; + } + + /** + * CPU usage percentage + * @return cpuUsedPct + **/ + @javax.annotation.Nonnull + public Float getCpuUsedPct() { + return cpuUsedPct; + } + + + public void setCpuUsedPct(Float cpuUsedPct) { + this.cpuUsedPct = cpuUsedPct; + } + + + public SandboxMetric memUsed(Long memUsed) { + + this.memUsed = memUsed; + return this; + } + + /** + * Memory used in bytes + * @return memUsed + **/ + @javax.annotation.Nonnull + public Long getMemUsed() { + return memUsed; + } + + + public void setMemUsed(Long memUsed) { + this.memUsed = memUsed; + } + + + public SandboxMetric memTotal(Long memTotal) { + + this.memTotal = memTotal; + return this; + } + + /** + * Total memory in bytes + * @return memTotal + **/ + @javax.annotation.Nonnull + public Long getMemTotal() { + return memTotal; + } + + + public void setMemTotal(Long memTotal) { + this.memTotal = memTotal; + } + + + public SandboxMetric diskUsed(Long diskUsed) { + + this.diskUsed = diskUsed; + return this; + } + + /** + * Disk used in bytes + * @return diskUsed + **/ + @javax.annotation.Nonnull + public Long getDiskUsed() { + return diskUsed; + } + + + public void setDiskUsed(Long diskUsed) { + this.diskUsed = diskUsed; + } + + + public SandboxMetric diskTotal(Long diskTotal) { + + this.diskTotal = diskTotal; + return this; + } + + /** + * Total disk space in bytes + * @return diskTotal + **/ + @javax.annotation.Nonnull + public Long getDiskTotal() { + return diskTotal; + } + + + public void setDiskTotal(Long diskTotal) { + this.diskTotal = diskTotal; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxMetric instance itself + */ + public SandboxMetric putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxMetric sandboxMetric = (SandboxMetric) o; + return Objects.equals(this.timestamp, sandboxMetric.timestamp) && + Objects.equals(this.timestampUnix, sandboxMetric.timestampUnix) && + Objects.equals(this.cpuCount, sandboxMetric.cpuCount) && + Objects.equals(this.cpuUsedPct, sandboxMetric.cpuUsedPct) && + Objects.equals(this.memUsed, sandboxMetric.memUsed) && + Objects.equals(this.memTotal, sandboxMetric.memTotal) && + Objects.equals(this.diskUsed, sandboxMetric.diskUsed) && + Objects.equals(this.diskTotal, sandboxMetric.diskTotal)&& + Objects.equals(this.additionalProperties, sandboxMetric.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, timestampUnix, cpuCount, cpuUsedPct, memUsed, memTotal, diskUsed, diskTotal, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxMetric {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" timestampUnix: ").append(toIndentedString(timestampUnix)).append("\n"); + sb.append(" cpuCount: ").append(toIndentedString(cpuCount)).append("\n"); + sb.append(" cpuUsedPct: ").append(toIndentedString(cpuUsedPct)).append("\n"); + sb.append(" memUsed: ").append(toIndentedString(memUsed)).append("\n"); + sb.append(" memTotal: ").append(toIndentedString(memTotal)).append("\n"); + sb.append(" diskUsed: ").append(toIndentedString(diskUsed)).append("\n"); + sb.append(" diskTotal: ").append(toIndentedString(diskTotal)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timestamp"); + openapiFields.add("timestampUnix"); + openapiFields.add("cpuCount"); + openapiFields.add("cpuUsedPct"); + openapiFields.add("memUsed"); + openapiFields.add("memTotal"); + openapiFields.add("diskUsed"); + openapiFields.add("diskTotal"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timestamp"); + openapiRequiredFields.add("timestampUnix"); + openapiRequiredFields.add("cpuCount"); + openapiRequiredFields.add("cpuUsedPct"); + openapiRequiredFields.add("memUsed"); + openapiRequiredFields.add("memTotal"); + openapiRequiredFields.add("diskUsed"); + openapiRequiredFields.add("diskTotal"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxMetric + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxMetric.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxMetric is not found in the empty JSON string", SandboxMetric.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxMetric.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxMetric.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxMetric' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxMetric.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxMetric value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxMetric read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxMetric instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxMetric given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxMetric + * @throws IOException if the JSON string is invalid with respect to SandboxMetric + */ + public static SandboxMetric fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxMetric.class); + } + + /** + * Convert an instance of SandboxMetric to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxNetworkConfig.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxNetworkConfig.java new file mode 100644 index 0000000..754843e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxNetworkConfig.java @@ -0,0 +1,393 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxNetworkConfig + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxNetworkConfig { + public static final String SERIALIZED_NAME_ALLOW_PUBLIC_TRAFFIC = "allowPublicTraffic"; + @SerializedName(SERIALIZED_NAME_ALLOW_PUBLIC_TRAFFIC) + private Boolean allowPublicTraffic = true; + + public static final String SERIALIZED_NAME_ALLOW_OUT = "allowOut"; + @SerializedName(SERIALIZED_NAME_ALLOW_OUT) + private List allowOut; + + public static final String SERIALIZED_NAME_DENY_OUT = "denyOut"; + @SerializedName(SERIALIZED_NAME_DENY_OUT) + private List denyOut; + + public static final String SERIALIZED_NAME_MASK_REQUEST_HOST = "maskRequestHost"; + @SerializedName(SERIALIZED_NAME_MASK_REQUEST_HOST) + private String maskRequestHost; + + public SandboxNetworkConfig() { + } + + public SandboxNetworkConfig allowPublicTraffic(Boolean allowPublicTraffic) { + + this.allowPublicTraffic = allowPublicTraffic; + return this; + } + + /** + * Specify if the sandbox URLs should be accessible only with authentication. + * @return allowPublicTraffic + **/ + @javax.annotation.Nullable + public Boolean getAllowPublicTraffic() { + return allowPublicTraffic; + } + + + public void setAllowPublicTraffic(Boolean allowPublicTraffic) { + this.allowPublicTraffic = allowPublicTraffic; + } + + + public SandboxNetworkConfig allowOut(List allowOut) { + + this.allowOut = allowOut; + return this; + } + + public SandboxNetworkConfig addAllowOutItem(String allowOutItem) { + if (this.allowOut == null) { + this.allowOut = new ArrayList<>(); + } + this.allowOut.add(allowOutItem); + return this; + } + + /** + * List of allowed CIDR blocks or IP addresses for egress traffic. Allowed addresses always take precedence over blocked addresses. + * @return allowOut + **/ + @javax.annotation.Nullable + public List getAllowOut() { + return allowOut; + } + + + public void setAllowOut(List allowOut) { + this.allowOut = allowOut; + } + + + public SandboxNetworkConfig denyOut(List denyOut) { + + this.denyOut = denyOut; + return this; + } + + public SandboxNetworkConfig addDenyOutItem(String denyOutItem) { + if (this.denyOut == null) { + this.denyOut = new ArrayList<>(); + } + this.denyOut.add(denyOutItem); + return this; + } + + /** + * List of denied CIDR blocks or IP addresses for egress traffic + * @return denyOut + **/ + @javax.annotation.Nullable + public List getDenyOut() { + return denyOut; + } + + + public void setDenyOut(List denyOut) { + this.denyOut = denyOut; + } + + + public SandboxNetworkConfig maskRequestHost(String maskRequestHost) { + + this.maskRequestHost = maskRequestHost; + return this; + } + + /** + * Specify host mask which will be used for all sandbox requests + * @return maskRequestHost + **/ + @javax.annotation.Nullable + public String getMaskRequestHost() { + return maskRequestHost; + } + + + public void setMaskRequestHost(String maskRequestHost) { + this.maskRequestHost = maskRequestHost; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxNetworkConfig instance itself + */ + public SandboxNetworkConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxNetworkConfig sandboxNetworkConfig = (SandboxNetworkConfig) o; + return Objects.equals(this.allowPublicTraffic, sandboxNetworkConfig.allowPublicTraffic) && + Objects.equals(this.allowOut, sandboxNetworkConfig.allowOut) && + Objects.equals(this.denyOut, sandboxNetworkConfig.denyOut) && + Objects.equals(this.maskRequestHost, sandboxNetworkConfig.maskRequestHost)&& + Objects.equals(this.additionalProperties, sandboxNetworkConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(allowPublicTraffic, allowOut, denyOut, maskRequestHost, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxNetworkConfig {\n"); + sb.append(" allowPublicTraffic: ").append(toIndentedString(allowPublicTraffic)).append("\n"); + sb.append(" allowOut: ").append(toIndentedString(allowOut)).append("\n"); + sb.append(" denyOut: ").append(toIndentedString(denyOut)).append("\n"); + sb.append(" maskRequestHost: ").append(toIndentedString(maskRequestHost)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("allowPublicTraffic"); + openapiFields.add("allowOut"); + openapiFields.add("denyOut"); + openapiFields.add("maskRequestHost"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxNetworkConfig + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxNetworkConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxNetworkConfig is not found in the empty JSON string", SandboxNetworkConfig.openapiRequiredFields.toString())); + } + } + // ensure the optional json data is an array if present + if (jsonObj.get("allowOut") != null && !jsonObj.get("allowOut").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `allowOut` to be an array in the JSON string but got `%s`", jsonObj.get("allowOut").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("denyOut") != null && !jsonObj.get("denyOut").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `denyOut` to be an array in the JSON string but got `%s`", jsonObj.get("denyOut").toString())); + } + if ((jsonObj.get("maskRequestHost") != null && !jsonObj.get("maskRequestHost").isJsonNull()) && !jsonObj.get("maskRequestHost").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `maskRequestHost` to be a primitive type in the JSON string but got `%s`", jsonObj.get("maskRequestHost").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxNetworkConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxNetworkConfig' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxNetworkConfig.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxNetworkConfig value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxNetworkConfig read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxNetworkConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxNetworkConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxNetworkConfig + * @throws IOException if the JSON string is invalid with respect to SandboxNetworkConfig + */ + public static SandboxNetworkConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxNetworkConfig.class); + } + + /** + * Convert an instance of SandboxNetworkConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxState.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxState.java new file mode 100644 index 0000000..efc9d03 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxState.java @@ -0,0 +1,73 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * State of the sandbox + */ +@JsonAdapter(SandboxState.Adapter.class) +public enum SandboxState { + + RUNNING("running"), + + PAUSED("paused"); + + private String value; + + SandboxState(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SandboxState fromValue(String value) { + for (SandboxState b : SandboxState.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SandboxState enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SandboxState read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SandboxState.fromValue(value); + } + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxVolumeMount.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxVolumeMount.java new file mode 100644 index 0000000..bd2550b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxVolumeMount.java @@ -0,0 +1,323 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxVolumeMount + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxVolumeMount { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + private String path; + + public SandboxVolumeMount() { + } + + public SandboxVolumeMount name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the volume + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public SandboxVolumeMount path(String path) { + + this.path = path; + return this; + } + + /** + * Path of the volume + * @return path + **/ + @javax.annotation.Nonnull + public String getPath() { + return path; + } + + + public void setPath(String path) { + this.path = path; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxVolumeMount instance itself + */ + public SandboxVolumeMount putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxVolumeMount sandboxVolumeMount = (SandboxVolumeMount) o; + return Objects.equals(this.name, sandboxVolumeMount.name) && + Objects.equals(this.path, sandboxVolumeMount.path)&& + Objects.equals(this.additionalProperties, sandboxVolumeMount.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, path, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxVolumeMount {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + openapiFields.add("path"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("path"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxVolumeMount + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxVolumeMount.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxVolumeMount is not found in the empty JSON string", SandboxVolumeMount.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxVolumeMount.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("path").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxVolumeMount.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxVolumeMount' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxVolumeMount.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxVolumeMount value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxVolumeMount read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxVolumeMount instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxVolumeMount given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxVolumeMount + * @throws IOException if the JSON string is invalid with respect to SandboxVolumeMount + */ + public static SandboxVolumeMount fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxVolumeMount.class); + } + + /** + * Convert an instance of SandboxVolumeMount to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesGet200ResponseInner.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesGet200ResponseInner.java new file mode 100644 index 0000000..f454c2d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesGet200ResponseInner.java @@ -0,0 +1,693 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxState; +import io.openkruise.agents.client.e2b.api.models.SandboxVolumeMount; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxesGet200ResponseInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxesGet200ResponseInner { + public static final String SERIALIZED_NAME_TEMPLATE_I_D = "templateID"; + @SerializedName(SERIALIZED_NAME_TEMPLATE_I_D) + private String templateID; + + public static final String SERIALIZED_NAME_ALIAS = "alias"; + @SerializedName(SERIALIZED_NAME_ALIAS) + private String alias; + + public static final String SERIALIZED_NAME_SANDBOX_I_D = "sandboxID"; + @SerializedName(SERIALIZED_NAME_SANDBOX_I_D) + private String sandboxID; + + public static final String SERIALIZED_NAME_CLIENT_I_D = "clientID"; + @Deprecated + @SerializedName(SERIALIZED_NAME_CLIENT_I_D) + private String clientID; + + public static final String SERIALIZED_NAME_STARTED_AT = "startedAt"; + @SerializedName(SERIALIZED_NAME_STARTED_AT) + private OffsetDateTime startedAt; + + public static final String SERIALIZED_NAME_END_AT = "endAt"; + @SerializedName(SERIALIZED_NAME_END_AT) + private OffsetDateTime endAt; + + public static final String SERIALIZED_NAME_CPU_COUNT = "cpuCount"; + @SerializedName(SERIALIZED_NAME_CPU_COUNT) + private Integer cpuCount; + + public static final String SERIALIZED_NAME_MEMORY_M_B = "memoryMB"; + @SerializedName(SERIALIZED_NAME_MEMORY_M_B) + private Integer memoryMB; + + public static final String SERIALIZED_NAME_DISK_SIZE_M_B = "diskSizeMB"; + @SerializedName(SERIALIZED_NAME_DISK_SIZE_M_B) + private Integer diskSizeMB; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private Map metadata = new HashMap<>(); + + public static final String SERIALIZED_NAME_STATE = "state"; + @SerializedName(SERIALIZED_NAME_STATE) + private SandboxState state; + + public static final String SERIALIZED_NAME_ENVD_VERSION = "envdVersion"; + @SerializedName(SERIALIZED_NAME_ENVD_VERSION) + private String envdVersion; + + public static final String SERIALIZED_NAME_VOLUME_MOUNTS = "volumeMounts"; + @SerializedName(SERIALIZED_NAME_VOLUME_MOUNTS) + private List volumeMounts; + + public SandboxesGet200ResponseInner() { + } + + public SandboxesGet200ResponseInner templateID(String templateID) { + + this.templateID = templateID; + return this; + } + + /** + * Identifier of the template from which is the sandbox created + * @return templateID + **/ + @javax.annotation.Nonnull + public String getTemplateID() { + return templateID; + } + + + public void setTemplateID(String templateID) { + this.templateID = templateID; + } + + + public SandboxesGet200ResponseInner alias(String alias) { + + this.alias = alias; + return this; + } + + /** + * Alias of the template + * @return alias + **/ + @javax.annotation.Nullable + public String getAlias() { + return alias; + } + + + public void setAlias(String alias) { + this.alias = alias; + } + + + public SandboxesGet200ResponseInner sandboxID(String sandboxID) { + + this.sandboxID = sandboxID; + return this; + } + + /** + * Identifier of the sandbox + * @return sandboxID + **/ + @javax.annotation.Nonnull + public String getSandboxID() { + return sandboxID; + } + + + public void setSandboxID(String sandboxID) { + this.sandboxID = sandboxID; + } + + + @Deprecated + public SandboxesGet200ResponseInner clientID(String clientID) { + + this.clientID = clientID; + return this; + } + + /** + * Identifier of the client + * @return clientID + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public String getClientID() { + return clientID; + } + + + @Deprecated + public void setClientID(String clientID) { + this.clientID = clientID; + } + + + public SandboxesGet200ResponseInner startedAt(OffsetDateTime startedAt) { + + this.startedAt = startedAt; + return this; + } + + /** + * Time when the sandbox was started + * @return startedAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getStartedAt() { + return startedAt; + } + + + public void setStartedAt(OffsetDateTime startedAt) { + this.startedAt = startedAt; + } + + + public SandboxesGet200ResponseInner endAt(OffsetDateTime endAt) { + + this.endAt = endAt; + return this; + } + + /** + * Time when the sandbox will expire + * @return endAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getEndAt() { + return endAt; + } + + + public void setEndAt(OffsetDateTime endAt) { + this.endAt = endAt; + } + + + public SandboxesGet200ResponseInner cpuCount(Integer cpuCount) { + + this.cpuCount = cpuCount; + return this; + } + + /** + * CPU cores for the sandbox + * minimum: 1 + * @return cpuCount + **/ + @javax.annotation.Nonnull + public Integer getCpuCount() { + return cpuCount; + } + + + public void setCpuCount(Integer cpuCount) { + this.cpuCount = cpuCount; + } + + + public SandboxesGet200ResponseInner memoryMB(Integer memoryMB) { + + this.memoryMB = memoryMB; + return this; + } + + /** + * Memory for the sandbox in MiB + * minimum: 128 + * @return memoryMB + **/ + @javax.annotation.Nonnull + public Integer getMemoryMB() { + return memoryMB; + } + + + public void setMemoryMB(Integer memoryMB) { + this.memoryMB = memoryMB; + } + + + public SandboxesGet200ResponseInner diskSizeMB(Integer diskSizeMB) { + + this.diskSizeMB = diskSizeMB; + return this; + } + + /** + * Disk size for the sandbox in MiB + * minimum: 0 + * @return diskSizeMB + **/ + @javax.annotation.Nonnull + public Integer getDiskSizeMB() { + return diskSizeMB; + } + + + public void setDiskSizeMB(Integer diskSizeMB) { + this.diskSizeMB = diskSizeMB; + } + + + public SandboxesGet200ResponseInner metadata(Map metadata) { + + this.metadata = metadata; + return this; + } + + public SandboxesGet200ResponseInner putMetadataItem(String key, String metadataItem) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.put(key, metadataItem); + return this; + } + + /** + * Get metadata + * @return metadata + **/ + @javax.annotation.Nullable + public Map getMetadata() { + return metadata; + } + + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + + public SandboxesGet200ResponseInner state(SandboxState state) { + + this.state = state; + return this; + } + + /** + * Get state + * @return state + **/ + @javax.annotation.Nonnull + public SandboxState getState() { + return state; + } + + + public void setState(SandboxState state) { + this.state = state; + } + + + public SandboxesGet200ResponseInner envdVersion(String envdVersion) { + + this.envdVersion = envdVersion; + return this; + } + + /** + * Version of the envd running in the sandbox + * @return envdVersion + **/ + @javax.annotation.Nonnull + public String getEnvdVersion() { + return envdVersion; + } + + + public void setEnvdVersion(String envdVersion) { + this.envdVersion = envdVersion; + } + + + public SandboxesGet200ResponseInner volumeMounts(List volumeMounts) { + + this.volumeMounts = volumeMounts; + return this; + } + + public SandboxesGet200ResponseInner addVolumeMountsItem(SandboxVolumeMount volumeMountsItem) { + if (this.volumeMounts == null) { + this.volumeMounts = new ArrayList<>(); + } + this.volumeMounts.add(volumeMountsItem); + return this; + } + + /** + * Get volumeMounts + * @return volumeMounts + **/ + @javax.annotation.Nullable + public List getVolumeMounts() { + return volumeMounts; + } + + + public void setVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxesGet200ResponseInner instance itself + */ + public SandboxesGet200ResponseInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxesGet200ResponseInner sandboxesGet200ResponseInner = (SandboxesGet200ResponseInner) o; + return Objects.equals(this.templateID, sandboxesGet200ResponseInner.templateID) && + Objects.equals(this.alias, sandboxesGet200ResponseInner.alias) && + Objects.equals(this.sandboxID, sandboxesGet200ResponseInner.sandboxID) && + Objects.equals(this.clientID, sandboxesGet200ResponseInner.clientID) && + Objects.equals(this.startedAt, sandboxesGet200ResponseInner.startedAt) && + Objects.equals(this.endAt, sandboxesGet200ResponseInner.endAt) && + Objects.equals(this.cpuCount, sandboxesGet200ResponseInner.cpuCount) && + Objects.equals(this.memoryMB, sandboxesGet200ResponseInner.memoryMB) && + Objects.equals(this.diskSizeMB, sandboxesGet200ResponseInner.diskSizeMB) && + Objects.equals(this.metadata, sandboxesGet200ResponseInner.metadata) && + Objects.equals(this.state, sandboxesGet200ResponseInner.state) && + Objects.equals(this.envdVersion, sandboxesGet200ResponseInner.envdVersion) && + Objects.equals(this.volumeMounts, sandboxesGet200ResponseInner.volumeMounts)&& + Objects.equals(this.additionalProperties, sandboxesGet200ResponseInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(templateID, alias, sandboxID, clientID, startedAt, endAt, cpuCount, memoryMB, diskSizeMB, metadata, state, envdVersion, volumeMounts, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxesGet200ResponseInner {\n"); + sb.append(" templateID: ").append(toIndentedString(templateID)).append("\n"); + sb.append(" alias: ").append(toIndentedString(alias)).append("\n"); + sb.append(" sandboxID: ").append(toIndentedString(sandboxID)).append("\n"); + sb.append(" clientID: ").append(toIndentedString(clientID)).append("\n"); + sb.append(" startedAt: ").append(toIndentedString(startedAt)).append("\n"); + sb.append(" endAt: ").append(toIndentedString(endAt)).append("\n"); + sb.append(" cpuCount: ").append(toIndentedString(cpuCount)).append("\n"); + sb.append(" memoryMB: ").append(toIndentedString(memoryMB)).append("\n"); + sb.append(" diskSizeMB: ").append(toIndentedString(diskSizeMB)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).append("\n"); + sb.append(" envdVersion: ").append(toIndentedString(envdVersion)).append("\n"); + sb.append(" volumeMounts: ").append(toIndentedString(volumeMounts)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("templateID"); + openapiFields.add("alias"); + openapiFields.add("sandboxID"); + openapiFields.add("clientID"); + openapiFields.add("startedAt"); + openapiFields.add("endAt"); + openapiFields.add("cpuCount"); + openapiFields.add("memoryMB"); + openapiFields.add("diskSizeMB"); + openapiFields.add("metadata"); + openapiFields.add("state"); + openapiFields.add("envdVersion"); + openapiFields.add("volumeMounts"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("templateID"); + openapiRequiredFields.add("sandboxID"); + openapiRequiredFields.add("clientID"); + openapiRequiredFields.add("startedAt"); + openapiRequiredFields.add("endAt"); + openapiRequiredFields.add("cpuCount"); + openapiRequiredFields.add("memoryMB"); + openapiRequiredFields.add("diskSizeMB"); + openapiRequiredFields.add("state"); + openapiRequiredFields.add("envdVersion"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxesGet200ResponseInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxesGet200ResponseInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxesGet200ResponseInner is not found in the empty JSON string", SandboxesGet200ResponseInner.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxesGet200ResponseInner.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("templateID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `templateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateID").toString())); + } + if ((jsonObj.get("alias") != null && !jsonObj.get("alias").isJsonNull()) && !jsonObj.get("alias").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `alias` to be a primitive type in the JSON string but got `%s`", jsonObj.get("alias").toString())); + } + if (!jsonObj.get("sandboxID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `sandboxID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sandboxID").toString())); + } + if (!jsonObj.get("clientID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `clientID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("clientID").toString())); + } + if (!jsonObj.get("envdVersion").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdVersion").toString())); + } + if (jsonObj.get("volumeMounts") != null && !jsonObj.get("volumeMounts").isJsonNull()) { + JsonArray jsonArrayvolumeMounts = jsonObj.getAsJsonArray("volumeMounts"); + if (jsonArrayvolumeMounts != null) { + // ensure the json data is an array + if (!jsonObj.get("volumeMounts").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `volumeMounts` to be an array in the JSON string but got `%s`", jsonObj.get("volumeMounts").toString())); + } + + // validate the optional field `volumeMounts` (array) + for (int i = 0; i < jsonArrayvolumeMounts.size(); i++) { + SandboxVolumeMount.validateJsonObject(jsonArrayvolumeMounts.get(i).getAsJsonObject()); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxesGet200ResponseInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxesGet200ResponseInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxesGet200ResponseInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxesGet200ResponseInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxesGet200ResponseInner read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxesGet200ResponseInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxesGet200ResponseInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxesGet200ResponseInner + * @throws IOException if the JSON string is invalid with respect to SandboxesGet200ResponseInner + */ + public static SandboxesGet200ResponseInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxesGet200ResponseInner.class); + } + + /** + * Convert an instance of SandboxesGet200ResponseInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDRefreshesPostRequest.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDRefreshesPostRequest.java new file mode 100644 index 0000000..2739559 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDRefreshesPostRequest.java @@ -0,0 +1,282 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxesSandboxIDRefreshesPostRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxesSandboxIDRefreshesPostRequest { + public static final String SERIALIZED_NAME_DURATION = "duration"; + @SerializedName(SERIALIZED_NAME_DURATION) + private Integer duration; + + public SandboxesSandboxIDRefreshesPostRequest() { + } + + public SandboxesSandboxIDRefreshesPostRequest duration(Integer duration) { + + this.duration = duration; + return this; + } + + /** + * Duration for which the sandbox should be kept alive in seconds + * minimum: 0 + * maximum: 3600 + * @return duration + **/ + @javax.annotation.Nullable + public Integer getDuration() { + return duration; + } + + + public void setDuration(Integer duration) { + this.duration = duration; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxesSandboxIDRefreshesPostRequest instance itself + */ + public SandboxesSandboxIDRefreshesPostRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxesSandboxIDRefreshesPostRequest sandboxesSandboxIDRefreshesPostRequest = (SandboxesSandboxIDRefreshesPostRequest) o; + return Objects.equals(this.duration, sandboxesSandboxIDRefreshesPostRequest.duration)&& + Objects.equals(this.additionalProperties, sandboxesSandboxIDRefreshesPostRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(duration, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxesSandboxIDRefreshesPostRequest {\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("duration"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxesSandboxIDRefreshesPostRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxesSandboxIDRefreshesPostRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxesSandboxIDRefreshesPostRequest is not found in the empty JSON string", SandboxesSandboxIDRefreshesPostRequest.openapiRequiredFields.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxesSandboxIDRefreshesPostRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxesSandboxIDRefreshesPostRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxesSandboxIDRefreshesPostRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxesSandboxIDRefreshesPostRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxesSandboxIDRefreshesPostRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxesSandboxIDRefreshesPostRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxesSandboxIDRefreshesPostRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxesSandboxIDRefreshesPostRequest + * @throws IOException if the JSON string is invalid with respect to SandboxesSandboxIDRefreshesPostRequest + */ + public static SandboxesSandboxIDRefreshesPostRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxesSandboxIDRefreshesPostRequest.class); + } + + /** + * Convert an instance of SandboxesSandboxIDRefreshesPostRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDSnapshotsPostRequest.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDSnapshotsPostRequest.java new file mode 100644 index 0000000..47f6baa --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDSnapshotsPostRequest.java @@ -0,0 +1,283 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxesSandboxIDSnapshotsPostRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxesSandboxIDSnapshotsPostRequest { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public SandboxesSandboxIDSnapshotsPostRequest() { + } + + public SandboxesSandboxIDSnapshotsPostRequest name(String name) { + + this.name = name; + return this; + } + + /** + * Optional name for the snapshot template. If a snapshot template with this name already exists, a new build will be assigned to the existing template instead of creating a new one. + * @return name + **/ + @javax.annotation.Nullable + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxesSandboxIDSnapshotsPostRequest instance itself + */ + public SandboxesSandboxIDSnapshotsPostRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxesSandboxIDSnapshotsPostRequest sandboxesSandboxIDSnapshotsPostRequest = (SandboxesSandboxIDSnapshotsPostRequest) o; + return Objects.equals(this.name, sandboxesSandboxIDSnapshotsPostRequest.name)&& + Objects.equals(this.additionalProperties, sandboxesSandboxIDSnapshotsPostRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxesSandboxIDSnapshotsPostRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("name"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxesSandboxIDSnapshotsPostRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxesSandboxIDSnapshotsPostRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxesSandboxIDSnapshotsPostRequest is not found in the empty JSON string", SandboxesSandboxIDSnapshotsPostRequest.openapiRequiredFields.toString())); + } + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxesSandboxIDSnapshotsPostRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxesSandboxIDSnapshotsPostRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxesSandboxIDSnapshotsPostRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxesSandboxIDSnapshotsPostRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxesSandboxIDSnapshotsPostRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxesSandboxIDSnapshotsPostRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxesSandboxIDSnapshotsPostRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxesSandboxIDSnapshotsPostRequest + * @throws IOException if the JSON string is invalid with respect to SandboxesSandboxIDSnapshotsPostRequest + */ + public static SandboxesSandboxIDSnapshotsPostRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxesSandboxIDSnapshotsPostRequest.class); + } + + /** + * Convert an instance of SandboxesSandboxIDSnapshotsPostRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDTimeoutPostRequest.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDTimeoutPostRequest.java new file mode 100644 index 0000000..0ecc26b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesSandboxIDTimeoutPostRequest.java @@ -0,0 +1,289 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxesSandboxIDTimeoutPostRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxesSandboxIDTimeoutPostRequest { + public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; + @SerializedName(SERIALIZED_NAME_TIMEOUT) + private Integer timeout; + + public SandboxesSandboxIDTimeoutPostRequest() { + } + + public SandboxesSandboxIDTimeoutPostRequest timeout(Integer timeout) { + + this.timeout = timeout; + return this; + } + + /** + * Timeout in seconds from the current time after which the sandbox should expire + * minimum: 0 + * @return timeout + **/ + @javax.annotation.Nonnull + public Integer getTimeout() { + return timeout; + } + + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxesSandboxIDTimeoutPostRequest instance itself + */ + public SandboxesSandboxIDTimeoutPostRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxesSandboxIDTimeoutPostRequest sandboxesSandboxIDTimeoutPostRequest = (SandboxesSandboxIDTimeoutPostRequest) o; + return Objects.equals(this.timeout, sandboxesSandboxIDTimeoutPostRequest.timeout)&& + Objects.equals(this.additionalProperties, sandboxesSandboxIDTimeoutPostRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timeout, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxesSandboxIDTimeoutPostRequest {\n"); + sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timeout"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timeout"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxesSandboxIDTimeoutPostRequest + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxesSandboxIDTimeoutPostRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxesSandboxIDTimeoutPostRequest is not found in the empty JSON string", SandboxesSandboxIDTimeoutPostRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxesSandboxIDTimeoutPostRequest.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxesSandboxIDTimeoutPostRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxesSandboxIDTimeoutPostRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxesSandboxIDTimeoutPostRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxesSandboxIDTimeoutPostRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxesSandboxIDTimeoutPostRequest read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxesSandboxIDTimeoutPostRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxesSandboxIDTimeoutPostRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxesSandboxIDTimeoutPostRequest + * @throws IOException if the JSON string is invalid with respect to SandboxesSandboxIDTimeoutPostRequest + */ + public static SandboxesSandboxIDTimeoutPostRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxesSandboxIDTimeoutPostRequest.class); + } + + /** + * Convert an instance of SandboxesSandboxIDTimeoutPostRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesWithMetrics.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesWithMetrics.java new file mode 100644 index 0000000..af5330c --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SandboxesWithMetrics.java @@ -0,0 +1,299 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.SandboxMetric; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SandboxesWithMetrics + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SandboxesWithMetrics { + public static final String SERIALIZED_NAME_SANDBOXES = "sandboxes"; + @SerializedName(SERIALIZED_NAME_SANDBOXES) + private Map sandboxes = new HashMap<>(); + + public SandboxesWithMetrics() { + } + + public SandboxesWithMetrics sandboxes(Map sandboxes) { + + this.sandboxes = sandboxes; + return this; + } + + public SandboxesWithMetrics putSandboxesItem(String key, SandboxMetric sandboxesItem) { + if (this.sandboxes == null) { + this.sandboxes = new HashMap<>(); + } + this.sandboxes.put(key, sandboxesItem); + return this; + } + + /** + * Get sandboxes + * @return sandboxes + **/ + @javax.annotation.Nonnull + public Map getSandboxes() { + return sandboxes; + } + + + public void setSandboxes(Map sandboxes) { + this.sandboxes = sandboxes; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SandboxesWithMetrics instance itself + */ + public SandboxesWithMetrics putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SandboxesWithMetrics sandboxesWithMetrics = (SandboxesWithMetrics) o; + return Objects.equals(this.sandboxes, sandboxesWithMetrics.sandboxes)&& + Objects.equals(this.additionalProperties, sandboxesWithMetrics.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(sandboxes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SandboxesWithMetrics {\n"); + sb.append(" sandboxes: ").append(toIndentedString(sandboxes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("sandboxes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("sandboxes"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SandboxesWithMetrics + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SandboxesWithMetrics.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SandboxesWithMetrics is not found in the empty JSON string", SandboxesWithMetrics.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SandboxesWithMetrics.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SandboxesWithMetrics.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SandboxesWithMetrics' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SandboxesWithMetrics.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SandboxesWithMetrics value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SandboxesWithMetrics read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SandboxesWithMetrics instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SandboxesWithMetrics given an JSON string + * + * @param jsonString JSON string + * @return An instance of SandboxesWithMetrics + * @throws IOException if the JSON string is invalid with respect to SandboxesWithMetrics + */ + public static SandboxesWithMetrics fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SandboxesWithMetrics.class); + } + + /** + * Convert an instance of SandboxesWithMetrics to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SnapshotInfo.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SnapshotInfo.java new file mode 100644 index 0000000..8b0b5e6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/SnapshotInfo.java @@ -0,0 +1,336 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * SnapshotInfo + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class SnapshotInfo { + public static final String SERIALIZED_NAME_SNAPSHOT_I_D = "snapshotID"; + @SerializedName(SERIALIZED_NAME_SNAPSHOT_I_D) + private String snapshotID; + + public static final String SERIALIZED_NAME_NAMES = "names"; + @SerializedName(SERIALIZED_NAME_NAMES) + private List names = new ArrayList<>(); + + public SnapshotInfo() { + } + + public SnapshotInfo snapshotID(String snapshotID) { + + this.snapshotID = snapshotID; + return this; + } + + /** + * Identifier of the snapshot template + * @return snapshotID + **/ + @javax.annotation.Nonnull + public String getSnapshotID() { + return snapshotID; + } + + + public void setSnapshotID(String snapshotID) { + this.snapshotID = snapshotID; + } + + + public SnapshotInfo names(List names) { + + this.names = names; + return this; + } + + public SnapshotInfo addNamesItem(String namesItem) { + if (this.names == null) { + this.names = new ArrayList<>(); + } + this.names.add(namesItem); + return this; + } + + /** + * Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2) + * @return names + **/ + @javax.annotation.Nonnull + public List getNames() { + return names; + } + + + public void setNames(List names) { + this.names = names; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SnapshotInfo instance itself + */ + public SnapshotInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SnapshotInfo snapshotInfo = (SnapshotInfo) o; + return Objects.equals(this.snapshotID, snapshotInfo.snapshotID) && + Objects.equals(this.names, snapshotInfo.names)&& + Objects.equals(this.additionalProperties, snapshotInfo.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(snapshotID, names, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SnapshotInfo {\n"); + sb.append(" snapshotID: ").append(toIndentedString(snapshotID)).append("\n"); + sb.append(" names: ").append(toIndentedString(names)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("snapshotID"); + openapiFields.add("names"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("snapshotID"); + openapiRequiredFields.add("names"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SnapshotInfo + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SnapshotInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SnapshotInfo is not found in the empty JSON string", SnapshotInfo.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SnapshotInfo.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("snapshotID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `snapshotID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("snapshotID").toString())); + } + // ensure the required json array is present + if (jsonObj.get("names") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("names").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `names` to be an array in the JSON string but got `%s`", jsonObj.get("names").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SnapshotInfo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SnapshotInfo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SnapshotInfo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SnapshotInfo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SnapshotInfo read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + SnapshotInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SnapshotInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of SnapshotInfo + * @throws IOException if the JSON string is invalid with respect to SnapshotInfo + */ + public static SnapshotInfo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SnapshotInfo.class); + } + + /** + * Convert an instance of SnapshotInfo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Team.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Team.java new file mode 100644 index 0000000..beb492d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Team.java @@ -0,0 +1,384 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Team + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Team { + public static final String SERIALIZED_NAME_TEAM_I_D = "teamID"; + @SerializedName(SERIALIZED_NAME_TEAM_I_D) + private String teamID; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_KEY = "apiKey"; + @SerializedName(SERIALIZED_NAME_API_KEY) + private String apiKey; + + public static final String SERIALIZED_NAME_IS_DEFAULT = "isDefault"; + @SerializedName(SERIALIZED_NAME_IS_DEFAULT) + private Boolean isDefault; + + public Team() { + } + + public Team teamID(String teamID) { + + this.teamID = teamID; + return this; + } + + /** + * Identifier of the team + * @return teamID + **/ + @javax.annotation.Nonnull + public String getTeamID() { + return teamID; + } + + + public void setTeamID(String teamID) { + this.teamID = teamID; + } + + + public Team name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the team + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public Team apiKey(String apiKey) { + + this.apiKey = apiKey; + return this; + } + + /** + * API key for the team + * @return apiKey + **/ + @javax.annotation.Nonnull + public String getApiKey() { + return apiKey; + } + + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + + public Team isDefault(Boolean isDefault) { + + this.isDefault = isDefault; + return this; + } + + /** + * Whether the team is the default team + * @return isDefault + **/ + @javax.annotation.Nonnull + public Boolean getIsDefault() { + return isDefault; + } + + + public void setIsDefault(Boolean isDefault) { + this.isDefault = isDefault; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Team instance itself + */ + public Team putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Team team = (Team) o; + return Objects.equals(this.teamID, team.teamID) && + Objects.equals(this.name, team.name) && + Objects.equals(this.apiKey, team.apiKey) && + Objects.equals(this.isDefault, team.isDefault)&& + Objects.equals(this.additionalProperties, team.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(teamID, name, apiKey, isDefault, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Team {\n"); + sb.append(" teamID: ").append(toIndentedString(teamID)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiKey: ").append(toIndentedString(apiKey)).append("\n"); + sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("teamID"); + openapiFields.add("name"); + openapiFields.add("apiKey"); + openapiFields.add("isDefault"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("teamID"); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("apiKey"); + openapiRequiredFields.add("isDefault"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Team + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Team.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Team is not found in the empty JSON string", Team.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Team.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("teamID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `teamID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("teamID").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("apiKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `apiKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("apiKey").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Team.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Team' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Team.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Team value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Team read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + Team instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Team given an JSON string + * + * @param jsonString JSON string + * @return An instance of Team + * @throws IOException if the JSON string is invalid with respect to Team + */ + public static Team fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Team.class); + } + + /** + * Convert an instance of Team to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamAPIKey.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamAPIKey.java new file mode 100644 index 0000000..42f137e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamAPIKey.java @@ -0,0 +1,459 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.IdentifierMaskingDetails; +import io.openkruise.agents.client.e2b.api.models.TeamUser; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * TeamAPIKey + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class TeamAPIKey { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_MASK = "mask"; + @SerializedName(SERIALIZED_NAME_MASK) + private IdentifierMaskingDetails mask; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_CREATED_BY = "createdBy"; + @SerializedName(SERIALIZED_NAME_CREATED_BY) + private TeamUser createdBy; + + public static final String SERIALIZED_NAME_LAST_USED = "lastUsed"; + @SerializedName(SERIALIZED_NAME_LAST_USED) + private OffsetDateTime lastUsed; + + public TeamAPIKey() { + } + + public TeamAPIKey id(UUID id) { + + this.id = id; + return this; + } + + /** + * Identifier of the API key + * @return id + **/ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + + public void setId(UUID id) { + this.id = id; + } + + + public TeamAPIKey name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the API key + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public TeamAPIKey mask(IdentifierMaskingDetails mask) { + + this.mask = mask; + return this; + } + + /** + * Get mask + * @return mask + **/ + @javax.annotation.Nonnull + public IdentifierMaskingDetails getMask() { + return mask; + } + + + public void setMask(IdentifierMaskingDetails mask) { + this.mask = mask; + } + + + public TeamAPIKey createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * Timestamp of API key creation + * @return createdAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public TeamAPIKey createdBy(TeamUser createdBy) { + + this.createdBy = createdBy; + return this; + } + + /** + * Get createdBy + * @return createdBy + **/ + @javax.annotation.Nullable + public TeamUser getCreatedBy() { + return createdBy; + } + + + public void setCreatedBy(TeamUser createdBy) { + this.createdBy = createdBy; + } + + + public TeamAPIKey lastUsed(OffsetDateTime lastUsed) { + + this.lastUsed = lastUsed; + return this; + } + + /** + * Last time this API key was used + * @return lastUsed + **/ + @javax.annotation.Nullable + public OffsetDateTime getLastUsed() { + return lastUsed; + } + + + public void setLastUsed(OffsetDateTime lastUsed) { + this.lastUsed = lastUsed; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TeamAPIKey instance itself + */ + public TeamAPIKey putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TeamAPIKey teamAPIKey = (TeamAPIKey) o; + return Objects.equals(this.id, teamAPIKey.id) && + Objects.equals(this.name, teamAPIKey.name) && + Objects.equals(this.mask, teamAPIKey.mask) && + Objects.equals(this.createdAt, teamAPIKey.createdAt) && + Objects.equals(this.createdBy, teamAPIKey.createdBy) && + Objects.equals(this.lastUsed, teamAPIKey.lastUsed)&& + Objects.equals(this.additionalProperties, teamAPIKey.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, mask, createdAt, createdBy, lastUsed, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TeamAPIKey {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" mask: ").append(toIndentedString(mask)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" lastUsed: ").append(toIndentedString(lastUsed)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("mask"); + openapiFields.add("createdAt"); + openapiFields.add("createdBy"); + openapiFields.add("lastUsed"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("mask"); + openapiRequiredFields.add("createdAt"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TeamAPIKey + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TeamAPIKey.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TeamAPIKey is not found in the empty JSON string", TeamAPIKey.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TeamAPIKey.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `mask` + IdentifierMaskingDetails.validateJsonObject(jsonObj.getAsJsonObject("mask")); + // validate the optional field `createdBy` + if (jsonObj.get("createdBy") != null && !jsonObj.get("createdBy").isJsonNull()) { + TeamUser.validateJsonObject(jsonObj.getAsJsonObject("createdBy")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TeamAPIKey.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TeamAPIKey' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TeamAPIKey.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TeamAPIKey value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TeamAPIKey read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + TeamAPIKey instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TeamAPIKey given an JSON string + * + * @param jsonString JSON string + * @return An instance of TeamAPIKey + * @throws IOException if the JSON string is invalid with respect to TeamAPIKey + */ + public static TeamAPIKey fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TeamAPIKey.class); + } + + /** + * Convert an instance of TeamAPIKey to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamMetric.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamMetric.java new file mode 100644 index 0000000..ca9697e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamMetric.java @@ -0,0 +1,381 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Team metric with timestamp + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class TeamMetric { + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + @Deprecated + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + private OffsetDateTime timestamp; + + public static final String SERIALIZED_NAME_TIMESTAMP_UNIX = "timestampUnix"; + @SerializedName(SERIALIZED_NAME_TIMESTAMP_UNIX) + private Long timestampUnix; + + public static final String SERIALIZED_NAME_CONCURRENT_SANDBOXES = "concurrentSandboxes"; + @SerializedName(SERIALIZED_NAME_CONCURRENT_SANDBOXES) + private Integer concurrentSandboxes; + + public static final String SERIALIZED_NAME_SANDBOX_START_RATE = "sandboxStartRate"; + @SerializedName(SERIALIZED_NAME_SANDBOX_START_RATE) + private Float sandboxStartRate; + + public TeamMetric() { + } + + @Deprecated + public TeamMetric timestamp(OffsetDateTime timestamp) { + + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp of the metric entry + * @return timestamp + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + + @Deprecated + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + + public TeamMetric timestampUnix(Long timestampUnix) { + + this.timestampUnix = timestampUnix; + return this; + } + + /** + * Timestamp of the metric entry in Unix time (seconds since epoch) + * @return timestampUnix + **/ + @javax.annotation.Nonnull + public Long getTimestampUnix() { + return timestampUnix; + } + + + public void setTimestampUnix(Long timestampUnix) { + this.timestampUnix = timestampUnix; + } + + + public TeamMetric concurrentSandboxes(Integer concurrentSandboxes) { + + this.concurrentSandboxes = concurrentSandboxes; + return this; + } + + /** + * The number of concurrent sandboxes for the team + * @return concurrentSandboxes + **/ + @javax.annotation.Nonnull + public Integer getConcurrentSandboxes() { + return concurrentSandboxes; + } + + + public void setConcurrentSandboxes(Integer concurrentSandboxes) { + this.concurrentSandboxes = concurrentSandboxes; + } + + + public TeamMetric sandboxStartRate(Float sandboxStartRate) { + + this.sandboxStartRate = sandboxStartRate; + return this; + } + + /** + * Number of sandboxes started per second + * @return sandboxStartRate + **/ + @javax.annotation.Nonnull + public Float getSandboxStartRate() { + return sandboxStartRate; + } + + + public void setSandboxStartRate(Float sandboxStartRate) { + this.sandboxStartRate = sandboxStartRate; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TeamMetric instance itself + */ + public TeamMetric putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TeamMetric teamMetric = (TeamMetric) o; + return Objects.equals(this.timestamp, teamMetric.timestamp) && + Objects.equals(this.timestampUnix, teamMetric.timestampUnix) && + Objects.equals(this.concurrentSandboxes, teamMetric.concurrentSandboxes) && + Objects.equals(this.sandboxStartRate, teamMetric.sandboxStartRate)&& + Objects.equals(this.additionalProperties, teamMetric.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, timestampUnix, concurrentSandboxes, sandboxStartRate, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TeamMetric {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" timestampUnix: ").append(toIndentedString(timestampUnix)).append("\n"); + sb.append(" concurrentSandboxes: ").append(toIndentedString(concurrentSandboxes)).append("\n"); + sb.append(" sandboxStartRate: ").append(toIndentedString(sandboxStartRate)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("timestamp"); + openapiFields.add("timestampUnix"); + openapiFields.add("concurrentSandboxes"); + openapiFields.add("sandboxStartRate"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("timestamp"); + openapiRequiredFields.add("timestampUnix"); + openapiRequiredFields.add("concurrentSandboxes"); + openapiRequiredFields.add("sandboxStartRate"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TeamMetric + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TeamMetric.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TeamMetric is not found in the empty JSON string", TeamMetric.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TeamMetric.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TeamMetric.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TeamMetric' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TeamMetric.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TeamMetric value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TeamMetric read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + TeamMetric instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TeamMetric given an JSON string + * + * @param jsonString JSON string + * @return An instance of TeamMetric + * @throws IOException if the JSON string is invalid with respect to TeamMetric + */ + public static TeamMetric fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TeamMetric.class); + } + + /** + * Convert an instance of TeamMetric to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamUser.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamUser.java new file mode 100644 index 0000000..32e1a4f --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamUser.java @@ -0,0 +1,324 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * TeamUser + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class TeamUser { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; + + public static final String SERIALIZED_NAME_EMAIL = "email"; + @SerializedName(SERIALIZED_NAME_EMAIL) + private String email; + + public TeamUser() { + } + + public TeamUser id(UUID id) { + + this.id = id; + return this; + } + + /** + * Identifier of the user + * @return id + **/ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + + public void setId(UUID id) { + this.id = id; + } + + + public TeamUser email(String email) { + + this.email = email; + return this; + } + + /** + * Email of the user + * @return email + **/ + @javax.annotation.Nonnull + public String getEmail() { + return email; + } + + + public void setEmail(String email) { + this.email = email; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TeamUser instance itself + */ + public TeamUser putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TeamUser teamUser = (TeamUser) o; + return Objects.equals(this.id, teamUser.id) && + Objects.equals(this.email, teamUser.email)&& + Objects.equals(this.additionalProperties, teamUser.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, email, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TeamUser {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("email"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("email"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TeamUser + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TeamUser.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TeamUser is not found in the empty JSON string", TeamUser.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TeamUser.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("email").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TeamUser.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TeamUser' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TeamUser.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TeamUser value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TeamUser read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + TeamUser instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TeamUser given an JSON string + * + * @param jsonString JSON string + * @return An instance of TeamUser + * @throws IOException if the JSON string is invalid with respect to TeamUser + */ + public static TeamUser fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TeamUser.class); + } + + /** + * Convert an instance of TeamUser to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamsGet200ResponseInner.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamsGet200ResponseInner.java new file mode 100644 index 0000000..334a383 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/TeamsGet200ResponseInner.java @@ -0,0 +1,384 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * TeamsGet200ResponseInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class TeamsGet200ResponseInner { + public static final String SERIALIZED_NAME_TEAM_I_D = "teamID"; + @SerializedName(SERIALIZED_NAME_TEAM_I_D) + private String teamID; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_KEY = "apiKey"; + @SerializedName(SERIALIZED_NAME_API_KEY) + private String apiKey; + + public static final String SERIALIZED_NAME_IS_DEFAULT = "isDefault"; + @SerializedName(SERIALIZED_NAME_IS_DEFAULT) + private Boolean isDefault; + + public TeamsGet200ResponseInner() { + } + + public TeamsGet200ResponseInner teamID(String teamID) { + + this.teamID = teamID; + return this; + } + + /** + * Identifier of the team + * @return teamID + **/ + @javax.annotation.Nonnull + public String getTeamID() { + return teamID; + } + + + public void setTeamID(String teamID) { + this.teamID = teamID; + } + + + public TeamsGet200ResponseInner name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the team + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public TeamsGet200ResponseInner apiKey(String apiKey) { + + this.apiKey = apiKey; + return this; + } + + /** + * API key for the team + * @return apiKey + **/ + @javax.annotation.Nonnull + public String getApiKey() { + return apiKey; + } + + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + + public TeamsGet200ResponseInner isDefault(Boolean isDefault) { + + this.isDefault = isDefault; + return this; + } + + /** + * Whether the team is the default team + * @return isDefault + **/ + @javax.annotation.Nonnull + public Boolean getIsDefault() { + return isDefault; + } + + + public void setIsDefault(Boolean isDefault) { + this.isDefault = isDefault; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TeamsGet200ResponseInner instance itself + */ + public TeamsGet200ResponseInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TeamsGet200ResponseInner teamsGet200ResponseInner = (TeamsGet200ResponseInner) o; + return Objects.equals(this.teamID, teamsGet200ResponseInner.teamID) && + Objects.equals(this.name, teamsGet200ResponseInner.name) && + Objects.equals(this.apiKey, teamsGet200ResponseInner.apiKey) && + Objects.equals(this.isDefault, teamsGet200ResponseInner.isDefault)&& + Objects.equals(this.additionalProperties, teamsGet200ResponseInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(teamID, name, apiKey, isDefault, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TeamsGet200ResponseInner {\n"); + sb.append(" teamID: ").append(toIndentedString(teamID)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiKey: ").append(toIndentedString(apiKey)).append("\n"); + sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("teamID"); + openapiFields.add("name"); + openapiFields.add("apiKey"); + openapiFields.add("isDefault"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("teamID"); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("apiKey"); + openapiRequiredFields.add("isDefault"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to TeamsGet200ResponseInner + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!TeamsGet200ResponseInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TeamsGet200ResponseInner is not found in the empty JSON string", TeamsGet200ResponseInner.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TeamsGet200ResponseInner.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("teamID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `teamID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("teamID").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("apiKey").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `apiKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("apiKey").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TeamsGet200ResponseInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TeamsGet200ResponseInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TeamsGet200ResponseInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TeamsGet200ResponseInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TeamsGet200ResponseInner read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + // store additional fields in the deserialized instance + TeamsGet200ResponseInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TeamsGet200ResponseInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of TeamsGet200ResponseInner + * @throws IOException if the JSON string is invalid with respect to TeamsGet200ResponseInner + */ + public static TeamsGet200ResponseInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TeamsGet200ResponseInner.class); + } + + /** + * Convert an instance of TeamsGet200ResponseInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Template.java b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Template.java new file mode 100644 index 0000000..156511e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/e2b/api/models/Template.java @@ -0,0 +1,775 @@ +/* + * E2B API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * 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.openkruise.agents.client.e2b.api.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.openkruise.agents.client.e2b.api.models.TeamUser; +import io.openkruise.agents.client.e2b.api.models.TemplateBuildStatus; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.openkruise.agents.client.e2b.api.invoker.JSON; + +/** + * Template + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-03-13T16:02:01.263+08:00[Asia/Shanghai]") +public class Template { + public static final String SERIALIZED_NAME_TEMPLATE_I_D = "templateID"; + @SerializedName(SERIALIZED_NAME_TEMPLATE_I_D) + private String templateID; + + public static final String SERIALIZED_NAME_BUILD_I_D = "buildID"; + @SerializedName(SERIALIZED_NAME_BUILD_I_D) + private String buildID; + + public static final String SERIALIZED_NAME_CPU_COUNT = "cpuCount"; + @SerializedName(SERIALIZED_NAME_CPU_COUNT) + private Integer cpuCount; + + public static final String SERIALIZED_NAME_MEMORY_M_B = "memoryMB"; + @SerializedName(SERIALIZED_NAME_MEMORY_M_B) + private Integer memoryMB; + + public static final String SERIALIZED_NAME_DISK_SIZE_M_B = "diskSizeMB"; + @SerializedName(SERIALIZED_NAME_DISK_SIZE_M_B) + private Integer diskSizeMB; + + public static final String SERIALIZED_NAME_PUBLIC = "public"; + @SerializedName(SERIALIZED_NAME_PUBLIC) + private Boolean _public; + + public static final String SERIALIZED_NAME_ALIASES = "aliases"; + @Deprecated + @SerializedName(SERIALIZED_NAME_ALIASES) + private List aliases = new ArrayList<>(); + + public static final String SERIALIZED_NAME_NAMES = "names"; + @SerializedName(SERIALIZED_NAME_NAMES) + private List names = new ArrayList<>(); + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public static final String SERIALIZED_NAME_CREATED_BY = "createdBy"; + @SerializedName(SERIALIZED_NAME_CREATED_BY) + private TeamUser createdBy; + + public static final String SERIALIZED_NAME_LAST_SPAWNED_AT = "lastSpawnedAt"; + @SerializedName(SERIALIZED_NAME_LAST_SPAWNED_AT) + private OffsetDateTime lastSpawnedAt; + + public static final String SERIALIZED_NAME_SPAWN_COUNT = "spawnCount"; + @SerializedName(SERIALIZED_NAME_SPAWN_COUNT) + private Long spawnCount; + + public static final String SERIALIZED_NAME_BUILD_COUNT = "buildCount"; + @SerializedName(SERIALIZED_NAME_BUILD_COUNT) + private Integer buildCount; + + public static final String SERIALIZED_NAME_ENVD_VERSION = "envdVersion"; + @SerializedName(SERIALIZED_NAME_ENVD_VERSION) + private String envdVersion; + + public static final String SERIALIZED_NAME_BUILD_STATUS = "buildStatus"; + @SerializedName(SERIALIZED_NAME_BUILD_STATUS) + private TemplateBuildStatus buildStatus; + + public Template() { + } + + public Template templateID(String templateID) { + + this.templateID = templateID; + return this; + } + + /** + * Identifier of the template + * @return templateID + **/ + @javax.annotation.Nonnull + public String getTemplateID() { + return templateID; + } + + + public void setTemplateID(String templateID) { + this.templateID = templateID; + } + + + public Template buildID(String buildID) { + + this.buildID = buildID; + return this; + } + + /** + * Identifier of the last successful build for given template + * @return buildID + **/ + @javax.annotation.Nonnull + public String getBuildID() { + return buildID; + } + + + public void setBuildID(String buildID) { + this.buildID = buildID; + } + + + public Template cpuCount(Integer cpuCount) { + + this.cpuCount = cpuCount; + return this; + } + + /** + * CPU cores for the sandbox + * minimum: 1 + * @return cpuCount + **/ + @javax.annotation.Nonnull + public Integer getCpuCount() { + return cpuCount; + } + + + public void setCpuCount(Integer cpuCount) { + this.cpuCount = cpuCount; + } + + + public Template memoryMB(Integer memoryMB) { + + this.memoryMB = memoryMB; + return this; + } + + /** + * Memory for the sandbox in MiB + * minimum: 128 + * @return memoryMB + **/ + @javax.annotation.Nonnull + public Integer getMemoryMB() { + return memoryMB; + } + + + public void setMemoryMB(Integer memoryMB) { + this.memoryMB = memoryMB; + } + + + public Template diskSizeMB(Integer diskSizeMB) { + + this.diskSizeMB = diskSizeMB; + return this; + } + + /** + * Disk size for the sandbox in MiB + * minimum: 0 + * @return diskSizeMB + **/ + @javax.annotation.Nonnull + public Integer getDiskSizeMB() { + return diskSizeMB; + } + + + public void setDiskSizeMB(Integer diskSizeMB) { + this.diskSizeMB = diskSizeMB; + } + + + public Template _public(Boolean _public) { + + this._public = _public; + return this; + } + + /** + * Whether the template is public or only accessible by the team + * @return _public + **/ + @javax.annotation.Nonnull + public Boolean getPublic() { + return _public; + } + + + public void setPublic(Boolean _public) { + this._public = _public; + } + + + @Deprecated + public Template aliases(List aliases) { + + this.aliases = aliases; + return this; + } + + public Template addAliasesItem(String aliasesItem) { + if (this.aliases == null) { + this.aliases = new ArrayList<>(); + } + this.aliases.add(aliasesItem); + return this; + } + + /** + * Aliases of the template + * @return aliases + * @deprecated + **/ + @Deprecated + @javax.annotation.Nonnull + public List getAliases() { + return aliases; + } + + + @Deprecated + public void setAliases(List aliases) { + this.aliases = aliases; + } + + + public Template names(List names) { + + this.names = names; + return this; + } + + public Template addNamesItem(String namesItem) { + if (this.names == null) { + this.names = new ArrayList<>(); + } + this.names.add(namesItem); + return this; + } + + /** + * Names of the template (namespace/alias format when namespaced) + * @return names + **/ + @javax.annotation.Nonnull + public List getNames() { + return names; + } + + + public void setNames(List names) { + this.names = names; + } + + + public Template createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * Time when the template was created + * @return createdAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public Template updatedAt(OffsetDateTime updatedAt) { + + this.updatedAt = updatedAt; + return this; + } + + /** + * Time when the template was last updated + * @return updatedAt + **/ + @javax.annotation.Nonnull + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + + public Template createdBy(TeamUser createdBy) { + + this.createdBy = createdBy; + return this; + } + + /** + * Get createdBy + * @return createdBy + **/ + @javax.annotation.Nullable + public TeamUser getCreatedBy() { + return createdBy; + } + + + public void setCreatedBy(TeamUser createdBy) { + this.createdBy = createdBy; + } + + + public Template lastSpawnedAt(OffsetDateTime lastSpawnedAt) { + + this.lastSpawnedAt = lastSpawnedAt; + return this; + } + + /** + * Time when the template was last used + * @return lastSpawnedAt + **/ + @javax.annotation.Nullable + public OffsetDateTime getLastSpawnedAt() { + return lastSpawnedAt; + } + + + public void setLastSpawnedAt(OffsetDateTime lastSpawnedAt) { + this.lastSpawnedAt = lastSpawnedAt; + } + + + public Template spawnCount(Long spawnCount) { + + this.spawnCount = spawnCount; + return this; + } + + /** + * Number of times the template was used + * @return spawnCount + **/ + @javax.annotation.Nonnull + public Long getSpawnCount() { + return spawnCount; + } + + + public void setSpawnCount(Long spawnCount) { + this.spawnCount = spawnCount; + } + + + public Template buildCount(Integer buildCount) { + + this.buildCount = buildCount; + return this; + } + + /** + * Number of times the template was built + * @return buildCount + **/ + @javax.annotation.Nonnull + public Integer getBuildCount() { + return buildCount; + } + + + public void setBuildCount(Integer buildCount) { + this.buildCount = buildCount; + } + + + public Template envdVersion(String envdVersion) { + + this.envdVersion = envdVersion; + return this; + } + + /** + * Version of the envd running in the sandbox + * @return envdVersion + **/ + @javax.annotation.Nonnull + public String getEnvdVersion() { + return envdVersion; + } + + + public void setEnvdVersion(String envdVersion) { + this.envdVersion = envdVersion; + } + + + public Template buildStatus(TemplateBuildStatus buildStatus) { + + this.buildStatus = buildStatus; + return this; + } + + /** + * Get buildStatus + * @return buildStatus + **/ + @javax.annotation.Nonnull + public TemplateBuildStatus getBuildStatus() { + return buildStatus; + } + + + public void setBuildStatus(TemplateBuildStatus buildStatus) { + this.buildStatus = buildStatus; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Template instance itself + */ + public Template putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Template template = (Template) o; + return Objects.equals(this.templateID, template.templateID) && + Objects.equals(this.buildID, template.buildID) && + Objects.equals(this.cpuCount, template.cpuCount) && + Objects.equals(this.memoryMB, template.memoryMB) && + Objects.equals(this.diskSizeMB, template.diskSizeMB) && + Objects.equals(this._public, template._public) && + Objects.equals(this.aliases, template.aliases) && + Objects.equals(this.names, template.names) && + Objects.equals(this.createdAt, template.createdAt) && + Objects.equals(this.updatedAt, template.updatedAt) && + Objects.equals(this.createdBy, template.createdBy) && + Objects.equals(this.lastSpawnedAt, template.lastSpawnedAt) && + Objects.equals(this.spawnCount, template.spawnCount) && + Objects.equals(this.buildCount, template.buildCount) && + Objects.equals(this.envdVersion, template.envdVersion) && + Objects.equals(this.buildStatus, template.buildStatus)&& + Objects.equals(this.additionalProperties, template.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(templateID, buildID, cpuCount, memoryMB, diskSizeMB, _public, aliases, names, createdAt, updatedAt, createdBy, lastSpawnedAt, spawnCount, buildCount, envdVersion, buildStatus, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Template {\n"); + sb.append(" templateID: ").append(toIndentedString(templateID)).append("\n"); + sb.append(" buildID: ").append(toIndentedString(buildID)).append("\n"); + sb.append(" cpuCount: ").append(toIndentedString(cpuCount)).append("\n"); + sb.append(" memoryMB: ").append(toIndentedString(memoryMB)).append("\n"); + sb.append(" diskSizeMB: ").append(toIndentedString(diskSizeMB)).append("\n"); + sb.append(" _public: ").append(toIndentedString(_public)).append("\n"); + sb.append(" aliases: ").append(toIndentedString(aliases)).append("\n"); + sb.append(" names: ").append(toIndentedString(names)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" lastSpawnedAt: ").append(toIndentedString(lastSpawnedAt)).append("\n"); + sb.append(" spawnCount: ").append(toIndentedString(spawnCount)).append("\n"); + sb.append(" buildCount: ").append(toIndentedString(buildCount)).append("\n"); + sb.append(" envdVersion: ").append(toIndentedString(envdVersion)).append("\n"); + sb.append(" buildStatus: ").append(toIndentedString(buildStatus)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("templateID"); + openapiFields.add("buildID"); + openapiFields.add("cpuCount"); + openapiFields.add("memoryMB"); + openapiFields.add("diskSizeMB"); + openapiFields.add("public"); + openapiFields.add("aliases"); + openapiFields.add("names"); + openapiFields.add("createdAt"); + openapiFields.add("updatedAt"); + openapiFields.add("createdBy"); + openapiFields.add("lastSpawnedAt"); + openapiFields.add("spawnCount"); + openapiFields.add("buildCount"); + openapiFields.add("envdVersion"); + openapiFields.add("buildStatus"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("templateID"); + openapiRequiredFields.add("buildID"); + openapiRequiredFields.add("cpuCount"); + openapiRequiredFields.add("memoryMB"); + openapiRequiredFields.add("diskSizeMB"); + openapiRequiredFields.add("public"); + openapiRequiredFields.add("aliases"); + openapiRequiredFields.add("names"); + openapiRequiredFields.add("createdAt"); + openapiRequiredFields.add("updatedAt"); + openapiRequiredFields.add("createdBy"); + openapiRequiredFields.add("lastSpawnedAt"); + openapiRequiredFields.add("spawnCount"); + openapiRequiredFields.add("buildCount"); + openapiRequiredFields.add("envdVersion"); + openapiRequiredFields.add("buildStatus"); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Template + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Template.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Template is not found in the empty JSON string", Template.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Template.openapiRequiredFields) { + if (jsonObj.get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString())); + } + } + if (!jsonObj.get("templateID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `templateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateID").toString())); + } + if (!jsonObj.get("buildID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `buildID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("buildID").toString())); + } + // ensure the required json array is present + if (jsonObj.get("aliases") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("aliases").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `aliases` to be an array in the JSON string but got `%s`", jsonObj.get("aliases").toString())); + } + // ensure the required json array is present + if (jsonObj.get("names") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("names").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `names` to be an array in the JSON string but got `%s`", jsonObj.get("names").toString())); + } + // validate the required field `createdBy` + TeamUser.validateJsonObject(jsonObj.getAsJsonObject("createdBy")); + if (!jsonObj.get("envdVersion").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `envdVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("envdVersion").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Template.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Template' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter