diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 53b8202c7..2706e2099 100755 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -d51b6c87771fef9fccd731995456dc9b0448d03a \ No newline at end of file +a50988a8da83d7f6610bf9ffc778e79dca626938 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 5548ae00d..0ab6d88f7 100755 --- a/.gitattributes +++ b/.gitattributes @@ -100,10 +100,16 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ComputeStatus. databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateAppDeploymentRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateAppRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateCustomTemplateRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceOperation.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CustomTemplate.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DatabricksServiceExceptionWithDetailsProto.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteAppRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteCustomTemplateRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceOperation.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/EnvVar.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ErrorCode.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetAppDeploymentRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetAppPermissionLevelsRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetAppPermissionLevelsResponse.java linguist-generated=true @@ -111,6 +117,8 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetAppPermissi databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetAppRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetAppUpdateRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetCustomTemplateRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetOperationRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetSpaceRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GitRepository.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GitSource.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppDeploymentsRequest.java linguist-generated=true @@ -119,10 +127,21 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppsReques databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppsResponse.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListCustomTemplatesRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListCustomTemplatesResponse.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesResponse.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Operation.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Space.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatus.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatusSpaceState.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdate.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateState.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateStatus.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/StartAppRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/StopAppRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateAppRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateCustomTemplateRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceOperation.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/billing/ActionConfiguration.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/billing/ActionConfigurationType.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/billing/AlertConfiguration.java linguist-generated=true @@ -1928,7 +1947,6 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SetModelTagReque databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SetModelVersionTagRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SetTag.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SlidingWindow.java linguist-generated=true -databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SqlTransformation.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/Status.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SubscriptionMode.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/TestRegistryWebhookRequest.java linguist-generated=true diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 6152427ba..054a3e4e8 100755 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -17,4 +17,8 @@ * Add `accountClient.endpoints()` service. * Add `filterCondition` and `transformations` fields for `com.databricks.sdk.service.ml.DeltaTableSource`. * Add `budgetPolicyId` and `customTags` fields for `com.databricks.sdk.service.postgres.ProjectSpec`. -* Add `budgetPolicyId` and `customTags` fields for `com.databricks.sdk.service.postgres.ProjectStatus`. \ No newline at end of file +* Add `budgetPolicyId` and `customTags` fields for `com.databricks.sdk.service.postgres.ProjectStatus`. +* Add `createSpace()`, `deleteSpace()`, `getSpace()`, `getSpaceOperation()`, `listSpaces()` and `updateSpace()` methods for `workspaceClient.apps()` service. +* Add `space` field for `com.databricks.sdk.service.apps.App`. +* Add `space` field for `com.databricks.sdk.service.apps.ListAppsRequest`. +* [Breaking] Remove `filterCondition` and `transformations` fields for `com.databricks.sdk.service.ml.DeltaTableSource`. \ No newline at end of file diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/App.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/App.java index d403abc7f..ef8f2a021 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/App.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/App.java @@ -113,6 +113,10 @@ public class App { @JsonProperty("service_principal_name") private String servicePrincipalName; + /** Name of the space this app belongs to. */ + @JsonProperty("space") + private String space; + /** The update time of the app. Formatted timestamp in ISO 6801. */ @JsonProperty("update_time") private String updateTime; @@ -331,6 +335,15 @@ public String getServicePrincipalName() { return servicePrincipalName; } + public App setSpace(String space) { + this.space = space; + return this; + } + + public String getSpace() { + return space; + } + public App setUpdateTime(String updateTime) { this.updateTime = updateTime; return this; @@ -403,6 +416,7 @@ public boolean equals(Object o) { && Objects.equals(servicePrincipalClientId, that.servicePrincipalClientId) && Objects.equals(servicePrincipalId, that.servicePrincipalId) && Objects.equals(servicePrincipalName, that.servicePrincipalName) + && Objects.equals(space, that.space) && Objects.equals(updateTime, that.updateTime) && Objects.equals(updater, that.updater) && Objects.equals(url, that.url) @@ -435,6 +449,7 @@ public int hashCode() { servicePrincipalClientId, servicePrincipalId, servicePrincipalName, + space, updateTime, updater, url, @@ -467,6 +482,7 @@ public String toString() { .add("servicePrincipalClientId", servicePrincipalClientId) .add("servicePrincipalId", servicePrincipalId) .add("servicePrincipalName", servicePrincipalName) + .add("space", space) .add("updateTime", updateTime) .add("updater", updater) .add("url", url) diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsAPI.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsAPI.java index 5e739d433..ae0263216 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsAPI.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsAPI.java @@ -235,6 +235,12 @@ public Wait create(CreateAppRequest request) { (timeout, callback) -> waitGetAppActive(response.getName(), timeout, callback), response); } + /** Creates a new app space. */ + public CreateSpaceOperation createSpace(CreateSpaceRequest request) { + Operation operation = impl.createSpace(request); + return new CreateSpaceOperation(impl, operation); + } + /** * Creates an app update and starts the update process. The update process is asynchronous and the * status of the update can be checked with the GetAppUpdate method. @@ -255,6 +261,16 @@ public App delete(DeleteAppRequest request) { return impl.delete(request); } + public DeleteSpaceOperation deleteSpace(String name) { + return deleteSpace(new DeleteSpaceRequest().setName(name)); + } + + /** Deletes an app space. */ + public DeleteSpaceOperation deleteSpace(DeleteSpaceRequest request) { + Operation operation = impl.deleteSpace(request); + return new DeleteSpaceOperation(impl, operation); + } + /** Creates an app deployment for the app with the supplied name. */ public Wait deploy(CreateAppDeploymentRequest request) { AppDeployment response = impl.deploy(request); @@ -302,6 +318,24 @@ public AppPermissions getPermissions(GetAppPermissionsRequest request) { return impl.getPermissions(request); } + public Space getSpace(String name) { + return getSpace(new GetSpaceRequest().setName(name)); + } + + /** Retrieves information for the app space with the supplied name. */ + public Space getSpace(GetSpaceRequest request) { + return impl.getSpace(request); + } + + public Operation getSpaceOperation(String name) { + return getSpaceOperation(new GetOperationRequest().setName(name)); + } + + /** Gets the status of an app space update operation. */ + public Operation getSpaceOperation(GetOperationRequest request) { + return impl.getSpaceOperation(request); + } + public AppUpdate getUpdate(String appName) { return getUpdate(new GetAppUpdateRequest().setAppName(appName)); } @@ -345,6 +379,21 @@ public Iterable listDeployments(ListAppDeploymentsRequest request }); } + /** Lists all app spaces in the workspace. */ + public Iterable listSpaces(ListSpacesRequest request) { + return new Paginator<>( + request, + impl::listSpaces, + ListSpacesResponse::getSpaces, + response -> { + String token = response.getNextPageToken(); + if (token == null || token.isEmpty()) { + return null; + } + return request.setPageToken(token); + }); + } + /** * Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct * permissions if none are specified. Objects can inherit permissions from their root object. @@ -377,6 +426,15 @@ public AppPermissions updatePermissions(AppPermissionsRequest request) { return impl.updatePermissions(request); } + /** + * Updates an app space. The update process is asynchronous and the status of the update can be + * checked with the GetSpaceOperation method. + */ + public UpdateSpaceOperation updateSpace(UpdateSpaceRequest request) { + Operation operation = impl.updateSpace(request); + return new UpdateSpaceOperation(impl, operation); + } + public AppsService impl() { return impl; } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsImpl.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsImpl.java index 77bd20657..48c68405c 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsImpl.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsImpl.java @@ -34,6 +34,24 @@ public App create(CreateAppRequest request) { } } + @Override + public Operation createSpace(CreateSpaceRequest request) { + String path = "/api/2.0/app-spaces"; + try { + Request req = new Request("POST", path, apiClient.serialize(request.getSpace())); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + req.withHeader("Content-Type", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Operation.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public AppUpdate createUpdate(AsyncUpdateAppRequest request) { String path = String.format("/api/2.0/apps/%s/update", request.getAppName()); @@ -69,6 +87,23 @@ public App delete(DeleteAppRequest request) { } } + @Override + public Operation deleteSpace(DeleteSpaceRequest request) { + String path = String.format("/api/2.0/app-spaces/%s", request.getName()); + try { + Request req = new Request("DELETE", path); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Operation.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public AppDeployment deploy(CreateAppDeploymentRequest request) { String path = String.format("/api/2.0/apps/%s/deployments", request.getAppName()); @@ -158,6 +193,40 @@ public AppPermissions getPermissions(GetAppPermissionsRequest request) { } } + @Override + public Space getSpace(GetSpaceRequest request) { + String path = String.format("/api/2.0/app-spaces/%s", request.getName()); + try { + Request req = new Request("GET", path); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Space.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + + @Override + public Operation getSpaceOperation(GetOperationRequest request) { + String path = String.format("/api/2.0/app-spaces/%s/operation", request.getName()); + try { + Request req = new Request("GET", path); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Operation.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public AppUpdate getUpdate(GetAppUpdateRequest request) { String path = String.format("/api/2.0/apps/%s/update", request.getAppName()); @@ -209,6 +278,23 @@ public ListAppDeploymentsResponse listDeployments(ListAppDeploymentsRequest requ } } + @Override + public ListSpacesResponse listSpaces(ListSpacesRequest request) { + String path = "/api/2.0/app-spaces"; + try { + Request req = new Request("GET", path); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, ListSpacesResponse.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public AppPermissions setPermissions(AppPermissionsRequest request) { String path = String.format("/api/2.0/permissions/apps/%s", request.getAppName()); @@ -298,4 +384,22 @@ public AppPermissions updatePermissions(AppPermissionsRequest request) { throw new DatabricksException("IO error: " + e.getMessage(), e); } } + + @Override + public Operation updateSpace(UpdateSpaceRequest request) { + String path = String.format("/api/2.0/app-spaces/%s", request.getName()); + try { + Request req = new Request("PATCH", path, apiClient.serialize(request.getSpace())); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + req.withHeader("Content-Type", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Org-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Operation.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsService.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsService.java index 0a84a93f7..3108a4851 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsService.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/AppsService.java @@ -16,6 +16,9 @@ public interface AppsService { /** Creates a new app. */ App create(CreateAppRequest createAppRequest); + /** Creates a new app space. */ + Operation createSpace(CreateSpaceRequest createSpaceRequest); + /** * Creates an app update and starts the update process. The update process is asynchronous and the * status of the update can be checked with the GetAppUpdate method. @@ -25,6 +28,9 @@ public interface AppsService { /** Deletes an app. */ App delete(DeleteAppRequest deleteAppRequest); + /** Deletes an app space. */ + Operation deleteSpace(DeleteSpaceRequest deleteSpaceRequest); + /** Creates an app deployment for the app with the supplied name. */ AppDeployment deploy(CreateAppDeploymentRequest createAppDeploymentRequest); @@ -41,6 +47,12 @@ GetAppPermissionLevelsResponse getPermissionLevels( /** Gets the permissions of an app. Apps can inherit permissions from their root object. */ AppPermissions getPermissions(GetAppPermissionsRequest getAppPermissionsRequest); + /** Retrieves information for the app space with the supplied name. */ + Space getSpace(GetSpaceRequest getSpaceRequest); + + /** Gets the status of an app space update operation. */ + Operation getSpaceOperation(GetOperationRequest getOperationRequest); + /** Gets the status of an app update. */ AppUpdate getUpdate(GetAppUpdateRequest getAppUpdateRequest); @@ -50,6 +62,9 @@ GetAppPermissionLevelsResponse getPermissionLevels( /** Lists all app deployments for the app with the supplied name. */ ListAppDeploymentsResponse listDeployments(ListAppDeploymentsRequest listAppDeploymentsRequest); + /** Lists all app spaces in the workspace. */ + ListSpacesResponse listSpaces(ListSpacesRequest listSpacesRequest); + /** * Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct * permissions if none are specified. Objects can inherit permissions from their root object. @@ -67,4 +82,10 @@ GetAppPermissionLevelsResponse getPermissionLevels( /** Updates the permissions on an app. Apps can inherit permissions from their root object. */ AppPermissions updatePermissions(AppPermissionsRequest appPermissionsRequest); + + /** + * Updates an app space. The update process is asynchronous and the status of the update can be + * checked with the GetSpaceOperation method. + */ + Operation updateSpace(UpdateSpaceRequest updateSpaceRequest); } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceOperation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceOperation.java new file mode 100755 index 000000000..5ea9cf251 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceOperation.java @@ -0,0 +1,161 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.core.DatabricksException; +import com.databricks.sdk.core.utils.SerDeUtils; +import com.databricks.sdk.service.common.lro.LroOptions; +import com.databricks.sdk.support.Generated; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.time.Duration; +import java.util.Optional; +import java.util.concurrent.TimeoutException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Wrapper for interacting with a long-running createSpace operation. Provides methods to wait for + * completion, check status, cancel, and access metadata. + */ +@Generated +public class CreateSpaceOperation { + private static final Logger LOG = LoggerFactory.getLogger(CreateSpaceOperation.class); + + private final AppsService impl; + private Operation operation; + private final ObjectMapper objectMapper; + + public CreateSpaceOperation(AppsService impl, Operation operation) { + this.impl = impl; + this.operation = operation; + this.objectMapper = SerDeUtils.createMapper(); + } + + /** + * Wait for the operation to complete and return the resulting Space. Waits indefinitely if no + * timeout is specified. + * + * @return the created Space + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public Space waitForCompletion() throws TimeoutException { + return waitForCompletion(Optional.empty()); + } + + /** + * Wait for the operation to complete and return the resulting Space. + * + * @param options the options for configuring the wait behavior, can be empty for defaults + * @return the created Space + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public Space waitForCompletion(Optional options) throws TimeoutException { + Optional timeout = options.flatMap(LroOptions::getTimeout); + long deadline = + timeout.isPresent() + ? System.currentTimeMillis() + timeout.get().toMillis() + : Long.MAX_VALUE; + String statusMessage = "polling operation..."; + int attempt = 1; + + while (System.currentTimeMillis() < deadline) { + // Refresh the operation state + refreshOperation(); + + if (operation.getDone() != null && operation.getDone()) { + // Operation completed, check for success or failure + if (operation.getError() != null) { + String errorMsg = "unknown error"; + if (operation.getError().getMessage() != null + && !operation.getError().getMessage().isEmpty()) { + errorMsg = operation.getError().getMessage(); + } + + if (operation.getError().getErrorCode() != null) { + errorMsg = String.format("[%s] %s", operation.getError().getErrorCode(), errorMsg); + } + + throw new DatabricksException("Operation failed: " + errorMsg); + } + + // Operation completed successfully, unmarshal response + if (operation.getResponse() == null) { + throw new DatabricksException("Operation completed but no response available"); + } + + try { + JsonNode responseJson = objectMapper.valueToTree(operation.getResponse()); + return objectMapper.treeToValue(responseJson, Space.class); + } catch (JsonProcessingException e) { + throw new DatabricksException("Failed to unmarshal space response: " + e.getMessage(), e); + } + } + + // Operation still in progress, wait before polling again + String prefix = String.format("operation=%s", operation.getName()); + int sleep = Math.min(attempt, 10); // sleep 10s max per attempt + LOG.info("{}: operation in progress (sleeping ~{}s)", prefix, sleep); + + try { + Thread.sleep((long) (sleep * 1000L + Math.random() * 1000)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new DatabricksException("Current thread was interrupted", e); + } + attempt++; + } + + String timeoutMessage = + timeout.isPresent() + ? String.format("Operation timed out after %s: %s", timeout.get(), statusMessage) + : String.format("Operation timed out: %s", statusMessage); + throw new TimeoutException(timeoutMessage); + } + + /** + * Get the operation name. + * + * @return the operation name + */ + public String getName() { + return operation.getName(); + } + + /** + * Get the operation metadata. + * + * @return the operation metadata, or null if not available + * @throws DatabricksException if the metadata cannot be deserialized + */ + public Space getMetadata() { + if (operation.getMetadata() == null) { + return null; + } + + try { + JsonNode metadataJson = objectMapper.valueToTree(operation.getMetadata()); + return objectMapper.treeToValue(metadataJson, Space.class); + } catch (JsonProcessingException e) { + throw new DatabricksException("Failed to unmarshal operation metadata: " + e.getMessage(), e); + } + } + + /** + * Check if the operation is done. This method refreshes the operation state before checking. + * + * @return true if the operation is complete, false otherwise + * @throws DatabricksException if the status check fails + */ + public boolean isDone() { + refreshOperation(); + return operation.getDone() != null && operation.getDone(); + } + + /** Refresh the operation state by polling the server. */ + private void refreshOperation() { + operation = impl.getSpaceOperation(new GetOperationRequest().setName(operation.getName())); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceRequest.java new file mode 100755 index 000000000..12dd798b0 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/CreateSpaceRequest.java @@ -0,0 +1,42 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +@Generated +public class CreateSpaceRequest { + /** */ + @JsonProperty("space") + private Space space; + + public CreateSpaceRequest setSpace(Space space) { + this.space = space; + return this; + } + + public Space getSpace() { + return space; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CreateSpaceRequest that = (CreateSpaceRequest) o; + return Objects.equals(space, that.space); + } + + @Override + public int hashCode() { + return Objects.hash(space); + } + + @Override + public String toString() { + return new ToStringer(CreateSpaceRequest.class).add("space", space).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DatabricksServiceExceptionWithDetailsProto.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DatabricksServiceExceptionWithDetailsProto.java new file mode 100755 index 000000000..4ad82a452 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DatabricksServiceExceptionWithDetailsProto.java @@ -0,0 +1,92 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collection; +import java.util.Objects; + +/** Databricks Error that is returned by all Databricks APIs. */ +@Generated +public class DatabricksServiceExceptionWithDetailsProto { + /** */ + @JsonProperty("details") + private Collection details; + + /** */ + @JsonProperty("error_code") + private ErrorCode errorCode; + + /** */ + @JsonProperty("message") + private String message; + + /** */ + @JsonProperty("stack_trace") + private String stackTrace; + + public DatabricksServiceExceptionWithDetailsProto setDetails(Collection details) { + this.details = details; + return this; + } + + public Collection getDetails() { + return details; + } + + public DatabricksServiceExceptionWithDetailsProto setErrorCode(ErrorCode errorCode) { + this.errorCode = errorCode; + return this; + } + + public ErrorCode getErrorCode() { + return errorCode; + } + + public DatabricksServiceExceptionWithDetailsProto setMessage(String message) { + this.message = message; + return this; + } + + public String getMessage() { + return message; + } + + public DatabricksServiceExceptionWithDetailsProto setStackTrace(String stackTrace) { + this.stackTrace = stackTrace; + return this; + } + + public String getStackTrace() { + return stackTrace; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DatabricksServiceExceptionWithDetailsProto that = + (DatabricksServiceExceptionWithDetailsProto) o; + return Objects.equals(details, that.details) + && Objects.equals(errorCode, that.errorCode) + && Objects.equals(message, that.message) + && Objects.equals(stackTrace, that.stackTrace); + } + + @Override + public int hashCode() { + return Objects.hash(details, errorCode, message, stackTrace); + } + + @Override + public String toString() { + return new ToStringer(DatabricksServiceExceptionWithDetailsProto.class) + .add("details", details) + .add("errorCode", errorCode) + .add("message", message) + .add("stackTrace", stackTrace) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceOperation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceOperation.java new file mode 100755 index 000000000..9666a9818 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceOperation.java @@ -0,0 +1,161 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.core.DatabricksException; +import com.databricks.sdk.core.utils.SerDeUtils; +import com.databricks.sdk.service.common.lro.LroOptions; +import com.databricks.sdk.support.Generated; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.time.Duration; +import java.util.Optional; +import java.util.concurrent.TimeoutException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Wrapper for interacting with a long-running deleteSpace operation. Provides methods to wait for + * completion, check status, cancel, and access metadata. + */ +@Generated +public class DeleteSpaceOperation { + private static final Logger LOG = LoggerFactory.getLogger(DeleteSpaceOperation.class); + + private final AppsService impl; + private Operation operation; + private final ObjectMapper objectMapper; + + public DeleteSpaceOperation(AppsService impl, Operation operation) { + this.impl = impl; + this.operation = operation; + this.objectMapper = SerDeUtils.createMapper(); + } + + /** + * Wait for the operation to complete and return the resulting . Waits indefinitely if no timeout + * is specified. + * + * @return the created + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public void waitForCompletion() throws TimeoutException { + waitForCompletion(Optional.empty()); + } + + /** + * Wait for the operation to complete and return the resulting . + * + * @param options the options for configuring the wait behavior, can be empty for defaults + * @return the created + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public void waitForCompletion(Optional options) throws TimeoutException { + Optional timeout = options.flatMap(LroOptions::getTimeout); + long deadline = + timeout.isPresent() + ? System.currentTimeMillis() + timeout.get().toMillis() + : Long.MAX_VALUE; + String statusMessage = "polling operation..."; + int attempt = 1; + + while (System.currentTimeMillis() < deadline) { + // Refresh the operation state + refreshOperation(); + + if (operation.getDone() != null && operation.getDone()) { + // Operation completed, check for success or failure + if (operation.getError() != null) { + String errorMsg = "unknown error"; + if (operation.getError().getMessage() != null + && !operation.getError().getMessage().isEmpty()) { + errorMsg = operation.getError().getMessage(); + } + + if (operation.getError().getErrorCode() != null) { + errorMsg = String.format("[%s] %s", operation.getError().getErrorCode(), errorMsg); + } + + throw new DatabricksException("Operation failed: " + errorMsg); + } + + // Operation completed successfully, unmarshal response + if (operation.getResponse() == null) { + throw new DatabricksException("Operation completed but no response available"); + } + + try { + JsonNode responseJson = objectMapper.valueToTree(operation.getResponse()); + objectMapper.treeToValue(responseJson, Void.class); + } catch (JsonProcessingException e) { + throw new DatabricksException("Failed to unmarshal response: " + e.getMessage(), e); + } + } + + // Operation still in progress, wait before polling again + String prefix = String.format("operation=%s", operation.getName()); + int sleep = Math.min(attempt, 10); // sleep 10s max per attempt + LOG.info("{}: operation in progress (sleeping ~{}s)", prefix, sleep); + + try { + Thread.sleep((long) (sleep * 1000L + Math.random() * 1000)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new DatabricksException("Current thread was interrupted", e); + } + attempt++; + } + + String timeoutMessage = + timeout.isPresent() + ? String.format("Operation timed out after %s: %s", timeout.get(), statusMessage) + : String.format("Operation timed out: %s", statusMessage); + throw new TimeoutException(timeoutMessage); + } + + /** + * Get the operation name. + * + * @return the operation name + */ + public String getName() { + return operation.getName(); + } + + /** + * Get the operation metadata. + * + * @return the operation metadata, or null if not available + * @throws DatabricksException if the metadata cannot be deserialized + */ + public Space getMetadata() { + if (operation.getMetadata() == null) { + return null; + } + + try { + JsonNode metadataJson = objectMapper.valueToTree(operation.getMetadata()); + return objectMapper.treeToValue(metadataJson, Space.class); + } catch (JsonProcessingException e) { + throw new DatabricksException("Failed to unmarshal operation metadata: " + e.getMessage(), e); + } + } + + /** + * Check if the operation is done. This method refreshes the operation state before checking. + * + * @return true if the operation is complete, false otherwise + * @throws DatabricksException if the status check fails + */ + public boolean isDone() { + refreshOperation(); + return operation.getDone() != null && operation.getDone(); + } + + /** Refresh the operation state by polling the server. */ + private void refreshOperation() { + operation = impl.getSpaceOperation(new GetOperationRequest().setName(operation.getName())); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceRequest.java new file mode 100755 index 000000000..093f636e8 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/DeleteSpaceRequest.java @@ -0,0 +1,41 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Objects; + +@Generated +public class DeleteSpaceRequest { + /** The name of the app space. */ + @JsonIgnore private String name; + + public DeleteSpaceRequest setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DeleteSpaceRequest that = (DeleteSpaceRequest) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return new ToStringer(DeleteSpaceRequest.class).add("name", name).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ErrorCode.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ErrorCode.java new file mode 100755 index 000000000..1f6cf901c --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ErrorCode.java @@ -0,0 +1,91 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; + +/** Error codes returned by Databricks APIs to indicate specific failure conditions. */ +@Generated +public enum ErrorCode { + ABORTED, + ALREADY_EXISTS, + BAD_REQUEST, + CANCELLED, + CATALOG_ALREADY_EXISTS, + CATALOG_DOES_NOT_EXIST, + CATALOG_NOT_EMPTY, + COULD_NOT_ACQUIRE_LOCK, + CUSTOMER_UNAUTHORIZED, + DAC_ALREADY_EXISTS, + DAC_DOES_NOT_EXIST, + DATA_LOSS, + DEADLINE_EXCEEDED, + DEPLOYMENT_TIMEOUT, + DIRECTORY_NOT_EMPTY, + DIRECTORY_PROTECTED, + DRY_RUN_FAILED, + ENDPOINT_NOT_FOUND, + EXTERNAL_LOCATION_ALREADY_EXISTS, + EXTERNAL_LOCATION_DOES_NOT_EXIST, + FEATURE_DISABLED, + GIT_CONFLICT, + GIT_REMOTE_ERROR, + GIT_SENSITIVE_TOKEN_DETECTED, + GIT_UNKNOWN_REF, + GIT_URL_NOT_ON_ALLOW_LIST, + INSECURE_PARTNER_RESPONSE, + INTERNAL_ERROR, + INVALID_PARAMETER_VALUE, + INVALID_STATE, + INVALID_STATE_TRANSITION, + IO_ERROR, + IPYNB_FILE_IN_REPO, + MALFORMED_PARTNER_RESPONSE, + MALFORMED_REQUEST, + MANAGED_RESOURCE_GROUP_DOES_NOT_EXIST, + MAX_BLOCK_SIZE_EXCEEDED, + MAX_CHILD_NODE_SIZE_EXCEEDED, + MAX_LIST_SIZE_EXCEEDED, + MAX_NOTEBOOK_SIZE_EXCEEDED, + MAX_READ_SIZE_EXCEEDED, + METASTORE_ALREADY_EXISTS, + METASTORE_DOES_NOT_EXIST, + METASTORE_NOT_EMPTY, + NOT_FOUND, + NOT_IMPLEMENTED, + PARTIAL_DELETE, + PERMISSION_DENIED, + PERMISSION_NOT_PROPAGATED, + PRINCIPAL_DOES_NOT_EXIST, + PROJECTS_OPERATION_TIMEOUT, + PROVIDER_ALREADY_EXISTS, + PROVIDER_DOES_NOT_EXIST, + PROVIDER_SHARE_NOT_ACCESSIBLE, + QUOTA_EXCEEDED, + RECIPIENT_ALREADY_EXISTS, + RECIPIENT_DOES_NOT_EXIST, + REQUEST_LIMIT_EXCEEDED, + RESOURCE_ALREADY_EXISTS, + RESOURCE_CONFLICT, + RESOURCE_DOES_NOT_EXIST, + RESOURCE_EXHAUSTED, + RESOURCE_LIMIT_EXCEEDED, + SCHEMA_ALREADY_EXISTS, + SCHEMA_DOES_NOT_EXIST, + SCHEMA_NOT_EMPTY, + SEARCH_QUERY_TOO_LONG, + SEARCH_QUERY_TOO_SHORT, + SERVICE_UNDER_MAINTENANCE, + SHARE_ALREADY_EXISTS, + SHARE_DOES_NOT_EXIST, + STORAGE_CREDENTIAL_ALREADY_EXISTS, + STORAGE_CREDENTIAL_DOES_NOT_EXIST, + TABLE_ALREADY_EXISTS, + TABLE_DOES_NOT_EXIST, + TEMPORARILY_UNAVAILABLE, + UNAUTHENTICATED, + UNAVAILABLE, + UNKNOWN, + UNPARSEABLE_HTTP_ERROR, + WORKSPACE_TEMPORARILY_UNAVAILABLE, +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetOperationRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetOperationRequest.java new file mode 100755 index 000000000..ea1e224af --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetOperationRequest.java @@ -0,0 +1,41 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Objects; + +@Generated +public class GetOperationRequest { + /** The name of the operation resource. */ + @JsonIgnore private String name; + + public GetOperationRequest setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GetOperationRequest that = (GetOperationRequest) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return new ToStringer(GetOperationRequest.class).add("name", name).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetSpaceRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetSpaceRequest.java new file mode 100755 index 000000000..d83df8c40 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/GetSpaceRequest.java @@ -0,0 +1,41 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Objects; + +@Generated +public class GetSpaceRequest { + /** The name of the app space. */ + @JsonIgnore private String name; + + public GetSpaceRequest setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GetSpaceRequest that = (GetSpaceRequest) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return new ToStringer(GetSpaceRequest.class).add("name", name).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppsRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppsRequest.java index e62e4e319..879d4ca5f 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppsRequest.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListAppsRequest.java @@ -20,6 +20,13 @@ public class ListAppsRequest { @QueryParam("page_token") private String pageToken; + /** + * Filter apps by app space name. When specified, only apps belonging to this space are returned. + */ + @JsonIgnore + @QueryParam("space") + private String space; + public ListAppsRequest setPageSize(Long pageSize) { this.pageSize = pageSize; return this; @@ -38,17 +45,28 @@ public String getPageToken() { return pageToken; } + public ListAppsRequest setSpace(String space) { + this.space = space; + return this; + } + + public String getSpace() { + return space; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ListAppsRequest that = (ListAppsRequest) o; - return Objects.equals(pageSize, that.pageSize) && Objects.equals(pageToken, that.pageToken); + return Objects.equals(pageSize, that.pageSize) + && Objects.equals(pageToken, that.pageToken) + && Objects.equals(space, that.space); } @Override public int hashCode() { - return Objects.hash(pageSize, pageToken); + return Objects.hash(pageSize, pageToken, space); } @Override @@ -56,6 +74,7 @@ public String toString() { return new ToStringer(ListAppsRequest.class) .add("pageSize", pageSize) .add("pageToken", pageToken) + .add("space", space) .toString(); } } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesRequest.java new file mode 100755 index 000000000..ebf79a929 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesRequest.java @@ -0,0 +1,61 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.QueryParam; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Objects; + +@Generated +public class ListSpacesRequest { + /** Upper bound for items returned. */ + @JsonIgnore + @QueryParam("page_size") + private Long pageSize; + + /** Pagination token to go to the next page of app spaces. Requests first page if absent. */ + @JsonIgnore + @QueryParam("page_token") + private String pageToken; + + public ListSpacesRequest setPageSize(Long pageSize) { + this.pageSize = pageSize; + return this; + } + + public Long getPageSize() { + return pageSize; + } + + public ListSpacesRequest setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public String getPageToken() { + return pageToken; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ListSpacesRequest that = (ListSpacesRequest) o; + return Objects.equals(pageSize, that.pageSize) && Objects.equals(pageToken, that.pageToken); + } + + @Override + public int hashCode() { + return Objects.hash(pageSize, pageToken); + } + + @Override + public String toString() { + return new ToStringer(ListSpacesRequest.class) + .add("pageSize", pageSize) + .add("pageToken", pageToken) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesResponse.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesResponse.java new file mode 100755 index 000000000..a30773452 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/ListSpacesResponse.java @@ -0,0 +1,59 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collection; +import java.util.Objects; + +@Generated +public class ListSpacesResponse { + /** Pagination token to request the next page of app spaces. */ + @JsonProperty("next_page_token") + private String nextPageToken; + + /** */ + @JsonProperty("spaces") + private Collection spaces; + + public ListSpacesResponse setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public String getNextPageToken() { + return nextPageToken; + } + + public ListSpacesResponse setSpaces(Collection spaces) { + this.spaces = spaces; + return this; + } + + public Collection getSpaces() { + return spaces; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ListSpacesResponse that = (ListSpacesResponse) o; + return Objects.equals(nextPageToken, that.nextPageToken) && Objects.equals(spaces, that.spaces); + } + + @Override + public int hashCode() { + return Objects.hash(nextPageToken, spaces); + } + + @Override + public String toString() { + return new ToStringer(ListSpacesResponse.class) + .add("nextPageToken", nextPageToken) + .add("spaces", spaces) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Operation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Operation.java new file mode 100755 index 000000000..610ba8296 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Operation.java @@ -0,0 +1,116 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +/** This resource represents a long-running operation that is the result of a network API call. */ +@Generated +public class Operation { + /** + * If the value is `false`, it means the operation is still in progress. If `true`, the operation + * is completed, and either `error` or `response` is available. + */ + @JsonProperty("done") + private Boolean done; + + /** The error result of the operation in case of failure or cancellation. */ + @JsonProperty("error") + private DatabricksServiceExceptionWithDetailsProto error; + + /** + * Service-specific metadata associated with the operation. It typically contains progress + * information and common metadata such as create time. Some services might not provide such + * metadata. + */ + @JsonProperty("metadata") + private Object metadata; + + /** + * The server-assigned name, which is only unique within the same service that originally returns + * it. If you use the default HTTP mapping, the `name` should be a resource name ending with + * `operations/{unique_id}`. + */ + @JsonProperty("name") + private String name; + + /** The normal, successful response of the operation. */ + @JsonProperty("response") + private Object response; + + public Operation setDone(Boolean done) { + this.done = done; + return this; + } + + public Boolean getDone() { + return done; + } + + public Operation setError(DatabricksServiceExceptionWithDetailsProto error) { + this.error = error; + return this; + } + + public DatabricksServiceExceptionWithDetailsProto getError() { + return error; + } + + public Operation setMetadata(Object metadata) { + this.metadata = metadata; + return this; + } + + public Object getMetadata() { + return metadata; + } + + public Operation setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public Operation setResponse(Object response) { + this.response = response; + return this; + } + + public Object getResponse() { + return response; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Operation that = (Operation) o; + return Objects.equals(done, that.done) + && Objects.equals(error, that.error) + && Objects.equals(metadata, that.metadata) + && Objects.equals(name, that.name) + && Objects.equals(response, that.response); + } + + @Override + public int hashCode() { + return Objects.hash(done, error, metadata, name, response); + } + + @Override + public String toString() { + return new ToStringer(Operation.class) + .add("done", done) + .add("error", error) + .add("metadata", metadata) + .add("name", name) + .add("response", response) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Space.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Space.java new file mode 100755 index 000000000..03b001f82 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/Space.java @@ -0,0 +1,325 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.protobuf.Timestamp; +import java.util.Collection; +import java.util.Objects; + +@Generated +public class Space { + /** The creation time of the app space. Formatted timestamp in ISO 6801. */ + @JsonProperty("create_time") + private Timestamp createTime; + + /** The email of the user that created the app space. */ + @JsonProperty("creator") + private String creator; + + /** The description of the app space. */ + @JsonProperty("description") + private String description; + + /** The effective usage policy ID used by apps in the space. */ + @JsonProperty("effective_usage_policy_id") + private String effectiveUsagePolicyId; + + /** The effective api scopes granted to the user access token. */ + @JsonProperty("effective_user_api_scopes") + private Collection effectiveUserApiScopes; + + /** The unique identifier of the app space. */ + @JsonProperty("id") + private String id; + + /** + * The name of the app space. The name must contain only lowercase alphanumeric characters and + * hyphens. It must be unique within the workspace. + */ + @JsonProperty("name") + private String name; + + /** The OAuth2 app client ID for the app space. */ + @JsonProperty("oauth2_app_client_id") + private String oauth2AppClientId; + + /** The OAuth2 app integration ID for the app space. */ + @JsonProperty("oauth2_app_integration_id") + private String oauth2AppIntegrationId; + + /** + * Resources for the app space. Resources configured at the space level are available to all apps + * in the space. + */ + @JsonProperty("resources") + private Collection resources; + + /** The service principal client ID for the app space. */ + @JsonProperty("service_principal_client_id") + private String servicePrincipalClientId; + + /** The service principal ID for the app space. */ + @JsonProperty("service_principal_id") + private Long servicePrincipalId; + + /** The service principal name for the app space. */ + @JsonProperty("service_principal_name") + private String servicePrincipalName; + + /** The status of the app space. */ + @JsonProperty("status") + private SpaceStatus status; + + /** The update time of the app space. Formatted timestamp in ISO 6801. */ + @JsonProperty("update_time") + private Timestamp updateTime; + + /** The email of the user that last updated the app space. */ + @JsonProperty("updater") + private String updater; + + /** The usage policy ID for managing cost at the space level. */ + @JsonProperty("usage_policy_id") + private String usagePolicyId; + + /** OAuth scopes for apps in the space. */ + @JsonProperty("user_api_scopes") + private Collection userApiScopes; + + public Space setCreateTime(Timestamp createTime) { + this.createTime = createTime; + return this; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public Space setCreator(String creator) { + this.creator = creator; + return this; + } + + public String getCreator() { + return creator; + } + + public Space setDescription(String description) { + this.description = description; + return this; + } + + public String getDescription() { + return description; + } + + public Space setEffectiveUsagePolicyId(String effectiveUsagePolicyId) { + this.effectiveUsagePolicyId = effectiveUsagePolicyId; + return this; + } + + public String getEffectiveUsagePolicyId() { + return effectiveUsagePolicyId; + } + + public Space setEffectiveUserApiScopes(Collection effectiveUserApiScopes) { + this.effectiveUserApiScopes = effectiveUserApiScopes; + return this; + } + + public Collection getEffectiveUserApiScopes() { + return effectiveUserApiScopes; + } + + public Space setId(String id) { + this.id = id; + return this; + } + + public String getId() { + return id; + } + + public Space setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public Space setOauth2AppClientId(String oauth2AppClientId) { + this.oauth2AppClientId = oauth2AppClientId; + return this; + } + + public String getOauth2AppClientId() { + return oauth2AppClientId; + } + + public Space setOauth2AppIntegrationId(String oauth2AppIntegrationId) { + this.oauth2AppIntegrationId = oauth2AppIntegrationId; + return this; + } + + public String getOauth2AppIntegrationId() { + return oauth2AppIntegrationId; + } + + public Space setResources(Collection resources) { + this.resources = resources; + return this; + } + + public Collection getResources() { + return resources; + } + + public Space setServicePrincipalClientId(String servicePrincipalClientId) { + this.servicePrincipalClientId = servicePrincipalClientId; + return this; + } + + public String getServicePrincipalClientId() { + return servicePrincipalClientId; + } + + public Space setServicePrincipalId(Long servicePrincipalId) { + this.servicePrincipalId = servicePrincipalId; + return this; + } + + public Long getServicePrincipalId() { + return servicePrincipalId; + } + + public Space setServicePrincipalName(String servicePrincipalName) { + this.servicePrincipalName = servicePrincipalName; + return this; + } + + public String getServicePrincipalName() { + return servicePrincipalName; + } + + public Space setStatus(SpaceStatus status) { + this.status = status; + return this; + } + + public SpaceStatus getStatus() { + return status; + } + + public Space setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + return this; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public Space setUpdater(String updater) { + this.updater = updater; + return this; + } + + public String getUpdater() { + return updater; + } + + public Space setUsagePolicyId(String usagePolicyId) { + this.usagePolicyId = usagePolicyId; + return this; + } + + public String getUsagePolicyId() { + return usagePolicyId; + } + + public Space setUserApiScopes(Collection userApiScopes) { + this.userApiScopes = userApiScopes; + return this; + } + + public Collection getUserApiScopes() { + return userApiScopes; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Space that = (Space) o; + return Objects.equals(createTime, that.createTime) + && Objects.equals(creator, that.creator) + && Objects.equals(description, that.description) + && Objects.equals(effectiveUsagePolicyId, that.effectiveUsagePolicyId) + && Objects.equals(effectiveUserApiScopes, that.effectiveUserApiScopes) + && Objects.equals(id, that.id) + && Objects.equals(name, that.name) + && Objects.equals(oauth2AppClientId, that.oauth2AppClientId) + && Objects.equals(oauth2AppIntegrationId, that.oauth2AppIntegrationId) + && Objects.equals(resources, that.resources) + && Objects.equals(servicePrincipalClientId, that.servicePrincipalClientId) + && Objects.equals(servicePrincipalId, that.servicePrincipalId) + && Objects.equals(servicePrincipalName, that.servicePrincipalName) + && Objects.equals(status, that.status) + && Objects.equals(updateTime, that.updateTime) + && Objects.equals(updater, that.updater) + && Objects.equals(usagePolicyId, that.usagePolicyId) + && Objects.equals(userApiScopes, that.userApiScopes); + } + + @Override + public int hashCode() { + return Objects.hash( + createTime, + creator, + description, + effectiveUsagePolicyId, + effectiveUserApiScopes, + id, + name, + oauth2AppClientId, + oauth2AppIntegrationId, + resources, + servicePrincipalClientId, + servicePrincipalId, + servicePrincipalName, + status, + updateTime, + updater, + usagePolicyId, + userApiScopes); + } + + @Override + public String toString() { + return new ToStringer(Space.class) + .add("createTime", createTime) + .add("creator", creator) + .add("description", description) + .add("effectiveUsagePolicyId", effectiveUsagePolicyId) + .add("effectiveUserApiScopes", effectiveUserApiScopes) + .add("id", id) + .add("name", name) + .add("oauth2AppClientId", oauth2AppClientId) + .add("oauth2AppIntegrationId", oauth2AppIntegrationId) + .add("resources", resources) + .add("servicePrincipalClientId", servicePrincipalClientId) + .add("servicePrincipalId", servicePrincipalId) + .add("servicePrincipalName", servicePrincipalName) + .add("status", status) + .add("updateTime", updateTime) + .add("updater", updater) + .add("usagePolicyId", usagePolicyId) + .add("userApiScopes", userApiScopes) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatus.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatus.java new file mode 100755 index 000000000..f2a7bd754 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatus.java @@ -0,0 +1,55 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +@Generated +public class SpaceStatus { + /** Message providing context about the current state. */ + @JsonProperty("message") + private String message; + + /** The state of the app space. */ + @JsonProperty("state") + private SpaceStatusSpaceState state; + + public SpaceStatus setMessage(String message) { + this.message = message; + return this; + } + + public String getMessage() { + return message; + } + + public SpaceStatus setState(SpaceStatusSpaceState state) { + this.state = state; + return this; + } + + public SpaceStatusSpaceState getState() { + return state; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SpaceStatus that = (SpaceStatus) o; + return Objects.equals(message, that.message) && Objects.equals(state, that.state); + } + + @Override + public int hashCode() { + return Objects.hash(message, state); + } + + @Override + public String toString() { + return new ToStringer(SpaceStatus.class).add("message", message).add("state", state).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatusSpaceState.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatusSpaceState.java new file mode 100755 index 000000000..950482969 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceStatusSpaceState.java @@ -0,0 +1,15 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; + +@Generated +public enum SpaceStatusSpaceState { + SPACE_ACTIVE, + SPACE_CREATING, + SPACE_DELETED, + SPACE_DELETING, + SPACE_ERROR, + SPACE_UPDATING, +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdate.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdate.java new file mode 100755 index 000000000..2488ac72a --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdate.java @@ -0,0 +1,106 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collection; +import java.util.Objects; + +/** Tracks app space update information. */ +@Generated +public class SpaceUpdate { + /** */ + @JsonProperty("description") + private String description; + + /** */ + @JsonProperty("resources") + private Collection resources; + + /** */ + @JsonProperty("status") + private SpaceUpdateStatus status; + + /** */ + @JsonProperty("usage_policy_id") + private String usagePolicyId; + + /** */ + @JsonProperty("user_api_scopes") + private Collection userApiScopes; + + public SpaceUpdate setDescription(String description) { + this.description = description; + return this; + } + + public String getDescription() { + return description; + } + + public SpaceUpdate setResources(Collection resources) { + this.resources = resources; + return this; + } + + public Collection getResources() { + return resources; + } + + public SpaceUpdate setStatus(SpaceUpdateStatus status) { + this.status = status; + return this; + } + + public SpaceUpdateStatus getStatus() { + return status; + } + + public SpaceUpdate setUsagePolicyId(String usagePolicyId) { + this.usagePolicyId = usagePolicyId; + return this; + } + + public String getUsagePolicyId() { + return usagePolicyId; + } + + public SpaceUpdate setUserApiScopes(Collection userApiScopes) { + this.userApiScopes = userApiScopes; + return this; + } + + public Collection getUserApiScopes() { + return userApiScopes; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SpaceUpdate that = (SpaceUpdate) o; + return Objects.equals(description, that.description) + && Objects.equals(resources, that.resources) + && Objects.equals(status, that.status) + && Objects.equals(usagePolicyId, that.usagePolicyId) + && Objects.equals(userApiScopes, that.userApiScopes); + } + + @Override + public int hashCode() { + return Objects.hash(description, resources, status, usagePolicyId, userApiScopes); + } + + @Override + public String toString() { + return new ToStringer(SpaceUpdate.class) + .add("description", description) + .add("resources", resources) + .add("status", status) + .add("usagePolicyId", usagePolicyId) + .add("userApiScopes", userApiScopes) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateState.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateState.java new file mode 100755 index 000000000..6b18751e0 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateState.java @@ -0,0 +1,13 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; + +@Generated +public enum SpaceUpdateState { + FAILED, + IN_PROGRESS, + NOT_UPDATED, + SUCCEEDED, +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateStatus.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateStatus.java new file mode 100755 index 000000000..c9b6b6d89 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/SpaceUpdateStatus.java @@ -0,0 +1,59 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +/** Status of an app space update operation */ +@Generated +public class SpaceUpdateStatus { + /** */ + @JsonProperty("message") + private String message; + + /** */ + @JsonProperty("state") + private SpaceUpdateState state; + + public SpaceUpdateStatus setMessage(String message) { + this.message = message; + return this; + } + + public String getMessage() { + return message; + } + + public SpaceUpdateStatus setState(SpaceUpdateState state) { + this.state = state; + return this; + } + + public SpaceUpdateState getState() { + return state; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SpaceUpdateStatus that = (SpaceUpdateStatus) o; + return Objects.equals(message, that.message) && Objects.equals(state, that.state); + } + + @Override + public int hashCode() { + return Objects.hash(message, state); + } + + @Override + public String toString() { + return new ToStringer(SpaceUpdateStatus.class) + .add("message", message) + .add("state", state) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceOperation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceOperation.java new file mode 100755 index 000000000..cf00c10e9 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceOperation.java @@ -0,0 +1,161 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.core.DatabricksException; +import com.databricks.sdk.core.utils.SerDeUtils; +import com.databricks.sdk.service.common.lro.LroOptions; +import com.databricks.sdk.support.Generated; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.time.Duration; +import java.util.Optional; +import java.util.concurrent.TimeoutException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Wrapper for interacting with a long-running updateSpace operation. Provides methods to wait for + * completion, check status, cancel, and access metadata. + */ +@Generated +public class UpdateSpaceOperation { + private static final Logger LOG = LoggerFactory.getLogger(UpdateSpaceOperation.class); + + private final AppsService impl; + private Operation operation; + private final ObjectMapper objectMapper; + + public UpdateSpaceOperation(AppsService impl, Operation operation) { + this.impl = impl; + this.operation = operation; + this.objectMapper = SerDeUtils.createMapper(); + } + + /** + * Wait for the operation to complete and return the resulting Space. Waits indefinitely if no + * timeout is specified. + * + * @return the created Space + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public Space waitForCompletion() throws TimeoutException { + return waitForCompletion(Optional.empty()); + } + + /** + * Wait for the operation to complete and return the resulting Space. + * + * @param options the options for configuring the wait behavior, can be empty for defaults + * @return the created Space + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public Space waitForCompletion(Optional options) throws TimeoutException { + Optional timeout = options.flatMap(LroOptions::getTimeout); + long deadline = + timeout.isPresent() + ? System.currentTimeMillis() + timeout.get().toMillis() + : Long.MAX_VALUE; + String statusMessage = "polling operation..."; + int attempt = 1; + + while (System.currentTimeMillis() < deadline) { + // Refresh the operation state + refreshOperation(); + + if (operation.getDone() != null && operation.getDone()) { + // Operation completed, check for success or failure + if (operation.getError() != null) { + String errorMsg = "unknown error"; + if (operation.getError().getMessage() != null + && !operation.getError().getMessage().isEmpty()) { + errorMsg = operation.getError().getMessage(); + } + + if (operation.getError().getErrorCode() != null) { + errorMsg = String.format("[%s] %s", operation.getError().getErrorCode(), errorMsg); + } + + throw new DatabricksException("Operation failed: " + errorMsg); + } + + // Operation completed successfully, unmarshal response + if (operation.getResponse() == null) { + throw new DatabricksException("Operation completed but no response available"); + } + + try { + JsonNode responseJson = objectMapper.valueToTree(operation.getResponse()); + return objectMapper.treeToValue(responseJson, Space.class); + } catch (JsonProcessingException e) { + throw new DatabricksException("Failed to unmarshal space response: " + e.getMessage(), e); + } + } + + // Operation still in progress, wait before polling again + String prefix = String.format("operation=%s", operation.getName()); + int sleep = Math.min(attempt, 10); // sleep 10s max per attempt + LOG.info("{}: operation in progress (sleeping ~{}s)", prefix, sleep); + + try { + Thread.sleep((long) (sleep * 1000L + Math.random() * 1000)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new DatabricksException("Current thread was interrupted", e); + } + attempt++; + } + + String timeoutMessage = + timeout.isPresent() + ? String.format("Operation timed out after %s: %s", timeout.get(), statusMessage) + : String.format("Operation timed out: %s", statusMessage); + throw new TimeoutException(timeoutMessage); + } + + /** + * Get the operation name. + * + * @return the operation name + */ + public String getName() { + return operation.getName(); + } + + /** + * Get the operation metadata. + * + * @return the operation metadata, or null if not available + * @throws DatabricksException if the metadata cannot be deserialized + */ + public SpaceUpdate getMetadata() { + if (operation.getMetadata() == null) { + return null; + } + + try { + JsonNode metadataJson = objectMapper.valueToTree(operation.getMetadata()); + return objectMapper.treeToValue(metadataJson, SpaceUpdate.class); + } catch (JsonProcessingException e) { + throw new DatabricksException("Failed to unmarshal operation metadata: " + e.getMessage(), e); + } + } + + /** + * Check if the operation is done. This method refreshes the operation state before checking. + * + * @return true if the operation is complete, false otherwise + * @throws DatabricksException if the status check fails + */ + public boolean isDone() { + refreshOperation(); + return operation.getDone() != null && operation.getDone(); + } + + /** Refresh the operation state by polling the server. */ + private void refreshOperation() { + operation = impl.getSpaceOperation(new GetOperationRequest().setName(operation.getName())); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceRequest.java new file mode 100755 index 000000000..7b4af79be --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/apps/UpdateSpaceRequest.java @@ -0,0 +1,90 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.apps; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.QueryParam; +import com.databricks.sdk.support.ToStringer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.protobuf.FieldMask; +import java.util.Objects; + +@Generated +public class UpdateSpaceRequest { + /** + * The name of the app space. The name must contain only lowercase alphanumeric characters and + * hyphens. It must be unique within the workspace. + */ + @JsonIgnore private String name; + + /** */ + @JsonProperty("space") + private Space space; + + /** + * The field mask must be a single string, with multiple fields separated by commas (no spaces). + * The field path is relative to the resource object, using a dot (`.`) to navigate sub-fields + * (e.g., `author.given_name`). Specification of elements in sequence or map fields is not + * allowed, as only the entire collection field can be specified. Field names must exactly match + * the resource field names. + * + *

A field mask of `*` indicates full replacement. It’s recommended to always explicitly list + * the fields being updated and avoid using `*` wildcards, as it can lead to unintended results if + * the API changes in the future. + */ + @JsonIgnore + @QueryParam("update_mask") + private FieldMask updateMask; + + public UpdateSpaceRequest setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public UpdateSpaceRequest setSpace(Space space) { + this.space = space; + return this; + } + + public Space getSpace() { + return space; + } + + public UpdateSpaceRequest setUpdateMask(FieldMask updateMask) { + this.updateMask = updateMask; + return this; + } + + public FieldMask getUpdateMask() { + return updateMask; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UpdateSpaceRequest that = (UpdateSpaceRequest) o; + return Objects.equals(name, that.name) + && Objects.equals(space, that.space) + && Objects.equals(updateMask, that.updateMask); + } + + @Override + public int hashCode() { + return Objects.hash(name, space, updateMask); + } + + @Override + public String toString() { + return new ToStringer(UpdateSpaceRequest.class) + .add("name", name) + .add("space", space) + .add("updateMask", updateMask) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/SecurableKind.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/SecurableKind.java index f642eaa16..91046f686 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/SecurableKind.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/SecurableKind.java @@ -4,7 +4,7 @@ import com.databricks.sdk.support.Generated; -/** Latest kind: CONNECTION_M365_AUDIT_LOGS_OAUTH_M2M = 297; Next id: 298 */ +/** Latest kind: CONNECTION_JDBC_OAUTH_M2M = 298; Next id: 299 */ @Generated public enum SecurableKind { TABLE_DB_STORAGE, diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/DeltaTableSource.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/DeltaTableSource.java index eb543980a..1c2130436 100755 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/DeltaTableSource.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/DeltaTableSource.java @@ -14,13 +14,6 @@ public class DeltaTableSource { @JsonProperty("entity_columns") private Collection entityColumns; - /** - * Single WHERE clause to filter delta table before applying transformations. Will be row-wise - * evaluated, so should only include conditionals and projections. - */ - @JsonProperty("filter_condition") - private String filterCondition; - /** The full three-part (catalog, schema, table) name of the Delta table. */ @JsonProperty("full_name") private String fullName; @@ -29,10 +22,6 @@ public class DeltaTableSource { @JsonProperty("timeseries_column") private String timeseriesColumn; - /** A series of SQL transformations which forms a DAG (think SQL SELECT). */ - @JsonProperty("transformations") - private Collection transformations; - public DeltaTableSource setEntityColumns(Collection entityColumns) { this.entityColumns = entityColumns; return this; @@ -42,15 +31,6 @@ public Collection getEntityColumns() { return entityColumns; } - public DeltaTableSource setFilterCondition(String filterCondition) { - this.filterCondition = filterCondition; - return this; - } - - public String getFilterCondition() { - return filterCondition; - } - public DeltaTableSource setFullName(String fullName) { this.fullName = fullName; return this; @@ -69,41 +49,27 @@ public String getTimeseriesColumn() { return timeseriesColumn; } - public DeltaTableSource setTransformations(Collection transformations) { - this.transformations = transformations; - return this; - } - - public Collection getTransformations() { - return transformations; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DeltaTableSource that = (DeltaTableSource) o; return Objects.equals(entityColumns, that.entityColumns) - && Objects.equals(filterCondition, that.filterCondition) && Objects.equals(fullName, that.fullName) - && Objects.equals(timeseriesColumn, that.timeseriesColumn) - && Objects.equals(transformations, that.transformations); + && Objects.equals(timeseriesColumn, that.timeseriesColumn); } @Override public int hashCode() { - return Objects.hash( - entityColumns, filterCondition, fullName, timeseriesColumn, transformations); + return Objects.hash(entityColumns, fullName, timeseriesColumn); } @Override public String toString() { return new ToStringer(DeltaTableSource.class) .add("entityColumns", entityColumns) - .add("filterCondition", filterCondition) .add("fullName", fullName) .add("timeseriesColumn", timeseriesColumn) - .add("transformations", transformations) .toString(); } } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SqlTransformation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SqlTransformation.java deleted file mode 100755 index 41428f081..000000000 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/ml/SqlTransformation.java +++ /dev/null @@ -1,61 +0,0 @@ -// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. - -package com.databricks.sdk.service.ml; - -import com.databricks.sdk.support.Generated; -import com.databricks.sdk.support.ToStringer; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Objects; - -@Generated -public class SqlTransformation { - /** The alias of the output column. */ - @JsonProperty("output_alias") - private String outputAlias; - - /** - * The SQL expression to evaluate. Will be row-wise evaluated (no aggregations). Conditionals and - * projections are supported. - */ - @JsonProperty("sql") - private String sql; - - public SqlTransformation setOutputAlias(String outputAlias) { - this.outputAlias = outputAlias; - return this; - } - - public String getOutputAlias() { - return outputAlias; - } - - public SqlTransformation setSql(String sql) { - this.sql = sql; - return this; - } - - public String getSql() { - return sql; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SqlTransformation that = (SqlTransformation) o; - return Objects.equals(outputAlias, that.outputAlias) && Objects.equals(sql, that.sql); - } - - @Override - public int hashCode() { - return Objects.hash(outputAlias, sql); - } - - @Override - public String toString() { - return new ToStringer(SqlTransformation.class) - .add("outputAlias", outputAlias) - .add("sql", sql) - .toString(); - } -}