diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index c65050618..1933662a1 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -f561754f59f7073b13f51aef07550e0ddaabf4ce \ No newline at end of file +5443705509e5ac693d61a35ba974cb7f68f444c6 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 3b4407940..706470a67 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2525,10 +2525,16 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/Catalog.ja databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CatalogCatalogSpec.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CatalogCatalogStatus.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CatalogOperationMetadata.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfig.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfigOperationMetadata.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfState.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfStatus.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateBranchOperation.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateBranchRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCatalogOperation.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCatalogRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigOperation.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateDataApiOperation.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateDataApiRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateDatabaseOperation.java linguist-generated=true @@ -2555,6 +2561,8 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteBran databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteBranchRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCatalogOperation.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCatalogRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigOperation.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteDataApiOperation.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteDataApiRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteDatabaseOperation.java linguist-generated=true @@ -2582,6 +2590,8 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ErrorCode. databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GenerateDatabaseCredentialRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetBranchRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCatalogRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfConfigRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfStatusRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetDataApiRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetDatabaseRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetEndpointRequest.java linguist-generated=true @@ -2593,6 +2603,10 @@ databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/InitialBra databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/InitialEndpointSpec.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListBranchesRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListBranchesResponse.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsResponse.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesRequest.java linguist-generated=true +databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesResponse.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListDatabasesRequest.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListDatabasesResponse.java linguist-generated=true databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListEndpointsRequest.java linguist-generated=true diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 9d159039c..4b0fa0c18 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -15,3 +15,7 @@ ### Internal Changes ### API Changes +* Add `createCdfConfig()`, `deleteCdfConfig()`, `getCdfConfig()`, `getCdfStatus()`, `listCdfConfigs()` and `listCdfStatuses()` methods for `workspaceClient.postgres()` service. +* Add `parent` field for `com.databricks.sdk.service.catalog.CreateConnection`. +* Add `parent` field for `com.databricks.sdk.service.catalog.ListConnectionsRequest`. +* Add `MINUTES` enum value for `com.databricks.sdk.service.jobs.PeriodicTriggerConfigurationTimeUnit`. \ No newline at end of file diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/CreateConnection.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/CreateConnection.java index f890b1b6e..5e4269b3f 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/CreateConnection.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/CreateConnection.java @@ -30,6 +30,13 @@ public class CreateConnection { @JsonProperty("options") private Map options; + /** + * Parent schema for schema-level connections, in format "schemas/{catalog}.{schema}". Absent for + * metastore-level (L1) connections. + */ + @JsonProperty("parent") + private String parent; + /** A map of key-value properties attached to the securable. */ @JsonProperty("properties") private Map properties; @@ -83,6 +90,15 @@ public Map getOptions() { return options; } + public CreateConnection setParent(String parent) { + this.parent = parent; + return this; + } + + public String getParent() { + return parent; + } + public CreateConnection setProperties(Map properties) { this.properties = properties; return this; @@ -111,6 +127,7 @@ public boolean equals(Object o) { && Objects.equals(environmentSettings, that.environmentSettings) && Objects.equals(name, that.name) && Objects.equals(options, that.options) + && Objects.equals(parent, that.parent) && Objects.equals(properties, that.properties) && Objects.equals(readOnly, that.readOnly); } @@ -118,7 +135,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - comment, connectionType, environmentSettings, name, options, properties, readOnly); + comment, connectionType, environmentSettings, name, options, parent, properties, readOnly); } @Override @@ -129,6 +146,7 @@ public String toString() { .add("environmentSettings", environmentSettings) .add("name", name) .add("options", options) + .add("parent", parent) .add("properties", properties) .add("readOnly", readOnly) .toString(); diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/ListConnectionsRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/ListConnectionsRequest.java index 4aae35586..9a304615b 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/ListConnectionsRequest.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/catalog/ListConnectionsRequest.java @@ -26,6 +26,14 @@ public class ListConnectionsRequest { @QueryParam("page_token") private String pageToken; + /** + * Optional. Parent schema filter for listing schema-level connections, in format + * "schemas/{catalog}.{schema}". + */ + @JsonIgnore + @QueryParam("parent") + private String parent; + public ListConnectionsRequest setMaxResults(Long maxResults) { this.maxResults = maxResults; return this; @@ -44,17 +52,28 @@ public String getPageToken() { return pageToken; } + public ListConnectionsRequest setParent(String parent) { + this.parent = parent; + return this; + } + + public String getParent() { + return parent; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ListConnectionsRequest that = (ListConnectionsRequest) o; - return Objects.equals(maxResults, that.maxResults) && Objects.equals(pageToken, that.pageToken); + return Objects.equals(maxResults, that.maxResults) + && Objects.equals(pageToken, that.pageToken) + && Objects.equals(parent, that.parent); } @Override public int hashCode() { - return Objects.hash(maxResults, pageToken); + return Objects.hash(maxResults, pageToken, parent); } @Override @@ -62,6 +81,7 @@ public String toString() { return new ToStringer(ListConnectionsRequest.class) .add("maxResults", maxResults) .add("pageToken", pageToken) + .add("parent", parent) .toString(); } } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/jobs/PeriodicTriggerConfigurationTimeUnit.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/jobs/PeriodicTriggerConfigurationTimeUnit.java index 3821f53c9..758d07954 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/jobs/PeriodicTriggerConfigurationTimeUnit.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/jobs/PeriodicTriggerConfigurationTimeUnit.java @@ -8,5 +8,6 @@ public enum PeriodicTriggerConfigurationTimeUnit { DAYS, HOURS, + MINUTES, WEEKS, } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfig.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfig.java new file mode 100644 index 000000000..1065d6ae5 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfig.java @@ -0,0 +1,139 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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.Objects; + +/** + * A Lakebase CDF configuration (CdfConfig): one per Postgres schema per database, replicating that + * schema's tables into a Unity Catalog schema. Immutable once created. + */ +@Generated +public class CdfConfig { + /** + * The Unity Catalog catalog that replicated tables are written into. Set at creation; the + * CdfConfig is immutable. + */ + @JsonProperty("catalog") + private String catalog; + + /** + * The user-specified id; equals the final segment of `name`. Defaults to the Postgres schema name + * for configs without an explicit id. + */ + @JsonProperty("cdf_config_id") + private String cdfConfigId; + + /** When the CdfConfig was created. */ + @JsonProperty("create_time") + private Timestamp createTime; + + /** + * Output only. The full resource name of the CdfConfig. Format: + * projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + */ + @JsonProperty("name") + private String name; + + /** + * The Postgres schema this CdfConfig replicates from. Unique within the parent database. Set at + * creation; the CdfConfig is immutable. + */ + @JsonProperty("postgres_schema") + private String postgresSchema; + + /** + * The Unity Catalog schema that replicated tables are written into. Set at creation; the + * CdfConfig is immutable. + */ + @JsonProperty("schema") + private String schema; + + public CdfConfig setCatalog(String catalog) { + this.catalog = catalog; + return this; + } + + public String getCatalog() { + return catalog; + } + + public CdfConfig setCdfConfigId(String cdfConfigId) { + this.cdfConfigId = cdfConfigId; + return this; + } + + public String getCdfConfigId() { + return cdfConfigId; + } + + public CdfConfig setCreateTime(Timestamp createTime) { + this.createTime = createTime; + return this; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public CdfConfig setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public CdfConfig setPostgresSchema(String postgresSchema) { + this.postgresSchema = postgresSchema; + return this; + } + + public String getPostgresSchema() { + return postgresSchema; + } + + public CdfConfig setSchema(String schema) { + this.schema = schema; + return this; + } + + public String getSchema() { + return schema; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CdfConfig that = (CdfConfig) o; + return Objects.equals(catalog, that.catalog) + && Objects.equals(cdfConfigId, that.cdfConfigId) + && Objects.equals(createTime, that.createTime) + && Objects.equals(name, that.name) + && Objects.equals(postgresSchema, that.postgresSchema) + && Objects.equals(schema, that.schema); + } + + @Override + public int hashCode() { + return Objects.hash(catalog, cdfConfigId, createTime, name, postgresSchema, schema); + } + + @Override + public String toString() { + return new ToStringer(CdfConfig.class) + .add("catalog", catalog) + .add("cdfConfigId", cdfConfigId) + .add("createTime", createTime) + .add("name", name) + .add("postgresSchema", postgresSchema) + .add("schema", schema) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfigOperationMetadata.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfigOperationMetadata.java new file mode 100644 index 000000000..80d1d0ae6 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfConfigOperationMetadata.java @@ -0,0 +1,32 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +import com.databricks.sdk.support.Generated; +import com.databricks.sdk.support.ToStringer; +import java.util.Objects; + +/** + * Metadata for CdfConfig long-running operations. Intentionally empty today; fields (e.g. progress) + * may be added as the operation contract grows. + */ +@Generated +public class CdfConfigOperationMetadata { + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + + @Override + public String toString() { + return new ToStringer(CdfConfigOperationMetadata.class).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfState.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfState.java new file mode 100644 index 000000000..17e9331cb --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfState.java @@ -0,0 +1,17 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +import com.databricks.sdk.support.Generated; + +/** + * The replication state of a single replicated table (CdfStatus), as reported by the wal2delta + * extension on the primary compute. + */ +@Generated +public enum CdfState { + CDF_STATE_SKIPPED, + CDF_STATE_SNAPSHOTTING, + CDF_STATE_STREAMING, + CDF_STATE_TERMINATED, +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfStatus.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfStatus.java new file mode 100644 index 000000000..7f3947f9e --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CdfStatus.java @@ -0,0 +1,162 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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.Objects; + +/** + * The read-only replication status of a single Postgres table replicated under a CdfConfig. One + * status exists per replicated table. It is created automatically and cannot be modified. + */ +@Generated +public class CdfStatus { + /** The high-watermark Log Sequence Number (LSN) committed to Delta Lake. */ + @JsonProperty("committed_lsn") + private String committedLsn; + + /** When replication for this table was first established. */ + @JsonProperty("create_time") + private Timestamp createTime; + + /** The last time wal2delta wrote changes for this table. */ + @JsonProperty("last_sync_time") + private Timestamp lastSyncTime; + + /** + * Output only. The full resource name of the CdfStatus. Format: + * projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config}/cdf-statuses/{cdf_status} + * The {cdf_status} segment is the Postgres table name. + */ + @JsonProperty("name") + private String name; + + /** The Postgres table being replicated. */ + @JsonProperty("postgres_table") + private String postgresTable; + + /** The current replication state of this table. */ + @JsonProperty("state") + private CdfState state; + + /** + * Human-readable detail for the current state (e.g. the skip/error reason). Empty for healthy + * states. + */ + @JsonProperty("status_detail") + private String statusDetail; + + /** The Unity Catalog table receiving replicated data. */ + @JsonProperty("uc_table") + private String ucTable; + + public CdfStatus setCommittedLsn(String committedLsn) { + this.committedLsn = committedLsn; + return this; + } + + public String getCommittedLsn() { + return committedLsn; + } + + public CdfStatus setCreateTime(Timestamp createTime) { + this.createTime = createTime; + return this; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public CdfStatus setLastSyncTime(Timestamp lastSyncTime) { + this.lastSyncTime = lastSyncTime; + return this; + } + + public Timestamp getLastSyncTime() { + return lastSyncTime; + } + + public CdfStatus setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + public CdfStatus setPostgresTable(String postgresTable) { + this.postgresTable = postgresTable; + return this; + } + + public String getPostgresTable() { + return postgresTable; + } + + public CdfStatus setState(CdfState state) { + this.state = state; + return this; + } + + public CdfState getState() { + return state; + } + + public CdfStatus setStatusDetail(String statusDetail) { + this.statusDetail = statusDetail; + return this; + } + + public String getStatusDetail() { + return statusDetail; + } + + public CdfStatus setUcTable(String ucTable) { + this.ucTable = ucTable; + return this; + } + + public String getUcTable() { + return ucTable; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CdfStatus that = (CdfStatus) o; + return Objects.equals(committedLsn, that.committedLsn) + && Objects.equals(createTime, that.createTime) + && Objects.equals(lastSyncTime, that.lastSyncTime) + && Objects.equals(name, that.name) + && Objects.equals(postgresTable, that.postgresTable) + && Objects.equals(state, that.state) + && Objects.equals(statusDetail, that.statusDetail) + && Objects.equals(ucTable, that.ucTable); + } + + @Override + public int hashCode() { + return Objects.hash( + committedLsn, createTime, lastSyncTime, name, postgresTable, state, statusDetail, ucTable); + } + + @Override + public String toString() { + return new ToStringer(CdfStatus.class) + .add("committedLsn", committedLsn) + .add("createTime", createTime) + .add("lastSyncTime", lastSyncTime) + .add("name", name) + .add("postgresTable", postgresTable) + .add("state", state) + .add("statusDetail", statusDetail) + .add("ucTable", ucTable) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigOperation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigOperation.java new file mode 100644 index 000000000..ae46af360 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigOperation.java @@ -0,0 +1,162 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +package com.databricks.sdk.service.postgres; + +import com.databricks.sdk.core.DatabricksException; +import com.databricks.sdk.core.logging.Logger; +import com.databricks.sdk.core.logging.LoggerFactory; +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; + +/** + * Wrapper for interacting with a long-running createCdfConfig operation. Provides methods to wait + * for completion, check status, cancel, and access metadata. + */ +@Generated +public class CreateCdfConfigOperation { + private static final Logger LOG = LoggerFactory.getLogger(CreateCdfConfigOperation.class); + + private final PostgresService impl; + private Operation operation; + private final ObjectMapper objectMapper; + + public CreateCdfConfigOperation(PostgresService impl, Operation operation) { + this.impl = impl; + this.operation = operation; + this.objectMapper = SerDeUtils.createMapper(); + } + + /** + * Wait for the operation to complete and return the resulting CdfConfig. Waits indefinitely if no + * timeout is specified. + * + * @return the created CdfConfig + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public CdfConfig waitForCompletion() throws TimeoutException { + return waitForCompletion(Optional.empty()); + } + + /** + * Wait for the operation to complete and return the resulting CdfConfig. + * + * @param options the options for configuring the wait behavior, can be empty for defaults + * @return the created CdfConfig + * @throws TimeoutException if the operation doesn't complete within the timeout + * @throws DatabricksException if the operation fails + */ + public CdfConfig 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, CdfConfig.class); + } catch (JsonProcessingException e) { + throw new DatabricksException( + "Failed to unmarshal cdfConfig 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 CdfConfigOperationMetadata getMetadata() { + if (operation.getMetadata() == null) { + return null; + } + + try { + JsonNode metadataJson = objectMapper.valueToTree(operation.getMetadata()); + return objectMapper.treeToValue(metadataJson, CdfConfigOperationMetadata.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.getOperation(new GetOperationRequest().setName(operation.getName())); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigRequest.java new file mode 100644 index 000000000..85fb29ff4 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/CreateCdfConfigRequest.java @@ -0,0 +1,85 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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 java.util.Objects; + +@Generated +public class CreateCdfConfigRequest { + /** + * The CdfConfig to create. The catalog, schema, and postgres_schema fields are required; all + * other fields are output only and ignored on input. + */ + @JsonProperty("cdf_config") + private CdfConfig cdfConfig; + + /** + * The user-specified id for the CdfConfig, forming the final segment of its resource name. Must + * match the pattern `[a-z][a-z0-9_]{0,62}`. Defaults to the Postgres schema name when omitted. + */ + @JsonIgnore + @QueryParam("cdf_config_id") + private String cdfConfigId; + + /** + * The parent database under which to create the CdfConfig. Format: + * projects/{project}/branches/{branch}/databases/{database} + */ + @JsonIgnore private String parent; + + public CreateCdfConfigRequest setCdfConfig(CdfConfig cdfConfig) { + this.cdfConfig = cdfConfig; + return this; + } + + public CdfConfig getCdfConfig() { + return cdfConfig; + } + + public CreateCdfConfigRequest setCdfConfigId(String cdfConfigId) { + this.cdfConfigId = cdfConfigId; + return this; + } + + public String getCdfConfigId() { + return cdfConfigId; + } + + public CreateCdfConfigRequest setParent(String parent) { + this.parent = parent; + return this; + } + + public String getParent() { + return parent; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CreateCdfConfigRequest that = (CreateCdfConfigRequest) o; + return Objects.equals(cdfConfig, that.cdfConfig) + && Objects.equals(cdfConfigId, that.cdfConfigId) + && Objects.equals(parent, that.parent); + } + + @Override + public int hashCode() { + return Objects.hash(cdfConfig, cdfConfigId, parent); + } + + @Override + public String toString() { + return new ToStringer(CreateCdfConfigRequest.class) + .add("cdfConfig", cdfConfig) + .add("cdfConfigId", cdfConfigId) + .add("parent", parent) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigOperation.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigOperation.java new file mode 100644 index 000000000..4df5e4f2d --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigOperation.java @@ -0,0 +1,162 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +package com.databricks.sdk.service.postgres; + +import com.databricks.sdk.core.DatabricksException; +import com.databricks.sdk.core.logging.Logger; +import com.databricks.sdk.core.logging.LoggerFactory; +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; + +/** + * Wrapper for interacting with a long-running deleteCdfConfig operation. Provides methods to wait + * for completion, check status, cancel, and access metadata. + */ +@Generated +public class DeleteCdfConfigOperation { + private static final Logger LOG = LoggerFactory.getLogger(DeleteCdfConfigOperation.class); + + private final PostgresService impl; + private Operation operation; + private final ObjectMapper objectMapper; + + public DeleteCdfConfigOperation(PostgresService 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); + return; + } 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 CdfConfigOperationMetadata getMetadata() { + if (operation.getMetadata() == null) { + return null; + } + + try { + JsonNode metadataJson = objectMapper.valueToTree(operation.getMetadata()); + return objectMapper.treeToValue(metadataJson, CdfConfigOperationMetadata.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.getOperation(new GetOperationRequest().setName(operation.getName())); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigRequest.java new file mode 100644 index 000000000..e71f438f9 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/DeleteCdfConfigRequest.java @@ -0,0 +1,65 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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 DeleteCdfConfigRequest { + /** + * When true, also drops the replicated Delta tables in Unity Catalog. When false (the default), + * the replicated tables are preserved at their last synced state. + */ + @JsonIgnore + @QueryParam("force") + private Boolean force; + + /** + * The resource name of the CdfConfig to delete. Format: + * projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + */ + @JsonIgnore private String name; + + public DeleteCdfConfigRequest setForce(Boolean force) { + this.force = force; + return this; + } + + public Boolean getForce() { + return force; + } + + public DeleteCdfConfigRequest 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; + DeleteCdfConfigRequest that = (DeleteCdfConfigRequest) o; + return Objects.equals(force, that.force) && Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(force, name); + } + + @Override + public String toString() { + return new ToStringer(DeleteCdfConfigRequest.class) + .add("force", force) + .add("name", name) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfConfigRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfConfigRequest.java new file mode 100644 index 000000000..7fe904264 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfConfigRequest.java @@ -0,0 +1,44 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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 GetCdfConfigRequest { + /** + * The resource name of the CdfConfig to retrieve. Format: + * projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + */ + @JsonIgnore private String name; + + public GetCdfConfigRequest 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; + GetCdfConfigRequest that = (GetCdfConfigRequest) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return new ToStringer(GetCdfConfigRequest.class).add("name", name).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfStatusRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfStatusRequest.java new file mode 100644 index 000000000..4c6e13c5f --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/GetCdfStatusRequest.java @@ -0,0 +1,44 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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 GetCdfStatusRequest { + /** + * The resource name of the CdfStatus to retrieve. Format: + * projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config}/cdf-statuses/{cdf_status} + */ + @JsonIgnore private String name; + + public GetCdfStatusRequest 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; + GetCdfStatusRequest that = (GetCdfStatusRequest) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return new ToStringer(GetCdfStatusRequest.class).add("name", name).toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsRequest.java new file mode 100644 index 000000000..a31da2726 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsRequest.java @@ -0,0 +1,79 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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 ListCdfConfigsRequest { + /** Maximum number of CdfConfigs to return. */ + @JsonIgnore + @QueryParam("page_size") + private Long pageSize; + + /** Pagination token returned by a previous ListCdfConfigs call. Empty on the first page. */ + @JsonIgnore + @QueryParam("page_token") + private String pageToken; + + /** + * The parent database to list CdfConfigs for. Format: + * projects/{project}/branches/{branch}/databases/{database} + */ + @JsonIgnore private String parent; + + public ListCdfConfigsRequest setPageSize(Long pageSize) { + this.pageSize = pageSize; + return this; + } + + public Long getPageSize() { + return pageSize; + } + + public ListCdfConfigsRequest setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public String getPageToken() { + return pageToken; + } + + public ListCdfConfigsRequest setParent(String parent) { + this.parent = parent; + return this; + } + + public String getParent() { + return parent; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ListCdfConfigsRequest that = (ListCdfConfigsRequest) o; + return Objects.equals(pageSize, that.pageSize) + && Objects.equals(pageToken, that.pageToken) + && Objects.equals(parent, that.parent); + } + + @Override + public int hashCode() { + return Objects.hash(pageSize, pageToken, parent); + } + + @Override + public String toString() { + return new ToStringer(ListCdfConfigsRequest.class) + .add("pageSize", pageSize) + .add("pageToken", pageToken) + .add("parent", parent) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsResponse.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsResponse.java new file mode 100644 index 000000000..8f3a0f2d4 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfConfigsResponse.java @@ -0,0 +1,64 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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; + +/** + * Response to a ListCdfConfigs request, containing a page of CdfConfigs and a token for fetching + * the next page. + */ +@Generated +public class ListCdfConfigsResponse { + /** The CdfConfigs under the parent database. */ + @JsonProperty("cdf_configs") + private Collection cdfConfigs; + + /** Token to retrieve the next page of results; empty when there are no more. */ + @JsonProperty("next_page_token") + private String nextPageToken; + + public ListCdfConfigsResponse setCdfConfigs(Collection cdfConfigs) { + this.cdfConfigs = cdfConfigs; + return this; + } + + public Collection getCdfConfigs() { + return cdfConfigs; + } + + public ListCdfConfigsResponse setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public String getNextPageToken() { + return nextPageToken; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ListCdfConfigsResponse that = (ListCdfConfigsResponse) o; + return Objects.equals(cdfConfigs, that.cdfConfigs) + && Objects.equals(nextPageToken, that.nextPageToken); + } + + @Override + public int hashCode() { + return Objects.hash(cdfConfigs, nextPageToken); + } + + @Override + public String toString() { + return new ToStringer(ListCdfConfigsResponse.class) + .add("cdfConfigs", cdfConfigs) + .add("nextPageToken", nextPageToken) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesRequest.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesRequest.java new file mode 100644 index 000000000..8f44c79f8 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesRequest.java @@ -0,0 +1,79 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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 ListCdfStatusesRequest { + /** Maximum number of CdfStatuses to return. */ + @JsonIgnore + @QueryParam("page_size") + private Long pageSize; + + /** Pagination token returned by a previous ListCdfStatuses call. Empty on the first page. */ + @JsonIgnore + @QueryParam("page_token") + private String pageToken; + + /** + * The parent CdfConfig to list CdfStatuses for. Format: + * projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + */ + @JsonIgnore private String parent; + + public ListCdfStatusesRequest setPageSize(Long pageSize) { + this.pageSize = pageSize; + return this; + } + + public Long getPageSize() { + return pageSize; + } + + public ListCdfStatusesRequest setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public String getPageToken() { + return pageToken; + } + + public ListCdfStatusesRequest setParent(String parent) { + this.parent = parent; + return this; + } + + public String getParent() { + return parent; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ListCdfStatusesRequest that = (ListCdfStatusesRequest) o; + return Objects.equals(pageSize, that.pageSize) + && Objects.equals(pageToken, that.pageToken) + && Objects.equals(parent, that.parent); + } + + @Override + public int hashCode() { + return Objects.hash(pageSize, pageToken, parent); + } + + @Override + public String toString() { + return new ToStringer(ListCdfStatusesRequest.class) + .add("pageSize", pageSize) + .add("pageToken", pageToken) + .add("parent", parent) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesResponse.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesResponse.java new file mode 100644 index 000000000..74e1bf7a2 --- /dev/null +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/ListCdfStatusesResponse.java @@ -0,0 +1,64 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package com.databricks.sdk.service.postgres; + +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; + +/** + * Response to a ListCdfStatuses request, containing a page of replicated table statuses and a token + * for fetching the next page. + */ +@Generated +public class ListCdfStatusesResponse { + /** The replicated tables under the parent CdfConfig. */ + @JsonProperty("cdf_statuses") + private Collection cdfStatuses; + + /** Token to retrieve the next page of results; empty when there are no more. */ + @JsonProperty("next_page_token") + private String nextPageToken; + + public ListCdfStatusesResponse setCdfStatuses(Collection cdfStatuses) { + this.cdfStatuses = cdfStatuses; + return this; + } + + public Collection getCdfStatuses() { + return cdfStatuses; + } + + public ListCdfStatusesResponse setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public String getNextPageToken() { + return nextPageToken; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ListCdfStatusesResponse that = (ListCdfStatusesResponse) o; + return Objects.equals(cdfStatuses, that.cdfStatuses) + && Objects.equals(nextPageToken, that.nextPageToken); + } + + @Override + public int hashCode() { + return Objects.hash(cdfStatuses, nextPageToken); + } + + @Override + public String toString() { + return new ToStringer(ListCdfStatusesResponse.class) + .add("cdfStatuses", cdfStatuses) + .add("nextPageToken", nextPageToken) + .toString(); + } +} diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresAPI.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresAPI.java index 7557fb4e0..41afbfd03 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresAPI.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresAPI.java @@ -49,6 +49,16 @@ public CreateCatalogOperation createCatalog(CreateCatalogRequest request) { return new CreateCatalogOperation(impl, operation); } + /** + * Create a Lakebase CDF configuration (CdfConfig). Replicates the tables of a Postgres schema + * into a Unity Catalog schema. Returns ALREADY_EXISTS if a config with the requested id exists, + * or if another config already replicates the target Postgres schema. + */ + public CreateCdfConfigOperation createCdfConfig(CreateCdfConfigRequest request) { + Operation operation = impl.createCdfConfig(request); + return new CreateCdfConfigOperation(impl, operation); + } + /** Enable Data API for a database. */ public CreateDataApiOperation createDataApi(CreateDataApiRequest request) { Operation operation = impl.createDataApi(request); @@ -112,6 +122,19 @@ public DeleteCatalogOperation deleteCatalog(DeleteCatalogRequest request) { return new DeleteCatalogOperation(impl, operation); } + public DeleteCdfConfigOperation deleteCdfConfig(String name) { + return deleteCdfConfig(new DeleteCdfConfigRequest().setName(name)); + } + + /** + * Delete a Lakebase CDF configuration (CdfConfig). Stops replication and removes the config. When + * force is true, also drops the replicated Delta tables in Unity Catalog. + */ + public DeleteCdfConfigOperation deleteCdfConfig(DeleteCdfConfigRequest request) { + Operation operation = impl.deleteCdfConfig(request); + return new DeleteCdfConfigOperation(impl, operation); + } + public DeleteDataApiOperation deleteDataApi(String name) { return deleteDataApi(new DeleteDataApiRequest().setName(name)); } @@ -195,6 +218,26 @@ public Catalog getCatalog(GetCatalogRequest request) { return impl.getCatalog(request); } + public CdfConfig getCdfConfig(String name) { + return getCdfConfig(new GetCdfConfigRequest().setName(name)); + } + + /** Get a single Lakebase CDF configuration (CdfConfig). */ + public CdfConfig getCdfConfig(GetCdfConfigRequest request) { + return impl.getCdfConfig(request); + } + + public CdfStatus getCdfStatus(String name) { + return getCdfStatus(new GetCdfStatusRequest().setName(name)); + } + + /** + * Get the replication status of a single replicated table within a Lakebase CDF configuration. + */ + public CdfStatus getCdfStatus(GetCdfStatusRequest request) { + return impl.getCdfStatus(request); + } + public DataApi getDataApi(String name) { return getDataApi(new GetDataApiRequest().setName(name)); } @@ -283,6 +326,44 @@ public Iterable listBranches(ListBranchesRequest request) { }); } + public Iterable listCdfConfigs(String parent) { + return listCdfConfigs(new ListCdfConfigsRequest().setParent(parent)); + } + + /** List the Lakebase CDF configurations (CdfConfigs) under a database. */ + public Iterable listCdfConfigs(ListCdfConfigsRequest request) { + return Paginator.newTokenPagination( + request, + impl::listCdfConfigs, + ListCdfConfigsResponse::getCdfConfigs, + response -> { + String token = response.getNextPageToken(); + if (token == null || token.isEmpty()) { + return null; + } + return request.setPageToken(token); + }); + } + + public Iterable listCdfStatuses(String parent) { + return listCdfStatuses(new ListCdfStatusesRequest().setParent(parent)); + } + + /** List the replication statuses of all tables replicated under a Lakebase CDF configuration. */ + public Iterable listCdfStatuses(ListCdfStatusesRequest request) { + return Paginator.newTokenPagination( + request, + impl::listCdfStatuses, + ListCdfStatusesResponse::getCdfStatuses, + response -> { + String token = response.getNextPageToken(); + if (token == null || token.isEmpty()) { + return null; + } + return request.setPageToken(token); + }); + } + public Iterable listDatabases(String parent) { return listDatabases(new ListDatabasesRequest().setParent(parent)); } diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresImpl.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresImpl.java index b00572fab..fba95be29 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresImpl.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresImpl.java @@ -52,6 +52,24 @@ public Operation createCatalog(CreateCatalogRequest request) { } } + @Override + public Operation createCdfConfig(CreateCdfConfigRequest request) { + String path = String.format("/api/2.0/postgres/%s/cdf-configs", request.getParent()); + try { + Request req = new Request("POST", path, apiClient.serialize(request.getCdfConfig())); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + req.withHeader("Content-Type", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Workspace-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Operation.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public Operation createDataApi(CreateDataApiRequest request) { String path = String.format("/api/2.0/postgres/%s/data-api", request.getParent()); @@ -194,6 +212,23 @@ public Operation deleteCatalog(DeleteCatalogRequest request) { } } + @Override + public Operation deleteCdfConfig(DeleteCdfConfigRequest request) { + String path = String.format("/api/2.0/postgres/%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-Workspace-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, Operation.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public Operation deleteDataApi(DeleteDataApiRequest request) { String path = String.format("/api/2.0/postgres/%s", request.getName()); @@ -348,6 +383,40 @@ public Catalog getCatalog(GetCatalogRequest request) { } } + @Override + public CdfConfig getCdfConfig(GetCdfConfigRequest request) { + String path = String.format("/api/2.0/postgres/%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-Workspace-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, CdfConfig.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + + @Override + public CdfStatus getCdfStatus(GetCdfStatusRequest request) { + String path = String.format("/api/2.0/postgres/%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-Workspace-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, CdfStatus.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public DataApi getDataApi(GetDataApiRequest request) { String path = String.format("/api/2.0/postgres/%s", request.getName()); @@ -484,6 +553,40 @@ public ListBranchesResponse listBranches(ListBranchesRequest request) { } } + @Override + public ListCdfConfigsResponse listCdfConfigs(ListCdfConfigsRequest request) { + String path = String.format("/api/2.0/postgres/%s/cdf-configs", request.getParent()); + try { + Request req = new Request("GET", path); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Workspace-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, ListCdfConfigsResponse.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + + @Override + public ListCdfStatusesResponse listCdfStatuses(ListCdfStatusesRequest request) { + String path = String.format("/api/2.0/postgres/%s/cdf-statuses", request.getParent()); + try { + Request req = new Request("GET", path); + + ApiClient.setQuery(req, request); + req.withHeader("Accept", "application/json"); + if (apiClient.workspaceId() != null) { + req.withHeader("X-Databricks-Workspace-Id", apiClient.workspaceId()); + } + return apiClient.execute(req, ListCdfStatusesResponse.class); + } catch (IOException e) { + throw new DatabricksException("IO error: " + e.getMessage(), e); + } + } + @Override public ListDatabasesResponse listDatabases(ListDatabasesRequest request) { String path = String.format("/api/2.0/postgres/%s/databases", request.getParent()); diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresService.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresService.java index 782e9f964..aa54b53fb 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresService.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/postgres/PostgresService.java @@ -29,6 +29,13 @@ public interface PostgresService { /** Register a Postgres database in the Unity Catalog. */ Operation createCatalog(CreateCatalogRequest createCatalogRequest); + /** + * Create a Lakebase CDF configuration (CdfConfig). Replicates the tables of a Postgres schema + * into a Unity Catalog schema. Returns ALREADY_EXISTS if a config with the requested id exists, + * or if another config already replicates the target Postgres schema. + */ + Operation createCdfConfig(CreateCdfConfigRequest createCdfConfigRequest); + /** Enable Data API for a database. */ Operation createDataApi(CreateDataApiRequest createDataApiRequest); @@ -60,6 +67,12 @@ public interface PostgresService { /** Delete a Database Catalog. */ Operation deleteCatalog(DeleteCatalogRequest deleteCatalogRequest); + /** + * Delete a Lakebase CDF configuration (CdfConfig). Stops replication and removes the config. When + * force is true, also drops the replicated Delta tables in Unity Catalog. + */ + Operation deleteCdfConfig(DeleteCdfConfigRequest deleteCdfConfigRequest); + /** Disable Data API for a database. */ Operation deleteDataApi(DeleteDataApiRequest deleteDataApiRequest); @@ -88,6 +101,14 @@ DatabaseCredential generateDatabaseCredential( /** Get a Database Catalog. */ Catalog getCatalog(GetCatalogRequest getCatalogRequest); + /** Get a single Lakebase CDF configuration (CdfConfig). */ + CdfConfig getCdfConfig(GetCdfConfigRequest getCdfConfigRequest); + + /** + * Get the replication status of a single replicated table within a Lakebase CDF configuration. + */ + CdfStatus getCdfStatus(GetCdfStatusRequest getCdfStatusRequest); + /** Get Data API configuration for a database. */ DataApi getDataApi(GetDataApiRequest getDataApiRequest); @@ -118,6 +139,12 @@ DatabaseCredential generateDatabaseCredential( /** Returns a paginated list of database branches in the project. */ ListBranchesResponse listBranches(ListBranchesRequest listBranchesRequest); + /** List the Lakebase CDF configurations (CdfConfigs) under a database. */ + ListCdfConfigsResponse listCdfConfigs(ListCdfConfigsRequest listCdfConfigsRequest); + + /** List the replication statuses of all tables replicated under a Lakebase CDF configuration. */ + ListCdfStatusesResponse listCdfStatuses(ListCdfStatusesRequest listCdfStatusesRequest); + /** List Databases. */ ListDatabasesResponse listDatabases(ListDatabasesRequest listDatabasesRequest); diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsAPI.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsAPI.java index 1092951e2..7bfdbb177 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsAPI.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsAPI.java @@ -37,9 +37,10 @@ public SupervisorAgent createSupervisorAgent(CreateSupervisorAgentRequest reques /** * Creates a Tool under a Supervisor Agent. Specify one of "genie_space", "knowledge_assistant", * "uc_function", "uc_connection", "app", "volume", "dashboard", "table", "vector_search_index", - * "catalog", "schema", "supervisor_agent", "web_search", "skill" in the request body. The legacy - * values "lakeview_dashboard" and "uc_table" are also accepted and remain equivalent to - * "dashboard" and "table" respectively. + * "catalog", "schema", "supervisor_agent", "databricks_web_search", "skill" in the request body. + * The legacy values "lakeview_dashboard", "uc_table", and "web_search" are also accepted and + * remain equivalent to "dashboard", "table", and "databricks_web_search" respectively. The + * "databricks_web_search" tool_type maps to the `web_search` spec field. */ public Tool createTool(CreateToolRequest request) { return impl.createTool(request); diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsService.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsService.java index af98daa20..34d547b5d 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsService.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/SupervisorAgentsService.java @@ -21,9 +21,10 @@ public interface SupervisorAgentsService { /** * Creates a Tool under a Supervisor Agent. Specify one of "genie_space", "knowledge_assistant", * "uc_function", "uc_connection", "app", "volume", "dashboard", "table", "vector_search_index", - * "catalog", "schema", "supervisor_agent", "web_search", "skill" in the request body. The legacy - * values "lakeview_dashboard" and "uc_table" are also accepted and remain equivalent to - * "dashboard" and "table" respectively. + * "catalog", "schema", "supervisor_agent", "databricks_web_search", "skill" in the request body. + * The legacy values "lakeview_dashboard", "uc_table", and "web_search" are also accepted and + * remain equivalent to "dashboard", "table", and "databricks_web_search" respectively. The + * "databricks_web_search" tool_type maps to the `web_search` spec field. */ Tool createTool(CreateToolRequest createToolRequest); diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/Tool.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/Tool.java index e64306898..70db45e8f 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/Tool.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/service/supervisoragents/Tool.java @@ -40,9 +40,10 @@ public class Tool { /** * Tool type. Must be one of: "genie_space", "knowledge_assistant", "uc_function", * "uc_connection", "uc_mcp", "app", "volume", "dashboard", "serving_endpoint", "table", - * "vector_search_index", "catalog", "schema", "supervisor_agent", "web_search", "skill". The - * legacy values "lakeview_dashboard" and "uc_table" are also accepted and remain equivalent to - * "dashboard" and "table" respectively. + * "vector_search_index", "catalog", "schema", "supervisor_agent", "databricks_web_search", + * "skill". The legacy values "lakeview_dashboard", "uc_table", and "web_search" are also accepted + * and remain equivalent to "dashboard", "table", and "databricks_web_search" respectively. The + * "databricks_web_search" tool_type maps to the `web_search` spec field. */ @JsonProperty("tool_type") private String toolType;