diff --git a/.codegen/_last_sha b/.codegen/_last_sha index b8fbe017..249e7828 100644 --- a/.codegen/_last_sha +++ b/.codegen/_last_sha @@ -1 +1 @@ -da7fcfc1c46b1bf871f3a25bb82e5c2ea62cdac0 \ No newline at end of file +07bd11eefe3ed30eebcfa846546af8b56b655973 \ No newline at end of file diff --git a/accessmanagement/CHANGELOG.md b/accessmanagement/CHANGELOG.md index 2fca2529..081443ac 100644 --- a/accessmanagement/CHANGELOG.md +++ b/accessmanagement/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.4.0 (2026-11-02) + ## Release v0.3.0 (2026-10-13) ## Release v0.2.0 (2026-10-06) diff --git a/accessmanagement/internal/version.go b/accessmanagement/internal/version.go index 6d9ab2fc..bf124629 100644 --- a/accessmanagement/internal/version.go +++ b/accessmanagement/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-accessmanagement" -const Version = "0.3.0" +const Version = "0.4.0" diff --git a/accessmanagement/v1/client.go b/accessmanagement/v1/client.go index ad477401..149b26c1 100644 --- a/accessmanagement/v1/client.go +++ b/accessmanagement/v1/client.go @@ -798,6 +798,72 @@ func (c *internalClient) UpdateRuleSetProxy(ctx context.Context, req UpdateRuleS return resp, nil } +// Migrate Permissions. +func (c *internalClient) MigratePermissions(ctx context.Context, req MigratePermissionsRequest, opts ...call.Option) (*MigratePermissionsResponse, error) { + wireReq, err := migratePermissionsRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + baseURL.Path = "/api/2.0/permissionmigration" + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *MigratePermissionsResponse + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migratePermissionsResponseWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migratePermissionsResponseFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + // Gets the permissions of an object. Objects can inherit permissions from their // parent objects or root object. func (c *internalClient) GetObjectPermissions(ctx context.Context, req GetObjectPermissionsRequest, opts ...call.Option) (*PermissionsResponse, error) { diff --git a/accessmanagement/v1/model.go b/accessmanagement/v1/model.go index 9290e195..343a8e7a 100644 --- a/accessmanagement/v1/model.go +++ b/accessmanagement/v1/model.go @@ -284,6 +284,23 @@ type ListWorkspacePermissionsResponse struct { Permissions []PermissionOutput } +type MigratePermissionsRequest struct { + // WorkspaceId of the associated workspace where the permission migration will + // occur. + WorkspaceId *int64 + // The name of the workspace group that permissions will be migrated from. + FromWorkspaceGroupName *string + // The name of the account group that permissions will be migrated to. + ToAccountGroupName *string + // The maximum number of permissions that will be migrated. + Size *int +} + +type MigratePermissionsResponse struct { + // Number of permissions migrated. + PermissionsMigrated *int +} + type Permission struct { PermissionLevel PermissionLevel Inherited *bool diff --git a/accessmanagement/v1/wire.go b/accessmanagement/v1/wire.go index 263571fa..98e24ed8 100644 --- a/accessmanagement/v1/wire.go +++ b/accessmanagement/v1/wire.go @@ -364,6 +364,42 @@ func listWorkspacePermissionsResponseFromWire(w *listWorkspacePermissionsRespons }, nil } +type migratePermissionsRequestWire struct { + WorkspaceId *wireInt64 `json:"workspace_id,omitempty"` + FromWorkspaceGroupName *string `json:"from_workspace_group_name,omitempty"` + ToAccountGroupName *string `json:"to_account_group_name,omitempty"` + Size *int `json:"size,omitempty"` +} + +func migratePermissionsRequestToWire(v *MigratePermissionsRequest) (*migratePermissionsRequestWire, error) { + if v == nil { + return nil, nil + } + workspaceIdWireValue, err := int64ToWire(v.WorkspaceId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MigratePermissionsRequest.WorkspaceId", err) + } + return &migratePermissionsRequestWire{ + WorkspaceId: workspaceIdWireValue, + FromWorkspaceGroupName: v.FromWorkspaceGroupName, + ToAccountGroupName: v.ToAccountGroupName, + Size: v.Size, + }, nil +} + +type migratePermissionsResponseWire struct { + PermissionsMigrated *int `json:"permissions_migrated,omitempty"` +} + +func migratePermissionsResponseFromWire(w *migratePermissionsResponseWire) (*MigratePermissionsResponse, error) { + if w == nil { + return nil, nil + } + return &MigratePermissionsResponse{ + PermissionsMigrated: w.PermissionsMigrated, + }, nil +} + type permissionWire struct { PermissionLevel PermissionLevel `json:"permission_level,omitempty"` Inherited *bool `json:"inherited,omitempty"` diff --git a/aigateway/CHANGELOG.md b/aigateway/CHANGELOG.md index 31248bc3..f66d04ea 100644 --- a/aigateway/CHANGELOG.md +++ b/aigateway/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.16.0 (2026-11-02) + ## Release v0.15.0 (2026-10-29) ## Release v0.14.0 (2026-10-28) diff --git a/aigateway/internal/version.go b/aigateway/internal/version.go index 596ea1ba..3c641ebf 100644 --- a/aigateway/internal/version.go +++ b/aigateway/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-aigateway" -const Version = "0.15.0" +const Version = "0.16.0" diff --git a/aigateway/v1/model.go b/aigateway/v1/model.go index bf33336e..6ac05a7d 100644 --- a/aigateway/v1/model.go +++ b/aigateway/v1/model.go @@ -32,7 +32,8 @@ const ( // inference-table details and rate-limit principal names. ListModelProviderServicesRequest_View_Full ListModelProviderServicesRequest_View = "FULL" // Basic resource metadata and selected configuration fields. Service-credential - // and inference-table details and rate-limit principal names are unset. + // and inference-table details and rate-limit principal names are unset. Custom + // provider base URLs may be omitted; use FULL or Get for the current endpoint. ListModelProviderServicesRequest_View_Basic ListModelProviderServicesRequest_View = "BASIC" ) @@ -114,7 +115,10 @@ const ( RateLimit_RateLimitKey_Unspecified RateLimit_RateLimitKey = "" // Rate limit applies to a specific user (matched on `principal`). RateLimit_RateLimitKey_RateLimitKeyUser RateLimit_RateLimitKey = "RATE_LIMIT_KEY_USER" - // Rate limit applies to all members of a group (matched on `principal`). + // Rate limit applies to direct members of a group (matched on `principal`), and + // to callers assuming the group directly or assuming a group that is a direct + // member of it (via role switching). Membership is not transitive, and a user + // assuming a role outside the group is not bound by it. RateLimit_RateLimitKey_RateLimitKeyUserGroup RateLimit_RateLimitKey = "RATE_LIMIT_KEY_USER_GROUP" // Rate limit applies to a specific service principal (matched on `principal`). RateLimit_RateLimitKey_RateLimitKeyServicePrincipal RateLimit_RateLimitKey = "RATE_LIMIT_KEY_SERVICE_PRINCIPAL" diff --git a/budgets/CHANGELOG.md b/budgets/CHANGELOG.md index f3d5bf6a..0ca3f2fc 100644 --- a/budgets/CHANGELOG.md +++ b/budgets/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.7.0 (2026-11-02) + ## Release v0.6.0 (2026-10-28) ## Release v0.5.0 (2026-10-22) diff --git a/budgets/internal/version.go b/budgets/internal/version.go index 21a3d3a1..deec6e5d 100644 --- a/budgets/internal/version.go +++ b/budgets/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-budgets" -const Version = "0.6.0" +const Version = "0.7.0" diff --git a/budgets/v1/model.go b/budgets/v1/model.go index 6db41b62..80d222e7 100644 --- a/budgets/v1/model.go +++ b/budgets/v1/model.go @@ -119,9 +119,10 @@ type AlertSpendStatus struct { Threshold *string // Percentage of the threshold consumed, as a decimal string rounded down to one // decimal place (for example, "68.4" means 68.4%). May exceed 100 when spend is - // over the threshold. Returns "0.0" if there's no spend, and is omitted if the - // threshold is $0. For shared thresholds, this is the only value returned; the - // absolute `spend` and `threshold` dollar amounts are withheld. + // over the threshold. Returns "0.0" if there's no spend, except that a $0 + // threshold always returns "100.0". For shared thresholds, this is the only + // value returned; the absolute `spend` and `threshold` dollar amounts are + // withheld. PercentConsumed *string } diff --git a/computemigrations/.package.json b/computemigrations/.package.json new file mode 100644 index 00000000..8ff7e286 --- /dev/null +++ b/computemigrations/.package.json @@ -0,0 +1,3 @@ +{ + "package": "computemigrations" +} diff --git a/computemigrations/CHANGELOG.md b/computemigrations/CHANGELOG.md new file mode 100644 index 00000000..c6015f19 --- /dev/null +++ b/computemigrations/CHANGELOG.md @@ -0,0 +1,3 @@ +# Version changelog + +## Release v0.1.0 (2026-11-02) diff --git a/computemigrations/README.md b/computemigrations/README.md new file mode 100644 index 00000000..b8c5ab95 --- /dev/null +++ b/computemigrations/README.md @@ -0,0 +1,26 @@ +# github.com/databricks/sdk-go/computemigrations + +> [!NOTE] +> +> ## Beta +> +> **This SDK is in Beta and is supported for production use cases.** Interfaces might still change slightly before GA (e.g. name standardization and minor ergonomic tweaks). We are keen to hear feedback from early adopters — please [file issues](https://github.com/databricks/sdk-go/issues), and we will address them. + +## Installation + +```bash +go get github.com/databricks/sdk-go/computemigrations@latest +``` + +## Usage + +```go +import "github.com/databricks/sdk-go/computemigrations/v1" + +client, err := computemigrations.NewClient(ctx) +if err != nil { + return err +} +``` + +For a full getting-started guide, see the [root README](../README.md). diff --git a/computemigrations/go.mod b/computemigrations/go.mod new file mode 100644 index 00000000..a47cdf39 --- /dev/null +++ b/computemigrations/go.mod @@ -0,0 +1,28 @@ +module github.com/databricks/sdk-go/computemigrations + +go 1.26.0 + +replace github.com/databricks/sdk-go/auth => ../auth + +replace github.com/databricks/sdk-go/core => ../core + +replace github.com/databricks/sdk-go/options => ../options + +require ( + github.com/databricks/sdk-go/auth v0.2.0 + github.com/databricks/sdk-go/core v0.1.0 + github.com/databricks/sdk-go/options v0.0.0-00010101000000-000000000000 +) + +require ( + github.com/databricks/databricks-sdk-go v0.92.0 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/oauth2 v0.33.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/time v0.5.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect +) diff --git a/computemigrations/internal/version.go b/computemigrations/internal/version.go new file mode 100644 index 00000000..ca93c3ba --- /dev/null +++ b/computemigrations/internal/version.go @@ -0,0 +1,5 @@ +package internal + +const ModuleName = "sdk-go-computemigrations" + +const Version = "0.1.0" diff --git a/computemigrations/v1/client.go b/computemigrations/v1/client.go new file mode 100644 index 00000000..7292449a --- /dev/null +++ b/computemigrations/v1/client.go @@ -0,0 +1,839 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package computemigrations + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "iter" + "log/slog" + "net/http" + "net/url" + "sync" + "time" + + "github.com/databricks/sdk-go/auth" + "github.com/databricks/sdk-go/computemigrations/internal" + "github.com/databricks/sdk-go/core/clientinfo" + "github.com/databricks/sdk-go/options/call" + "github.com/databricks/sdk-go/options/client" + "github.com/databricks/sdk-go/options/internaloptions" +) + +type Client struct { + internalClient + + // extensions is a per-client store for hand-written mixins to attach + // lazily-built state. Keys should be unexported types private to the + // mixin, following the context.Value convention, to avoid collisions. + // The zero value is ready to use; it is safe for concurrent use. + extensions sync.Map +} + +type internalClient struct { + httpClient *http.Client + callTimeout *time.Duration + credentials auth.Credentials + logger *slog.Logger + userAgent func() (string, error) + host string + workspaceID string + accountID string +} + +func NewClient(ctx context.Context, opts ...client.Option) (*Client, error) { + cfg := internaloptions.ClientOptions{} + for _, opt := range opts { + if err := opt(&cfg); err != nil { + return nil, err + } + } + if err := cfg.Resolve(); err != nil { + return nil, err + } + userAgent := func() (string, error) { + info, err := clientinfo.Default().With( + internal.ModuleName, internal.Version, + "auth", cfg.Credentials.Name(), + ) + if err != nil { + return "", err + } + return info.String(), nil + } + + return &Client{ + internalClient: internalClient{ + httpClient: cfg.HTTPClient, + callTimeout: cfg.Timeout, + credentials: cfg.Credentials, + logger: cfg.Logger, + userAgent: userAgent, + host: cfg.Host, + workspaceID: cfg.WorkspaceID, + accountID: cfg.AccountID, + }, + }, nil +} + +// Approves migration execution at the MIGRATION_REVIEW gate, advancing to +// execution. +// +// Valid only when the migration is in MIGRATION_REVIEW. If supplied, the `etag` +// must match the current server value. +// +// Returns NOT_FOUND if the migration does not exist. Returns +// FAILED_PRECONDITION if the migration is not in MIGRATION_REVIEW. Returns +// ABORTED if the etag does not match the current resource version. +func (c *internalClient) ApproveMigrationExecution(ctx context.Context, req ApproveMigrationExecutionRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := approveMigrationExecutionRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + pb.literal("/approveExecution") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Approves the working copy at the TRANSLATION_READY gate. If the migration was +// created with `run_validation`, the working copy is then run to verify it +// executes successfully before the migration is presented for execution review; +// otherwise it advances straight to MIGRATION_REVIEW. +// +// Valid only when the migration is in TRANSLATION_READY. If supplied, the +// `etag` must match the current server value. +// +// Returns NOT_FOUND if the migration does not exist. Returns +// FAILED_PRECONDITION if the migration is not in TRANSLATION_READY. Returns +// ABORTED if the etag does not match the current resource version. +func (c *internalClient) ApproveMigrationTranslation(ctx context.Context, req ApproveMigrationTranslationRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := approveMigrationTranslationRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + pb.literal("/approveTranslation") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Cancels the migration, transitioning it to CANCELLED. +// +// Valid from any non-terminal state, unlike the review-gate transitions, which +// each require a specific state. Any in-flight agent work is abandoned and the +// migration stops advancing. The resource is retained for auditability. +// +// Returns NOT_FOUND if the migration does not exist. Returns +// FAILED_PRECONDITION if the migration is already in a terminal state. Returns +// ABORTED if the etag does not match the current resource version. +func (c *internalClient) CancelMigration(ctx context.Context, req CancelMigrationRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := cancelMigrationRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + pb.literal("/cancel") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Creates a new migration for a Classic compute asset. +// +// The migration is created in PLANNING_PENDING and advances through the state +// machine as planning work is scheduled. The caller must have appropriate +// permissions: workspace admin for infrastructure-scoped migrations, job +// owner/admin for individual workload migrations. +// +// At most one migration may hold an asset. Returns ALREADY_EXISTS if the asset +// has a migration in flight, or one that already migrated it successfully; a +// migration that ended without succeeding, or was deleted, releases the asset +// so it can be migrated again. Returns INVALID_PARAMETER_VALUE if the asset is +// not eligible for migration. +func (c *internalClient) CreateMigration(ctx context.Context, req CreateMigrationRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := createMigrationRequestToWire(&req) + if err != nil { + return nil, err + } + if wireReq.RequestId == nil || *wireReq.RequestId == "" { + wireReq.RequestId = new(generateRequestID()) + } + body, err := json.Marshal(wireReq.Migration) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + baseURL.Path = "/api/compute-migrations/v1/migrations" + queryParams := url.Values{} + if err := addQueryValue(queryParams, "request_id", wireReq.RequestId); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Deletes a migration (soft-delete). +// +// Allowed from any state. Deleting a migration marks the record deleted only +// — it does not roll back a migration that already ran, and resources created +// during the migration are not cleaned up. The migration resource is retained +// for auditability. To stop an in-flight migration (agent teardown, transition +// to CANCELLED), use CancelMigration instead. +// +// Returns NOT_FOUND if the migration does not exist, or was already deleted: a +// deleted migration is hidden from every method (Get, Update, List, and +// Delete), so it cannot be deleted again. Returns ABORTED if a supplied +// nonempty request etag does not match the resource version. +func (c *internalClient) DeleteMigration(ctx context.Context, req DeleteMigrationRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := deleteMigrationRequestToWire(&req) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "etag", wireReq.Etag); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "DELETE", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Retrieves a migration by its ID. +// +// Returns the current state, configuration, and output artifacts of the +// migration. Use this to poll migration progress or inspect artifacts after +// state transitions. Returns NOT_FOUND if the migration does not exist in the +// caller's workspace. +func (c *internalClient) GetMigration(ctx context.Context, req GetMigrationRequest, opts ...call.Option) (*Migration, error) { + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Lists migrations in the caller's workspace, ordered by migration ID, with +// cursor-based pagination and filtering by asset type and state. +// +// Eventually consistent: results are read from a cache, and pagination is not a +// point-in-time snapshot, so a migration created during a List may not appear +// until a subsequent one. +func (c *internalClient) ListMigrations(ctx context.Context, req ListMigrationsRequest, opts ...call.Option) (*ListMigrationsResponse, error) { + wireReq, err := listMigrationsRequestToWire(&req) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + baseURL.Path = "/api/compute-migrations/v1/migrations" + queryParams := url.Values{} + if err := addQueryValue(queryParams, "page_size", wireReq.PageSize); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "page_token", wireReq.PageToken); err != nil { + return nil, err + } + if wireReq.AssetType != "" { + if err := addQueryValue(queryParams, "asset_type", wireReq.AssetType); err != nil { + return nil, err + } + } + if err := addQueryValue(queryParams, "states", wireReq.States); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *ListMigrationsResponse + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp listMigrationsResponseWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = listMigrationsResponseFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// ListMigrationsIter returns an iterator that iterates +// over the results of ListMigrations. +// +// For example: +// +// for item, err := range c.ListMigrationsIter(ctx, ListMigrationsRequest{}) { +// if err != nil { +// return err +// } +// fmt.Println(item) +// } +// +// Options opts are passed to each ListMigrations call +// made by the iterator under the hood. +// +// Callers who need custom pagination logic should use +// ListMigrations directly. +func (c *internalClient) ListMigrationsIter(ctx context.Context, req ListMigrationsRequest, opts ...call.Option) iter.Seq2[*Migration, error] { + return func(yield func(*Migration, error) bool) { + // Keep pagination state local to this traversal so reusing the iterator starts + // from the original request. Reference-bearing fields remain shared and read-only. + pageReq := req + for { + resp, err := c.ListMigrations(ctx, pageReq, opts...) + if err != nil { + yield(nil, err) + return + } + for i := range resp.Migrations { + if !yield(&resp.Migrations[i], nil) { + return + } + } + if resp.NextPageToken == nil || *resp.NextPageToken == "" { + return + } + pageReq.PageToken = resp.NextPageToken + } + } +} + +// Rejects migration execution at the MIGRATION_REVIEW gate, sending the +// migration to REVISION_PENDING to loop back for re-planning. +// +// Valid only when the migration is in MIGRATION_REVIEW. If supplied, the `etag` +// must match the current server value. +// +// Returns NOT_FOUND if the migration does not exist. Returns +// FAILED_PRECONDITION if the migration is not in MIGRATION_REVIEW. Returns +// ABORTED if the etag does not match the current resource version. +func (c *internalClient) RejectMigrationExecution(ctx context.Context, req RejectMigrationExecutionRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := rejectMigrationExecutionRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + pb.literal("/rejectExecution") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Rejects the working copy at the TRANSLATION_READY gate, sending the migration +// to REVISION_PENDING to loop back for re-planning. +// +// Valid only when the migration is in TRANSLATION_READY. If supplied, the +// `etag` must match the current server value. +// +// Returns NOT_FOUND if the migration does not exist. Returns +// FAILED_PRECONDITION if the migration is not in TRANSLATION_READY. Returns +// ABORTED if the etag does not match the current resource version. +func (c *internalClient) RejectMigrationTranslation(ctx context.Context, req RejectMigrationTranslationRequest, opts ...call.Option) (*Migration, error) { + wireReq, err := rejectMigrationTranslationRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/compute-migrations/v1/migrations/") + if req.MigrationId == nil { + return nil, fmt.Errorf("path parameter %q is required", "migration_id") + } + pb.singleSegment(*req.MigrationId) + pb.literal("/rejectTranslation") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Migration + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp migrationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = migrationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} diff --git a/computemigrations/v1/genhelper.go b/computemigrations/v1/genhelper.go new file mode 100644 index 00000000..27fec022 --- /dev/null +++ b/computemigrations/v1/genhelper.go @@ -0,0 +1,253 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package computemigrations + +import ( + "bytes" + "context" + "crypto/rand" + "encoding/json" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "strings" + "time" + + "github.com/databricks/sdk-go/auth" + "github.com/databricks/sdk-go/core/apierr" + "github.com/databricks/sdk-go/core/ops" + "github.com/databricks/sdk-go/options/call" + "github.com/databricks/sdk-go/options/internaloptions" +) + +type httpCallOptions struct { + req *http.Request + client *http.Client + logger *slog.Logger +} + +type httpRequestOptions struct { + Method string + URL string + Credentials auth.Credentials + UserAgent func() (string, error) + Headers http.Header + Body io.Reader +} + +func newHTTPRequest(ctx context.Context, opts httpRequestOptions) (*http.Request, error) { + req, err := http.NewRequestWithContext(ctx, opts.Method, opts.URL, opts.Body) + if err != nil { + closeBody(opts.Body) + return nil, err + } + + req.Header = opts.Headers.Clone() + if opts.Credentials != nil { + headers, err := opts.Credentials.AuthHeaders(ctx) + if err != nil { + closeBody(opts.Body) + return nil, err + } + for _, h := range headers { + req.Header.Add(h.Key, h.Value) + } + } + if opts.UserAgent != nil { + userAgent, err := opts.UserAgent() + if err != nil { + closeBody(opts.Body) + return nil, err + } + if userAgent != "" { + req.Header.Set("User-Agent", userAgent) + } + } + + return req, nil +} + +func closeBody(body io.Reader) { + if body == nil { + return + } + if rc, ok := body.(io.ReadCloser); ok { + _ = rc.Close() + } +} + +// lazyRequest implements slog.LogValuer for lazy evaluation of request +// logging. +type lazyRequest struct{ req *http.Request } + +func (r lazyRequest) LogValue() slog.Value { + return slog.GroupValue( + slog.String("method", r.req.Method), + slog.String("url", r.req.URL.String()), + ) +} + +// lazyResponse implements slog.LogValuer for lazy evaluation of response +// logging. +type lazyResponse struct { + resp *http.Response + body []byte +} + +func (r lazyResponse) LogValue() slog.Value { + return slog.GroupValue( + slog.Int("status", r.resp.StatusCode), + slog.String("body", string(r.body)), + ) +} + +// executeHTTPCall executes an HTTP call and returns the response body and +// headers, or an error. The headers are returned so callers can populate +// header-mapped response fields alongside the JSON body. This function takes +// care of logging the request and response. +func executeHTTPCall(opts httpCallOptions) ([]byte, http.Header, error) { + opts.logger.Debug("HTTP request", "request", lazyRequest{opts.req}) + resp, err := opts.client.Do(opts.req) + if err != nil { + return nil, nil, err + } + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, nil}) + return nil, nil, err + } + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, body}) + if err := apierr.FromHTTPError(resp.StatusCode, resp.Header, body); err != nil { + return nil, nil, err + } + return body, resp.Header, nil +} + +func (c *internalClient) resolveCallOptions( + opts []call.Option, + timeout time.Duration, +) (internaloptions.CallOptions, error) { + cfg := internaloptions.CallOptions{Timeout: timeout} + if c.callTimeout != nil { + cfg.Timeout = *c.callTimeout + } + for _, opt := range opts { + if err := opt(&cfg); err != nil { + return internaloptions.CallOptions{}, err + } + } + return cfg, nil +} + +func (c *internalClient) executeCall( + ctx context.Context, + op func(context.Context) error, + opts []call.Option, +) error { + cfg, err := c.resolveCallOptions(opts, 5*time.Minute) + if err != nil { + return err + } + return executeResolvedCall(ctx, op, cfg) +} + +func executeResolvedCall(ctx context.Context, op func(context.Context) error, cfg internaloptions.CallOptions) error { + return ops.Execute(ctx, op, + ops.WithRetrier(cfg.Retrier), + ops.WithLimiter(cfg.RateLimiter), + ops.WithTimeout(cfg.Timeout), + ) +} + +func addQueryValue(params url.Values, key string, value any) error { + data, err := json.Marshal(value) + if err != nil { + return err + } + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.UseNumber() + var decoded any + if err := decoder.Decode(&decoded); err != nil { + return err + } + flattenQueryValue(params, key, decoded) + return nil +} + +func flattenQueryValue(params url.Values, key string, value any) { + switch value := value.(type) { + case nil: + // JSON null represents an absent query value. + case map[string]any: + for childKey, child := range value { + flattenQueryValue(params, key+"."+childKey, child) + } + case []any: + for _, item := range value { + params.Add(key, fmt.Sprintf("%v", item)) + } + default: + params.Add(key, fmt.Sprintf("%v", value)) + } +} + +// generateRequestID returns a random RFC 4122 version 4 UUID string, used as an +// idempotency token when the caller does not supply one. It uses crypto/rand to +// avoid a UUID dependency; a read failure is treated as unrecoverable. +func generateRequestID() string { + var b [16]byte + if _, err := rand.Read(b[:]); err != nil { + panic(fmt.Sprintf("generate request id: %v", err)) + } + b[6] = (b[6] & 0x0f) | 0x40 // version 4 + b[8] = (b[8] & 0x3f) | 0x80 // variant 10 + return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]) +} + +// pathBuilder assembles request paths so "/" in parameter values remains a +// path separator while characters that cannot appear literally in a URL path +// are percent-encoded when the request URL is serialized. +// +// It builds url.URL.Path and url.URL.RawPath together. net/url uses RawPath only +// when it is a valid encoding of Path; otherwise it escapes Path. +type pathBuilder struct { + path strings.Builder + raw strings.Builder +} + +// literal appends a static path segment, identical on the decoded and escaped +// paths. +func (b *pathBuilder) literal(s string) { + b.path.WriteString(s) + b.raw.WriteString(s) +} + +// singleSegment appends the value unchanged to Path and RawPath. When the URL +// is serialized, net/url keeps "/" literal and percent-encodes characters such +// as spaces, "?", and "#". +// The value is formatted with %v so strings, enums, and numbers all work. +func (b *pathBuilder) singleSegment(v any) { + s := fmt.Sprintf("%v", v) + b.path.WriteString(s) + b.raw.WriteString(s) +} + +// multiSegments appends a multi-segment path parameter: the value spans several +// path segments, so each segment is escaped but the "/" separators are kept. +// The value is formatted with %v so strings, enums, and numbers all work. +func (b *pathBuilder) multiSegments(v any) { + s := fmt.Sprintf("%v", v) + b.path.WriteString(s) + segments := strings.Split(s, "/") + for i, seg := range segments { + segments[i] = url.PathEscape(seg) + } + b.raw.WriteString(strings.Join(segments, "/")) +} + +func (b *pathBuilder) build() (path, rawPath string) { + return b.path.String(), b.raw.String() +} diff --git a/computemigrations/v1/model.go b/computemigrations/v1/model.go new file mode 100644 index 00000000..c5e7bc4b --- /dev/null +++ b/computemigrations/v1/model.go @@ -0,0 +1,327 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package computemigrations + +import ( + "github.com/databricks/sdk-go/core/types" +) + +// Type of a migration asset: the Classic asset being migrated, or an asset the +// migration agent created for it. Migrations can only be created for JOB +// assets. +type Migration_AssetType string + +const ( + Migration_AssetType_Unspecified Migration_AssetType = "" + // A Databricks job. + Migration_AssetType_Job Migration_AssetType = "JOB" + // A Databricks Interactive notebook. + Migration_AssetType_Interactive Migration_AssetType = "INTERACTIVE" + // A workspace file. + Migration_AssetType_File Migration_AssetType = "FILE" +) + +// Role of the migration initiator, determining approval authority. +type Migration_Initiator_Role string + +const ( + Migration_Initiator_Role_Unspecified Migration_Initiator_Role = "" + // A workspace administrator. + Migration_Initiator_Role_WorkspaceAdmin Migration_Initiator_Role = "WORKSPACE_ADMIN" + // A job administrator or owner. + Migration_Initiator_Role_JobAdmin Migration_Initiator_Role = "JOB_ADMIN" + // An account administrator. + Migration_Initiator_Role_AccountAdmin Migration_Initiator_Role = "ACCOUNT_ADMIN" + // System-initiated migration (e.g., campaign-driven). + Migration_Initiator_Role_System Migration_Initiator_Role = "SYSTEM" +) + +// The state of a migration in its lifecycle. +type Migration_State string + +const ( + Migration_State_Unspecified Migration_State = "" + // Migration created. Pending planning-work scheduling. + Migration_State_PlanningPending Migration_State = "PLANNING_PENDING" + // Planning work is scheduled and actively running. + Migration_State_PlanningRunning Migration_State = "PLANNING_RUNNING" + // Legacy state retained for compatibility; not entered by the scheduler. + Migration_State_PlanningReview Migration_State = "PLANNING_REVIEW" + // User rejected the current plan and requested changes; the migration loops + // back for re-planning. + Migration_State_RevisionPending Migration_State = "REVISION_PENDING" + // User accepted the plan. Pending translation scheduling, where the workload is + // translated into a working copy. + Migration_State_TranslationPending Migration_State = "TRANSLATION_PENDING" + // The workload is being translated into a working copy. + Migration_State_TranslationCreating Migration_State = "TRANSLATION_CREATING" + // The working copy is ready for the user to review before it is validated. + Migration_State_TranslationReady Migration_State = "TRANSLATION_READY" + // User finished validating the artifacts. Presented for review; the user can + // confirm migration execution or request changes. + Migration_State_MigrationReview Migration_State = "MIGRATION_REVIEW" + // User confirmed migration execution. Pending execution scheduling. + Migration_State_MigrationPending Migration_State = "MIGRATION_PENDING" + // Migration execution is scheduled and actively running. + Migration_State_MigrationRunning Migration_State = "MIGRATION_RUNNING" + // Migration successfully executed. Under observation for the rollback-eligible + // baking period. + Migration_State_MigrationObservation Migration_State = "MIGRATION_OBSERVATION" + // The baking / rollback-eligible period has passed. The migration is complete. + Migration_State_MigrationComplete Migration_State = "MIGRATION_COMPLETE" + // Migration planning determined the workload ineligible for migration due to a + // non-resolvable incompatibility (e.g. feature gap, missing workspace admin + // action). + Migration_State_NotSupported Migration_State = "NOT_SUPPORTED" + // Encountered a fatal error during the current state. + Migration_State_Failed Migration_State = "FAILED" + // User cancelled the migration. + Migration_State_Cancelled Migration_State = "CANCELLED" + // Working copy submitted for a validation run to verify it executes + // successfully. Follows TRANSLATION_READY. + Migration_State_ValidationScheduling Migration_State = "VALIDATION_SCHEDULING" + // The validation run is executing. On success the migration advances to + // MIGRATION_REVIEW; on failure it returns to REVISION_PENDING. + Migration_State_ValidationRunning Migration_State = "VALIDATION_RUNNING" +) + +// A request to approve migration execution at the MIGRATION_REVIEW gate.. +type ApproveMigrationExecutionRequest struct { + // The ID of the migration to approve for execution. + MigrationId *string + // Optional resource version for optimistic concurrency control. If supplied, it + // must match the current server value. + Etag *string + // Optional free-text feedback or instructions the user provides along with the + // approval, carried into the next stage of the migration. + AdditionalFeedback *string +} + +// A request to approve the working copy at the TRANSLATION_READY gate.. +type ApproveMigrationTranslationRequest struct { + // The ID of the migration to approve. + MigrationId *string + // Optional resource version for optimistic concurrency control. If supplied, it + // must match the current server value. + Etag *string + // Optional free-text feedback or instructions the user provides along with the + // approval, carried into the next stage of the migration. + AdditionalFeedback *string +} + +// Configuration for the baking window (post-execution production monitoring).. +type BakingConfig struct { + // Number of successful production runs required before the migration reaches + // MIGRATION_COMPLETE. Default applied by the server (configurable). + RunCount *int + // Maximum baking window duration in hours. If the required run_count has not + // been reached within this window, the migration transitions to FAILED. Default + // applied by the server (configurable). + TimeWindowHours *int +} + +// Summary of baking metrics after the baking window completes.. +type BakingReport struct { + // Number of runs observed during the baking window. + TotalRuns *int + // Number of successful runs. + SuccessfulRuns *int +} + +// A request to cancel a migration from any non-terminal state.. +type CancelMigrationRequest struct { + // The ID of the migration to cancel. + MigrationId *string + // Optional resource version for optimistic concurrency control. If supplied, it + // must match the current server value. + Etag *string + // Optional free-text reason for the cancellation. + CancellationReason *string +} + +// A request to create a new migration.. +type CreateMigrationRequest struct { + // The migration to create. The server generates `migration_id` and sets `state` + // to PLANNING_PENDING. Required fields: `asset_type`, `asset_uri`. + Migration *Migration + // Client-generated request ID for idempotent request deduplication. The server + // de-duplicates requests with the same request_id for at least 24 hours, + // returning the existing migration instead of creating a duplicate. + RequestId *string +} + +// A request to cancel (soft-delete) a migration.. +type DeleteMigrationRequest struct { + // The ID of the migration to cancel. + MigrationId *string + // If nonempty, must match the current resource etag or the request fails with + // ABORTED. + Etag *string +} + +// A request to retrieve a Migration.. +type GetMigrationRequest struct { + // The ID of the migration to retrieve. + MigrationId *string +} + +// A request to list migrations in the caller's workspace.. +type ListMigrationsRequest struct { + // Maximum number of migrations to return. Default: 50, maximum: 1000. + PageSize *int + // Page token from a previous ListMigrations call. When paginating, all other + // parameters must match the call that provided the page token. + PageToken *string + // Filter by asset type. + AssetType Migration_AssetType + // Filter by migration state. Returns migrations in any of the specified states. + States []Migration_State +} + +// Response containing a paginated list of migrations matching the request +// filters.. +type ListMigrationsResponse struct { + // The migrations matching the request filters. + Migrations []Migration + // Token for the next page. Omitted if there are no more results. + NextPageToken *string +} + +// A persistent object tracking the full lifecycle of migrating one Classic +// compute asset to Serverless. Each Migration has a well-defined state machine +// and is the unit of orchestration, approval, and rollback.. +type Migration struct { + // Server-generated unique identifier for this migration. + MigrationId *string + // Type of Classic compute asset being migrated. Cannot be changed after + // creation. + AssetType Migration_AssetType + // URI of the source asset (e.g., "jobs/12345"). Cannot be changed after + // creation. + AssetUri *string + // Current state of the migration in the state machine. Managed by the server. + State Migration_State + // The user who initiated this migration and their role. Set at creation. + Initiator *Migration_Initiator + // Agent-produced validation results from sandbox execution. + ValidationReport *ValidationReport + // Baking window configuration. Mutable via UpdateMigration before baking + // starts. + BakingConfig *BakingConfig + // Timestamp when the migration was created. + CreateTime *types.Time + // Summary of baking metrics after the baking window completes. + BakingReport *BakingReport + // History of state transitions, ordered chronologically. Each entry records the + // state entered and the timestamp of the transition. + StateHistory []Migration_StateTransition + // Resource version for optimistic concurrency control. Clients read this from + // GetMigration or ListMigrations and pass it back as the request `etag` on + // update, delete, approve, reject, and cancel methods. + Etag *string + // When true, the server skips the translation review (TRANSLATION_READY) + // instead of waiting for an explicit ApproveMigrationTranslation. + // MIGRATION_REVIEW is never skipped. Unset/false means the translation review + // requires explicit user action. Set at creation; cannot be changed afterward. + // Does not suppress cancellation or terminal failures. + AutoApprove *bool + // Agent-produced planning report, presented to the user at the review gates. + MigrationReport *MigrationReport + // When true, Databricks runs the working copy to validate it after the + // translation review. Unset/false skips the run, so the migration goes from the + // translation review straight to execution review. Whether the translation + // review waits for the user is controlled by `auto_approve`, not this field. + // Set at creation; cannot be changed afterward. + RunValidation *bool +} + +// The initiator of a migration, including their role and user identity.. +type Migration_Initiator struct { + // The role of the initiator, determining approval authority. Set by the server: + // the role is resolved from the caller's identity and permissions on the asset, + // never taken from the request, since a caller must not be able to assert its + // own approval authority. + Role Migration_Initiator_Role + // The user ID of the initiator. Set by the server from the request context. + UserId *int64 +} + +// A record of a state transition in the migration lifecycle.. +type Migration_StateTransition struct { + // The state that was entered. + State Migration_State + // Timestamp when this state was entered. + TransitionTime *types.Time + // Free-text the initiating user supplied at a user-driven transition — + // reviewer feedback on an approval, or the reason for a rejection or + // cancellation. Empty for transitions the service drives internally. + UserComment *string + // Free-text the service recorded for this transition — e.g. an + // internally-determined cancellation or failure reason. Empty for user-driven + // transitions. + InternalComment *string +} + +// A working copy (job or notebook) the migration agent created for the +// migration.. +type MigrationAsset struct { + // Type of asset this working copy represents. + AssetType Migration_AssetType + // Link to the asset, e.g. "jobs/12345". + Uri *string + // Identifier of the asset. + Id *string +} + +// Agent-produced planning report, presented to the user at the review gates.. +type MigrationReport struct { + // The primary asset the agent created — the entry point / validation target. + PrimaryAsset *MigrationAsset + // Additional assets the agent created (e.g. notebooks or jobs the primary asset + // invokes). + SecondaryAssets []MigrationAsset +} + +// A request to reject migration execution at the MIGRATION_REVIEW gate, looping +// back to REVISION_PENDING.. +type RejectMigrationExecutionRequest struct { + // The ID of the migration to reject. + MigrationId *string + // Optional resource version for optimistic concurrency control. If supplied, it + // must match the current server value. + Etag *string + // Required free-text reason for the rejection, fed back into re-planning so the + // next plan can address the user's concerns. + RejectionReason *string +} + +// A request to reject the working copy at the TRANSLATION_READY gate, looping +// back to REVISION_PENDING.. +type RejectMigrationTranslationRequest struct { + // The ID of the migration to reject. + MigrationId *string + // Optional resource version for optimistic concurrency control. If supplied, it + // must match the current server value. + Etag *string + // Required free-text reason for the rejection, fed back into re-planning so the + // next plan can address the user's concerns. + RejectionReason *string +} + +// Validation results from running the translated workload in the sandbox.. +type ValidationReport struct { + // Databricks-internal recommendation on whether to proceed with the migration, + // based on the validation run. May differ from run_status: a run can succeed + // while the recommendation is negative, or vice versa. + Passed *bool + // Duration of the sandbox validation run in milliseconds. Pair with start_time + // to derive the end time. + DurationMs *int64 + // Timestamp when validation started in the sandbox. + StartTime *types.Time + // Status of the validation run itself (the objective run outcome), as reported + // by the run system, e.g. "SUCCESS" / "FAILED" / "TIMED_OUT". + RunStatus *string + // Link to the validation run (job or notebook). + RunUrl *string +} diff --git a/computemigrations/v1/wire.go b/computemigrations/v1/wire.go new file mode 100644 index 00000000..d9df0379 --- /dev/null +++ b/computemigrations/v1/wire.go @@ -0,0 +1,561 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package computemigrations + +import ( + "bytes" + "encoding/json" + "fmt" + "strconv" + + "github.com/databricks/sdk-go/core/types" +) + +type wireInt64 int64 + +func (v *wireInt64) UnmarshalJSON(data []byte) error { + data = bytes.TrimSpace(data) + if string(data) == "null" { + return fmt.Errorf("parse int64: null is not valid") + } + if len(data) > 0 && data[0] == '"' { + var text string + if err := json.Unmarshal(data, &text); err != nil { + return err + } + parsed, err := strconv.ParseInt(text, 10, 64) + if err != nil { + return fmt.Errorf("parse int64 %q: %w", text, err) + } + *v = wireInt64(parsed) + return nil + } + var parsed int64 + if err := json.Unmarshal(data, &parsed); err != nil { + return err + } + *v = wireInt64(parsed) + return nil +} + +func int64ToWire(v *int64) (*wireInt64, error) { + if v == nil { + return nil, nil + } + converted := wireInt64(*v) + return &converted, nil +} + +func int64FromWire(v *wireInt64) (*int64, error) { + if v == nil { + return nil, nil + } + converted := int64(*v) + return &converted, nil +} + +type approveMigrationExecutionRequestWire struct { + MigrationId *string `json:"migration_id,omitempty"` + Etag *string `json:"etag,omitempty"` + AdditionalFeedback *string `json:"additional_feedback,omitempty"` +} + +func approveMigrationExecutionRequestToWire(v *ApproveMigrationExecutionRequest) (*approveMigrationExecutionRequestWire, error) { + if v == nil { + return nil, nil + } + return &approveMigrationExecutionRequestWire{ + MigrationId: v.MigrationId, + Etag: v.Etag, + AdditionalFeedback: v.AdditionalFeedback, + }, nil +} + +type approveMigrationTranslationRequestWire struct { + MigrationId *string `json:"migration_id,omitempty"` + Etag *string `json:"etag,omitempty"` + AdditionalFeedback *string `json:"additional_feedback,omitempty"` +} + +func approveMigrationTranslationRequestToWire(v *ApproveMigrationTranslationRequest) (*approveMigrationTranslationRequestWire, error) { + if v == nil { + return nil, nil + } + return &approveMigrationTranslationRequestWire{ + MigrationId: v.MigrationId, + Etag: v.Etag, + AdditionalFeedback: v.AdditionalFeedback, + }, nil +} + +type bakingConfigWire struct { + RunCount *int `json:"run_count,omitempty"` + TimeWindowHours *int `json:"time_window_hours,omitempty"` +} + +func bakingConfigToWire(v *BakingConfig) (*bakingConfigWire, error) { + if v == nil { + return nil, nil + } + return &bakingConfigWire{ + RunCount: v.RunCount, + TimeWindowHours: v.TimeWindowHours, + }, nil +} + +func bakingConfigFromWire(w *bakingConfigWire) (*BakingConfig, error) { + if w == nil { + return nil, nil + } + return &BakingConfig{ + RunCount: w.RunCount, + TimeWindowHours: w.TimeWindowHours, + }, nil +} + +type bakingReportWire struct { + TotalRuns *int `json:"total_runs,omitempty"` + SuccessfulRuns *int `json:"successful_runs,omitempty"` +} + +func bakingReportToWire(v *BakingReport) (*bakingReportWire, error) { + if v == nil { + return nil, nil + } + return &bakingReportWire{ + TotalRuns: v.TotalRuns, + SuccessfulRuns: v.SuccessfulRuns, + }, nil +} + +func bakingReportFromWire(w *bakingReportWire) (*BakingReport, error) { + if w == nil { + return nil, nil + } + return &BakingReport{ + TotalRuns: w.TotalRuns, + SuccessfulRuns: w.SuccessfulRuns, + }, nil +} + +type cancelMigrationRequestWire struct { + MigrationId *string `json:"migration_id,omitempty"` + Etag *string `json:"etag,omitempty"` + CancellationReason *string `json:"cancellation_reason,omitempty"` +} + +func cancelMigrationRequestToWire(v *CancelMigrationRequest) (*cancelMigrationRequestWire, error) { + if v == nil { + return nil, nil + } + return &cancelMigrationRequestWire{ + MigrationId: v.MigrationId, + Etag: v.Etag, + CancellationReason: v.CancellationReason, + }, nil +} + +type createMigrationRequestWire struct { + Migration *migrationWire `json:"migration,omitempty"` + RequestId *string `json:"request_id,omitempty"` +} + +func createMigrationRequestToWire(v *CreateMigrationRequest) (*createMigrationRequestWire, error) { + if v == nil { + return nil, nil + } + migrationWireValue, err := migrationToWire(v.Migration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMigrationRequest.Migration", err) + } + return &createMigrationRequestWire{ + Migration: migrationWireValue, + RequestId: v.RequestId, + }, nil +} + +type deleteMigrationRequestWire struct { + MigrationId *string `json:"migration_id,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +func deleteMigrationRequestToWire(v *DeleteMigrationRequest) (*deleteMigrationRequestWire, error) { + if v == nil { + return nil, nil + } + return &deleteMigrationRequestWire{ + MigrationId: v.MigrationId, + Etag: v.Etag, + }, nil +} + +type listMigrationsRequestWire struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + AssetType Migration_AssetType `json:"asset_type,omitempty"` + States []Migration_State `json:"states,omitempty"` +} + +func listMigrationsRequestToWire(v *ListMigrationsRequest) (*listMigrationsRequestWire, error) { + if v == nil { + return nil, nil + } + return &listMigrationsRequestWire{ + PageSize: v.PageSize, + PageToken: v.PageToken, + AssetType: v.AssetType, + States: v.States, + }, nil +} + +type listMigrationsResponseWire struct { + Migrations []migrationWire `json:"migrations,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +func listMigrationsResponseFromWire(w *listMigrationsResponseWire) (*ListMigrationsResponse, error) { + if w == nil { + return nil, nil + } + migrationsPublicValue, err := convertSlice(w.Migrations, migrationFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMigrationsResponse.Migrations", err) + } + return &ListMigrationsResponse{ + Migrations: migrationsPublicValue, + NextPageToken: w.NextPageToken, + }, nil +} + +type migrationWire struct { + MigrationId *string `json:"migration_id,omitempty"` + AssetType Migration_AssetType `json:"asset_type,omitempty"` + AssetUri *string `json:"asset_uri,omitempty"` + State Migration_State `json:"state,omitempty"` + Initiator *migration_InitiatorWire `json:"initiator,omitempty"` + ValidationReport *validationReportWire `json:"validation_report,omitempty"` + BakingConfig *bakingConfigWire `json:"baking_config,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + BakingReport *bakingReportWire `json:"baking_report,omitempty"` + StateHistory []migration_StateTransitionWire `json:"state_history,omitempty"` + Etag *string `json:"etag,omitempty"` + AutoApprove *bool `json:"auto_approve,omitempty"` + MigrationReport *migrationReportWire `json:"migration_report,omitempty"` + RunValidation *bool `json:"run_validation,omitempty"` +} + +func migrationToWire(v *Migration) (*migrationWire, error) { + if v == nil { + return nil, nil + } + initiatorWireValue, err := migration_InitiatorToWire(v.Initiator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.Initiator", err) + } + validationReportWireValue, err := validationReportToWire(v.ValidationReport) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.ValidationReport", err) + } + bakingConfigWireValue, err := bakingConfigToWire(v.BakingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.BakingConfig", err) + } + bakingReportWireValue, err := bakingReportToWire(v.BakingReport) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.BakingReport", err) + } + stateHistoryWireValue, err := convertSlice(v.StateHistory, migration_StateTransitionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.StateHistory", err) + } + migrationReportWireValue, err := migrationReportToWire(v.MigrationReport) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.MigrationReport", err) + } + return &migrationWire{ + MigrationId: v.MigrationId, + AssetType: v.AssetType, + AssetUri: v.AssetUri, + State: v.State, + Initiator: initiatorWireValue, + ValidationReport: validationReportWireValue, + BakingConfig: bakingConfigWireValue, + CreateTime: v.CreateTime, + BakingReport: bakingReportWireValue, + StateHistory: stateHistoryWireValue, + Etag: v.Etag, + AutoApprove: v.AutoApprove, + MigrationReport: migrationReportWireValue, + RunValidation: v.RunValidation, + }, nil +} + +func migrationFromWire(w *migrationWire) (*Migration, error) { + if w == nil { + return nil, nil + } + initiatorPublicValue, err := migration_InitiatorFromWire(w.Initiator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.Initiator", err) + } + validationReportPublicValue, err := validationReportFromWire(w.ValidationReport) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.ValidationReport", err) + } + bakingConfigPublicValue, err := bakingConfigFromWire(w.BakingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.BakingConfig", err) + } + bakingReportPublicValue, err := bakingReportFromWire(w.BakingReport) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.BakingReport", err) + } + stateHistoryPublicValue, err := convertSlice(w.StateHistory, migration_StateTransitionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.StateHistory", err) + } + migrationReportPublicValue, err := migrationReportFromWire(w.MigrationReport) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration.MigrationReport", err) + } + return &Migration{ + MigrationId: w.MigrationId, + AssetType: w.AssetType, + AssetUri: w.AssetUri, + State: w.State, + Initiator: initiatorPublicValue, + ValidationReport: validationReportPublicValue, + BakingConfig: bakingConfigPublicValue, + CreateTime: w.CreateTime, + BakingReport: bakingReportPublicValue, + StateHistory: stateHistoryPublicValue, + Etag: w.Etag, + AutoApprove: w.AutoApprove, + MigrationReport: migrationReportPublicValue, + RunValidation: w.RunValidation, + }, nil +} + +type migration_InitiatorWire struct { + Role Migration_Initiator_Role `json:"role,omitempty"` + UserId *wireInt64 `json:"user_id,omitempty"` +} + +func migration_InitiatorToWire(v *Migration_Initiator) (*migration_InitiatorWire, error) { + if v == nil { + return nil, nil + } + userIdWireValue, err := int64ToWire(v.UserId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration_Initiator.UserId", err) + } + return &migration_InitiatorWire{ + Role: v.Role, + UserId: userIdWireValue, + }, nil +} + +func migration_InitiatorFromWire(w *migration_InitiatorWire) (*Migration_Initiator, error) { + if w == nil { + return nil, nil + } + userIdPublicValue, err := int64FromWire(w.UserId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Migration_Initiator.UserId", err) + } + return &Migration_Initiator{ + Role: w.Role, + UserId: userIdPublicValue, + }, nil +} + +type migration_StateTransitionWire struct { + State Migration_State `json:"state,omitempty"` + TransitionTime *types.Time `json:"transition_time,omitempty"` + UserComment *string `json:"user_comment,omitempty"` + InternalComment *string `json:"internal_comment,omitempty"` +} + +func migration_StateTransitionToWire(v *Migration_StateTransition) (*migration_StateTransitionWire, error) { + if v == nil { + return nil, nil + } + return &migration_StateTransitionWire{ + State: v.State, + TransitionTime: v.TransitionTime, + UserComment: v.UserComment, + InternalComment: v.InternalComment, + }, nil +} + +func migration_StateTransitionFromWire(w *migration_StateTransitionWire) (*Migration_StateTransition, error) { + if w == nil { + return nil, nil + } + return &Migration_StateTransition{ + State: w.State, + TransitionTime: w.TransitionTime, + UserComment: w.UserComment, + InternalComment: w.InternalComment, + }, nil +} + +type migrationAssetWire struct { + AssetType Migration_AssetType `json:"asset_type,omitempty"` + Uri *string `json:"uri,omitempty"` + Id *string `json:"id,omitempty"` +} + +func migrationAssetToWire(v *MigrationAsset) (*migrationAssetWire, error) { + if v == nil { + return nil, nil + } + return &migrationAssetWire{ + AssetType: v.AssetType, + Uri: v.Uri, + Id: v.Id, + }, nil +} + +func migrationAssetFromWire(w *migrationAssetWire) (*MigrationAsset, error) { + if w == nil { + return nil, nil + } + return &MigrationAsset{ + AssetType: w.AssetType, + Uri: w.Uri, + Id: w.Id, + }, nil +} + +type migrationReportWire struct { + PrimaryAsset *migrationAssetWire `json:"primary_asset,omitempty"` + SecondaryAssets []migrationAssetWire `json:"secondary_assets,omitempty"` +} + +func migrationReportToWire(v *MigrationReport) (*migrationReportWire, error) { + if v == nil { + return nil, nil + } + primaryAssetWireValue, err := migrationAssetToWire(v.PrimaryAsset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MigrationReport.PrimaryAsset", err) + } + secondaryAssetsWireValue, err := convertSlice(v.SecondaryAssets, migrationAssetToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MigrationReport.SecondaryAssets", err) + } + return &migrationReportWire{ + PrimaryAsset: primaryAssetWireValue, + SecondaryAssets: secondaryAssetsWireValue, + }, nil +} + +func migrationReportFromWire(w *migrationReportWire) (*MigrationReport, error) { + if w == nil { + return nil, nil + } + primaryAssetPublicValue, err := migrationAssetFromWire(w.PrimaryAsset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MigrationReport.PrimaryAsset", err) + } + secondaryAssetsPublicValue, err := convertSlice(w.SecondaryAssets, migrationAssetFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MigrationReport.SecondaryAssets", err) + } + return &MigrationReport{ + PrimaryAsset: primaryAssetPublicValue, + SecondaryAssets: secondaryAssetsPublicValue, + }, nil +} + +type rejectMigrationExecutionRequestWire struct { + MigrationId *string `json:"migration_id,omitempty"` + Etag *string `json:"etag,omitempty"` + RejectionReason *string `json:"rejection_reason,omitempty"` +} + +func rejectMigrationExecutionRequestToWire(v *RejectMigrationExecutionRequest) (*rejectMigrationExecutionRequestWire, error) { + if v == nil { + return nil, nil + } + return &rejectMigrationExecutionRequestWire{ + MigrationId: v.MigrationId, + Etag: v.Etag, + RejectionReason: v.RejectionReason, + }, nil +} + +type rejectMigrationTranslationRequestWire struct { + MigrationId *string `json:"migration_id,omitempty"` + Etag *string `json:"etag,omitempty"` + RejectionReason *string `json:"rejection_reason,omitempty"` +} + +func rejectMigrationTranslationRequestToWire(v *RejectMigrationTranslationRequest) (*rejectMigrationTranslationRequestWire, error) { + if v == nil { + return nil, nil + } + return &rejectMigrationTranslationRequestWire{ + MigrationId: v.MigrationId, + Etag: v.Etag, + RejectionReason: v.RejectionReason, + }, nil +} + +type validationReportWire struct { + Passed *bool `json:"passed,omitempty"` + DurationMs *wireInt64 `json:"duration_ms,omitempty"` + StartTime *types.Time `json:"start_time,omitempty"` + RunStatus *string `json:"run_status,omitempty"` + RunUrl *string `json:"run_url,omitempty"` +} + +func validationReportToWire(v *ValidationReport) (*validationReportWire, error) { + if v == nil { + return nil, nil + } + durationMsWireValue, err := int64ToWire(v.DurationMs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidationReport.DurationMs", err) + } + return &validationReportWire{ + Passed: v.Passed, + DurationMs: durationMsWireValue, + StartTime: v.StartTime, + RunStatus: v.RunStatus, + RunUrl: v.RunUrl, + }, nil +} + +func validationReportFromWire(w *validationReportWire) (*ValidationReport, error) { + if w == nil { + return nil, nil + } + durationMsPublicValue, err := int64FromWire(w.DurationMs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidationReport.DurationMs", err) + } + return &ValidationReport{ + Passed: w.Passed, + DurationMs: durationMsPublicValue, + StartTime: w.StartTime, + RunStatus: w.RunStatus, + RunUrl: w.RunUrl, + }, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/features/CHANGELOG.md b/features/CHANGELOG.md index 08473400..57046b4e 100644 --- a/features/CHANGELOG.md +++ b/features/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.14.0 (2026-11-02) + ## Release v0.13.0 (2026-10-29) ## Release v0.12.0 (2026-10-26) diff --git a/features/internal/version.go b/features/internal/version.go index 5caba768..668b23db 100644 --- a/features/internal/version.go +++ b/features/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-features" -const Version = "0.13.0" +const Version = "0.14.0" diff --git a/features/v1/client.go b/features/v1/client.go index 56e62f00..c9a6cb4e 100644 --- a/features/v1/client.go +++ b/features/v1/client.go @@ -2545,7 +2545,7 @@ func (o *UpdateMaterializationSetOperation) Wait(ctx context.Context, opts ...lr return result, nil } -// Update a materialized feature (pause/resume). +// Updates a materialized feature. func (c *internalClient) UpdateMaterializedFeature(ctx context.Context, req UpdateMaterializedFeatureRequest, opts ...call.Option) (*MaterializedFeature, error) { wireReq, err := updateMaterializedFeatureRequestToWire(&req) if err != nil { diff --git a/features/v1/model.go b/features/v1/model.go index 8990a84f..e6dbaf15 100644 --- a/features/v1/model.go +++ b/features/v1/model.go @@ -831,9 +831,12 @@ type AvgFunction struct { } type BackfillFeaturesRequest struct { - // Full names of the features to backfill. + // Full names of the features to backfill. All features must share the same + // interval between values and the same offset. The interval is the + // slide_duration of a sliding window or the window_duration of a tumbling + // window. FeatureFullNames []string - // Output ranges to backfill. + // Time ranges of source data to backfill. Ranges must not overlap. BackfillRanges []BackfillRange // Idempotency token for the request. RequestId *string @@ -859,18 +862,27 @@ type BackfillFeaturesResponse struct { type BackfillOperationMetadata struct { // Full names of the features targeted by the backfill. FeatureFullNames []string - // Output ranges targeted by the backfill. + // The requested time ranges, each aligned outward to the boundaries at which + // the features emit values. Ranges that overlap after alignment are combined + // into one. The backfill stops at the most recent materialized values, so a + // range may extend past the values that it recomputed. BackfillRanges []BackfillRange // Current state of the backfill. State BackfillOperationMetadata_State } -// A time range for a backfill.. +// A time range of source data for a backfill. The range is aligned outward to +// the boundaries at which the feature emits values: every slide_duration for a +// sliding window or every window_duration for a tumbling window, shifted by +// offset. Feature values up to one window_duration after the aligned end may +// change. The backfill stops at the most recent materialized values and leaves +// later values to materialization.. type BackfillRange struct { // Start of the backfill range, inclusive. If unset, defaults to the earliest // source timestamp of the feature. StartTime *types.Time - // End of the backfill range, exclusive. If unset, defaults to the current time. + // End of the backfill range, exclusive. If unset, defaults to the most recent + // materialized values. EndTime *types.Time } @@ -1721,8 +1733,8 @@ type MaterializationFailureNotification struct { FinalAttemptOnly *bool `fieldmask:"final_attempt_only"` } -// Notifications for the jobs and pipelines that materialize a feature, one -// field per trigger.. +// Notifications for the jobs and pipelines that materialize the features in a +// set, one field per trigger.. type MaterializationNotifications struct { // Who to notify when a run succeeds. OnSuccess *MaterializationSuccessNotification `fieldmask:"on_success"` @@ -1829,8 +1841,8 @@ type MaterializedFeature struct { // The fully qualified Unity Catalog path to the table containing the // materialized feature (Delta table or Lakebase table). Output only. TableName *string `fieldmask:"table_name"` - // The schedule state of the materialization pipeline. Hidden from GraphQL: - // being deprecated, so not exposed to Catalog Explorer. + // Deprecated: This legacy pipeline setting does not control batch job + // scheduling. PipelineScheduleState MaterializedFeature_PipelineScheduleState `fieldmask:"pipeline_schedule_state"` // The timestamp when the pipeline last ran and updated the materialized feature // values. If the pipeline has not run yet, this field will be null. @@ -1863,14 +1875,11 @@ type MaterializedFeature struct { // The ID of the job that materializes the feature. This is present for both // batch and streaming features. JobId *int64 `fieldmask:"job_id"` - // Notification configuration around the materialization job or pipeline - // lifecycle. They are applied to every job and pipeline that materializes this - // feature. Features which are materialized in the same pipeline will share the - // same notification. + // Notification configuration for the jobs and pipelines that materialize this + // feature. Notifications *MaterializationNotifications `fieldmask:"notifications"` - // The materialization set this materialized feature was created for, through - // DABs or direct-engine creation. Unset for a materialized feature that was not - // created as part of a set. + // The ID of the materialization set containing this materialized feature. Unset + // for a materialized feature that is not part of a set. MaterializationSetId *string `fieldmask:"materialization_set_id"` _ [0]materializedFeatureDestinationFieldMaskMetadata `fieldmask_oneof:"Destination"` _ [0]materializedFeatureTriggerFieldMaskMetadata `fieldmask_oneof:"Trigger"` @@ -2811,8 +2820,7 @@ type UpdateMaterializationSetRequest struct { type UpdateMaterializedFeatureRequest struct { // The materialized feature to update. MaterializedFeature *MaterializedFeature - // Provide the materialization feature fields which should be updated. - // Currently, only the pipeline_state field can be updated. + // The fields to update. Only `pipeline_schedule_state` is supported. UpdateMask *types.FieldMask[MaterializedFeature] } diff --git a/genieagents/.package.json b/genieagents/.package.json new file mode 100644 index 00000000..5ce1700d --- /dev/null +++ b/genieagents/.package.json @@ -0,0 +1,3 @@ +{ + "package": "genieagents" +} diff --git a/genieagents/CHANGELOG.md b/genieagents/CHANGELOG.md new file mode 100644 index 00000000..c6015f19 --- /dev/null +++ b/genieagents/CHANGELOG.md @@ -0,0 +1,3 @@ +# Version changelog + +## Release v0.1.0 (2026-11-02) diff --git a/genieagents/README.md b/genieagents/README.md new file mode 100644 index 00000000..8c4b6fd8 --- /dev/null +++ b/genieagents/README.md @@ -0,0 +1,26 @@ +# github.com/databricks/sdk-go/genieagents + +> [!NOTE] +> +> ## Beta +> +> **This SDK is in Beta and is supported for production use cases.** Interfaces might still change slightly before GA (e.g. name standardization and minor ergonomic tweaks). We are keen to hear feedback from early adopters — please [file issues](https://github.com/databricks/sdk-go/issues), and we will address them. + +## Installation + +```bash +go get github.com/databricks/sdk-go/genieagents@latest +``` + +## Usage + +```go +import "github.com/databricks/sdk-go/genieagents/v1" + +client, err := genieagents.NewClient(ctx) +if err != nil { + return err +} +``` + +For a full getting-started guide, see the [root README](../README.md). diff --git a/genieagents/go.mod b/genieagents/go.mod new file mode 100644 index 00000000..00e12ba7 --- /dev/null +++ b/genieagents/go.mod @@ -0,0 +1,28 @@ +module github.com/databricks/sdk-go/genieagents + +go 1.26.0 + +replace github.com/databricks/sdk-go/auth => ../auth + +replace github.com/databricks/sdk-go/core => ../core + +replace github.com/databricks/sdk-go/options => ../options + +require ( + github.com/databricks/sdk-go/auth v0.2.0 + github.com/databricks/sdk-go/core v0.1.0 + github.com/databricks/sdk-go/options v0.0.0-00010101000000-000000000000 +) + +require ( + github.com/databricks/databricks-sdk-go v0.92.0 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/oauth2 v0.33.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/time v0.5.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect +) diff --git a/genieagents/internal/version.go b/genieagents/internal/version.go new file mode 100644 index 00000000..cc838793 --- /dev/null +++ b/genieagents/internal/version.go @@ -0,0 +1,5 @@ +package internal + +const ModuleName = "sdk-go-genieagents" + +const Version = "0.1.0" diff --git a/genieagents/v1/client.go b/genieagents/v1/client.go new file mode 100644 index 00000000..1c91a127 --- /dev/null +++ b/genieagents/v1/client.go @@ -0,0 +1,465 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package genieagents + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "iter" + "log/slog" + "net/http" + "net/url" + "sync" + "time" + + "github.com/databricks/sdk-go/auth" + "github.com/databricks/sdk-go/core/clientinfo" + "github.com/databricks/sdk-go/genieagents/internal" + "github.com/databricks/sdk-go/options/call" + "github.com/databricks/sdk-go/options/client" + "github.com/databricks/sdk-go/options/internaloptions" +) + +type Client struct { + internalClient + + // extensions is a per-client store for hand-written mixins to attach + // lazily-built state. Keys should be unexported types private to the + // mixin, following the context.Value convention, to avoid collisions. + // The zero value is ready to use; it is safe for concurrent use. + extensions sync.Map +} + +type internalClient struct { + httpClient *http.Client + callTimeout *time.Duration + credentials auth.Credentials + logger *slog.Logger + userAgent func() (string, error) + host string + workspaceID string + accountID string +} + +func NewClient(ctx context.Context, opts ...client.Option) (*Client, error) { + cfg := internaloptions.ClientOptions{} + for _, opt := range opts { + if err := opt(&cfg); err != nil { + return nil, err + } + } + if err := cfg.Resolve(); err != nil { + return nil, err + } + userAgent := func() (string, error) { + info, err := clientinfo.Default().With( + internal.ModuleName, internal.Version, + "auth", cfg.Credentials.Name(), + ) + if err != nil { + return "", err + } + return info.String(), nil + } + + return &Client{ + internalClient: internalClient{ + httpClient: cfg.HTTPClient, + callTimeout: cfg.Timeout, + credentials: cfg.Credentials, + logger: cfg.Logger, + userAgent: userAgent, + host: cfg.Host, + workspaceID: cfg.WorkspaceID, + accountID: cfg.AccountID, + }, + }, nil +} + +// Creates a Genie Agent. +func (c *internalClient) CreateGenieAgent(ctx context.Context, req CreateGenieAgentRequest, opts ...call.Option) (*GenieAgent, error) { + wireReq, err := createGenieAgentRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq.GenieAgent) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + baseURL.Path = "/api/2.0/genie/agents" + queryParams := url.Values{} + if err := addQueryValue(queryParams, "genie_agent_id", wireReq.GenieAgentId); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *GenieAgent + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp genieAgentWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = genieAgentFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Deletes a Genie Agent, moving it to trash. +func (c *internalClient) DeleteGenieAgent(ctx context.Context, req DeleteGenieAgentRequest, opts ...call.Option) error { + wireReq, err := deleteGenieAgentRequestToWire(&req) + if err != nil { + return err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return err + } + pb := pathBuilder{} + pb.literal("/api/2.0/genie/") + if req.Name == nil { + return fmt.Errorf("path parameter %q is required", "name") + } + pb.singleSegment(*req.Name) + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "etag", wireReq.Etag); err != nil { + return err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "DELETE", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + _ = respBody + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return err + } + return nil +} + +// Gets a Genie Agent. +func (c *internalClient) GetGenieAgent(ctx context.Context, req GetGenieAgentRequest, opts ...call.Option) (*GenieAgent, error) { + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/2.0/genie/") + if req.Name == nil { + return nil, fmt.Errorf("path parameter %q is required", "name") + } + pb.singleSegment(*req.Name) + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *GenieAgent + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp genieAgentWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = genieAgentFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Lists the Genie Agents in the workspace. Genie Agents created from an +// integration (for example, from a dashboard) are not listed. +func (c *internalClient) ListGenieAgents(ctx context.Context, req ListGenieAgentsRequest, opts ...call.Option) (*ListGenieAgentsResponse, error) { + wireReq, err := listGenieAgentsRequestToWire(&req) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + baseURL.Path = "/api/2.0/genie/agents" + queryParams := url.Values{} + if err := addQueryValue(queryParams, "page_size", wireReq.PageSize); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "page_token", wireReq.PageToken); err != nil { + return nil, err + } + if wireReq.View != "" { + if err := addQueryValue(queryParams, "view", wireReq.View); err != nil { + return nil, err + } + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *ListGenieAgentsResponse + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp listGenieAgentsResponseWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = listGenieAgentsResponseFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// ListGenieAgentsIter returns an iterator that iterates +// over the results of ListGenieAgents. +// +// For example: +// +// for item, err := range c.ListGenieAgentsIter(ctx, ListGenieAgentsRequest{}) { +// if err != nil { +// return err +// } +// fmt.Println(item) +// } +// +// Options opts are passed to each ListGenieAgents call +// made by the iterator under the hood. +// +// Callers who need custom pagination logic should use +// ListGenieAgents directly. +func (c *internalClient) ListGenieAgentsIter(ctx context.Context, req ListGenieAgentsRequest, opts ...call.Option) iter.Seq2[*GenieAgent, error] { + return func(yield func(*GenieAgent, error) bool) { + // Keep pagination state local to this traversal so reusing the iterator starts + // from the original request. Reference-bearing fields remain shared and read-only. + pageReq := req + for { + resp, err := c.ListGenieAgents(ctx, pageReq, opts...) + if err != nil { + yield(nil, err) + return + } + for i := range resp.GenieAgents { + if !yield(&resp.GenieAgents[i], nil) { + return + } + } + if resp.NextPageToken == nil || *resp.NextPageToken == "" { + return + } + pageReq.PageToken = resp.NextPageToken + } + } +} + +// Updates a Genie Agent. Only the fields named in update_mask are applied. +func (c *internalClient) UpdateGenieAgent(ctx context.Context, req UpdateGenieAgentRequest, opts ...call.Option) (*GenieAgent, error) { + wireReq, err := updateGenieAgentRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq.GenieAgent) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/2.0/genie/") + if req.GenieAgent == nil || req.GenieAgent.Name == nil { + pb.singleSegment("") + } else { + pb.singleSegment(*req.GenieAgent.Name) + } + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "update_mask", wireReq.UpdateMask); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "etag", wireReq.Etag); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *GenieAgent + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "PATCH", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp genieAgentWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = genieAgentFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} diff --git a/genieagents/v1/genhelper.go b/genieagents/v1/genhelper.go new file mode 100644 index 00000000..8b65a57c --- /dev/null +++ b/genieagents/v1/genhelper.go @@ -0,0 +1,239 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package genieagents + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "strings" + "time" + + "github.com/databricks/sdk-go/auth" + "github.com/databricks/sdk-go/core/apierr" + "github.com/databricks/sdk-go/core/ops" + "github.com/databricks/sdk-go/options/call" + "github.com/databricks/sdk-go/options/internaloptions" +) + +type httpCallOptions struct { + req *http.Request + client *http.Client + logger *slog.Logger +} + +type httpRequestOptions struct { + Method string + URL string + Credentials auth.Credentials + UserAgent func() (string, error) + Headers http.Header + Body io.Reader +} + +func newHTTPRequest(ctx context.Context, opts httpRequestOptions) (*http.Request, error) { + req, err := http.NewRequestWithContext(ctx, opts.Method, opts.URL, opts.Body) + if err != nil { + closeBody(opts.Body) + return nil, err + } + + req.Header = opts.Headers.Clone() + if opts.Credentials != nil { + headers, err := opts.Credentials.AuthHeaders(ctx) + if err != nil { + closeBody(opts.Body) + return nil, err + } + for _, h := range headers { + req.Header.Add(h.Key, h.Value) + } + } + if opts.UserAgent != nil { + userAgent, err := opts.UserAgent() + if err != nil { + closeBody(opts.Body) + return nil, err + } + if userAgent != "" { + req.Header.Set("User-Agent", userAgent) + } + } + + return req, nil +} + +func closeBody(body io.Reader) { + if body == nil { + return + } + if rc, ok := body.(io.ReadCloser); ok { + _ = rc.Close() + } +} + +// lazyRequest implements slog.LogValuer for lazy evaluation of request +// logging. +type lazyRequest struct{ req *http.Request } + +func (r lazyRequest) LogValue() slog.Value { + return slog.GroupValue( + slog.String("method", r.req.Method), + slog.String("url", r.req.URL.String()), + ) +} + +// lazyResponse implements slog.LogValuer for lazy evaluation of response +// logging. +type lazyResponse struct { + resp *http.Response + body []byte +} + +func (r lazyResponse) LogValue() slog.Value { + return slog.GroupValue( + slog.Int("status", r.resp.StatusCode), + slog.String("body", string(r.body)), + ) +} + +// executeHTTPCall executes an HTTP call and returns the response body and +// headers, or an error. The headers are returned so callers can populate +// header-mapped response fields alongside the JSON body. This function takes +// care of logging the request and response. +func executeHTTPCall(opts httpCallOptions) ([]byte, http.Header, error) { + opts.logger.Debug("HTTP request", "request", lazyRequest{opts.req}) + resp, err := opts.client.Do(opts.req) + if err != nil { + return nil, nil, err + } + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, nil}) + return nil, nil, err + } + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, body}) + if err := apierr.FromHTTPError(resp.StatusCode, resp.Header, body); err != nil { + return nil, nil, err + } + return body, resp.Header, nil +} + +func (c *internalClient) resolveCallOptions( + opts []call.Option, + timeout time.Duration, +) (internaloptions.CallOptions, error) { + cfg := internaloptions.CallOptions{Timeout: timeout} + if c.callTimeout != nil { + cfg.Timeout = *c.callTimeout + } + for _, opt := range opts { + if err := opt(&cfg); err != nil { + return internaloptions.CallOptions{}, err + } + } + return cfg, nil +} + +func (c *internalClient) executeCall( + ctx context.Context, + op func(context.Context) error, + opts []call.Option, +) error { + cfg, err := c.resolveCallOptions(opts, 5*time.Minute) + if err != nil { + return err + } + return executeResolvedCall(ctx, op, cfg) +} + +func executeResolvedCall(ctx context.Context, op func(context.Context) error, cfg internaloptions.CallOptions) error { + return ops.Execute(ctx, op, + ops.WithRetrier(cfg.Retrier), + ops.WithLimiter(cfg.RateLimiter), + ops.WithTimeout(cfg.Timeout), + ) +} + +func addQueryValue(params url.Values, key string, value any) error { + data, err := json.Marshal(value) + if err != nil { + return err + } + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.UseNumber() + var decoded any + if err := decoder.Decode(&decoded); err != nil { + return err + } + flattenQueryValue(params, key, decoded) + return nil +} + +func flattenQueryValue(params url.Values, key string, value any) { + switch value := value.(type) { + case nil: + // JSON null represents an absent query value. + case map[string]any: + for childKey, child := range value { + flattenQueryValue(params, key+"."+childKey, child) + } + case []any: + for _, item := range value { + params.Add(key, fmt.Sprintf("%v", item)) + } + default: + params.Add(key, fmt.Sprintf("%v", value)) + } +} + +// pathBuilder assembles request paths so "/" in parameter values remains a +// path separator while characters that cannot appear literally in a URL path +// are percent-encoded when the request URL is serialized. +// +// It builds url.URL.Path and url.URL.RawPath together. net/url uses RawPath only +// when it is a valid encoding of Path; otherwise it escapes Path. +type pathBuilder struct { + path strings.Builder + raw strings.Builder +} + +// literal appends a static path segment, identical on the decoded and escaped +// paths. +func (b *pathBuilder) literal(s string) { + b.path.WriteString(s) + b.raw.WriteString(s) +} + +// singleSegment appends the value unchanged to Path and RawPath. When the URL +// is serialized, net/url keeps "/" literal and percent-encodes characters such +// as spaces, "?", and "#". +// The value is formatted with %v so strings, enums, and numbers all work. +func (b *pathBuilder) singleSegment(v any) { + s := fmt.Sprintf("%v", v) + b.path.WriteString(s) + b.raw.WriteString(s) +} + +// multiSegments appends a multi-segment path parameter: the value spans several +// path segments, so each segment is escaped but the "/" separators are kept. +// The value is formatted with %v so strings, enums, and numbers all work. +func (b *pathBuilder) multiSegments(v any) { + s := fmt.Sprintf("%v", v) + b.path.WriteString(s) + segments := strings.Split(s, "/") + for i, seg := range segments { + segments[i] = url.PathEscape(seg) + } + b.raw.WriteString(strings.Join(segments, "/")) +} + +func (b *pathBuilder) build() (path, rawPath string) { + return b.path.String(), b.raw.String() +} diff --git a/genieagents/v1/model.go b/genieagents/v1/model.go new file mode 100644 index 00000000..40083db8 --- /dev/null +++ b/genieagents/v1/model.go @@ -0,0 +1,449 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package genieagents + +import ( + "github.com/databricks/sdk-go/core/types" +) + +// The format of a benchmark answer. +type GenieAgentBenchmarkAnswerFormat string + +const ( + GenieAgentBenchmarkAnswerFormat_Unspecified GenieAgentBenchmarkAnswerFormat = "" + // The answer is a SQL query. + GenieAgentBenchmarkAnswerFormat_GenieAgentBenchmarkAnswerFormatSql GenieAgentBenchmarkAnswerFormat = "GENIE_AGENT_BENCHMARK_ANSWER_FORMAT_SQL" +) + +// How the rows of the two sides of a join relate. +type GenieAgentJoinRelationshipType string + +const ( + GenieAgentJoinRelationshipType_Unspecified GenieAgentJoinRelationshipType = "" + // Each row of `left` matches at most one row of `right`. + GenieAgentJoinRelationshipType_GenieAgentJoinRelationshipTypeManyToOne GenieAgentJoinRelationshipType = "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_MANY_TO_ONE" + // Each row of `right` matches at most one row of `left`. + GenieAgentJoinRelationshipType_GenieAgentJoinRelationshipTypeOneToMany GenieAgentJoinRelationshipType = "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_ONE_TO_MANY" + // Each row of either side matches at most one row of the other. + GenieAgentJoinRelationshipType_GenieAgentJoinRelationshipTypeOneToOne GenieAgentJoinRelationshipType = "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_ONE_TO_ONE" + // Rows of either side may match many rows of the other. + GenieAgentJoinRelationshipType_GenieAgentJoinRelationshipTypeManyToMany GenieAgentJoinRelationshipType = "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_MANY_TO_MANY" +) + +// The fields returned for each Genie Agent in a list response. +type GenieAgentView string + +const ( + GenieAgentView_Unspecified GenieAgentView = "" + // `name`, `display_name`, `description`, `warehouse_id`, `create_time`, and + // `update_time`. + GenieAgentView_GenieAgentViewBasic GenieAgentView = "GENIE_AGENT_VIEW_BASIC" + // The complete Genie Agent: the `GENIE_AGENT_VIEW_BASIC` fields plus + // `definition`, `parent_path`, `effective_parent_path`, and `etag`. + GenieAgentView_GenieAgentViewFull GenieAgentView = "GENIE_AGENT_VIEW_FULL" +) + +// Request to create a Genie Agent.. +type CreateGenieAgentRequest struct { + // The Genie Agent to create. + GenieAgent *GenieAgent + // The ID for the new Genie Agent: 32 lowercase hexadecimal characters (a UUID + // without dashes), not all zeros. Assigned by the server if omitted. Fails with + // ALREADY_EXISTS if the ID is in use in the workspace, including by a Genie + // Agent in the trash, or PERMISSION_DENIED if the caller cannot view the Genie + // Agent using it. + GenieAgentId *string +} + +// Request to delete (move to trash) a Genie Agent by its resource name.. +type DeleteGenieAgentRequest struct { + // The resource name of the Genie Agent to delete, in the form + // `agents/{genie_agent_id}`. + Name *string + // Etag from a previous read. On mismatch the delete fails with ABORTED and + // nothing is deleted. + Etag *string +} + +// A Genie Agent resource.. +type GenieAgent struct { + // The resource name of the Genie Agent, in the form `agents/{genie_agent_id}`. + // Ignored on create. + Name *string `fieldmask:"name"` + // Display name of the Genie Agent. Must be unique within its folder + // (effective_parent_path): a create, rename, or move that would collide with an + // existing Genie Agent's name in the target folder is rejected with + // ALREADY_EXISTS. + // + // The maximum length is 63 characters. Requests with a longer value are + // rejected with INVALID_PARAMETER_VALUE. + DisplayName *string `fieldmask:"display_name"` + // Description of the Genie Agent. + // + // The maximum length is 4,096 characters. Requests with a longer value are + // rejected with INVALID_PARAMETER_VALUE. + Description *string `fieldmask:"description"` + // The definition of the Genie Agent: its sample questions, data sources, + // instructions, and benchmarks. Must set at least one field. Returned on get + // and on list with `GENIE_AGENT_VIEW_FULL`. Create and update return a + // submitted definition unchanged; one the service would store differently, or + // with a column config the workspace can't keep (unknown column, or a display + // name while those are disabled), is rejected with INVALID_PARAMETER_VALUE. + Definition *GenieAgentDefinition `fieldmask:"definition"` + // Warehouse associated with the Genie Agent. + WarehouseId *string `fieldmask:"warehouse_id"` + // The workspace folder to create the Genie Agent in. If omitted, the caller's + // home folder is used. Returned exactly as submitted; see + // `effective_parent_path` for the current folder. On update, setting it moves + // the Genie Agent and clearing it does not. At most 4,096 characters. + ParentPath *string `fieldmask:"parent_path"` + // Weak etag of `definition` only; metadata changes do not affect it. Send it on + // update or delete to detect concurrent definition changes. + Etag *string `fieldmask:"etag"` + // Time when the Genie Agent was created. + CreateTime *types.Time `fieldmask:"create_time"` + // Time when the Genie Agent was last modified. + UpdateTime *types.Time `fieldmask:"update_time"` + // The workspace folder that contains the Genie Agent. + EffectiveParentPath *string `fieldmask:"effective_parent_path"` +} + +// The expected answer to a benchmark question.. +type GenieAgentBenchmarkAnswer struct { + // The format of the answer. + Format GenieAgentBenchmarkAnswerFormat + // The answer. + Content *string +} + +// A benchmark question with its expected answer.. +type GenieAgentBenchmarkQuestion struct { + // Identifier of the question: 32 lowercase hexadecimal characters, unique + // within the Genie Agent. + Id *string + // The question. + Question *string + // The expected answer. At most one answer is supported; omit it when the + // question has no expected answer. + Answer []GenieAgentBenchmarkAnswer + // Notes on how to evaluate answers to the question. + EvaluationNote *string +} + +// Benchmarks for evaluating a Genie Agent.. +type GenieAgentBenchmarks struct { + // The benchmark questions, sorted by `id` in descending order. + Questions []GenieAgentBenchmarkQuestion `fieldmask:"questions"` +} + +// Settings for one column of a table or metric view.. +type GenieAgentColumnConfig struct { + // The name of the column. Must exist in the table or metric view. + Column *string + // Description of the column, overriding its Unity Catalog comment. + Description *string + // Synonyms for the column name. + Synonyms []string + // Whether the column is hidden from the Genie Agent. + Exclude *bool + // Whether the Genie Agent samples example values from the column to learn its + // format. + EnableFormatAssistance *bool + // Whether the Genie Agent indexes the column's values to match them in + // questions. + EnableEntityMatching *bool + // Display name of the column in the Genie Agent. Accepted only where column + // display names are enabled for the workspace. + DisplayName *string +} + +// General settings of a Genie Agent. The warehouse, display name, and +// description are separate fields of the Genie Agent.. +type GenieAgentConfig struct { + // Sample questions shown to users of the Genie Agent, sorted by `id`. + SampleQuestions []GenieAgentSampleQuestion `fieldmask:"sample_questions"` +} + +// The data a Genie Agent can access.. +type GenieAgentDataSources struct { + // Unity Catalog tables, views, and metric views, in the order they were added. + Tables []GenieAgentTable `fieldmask:"tables"` + // Unity Catalog volumes, in the order they were added. + Volumes []GenieAgentVolume `fieldmask:"volumes"` + // Unity Catalog MCP connections, sorted by `mcp_connection`. + McpConnections []GenieAgentMcpConnection `fieldmask:"mcp_connections"` +} + +// The definition of a Genie Agent.. +type GenieAgentDefinition struct { + // General settings of the Genie Agent. + Config *GenieAgentConfig `fieldmask:"config"` + // The data the Genie Agent can access. + DataSources *GenieAgentDataSources `fieldmask:"data_sources"` + // Instructions and SQL that guide how the Genie Agent answers questions. + Instructions *GenieAgentInstructions `fieldmask:"instructions"` + // Benchmarks for evaluating the quality of the Genie Agent's answers. + Benchmarks *GenieAgentBenchmarks `fieldmask:"benchmarks"` +} + +// An example question paired with the SQL that answers it.. +type GenieAgentExampleQuestionSql struct { + // Identifier of the example: 32 lowercase hexadecimal characters, unique within + // the Genie Agent. + Id *string + // The question. + Question *string + // The SQL that answers the question. + Sql *string + // Parameters used in the SQL, in the order given. + Parameters []GenieAgentSqlParameter + // Guidance on when to use this example. + UsageGuidance *string +} + +// Instructions and SQL that guide how a Genie Agent answers questions.. +type GenieAgentInstructions struct { + // General text instructions. At most one text instruction is supported. + TextInstructions []GenieAgentTextInstruction `fieldmask:"text_instructions"` + // Example questions paired with the SQL that answers them. + ExampleQuestionSqls []GenieAgentExampleQuestionSql `fieldmask:"example_question_sqls"` + // Unity Catalog SQL functions the generated SQL may call. + SqlFunctions []GenieAgentSqlFunction `fieldmask:"sql_functions"` + // Predefined joins between tables or metric views. + JoinSpecs []GenieAgentJoinSpec `fieldmask:"join_specs"` + // Reusable SQL filters, expressions, and measures. + SqlSnippets *GenieAgentSqlSnippets `fieldmask:"sql_snippets"` +} + +// One side of a join.. +type GenieAgentJoinSource struct { + // The full three-level name of the table or metric view. + Identifier *string + // The alias the join condition uses for this side. + Alias *string +} + +// A predefined join between two tables or metric views.. +type GenieAgentJoinSpec struct { + // Identifier of the join: 32 lowercase hexadecimal characters, unique within + // the Genie Agent. + Id *string + // The left side of the join. + Left *GenieAgentJoinSource + // The right side of the join. + Right *GenieAgentJoinSource + // The join condition, for example `orders.customer_id = customers.id`. + Sql *string + // How the rows of the two sides relate. + RelationshipType GenieAgentJoinRelationshipType + // Description of the join's purpose. + Comment *string + // Guidance on when to use the join. + Instruction *string +} + +// A Unity Catalog MCP connection the Genie Agent can use.. +type GenieAgentMcpConnection struct { + // The name of the Unity Catalog connection, for example + // `system.ai.google_calendar`. + McpConnection *string +} + +// A sample question shown to users of the Genie Agent.. +type GenieAgentSampleQuestion struct { + // Identifier of the sample question: 32 lowercase hexadecimal characters, + // unique within the Genie Agent. + Id *string + // The text of the question. + Question *string +} + +// A reusable non-aggregated SQL expression (dimension).. +type GenieAgentSqlExpression struct { + // Identifier of the expression: 32 lowercase hexadecimal characters, unique + // within the Genie Agent. + Id *string + // The alias the Genie Agent uses for the expression in generated SQL. + Alias *string + // The SQL of the expression. + Sql *string + // Display name of the expression. + DisplayName *string + // Guidance on when to use the expression. + Instruction *string + // Synonyms for the expression. + Synonyms []string +} + +// A reusable SQL filter.. +type GenieAgentSqlFilter struct { + // Identifier of the filter: 32 lowercase hexadecimal characters, unique within + // the Genie Agent. + Id *string + // The SQL of the filter. + Sql *string + // Display name of the filter. + DisplayName *string + // Guidance on when to use the filter. + Instruction *string + // Synonyms for the filter. + Synonyms []string +} + +// A Unity Catalog SQL function the generated SQL may call.. +type GenieAgentSqlFunction struct { + // Identifier of the entry: 32 lowercase hexadecimal characters, unique within + // the Genie Agent. + Id *string + // The full three-level name of the function, for example + // `catalog.schema.function`. + Identifier *string +} + +// A reusable aggregated SQL measure.. +type GenieAgentSqlMeasure struct { + // Identifier of the measure: 32 lowercase hexadecimal characters, unique within + // the Genie Agent. + Id *string + // The alias the Genie Agent uses for the measure in generated SQL. + Alias *string + // The SQL of the measure. + Sql *string + // Display name of the measure. + DisplayName *string + // Guidance on when to use the measure. + Instruction *string + // Synonyms for the measure. + Synonyms []string +} + +// A parameter of a parameterized SQL example.. +type GenieAgentSqlParameter struct { + // The name of the parameter in the SQL. + Name *string + // The parameter's data type, for example `STRING` or `INTEGER`. + TypeHint *string + // Description of the parameter. + Description *string + // The parameter's default value. + DefaultValue *GenieAgentSqlParameterDefaultValue +} + +// A range of default values for a SQL parameter.. +type GenieAgentSqlParameterDefaultRange struct { + // The lower end of the range. + Min *string + // The upper end of the range. + Max *string +} + +// The default value of a SQL parameter: a list of values or a range.. +type GenieAgentSqlParameterDefaultValue struct { + // The default values. A single default is a one-element list. + Values []string + // The default range. + ValueRange *GenieAgentSqlParameterDefaultRange +} + +// Reusable SQL snippets.. +type GenieAgentSqlSnippets struct { + // Filters, such as `state = 'CA'`. + Filters []GenieAgentSqlFilter `fieldmask:"filters"` + // Non-aggregated expressions (dimensions), such as `price * units`. + Expressions []GenieAgentSqlExpression `fieldmask:"expressions"` + // Aggregated measures, such as `SUM(price * units)`. + Measures []GenieAgentSqlMeasure `fieldmask:"measures"` +} + +// A Unity Catalog table, view, or metric view the Genie Agent can access.. +type GenieAgentTable struct { + // The full three-level name, for example `catalog.schema.table`. + Identifier *string + // Description of the table. + Description *string + // Column settings for the table, sorted by `column`. + ColumnConfigs []GenieAgentColumnConfig +} + +// A general text instruction for the Genie Agent.. +type GenieAgentTextInstruction struct { + // Identifier of the instruction: 32 lowercase hexadecimal characters, unique + // within the Genie Agent. + Id *string + // The text of the instruction. + Content *string +} + +// A Unity Catalog volume the Genie Agent can access.. +type GenieAgentVolume struct { + // The volume path, for example `/Volumes/catalog/schema/volume`. May name a + // directory or file within the volume. + Path *string + // Description of the volume. + Description *string +} + +// Request to retrieve a single Genie Agent by its resource name.. +type GetGenieAgentRequest struct { + // The resource name of the Genie Agent to retrieve, in the form + // `agents/{genie_agent_id}`. + Name *string +} + +// Request to list the Genie Agents in the workspace, one page at a time.. +type ListGenieAgentsRequest struct { + // Maximum number of Genie Agents to return per page. Defaults to 20 when unset + // or 0; values above 100 are coerced to 100. Negative values are rejected with + // INVALID_PARAMETER_VALUE. With `GENIE_AGENT_VIEW_FULL`, a smaller per-page + // maximum applies. + PageSize *int + // Pagination token from a previous response's `next_page_token`. A token that + // was not returned by this method is rejected with INVALID_PARAMETER_VALUE. + PageToken *string + // The fields to return for each Genie Agent. Defaults to + // `GENIE_AGENT_VIEW_BASIC`. Use `GENIE_AGENT_VIEW_FULL` only when the agent + // bodies are needed, since it returns smaller pages. + View GenieAgentView +} + +// Response for a list request: a page of Genie Agents plus the token for the +// next page.. +type ListGenieAgentsResponse struct { + // The Genie Agents, with the fields selected by the request's `view`. + GenieAgents []GenieAgent + // Token to get the next page of results. + NextPageToken *string + // Resource names, in the form `agents/{genie_agent_id}`, of Genie Agents in + // this page that could not be read and are omitted from `genie_agents`. + // Populated only for `GENIE_AGENT_VIEW_FULL`. To see why, get the Genie Agent + // by name; to retry, repeat the request. Other kinds of resource names may be + // added to this field in the future. + Unreachable []string +} + +// Request to update a Genie Agent, applying only the fields named in the update +// mask.. +type UpdateGenieAgentRequest struct { + // The Genie Agent to update. Its `name` identifies the resource; fields named + // in update_mask are applied. + GenieAgent *GenieAgent + // The set of fields to update. The mask is required and must name at least one + // field; an empty or absent mask is rejected with INVALID_PARAMETER_VALUE, as + // is a path that is not an updatable field. + // + // A field named in the mask takes the value from `genie_agent`, even when it is + // unset there: an unset `description` is cleared; an unset `display_name`, + // `warehouse_id`, or `definition` is rejected with INVALID_PARAMETER_VALUE; an + // unset `parent_path` is cleared without moving the Genie Agent. `definition` + // is replaced as a whole; paths within it are not supported. + // + // The special value `*` replaces the whole Genie Agent, as if every updatable + // field were named. It must be the only path in the mask. Prefer naming fields + // explicitly: with `*`, any field added to Genie Agent later is also replaced, + // so a client unaware of it may clear it. + UpdateMask *types.FieldMask[GenieAgent] + // Etag from a previous read. On mismatch the update fails with ABORTED + // (metadata changes may already be applied); get the agent and retry. May + // return TEMPORARILY_UNAVAILABLE. + Etag *string +} diff --git a/genieagents/v1/wire.go b/genieagents/v1/wire.go new file mode 100644 index 00000000..2a445b58 --- /dev/null +++ b/genieagents/v1/wire.go @@ -0,0 +1,1073 @@ +// Code generated by Databricks SDK Generator. DO NOT EDIT. + +package genieagents + +import ( + "fmt" + + "github.com/databricks/sdk-go/core/types" +) + +func fieldMaskToWire[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +type createGenieAgentRequestWire struct { + GenieAgent *genieAgentWire `json:"genie_agent,omitempty"` + GenieAgentId *string `json:"genie_agent_id,omitempty"` +} + +func createGenieAgentRequestToWire(v *CreateGenieAgentRequest) (*createGenieAgentRequestWire, error) { + if v == nil { + return nil, nil + } + genieAgentWireValue, err := genieAgentToWire(v.GenieAgent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGenieAgentRequest.GenieAgent", err) + } + return &createGenieAgentRequestWire{ + GenieAgent: genieAgentWireValue, + GenieAgentId: v.GenieAgentId, + }, nil +} + +type deleteGenieAgentRequestWire struct { + Name *string `json:"name,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +func deleteGenieAgentRequestToWire(v *DeleteGenieAgentRequest) (*deleteGenieAgentRequestWire, error) { + if v == nil { + return nil, nil + } + return &deleteGenieAgentRequestWire{ + Name: v.Name, + Etag: v.Etag, + }, nil +} + +type genieAgentWire struct { + Name *string `json:"name,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + Description *string `json:"description,omitempty"` + Definition *genieAgentDefinitionWire `json:"definition,omitempty"` + WarehouseId *string `json:"warehouse_id,omitempty"` + ParentPath *string `json:"parent_path,omitempty"` + Etag *string `json:"etag,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` + EffectiveParentPath *string `json:"effective_parent_path,omitempty"` +} + +func genieAgentToWire(v *GenieAgent) (*genieAgentWire, error) { + if v == nil { + return nil, nil + } + definitionWireValue, err := genieAgentDefinitionToWire(v.Definition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgent.Definition", err) + } + return &genieAgentWire{ + Name: v.Name, + DisplayName: v.DisplayName, + Description: v.Description, + Definition: definitionWireValue, + WarehouseId: v.WarehouseId, + ParentPath: v.ParentPath, + Etag: v.Etag, + CreateTime: v.CreateTime, + UpdateTime: v.UpdateTime, + EffectiveParentPath: v.EffectiveParentPath, + }, nil +} + +func genieAgentFromWire(w *genieAgentWire) (*GenieAgent, error) { + if w == nil { + return nil, nil + } + definitionPublicValue, err := genieAgentDefinitionFromWire(w.Definition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgent.Definition", err) + } + return &GenieAgent{ + Name: w.Name, + DisplayName: w.DisplayName, + Description: w.Description, + Definition: definitionPublicValue, + WarehouseId: w.WarehouseId, + ParentPath: w.ParentPath, + Etag: w.Etag, + CreateTime: w.CreateTime, + UpdateTime: w.UpdateTime, + EffectiveParentPath: w.EffectiveParentPath, + }, nil +} + +type genieAgentBenchmarkAnswerWire struct { + Format GenieAgentBenchmarkAnswerFormat `json:"format,omitempty"` + Content *string `json:"content,omitempty"` +} + +func genieAgentBenchmarkAnswerToWire(v *GenieAgentBenchmarkAnswer) (*genieAgentBenchmarkAnswerWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentBenchmarkAnswerWire{ + Format: v.Format, + Content: v.Content, + }, nil +} + +func genieAgentBenchmarkAnswerFromWire(w *genieAgentBenchmarkAnswerWire) (*GenieAgentBenchmarkAnswer, error) { + if w == nil { + return nil, nil + } + return &GenieAgentBenchmarkAnswer{ + Format: w.Format, + Content: w.Content, + }, nil +} + +type genieAgentBenchmarkQuestionWire struct { + Id *string `json:"id,omitempty"` + Question *string `json:"question,omitempty"` + Answer []genieAgentBenchmarkAnswerWire `json:"answer,omitempty"` + EvaluationNote *string `json:"evaluation_note,omitempty"` +} + +func genieAgentBenchmarkQuestionToWire(v *GenieAgentBenchmarkQuestion) (*genieAgentBenchmarkQuestionWire, error) { + if v == nil { + return nil, nil + } + answerWireValue, err := convertSlice(v.Answer, genieAgentBenchmarkAnswerToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentBenchmarkQuestion.Answer", err) + } + return &genieAgentBenchmarkQuestionWire{ + Id: v.Id, + Question: v.Question, + Answer: answerWireValue, + EvaluationNote: v.EvaluationNote, + }, nil +} + +func genieAgentBenchmarkQuestionFromWire(w *genieAgentBenchmarkQuestionWire) (*GenieAgentBenchmarkQuestion, error) { + if w == nil { + return nil, nil + } + answerPublicValue, err := convertSlice(w.Answer, genieAgentBenchmarkAnswerFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentBenchmarkQuestion.Answer", err) + } + return &GenieAgentBenchmarkQuestion{ + Id: w.Id, + Question: w.Question, + Answer: answerPublicValue, + EvaluationNote: w.EvaluationNote, + }, nil +} + +type genieAgentBenchmarksWire struct { + Questions []genieAgentBenchmarkQuestionWire `json:"questions,omitempty"` +} + +func genieAgentBenchmarksToWire(v *GenieAgentBenchmarks) (*genieAgentBenchmarksWire, error) { + if v == nil { + return nil, nil + } + questionsWireValue, err := convertSlice(v.Questions, genieAgentBenchmarkQuestionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentBenchmarks.Questions", err) + } + return &genieAgentBenchmarksWire{ + Questions: questionsWireValue, + }, nil +} + +func genieAgentBenchmarksFromWire(w *genieAgentBenchmarksWire) (*GenieAgentBenchmarks, error) { + if w == nil { + return nil, nil + } + questionsPublicValue, err := convertSlice(w.Questions, genieAgentBenchmarkQuestionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentBenchmarks.Questions", err) + } + return &GenieAgentBenchmarks{ + Questions: questionsPublicValue, + }, nil +} + +type genieAgentColumnConfigWire struct { + Column *string `json:"column,omitempty"` + Description *string `json:"description,omitempty"` + Synonyms []string `json:"synonyms,omitempty"` + Exclude *bool `json:"exclude,omitempty"` + EnableFormatAssistance *bool `json:"enable_format_assistance,omitempty"` + EnableEntityMatching *bool `json:"enable_entity_matching,omitempty"` + DisplayName *string `json:"display_name,omitempty"` +} + +func genieAgentColumnConfigToWire(v *GenieAgentColumnConfig) (*genieAgentColumnConfigWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentColumnConfigWire{ + Column: v.Column, + Description: v.Description, + Synonyms: v.Synonyms, + Exclude: v.Exclude, + EnableFormatAssistance: v.EnableFormatAssistance, + EnableEntityMatching: v.EnableEntityMatching, + DisplayName: v.DisplayName, + }, nil +} + +func genieAgentColumnConfigFromWire(w *genieAgentColumnConfigWire) (*GenieAgentColumnConfig, error) { + if w == nil { + return nil, nil + } + return &GenieAgentColumnConfig{ + Column: w.Column, + Description: w.Description, + Synonyms: w.Synonyms, + Exclude: w.Exclude, + EnableFormatAssistance: w.EnableFormatAssistance, + EnableEntityMatching: w.EnableEntityMatching, + DisplayName: w.DisplayName, + }, nil +} + +type genieAgentConfigWire struct { + SampleQuestions []genieAgentSampleQuestionWire `json:"sample_questions,omitempty"` +} + +func genieAgentConfigToWire(v *GenieAgentConfig) (*genieAgentConfigWire, error) { + if v == nil { + return nil, nil + } + sampleQuestionsWireValue, err := convertSlice(v.SampleQuestions, genieAgentSampleQuestionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentConfig.SampleQuestions", err) + } + return &genieAgentConfigWire{ + SampleQuestions: sampleQuestionsWireValue, + }, nil +} + +func genieAgentConfigFromWire(w *genieAgentConfigWire) (*GenieAgentConfig, error) { + if w == nil { + return nil, nil + } + sampleQuestionsPublicValue, err := convertSlice(w.SampleQuestions, genieAgentSampleQuestionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentConfig.SampleQuestions", err) + } + return &GenieAgentConfig{ + SampleQuestions: sampleQuestionsPublicValue, + }, nil +} + +type genieAgentDataSourcesWire struct { + Tables []genieAgentTableWire `json:"tables,omitempty"` + Volumes []genieAgentVolumeWire `json:"volumes,omitempty"` + McpConnections []genieAgentMcpConnectionWire `json:"mcp_connections,omitempty"` +} + +func genieAgentDataSourcesToWire(v *GenieAgentDataSources) (*genieAgentDataSourcesWire, error) { + if v == nil { + return nil, nil + } + tablesWireValue, err := convertSlice(v.Tables, genieAgentTableToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDataSources.Tables", err) + } + volumesWireValue, err := convertSlice(v.Volumes, genieAgentVolumeToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDataSources.Volumes", err) + } + mcpConnectionsWireValue, err := convertSlice(v.McpConnections, genieAgentMcpConnectionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDataSources.McpConnections", err) + } + return &genieAgentDataSourcesWire{ + Tables: tablesWireValue, + Volumes: volumesWireValue, + McpConnections: mcpConnectionsWireValue, + }, nil +} + +func genieAgentDataSourcesFromWire(w *genieAgentDataSourcesWire) (*GenieAgentDataSources, error) { + if w == nil { + return nil, nil + } + tablesPublicValue, err := convertSlice(w.Tables, genieAgentTableFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDataSources.Tables", err) + } + volumesPublicValue, err := convertSlice(w.Volumes, genieAgentVolumeFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDataSources.Volumes", err) + } + mcpConnectionsPublicValue, err := convertSlice(w.McpConnections, genieAgentMcpConnectionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDataSources.McpConnections", err) + } + return &GenieAgentDataSources{ + Tables: tablesPublicValue, + Volumes: volumesPublicValue, + McpConnections: mcpConnectionsPublicValue, + }, nil +} + +type genieAgentDefinitionWire struct { + Config *genieAgentConfigWire `json:"config,omitempty"` + DataSources *genieAgentDataSourcesWire `json:"data_sources,omitempty"` + Instructions *genieAgentInstructionsWire `json:"instructions,omitempty"` + Benchmarks *genieAgentBenchmarksWire `json:"benchmarks,omitempty"` +} + +func genieAgentDefinitionToWire(v *GenieAgentDefinition) (*genieAgentDefinitionWire, error) { + if v == nil { + return nil, nil + } + configWireValue, err := genieAgentConfigToWire(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.Config", err) + } + dataSourcesWireValue, err := genieAgentDataSourcesToWire(v.DataSources) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.DataSources", err) + } + instructionsWireValue, err := genieAgentInstructionsToWire(v.Instructions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.Instructions", err) + } + benchmarksWireValue, err := genieAgentBenchmarksToWire(v.Benchmarks) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.Benchmarks", err) + } + return &genieAgentDefinitionWire{ + Config: configWireValue, + DataSources: dataSourcesWireValue, + Instructions: instructionsWireValue, + Benchmarks: benchmarksWireValue, + }, nil +} + +func genieAgentDefinitionFromWire(w *genieAgentDefinitionWire) (*GenieAgentDefinition, error) { + if w == nil { + return nil, nil + } + configPublicValue, err := genieAgentConfigFromWire(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.Config", err) + } + dataSourcesPublicValue, err := genieAgentDataSourcesFromWire(w.DataSources) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.DataSources", err) + } + instructionsPublicValue, err := genieAgentInstructionsFromWire(w.Instructions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.Instructions", err) + } + benchmarksPublicValue, err := genieAgentBenchmarksFromWire(w.Benchmarks) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentDefinition.Benchmarks", err) + } + return &GenieAgentDefinition{ + Config: configPublicValue, + DataSources: dataSourcesPublicValue, + Instructions: instructionsPublicValue, + Benchmarks: benchmarksPublicValue, + }, nil +} + +type genieAgentExampleQuestionSqlWire struct { + Id *string `json:"id,omitempty"` + Question *string `json:"question,omitempty"` + Sql *string `json:"sql,omitempty"` + Parameters []genieAgentSqlParameterWire `json:"parameters,omitempty"` + UsageGuidance *string `json:"usage_guidance,omitempty"` +} + +func genieAgentExampleQuestionSqlToWire(v *GenieAgentExampleQuestionSql) (*genieAgentExampleQuestionSqlWire, error) { + if v == nil { + return nil, nil + } + parametersWireValue, err := convertSlice(v.Parameters, genieAgentSqlParameterToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentExampleQuestionSql.Parameters", err) + } + return &genieAgentExampleQuestionSqlWire{ + Id: v.Id, + Question: v.Question, + Sql: v.Sql, + Parameters: parametersWireValue, + UsageGuidance: v.UsageGuidance, + }, nil +} + +func genieAgentExampleQuestionSqlFromWire(w *genieAgentExampleQuestionSqlWire) (*GenieAgentExampleQuestionSql, error) { + if w == nil { + return nil, nil + } + parametersPublicValue, err := convertSlice(w.Parameters, genieAgentSqlParameterFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentExampleQuestionSql.Parameters", err) + } + return &GenieAgentExampleQuestionSql{ + Id: w.Id, + Question: w.Question, + Sql: w.Sql, + Parameters: parametersPublicValue, + UsageGuidance: w.UsageGuidance, + }, nil +} + +type genieAgentInstructionsWire struct { + TextInstructions []genieAgentTextInstructionWire `json:"text_instructions,omitempty"` + ExampleQuestionSqls []genieAgentExampleQuestionSqlWire `json:"example_question_sqls,omitempty"` + SqlFunctions []genieAgentSqlFunctionWire `json:"sql_functions,omitempty"` + JoinSpecs []genieAgentJoinSpecWire `json:"join_specs,omitempty"` + SqlSnippets *genieAgentSqlSnippetsWire `json:"sql_snippets,omitempty"` +} + +func genieAgentInstructionsToWire(v *GenieAgentInstructions) (*genieAgentInstructionsWire, error) { + if v == nil { + return nil, nil + } + textInstructionsWireValue, err := convertSlice(v.TextInstructions, genieAgentTextInstructionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.TextInstructions", err) + } + exampleQuestionSqlsWireValue, err := convertSlice(v.ExampleQuestionSqls, genieAgentExampleQuestionSqlToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.ExampleQuestionSqls", err) + } + sqlFunctionsWireValue, err := convertSlice(v.SqlFunctions, genieAgentSqlFunctionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.SqlFunctions", err) + } + joinSpecsWireValue, err := convertSlice(v.JoinSpecs, genieAgentJoinSpecToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.JoinSpecs", err) + } + sqlSnippetsWireValue, err := genieAgentSqlSnippetsToWire(v.SqlSnippets) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.SqlSnippets", err) + } + return &genieAgentInstructionsWire{ + TextInstructions: textInstructionsWireValue, + ExampleQuestionSqls: exampleQuestionSqlsWireValue, + SqlFunctions: sqlFunctionsWireValue, + JoinSpecs: joinSpecsWireValue, + SqlSnippets: sqlSnippetsWireValue, + }, nil +} + +func genieAgentInstructionsFromWire(w *genieAgentInstructionsWire) (*GenieAgentInstructions, error) { + if w == nil { + return nil, nil + } + textInstructionsPublicValue, err := convertSlice(w.TextInstructions, genieAgentTextInstructionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.TextInstructions", err) + } + exampleQuestionSqlsPublicValue, err := convertSlice(w.ExampleQuestionSqls, genieAgentExampleQuestionSqlFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.ExampleQuestionSqls", err) + } + sqlFunctionsPublicValue, err := convertSlice(w.SqlFunctions, genieAgentSqlFunctionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.SqlFunctions", err) + } + joinSpecsPublicValue, err := convertSlice(w.JoinSpecs, genieAgentJoinSpecFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.JoinSpecs", err) + } + sqlSnippetsPublicValue, err := genieAgentSqlSnippetsFromWire(w.SqlSnippets) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentInstructions.SqlSnippets", err) + } + return &GenieAgentInstructions{ + TextInstructions: textInstructionsPublicValue, + ExampleQuestionSqls: exampleQuestionSqlsPublicValue, + SqlFunctions: sqlFunctionsPublicValue, + JoinSpecs: joinSpecsPublicValue, + SqlSnippets: sqlSnippetsPublicValue, + }, nil +} + +type genieAgentJoinSourceWire struct { + Identifier *string `json:"identifier,omitempty"` + Alias *string `json:"alias,omitempty"` +} + +func genieAgentJoinSourceToWire(v *GenieAgentJoinSource) (*genieAgentJoinSourceWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentJoinSourceWire{ + Identifier: v.Identifier, + Alias: v.Alias, + }, nil +} + +func genieAgentJoinSourceFromWire(w *genieAgentJoinSourceWire) (*GenieAgentJoinSource, error) { + if w == nil { + return nil, nil + } + return &GenieAgentJoinSource{ + Identifier: w.Identifier, + Alias: w.Alias, + }, nil +} + +type genieAgentJoinSpecWire struct { + Id *string `json:"id,omitempty"` + Left *genieAgentJoinSourceWire `json:"left,omitempty"` + Right *genieAgentJoinSourceWire `json:"right,omitempty"` + Sql *string `json:"sql,omitempty"` + RelationshipType GenieAgentJoinRelationshipType `json:"relationship_type,omitempty"` + Comment *string `json:"comment,omitempty"` + Instruction *string `json:"instruction,omitempty"` +} + +func genieAgentJoinSpecToWire(v *GenieAgentJoinSpec) (*genieAgentJoinSpecWire, error) { + if v == nil { + return nil, nil + } + leftWireValue, err := genieAgentJoinSourceToWire(v.Left) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentJoinSpec.Left", err) + } + rightWireValue, err := genieAgentJoinSourceToWire(v.Right) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentJoinSpec.Right", err) + } + return &genieAgentJoinSpecWire{ + Id: v.Id, + Left: leftWireValue, + Right: rightWireValue, + Sql: v.Sql, + RelationshipType: v.RelationshipType, + Comment: v.Comment, + Instruction: v.Instruction, + }, nil +} + +func genieAgentJoinSpecFromWire(w *genieAgentJoinSpecWire) (*GenieAgentJoinSpec, error) { + if w == nil { + return nil, nil + } + leftPublicValue, err := genieAgentJoinSourceFromWire(w.Left) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentJoinSpec.Left", err) + } + rightPublicValue, err := genieAgentJoinSourceFromWire(w.Right) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentJoinSpec.Right", err) + } + return &GenieAgentJoinSpec{ + Id: w.Id, + Left: leftPublicValue, + Right: rightPublicValue, + Sql: w.Sql, + RelationshipType: w.RelationshipType, + Comment: w.Comment, + Instruction: w.Instruction, + }, nil +} + +type genieAgentMcpConnectionWire struct { + McpConnection *string `json:"mcp_connection,omitempty"` +} + +func genieAgentMcpConnectionToWire(v *GenieAgentMcpConnection) (*genieAgentMcpConnectionWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentMcpConnectionWire{ + McpConnection: v.McpConnection, + }, nil +} + +func genieAgentMcpConnectionFromWire(w *genieAgentMcpConnectionWire) (*GenieAgentMcpConnection, error) { + if w == nil { + return nil, nil + } + return &GenieAgentMcpConnection{ + McpConnection: w.McpConnection, + }, nil +} + +type genieAgentSampleQuestionWire struct { + Id *string `json:"id,omitempty"` + Question *string `json:"question,omitempty"` +} + +func genieAgentSampleQuestionToWire(v *GenieAgentSampleQuestion) (*genieAgentSampleQuestionWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentSampleQuestionWire{ + Id: v.Id, + Question: v.Question, + }, nil +} + +func genieAgentSampleQuestionFromWire(w *genieAgentSampleQuestionWire) (*GenieAgentSampleQuestion, error) { + if w == nil { + return nil, nil + } + return &GenieAgentSampleQuestion{ + Id: w.Id, + Question: w.Question, + }, nil +} + +type genieAgentSqlExpressionWire struct { + Id *string `json:"id,omitempty"` + Alias *string `json:"alias,omitempty"` + Sql *string `json:"sql,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + Instruction *string `json:"instruction,omitempty"` + Synonyms []string `json:"synonyms,omitempty"` +} + +func genieAgentSqlExpressionToWire(v *GenieAgentSqlExpression) (*genieAgentSqlExpressionWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentSqlExpressionWire{ + Id: v.Id, + Alias: v.Alias, + Sql: v.Sql, + DisplayName: v.DisplayName, + Instruction: v.Instruction, + Synonyms: v.Synonyms, + }, nil +} + +func genieAgentSqlExpressionFromWire(w *genieAgentSqlExpressionWire) (*GenieAgentSqlExpression, error) { + if w == nil { + return nil, nil + } + return &GenieAgentSqlExpression{ + Id: w.Id, + Alias: w.Alias, + Sql: w.Sql, + DisplayName: w.DisplayName, + Instruction: w.Instruction, + Synonyms: w.Synonyms, + }, nil +} + +type genieAgentSqlFilterWire struct { + Id *string `json:"id,omitempty"` + Sql *string `json:"sql,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + Instruction *string `json:"instruction,omitempty"` + Synonyms []string `json:"synonyms,omitempty"` +} + +func genieAgentSqlFilterToWire(v *GenieAgentSqlFilter) (*genieAgentSqlFilterWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentSqlFilterWire{ + Id: v.Id, + Sql: v.Sql, + DisplayName: v.DisplayName, + Instruction: v.Instruction, + Synonyms: v.Synonyms, + }, nil +} + +func genieAgentSqlFilterFromWire(w *genieAgentSqlFilterWire) (*GenieAgentSqlFilter, error) { + if w == nil { + return nil, nil + } + return &GenieAgentSqlFilter{ + Id: w.Id, + Sql: w.Sql, + DisplayName: w.DisplayName, + Instruction: w.Instruction, + Synonyms: w.Synonyms, + }, nil +} + +type genieAgentSqlFunctionWire struct { + Id *string `json:"id,omitempty"` + Identifier *string `json:"identifier,omitempty"` +} + +func genieAgentSqlFunctionToWire(v *GenieAgentSqlFunction) (*genieAgentSqlFunctionWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentSqlFunctionWire{ + Id: v.Id, + Identifier: v.Identifier, + }, nil +} + +func genieAgentSqlFunctionFromWire(w *genieAgentSqlFunctionWire) (*GenieAgentSqlFunction, error) { + if w == nil { + return nil, nil + } + return &GenieAgentSqlFunction{ + Id: w.Id, + Identifier: w.Identifier, + }, nil +} + +type genieAgentSqlMeasureWire struct { + Id *string `json:"id,omitempty"` + Alias *string `json:"alias,omitempty"` + Sql *string `json:"sql,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + Instruction *string `json:"instruction,omitempty"` + Synonyms []string `json:"synonyms,omitempty"` +} + +func genieAgentSqlMeasureToWire(v *GenieAgentSqlMeasure) (*genieAgentSqlMeasureWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentSqlMeasureWire{ + Id: v.Id, + Alias: v.Alias, + Sql: v.Sql, + DisplayName: v.DisplayName, + Instruction: v.Instruction, + Synonyms: v.Synonyms, + }, nil +} + +func genieAgentSqlMeasureFromWire(w *genieAgentSqlMeasureWire) (*GenieAgentSqlMeasure, error) { + if w == nil { + return nil, nil + } + return &GenieAgentSqlMeasure{ + Id: w.Id, + Alias: w.Alias, + Sql: w.Sql, + DisplayName: w.DisplayName, + Instruction: w.Instruction, + Synonyms: w.Synonyms, + }, nil +} + +type genieAgentSqlParameterWire struct { + Name *string `json:"name,omitempty"` + TypeHint *string `json:"type_hint,omitempty"` + Description *string `json:"description,omitempty"` + DefaultValue *genieAgentSqlParameterDefaultValueWire `json:"default_value,omitempty"` +} + +func genieAgentSqlParameterToWire(v *GenieAgentSqlParameter) (*genieAgentSqlParameterWire, error) { + if v == nil { + return nil, nil + } + defaultValueWireValue, err := genieAgentSqlParameterDefaultValueToWire(v.DefaultValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlParameter.DefaultValue", err) + } + return &genieAgentSqlParameterWire{ + Name: v.Name, + TypeHint: v.TypeHint, + Description: v.Description, + DefaultValue: defaultValueWireValue, + }, nil +} + +func genieAgentSqlParameterFromWire(w *genieAgentSqlParameterWire) (*GenieAgentSqlParameter, error) { + if w == nil { + return nil, nil + } + defaultValuePublicValue, err := genieAgentSqlParameterDefaultValueFromWire(w.DefaultValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlParameter.DefaultValue", err) + } + return &GenieAgentSqlParameter{ + Name: w.Name, + TypeHint: w.TypeHint, + Description: w.Description, + DefaultValue: defaultValuePublicValue, + }, nil +} + +type genieAgentSqlParameterDefaultRangeWire struct { + Min *string `json:"min,omitempty"` + Max *string `json:"max,omitempty"` +} + +func genieAgentSqlParameterDefaultRangeToWire(v *GenieAgentSqlParameterDefaultRange) (*genieAgentSqlParameterDefaultRangeWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentSqlParameterDefaultRangeWire{ + Min: v.Min, + Max: v.Max, + }, nil +} + +func genieAgentSqlParameterDefaultRangeFromWire(w *genieAgentSqlParameterDefaultRangeWire) (*GenieAgentSqlParameterDefaultRange, error) { + if w == nil { + return nil, nil + } + return &GenieAgentSqlParameterDefaultRange{ + Min: w.Min, + Max: w.Max, + }, nil +} + +type genieAgentSqlParameterDefaultValueWire struct { + Values []string `json:"values,omitempty"` + ValueRange *genieAgentSqlParameterDefaultRangeWire `json:"value_range,omitempty"` +} + +func genieAgentSqlParameterDefaultValueToWire(v *GenieAgentSqlParameterDefaultValue) (*genieAgentSqlParameterDefaultValueWire, error) { + if v == nil { + return nil, nil + } + valueRangeWireValue, err := genieAgentSqlParameterDefaultRangeToWire(v.ValueRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlParameterDefaultValue.ValueRange", err) + } + return &genieAgentSqlParameterDefaultValueWire{ + Values: v.Values, + ValueRange: valueRangeWireValue, + }, nil +} + +func genieAgentSqlParameterDefaultValueFromWire(w *genieAgentSqlParameterDefaultValueWire) (*GenieAgentSqlParameterDefaultValue, error) { + if w == nil { + return nil, nil + } + valueRangePublicValue, err := genieAgentSqlParameterDefaultRangeFromWire(w.ValueRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlParameterDefaultValue.ValueRange", err) + } + return &GenieAgentSqlParameterDefaultValue{ + Values: w.Values, + ValueRange: valueRangePublicValue, + }, nil +} + +type genieAgentSqlSnippetsWire struct { + Filters []genieAgentSqlFilterWire `json:"filters,omitempty"` + Expressions []genieAgentSqlExpressionWire `json:"expressions,omitempty"` + Measures []genieAgentSqlMeasureWire `json:"measures,omitempty"` +} + +func genieAgentSqlSnippetsToWire(v *GenieAgentSqlSnippets) (*genieAgentSqlSnippetsWire, error) { + if v == nil { + return nil, nil + } + filtersWireValue, err := convertSlice(v.Filters, genieAgentSqlFilterToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlSnippets.Filters", err) + } + expressionsWireValue, err := convertSlice(v.Expressions, genieAgentSqlExpressionToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlSnippets.Expressions", err) + } + measuresWireValue, err := convertSlice(v.Measures, genieAgentSqlMeasureToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlSnippets.Measures", err) + } + return &genieAgentSqlSnippetsWire{ + Filters: filtersWireValue, + Expressions: expressionsWireValue, + Measures: measuresWireValue, + }, nil +} + +func genieAgentSqlSnippetsFromWire(w *genieAgentSqlSnippetsWire) (*GenieAgentSqlSnippets, error) { + if w == nil { + return nil, nil + } + filtersPublicValue, err := convertSlice(w.Filters, genieAgentSqlFilterFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlSnippets.Filters", err) + } + expressionsPublicValue, err := convertSlice(w.Expressions, genieAgentSqlExpressionFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlSnippets.Expressions", err) + } + measuresPublicValue, err := convertSlice(w.Measures, genieAgentSqlMeasureFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentSqlSnippets.Measures", err) + } + return &GenieAgentSqlSnippets{ + Filters: filtersPublicValue, + Expressions: expressionsPublicValue, + Measures: measuresPublicValue, + }, nil +} + +type genieAgentTableWire struct { + Identifier *string `json:"identifier,omitempty"` + Description *string `json:"description,omitempty"` + ColumnConfigs []genieAgentColumnConfigWire `json:"column_configs,omitempty"` +} + +func genieAgentTableToWire(v *GenieAgentTable) (*genieAgentTableWire, error) { + if v == nil { + return nil, nil + } + columnConfigsWireValue, err := convertSlice(v.ColumnConfigs, genieAgentColumnConfigToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentTable.ColumnConfigs", err) + } + return &genieAgentTableWire{ + Identifier: v.Identifier, + Description: v.Description, + ColumnConfigs: columnConfigsWireValue, + }, nil +} + +func genieAgentTableFromWire(w *genieAgentTableWire) (*GenieAgentTable, error) { + if w == nil { + return nil, nil + } + columnConfigsPublicValue, err := convertSlice(w.ColumnConfigs, genieAgentColumnConfigFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAgentTable.ColumnConfigs", err) + } + return &GenieAgentTable{ + Identifier: w.Identifier, + Description: w.Description, + ColumnConfigs: columnConfigsPublicValue, + }, nil +} + +type genieAgentTextInstructionWire struct { + Id *string `json:"id,omitempty"` + Content *string `json:"content,omitempty"` +} + +func genieAgentTextInstructionToWire(v *GenieAgentTextInstruction) (*genieAgentTextInstructionWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentTextInstructionWire{ + Id: v.Id, + Content: v.Content, + }, nil +} + +func genieAgentTextInstructionFromWire(w *genieAgentTextInstructionWire) (*GenieAgentTextInstruction, error) { + if w == nil { + return nil, nil + } + return &GenieAgentTextInstruction{ + Id: w.Id, + Content: w.Content, + }, nil +} + +type genieAgentVolumeWire struct { + Path *string `json:"path,omitempty"` + Description *string `json:"description,omitempty"` +} + +func genieAgentVolumeToWire(v *GenieAgentVolume) (*genieAgentVolumeWire, error) { + if v == nil { + return nil, nil + } + return &genieAgentVolumeWire{ + Path: v.Path, + Description: v.Description, + }, nil +} + +func genieAgentVolumeFromWire(w *genieAgentVolumeWire) (*GenieAgentVolume, error) { + if w == nil { + return nil, nil + } + return &GenieAgentVolume{ + Path: w.Path, + Description: w.Description, + }, nil +} + +type listGenieAgentsRequestWire struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + View GenieAgentView `json:"view,omitempty"` +} + +func listGenieAgentsRequestToWire(v *ListGenieAgentsRequest) (*listGenieAgentsRequestWire, error) { + if v == nil { + return nil, nil + } + return &listGenieAgentsRequestWire{ + PageSize: v.PageSize, + PageToken: v.PageToken, + View: v.View, + }, nil +} + +type listGenieAgentsResponseWire struct { + GenieAgents []genieAgentWire `json:"genie_agents,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` + Unreachable []string `json:"unreachable,omitempty"` +} + +func listGenieAgentsResponseFromWire(w *listGenieAgentsResponseWire) (*ListGenieAgentsResponse, error) { + if w == nil { + return nil, nil + } + genieAgentsPublicValue, err := convertSlice(w.GenieAgents, genieAgentFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListGenieAgentsResponse.GenieAgents", err) + } + return &ListGenieAgentsResponse{ + GenieAgents: genieAgentsPublicValue, + NextPageToken: w.NextPageToken, + Unreachable: w.Unreachable, + }, nil +} + +type updateGenieAgentRequestWire struct { + GenieAgent *genieAgentWire `json:"genie_agent,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +func updateGenieAgentRequestToWire(v *UpdateGenieAgentRequest) (*updateGenieAgentRequestWire, error) { + if v == nil { + return nil, nil + } + genieAgentWireValue, err := genieAgentToWire(v.GenieAgent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGenieAgentRequest.GenieAgent", err) + } + return &updateGenieAgentRequestWire{ + GenieAgent: genieAgentWireValue, + UpdateMask: fieldMaskToWire(v.UpdateMask), + Etag: v.Etag, + }, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/go.work b/go.work index 3948c94e..79020649 100644 --- a/go.work +++ b/go.work @@ -17,6 +17,7 @@ use ( ./clusterpolicies ./clusters ./commandexecution + ./computemigrations ./core ./customllms ./database @@ -32,6 +33,7 @@ use ( ./files ./forecasting ./genie + ./genieagents ./gitcredentials ./globalinitscripts ./instancepools diff --git a/jobs/CHANGELOG.md b/jobs/CHANGELOG.md index a3dc007b..6c665a4f 100644 --- a/jobs/CHANGELOG.md +++ b/jobs/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.8.0 (2026-11-02) + ## Release v0.7.0 (2026-10-29) ## Release v0.6.0 (2026-10-26) diff --git a/jobs/internal/version.go b/jobs/internal/version.go index dfc58624..fd7acb76 100644 --- a/jobs/internal/version.go +++ b/jobs/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-jobs" -const Version = "0.7.0" +const Version = "0.8.0" diff --git a/jobs/v2/model.go b/jobs/v2/model.go index e4d1d1b3..6cc59ad8 100644 --- a/jobs/v2/model.go +++ b/jobs/v2/model.go @@ -435,6 +435,7 @@ const ( TriggerType_Continuous TriggerType = "CONTINUOUS" TriggerType_Table TriggerType = "TABLE" TriggerType_ContinuousRestart TriggerType = "CONTINUOUS_RESTART" + TriggerType_JobCompletion TriggerType = "JOB_COMPLETION" ) // * `NOTEBOOK`: Notebook view item. * `DASHBOARD`: Dashboard view item. @@ -590,6 +591,22 @@ const ( ConditionTask_ConditionTaskOperator_NotEqual ConditionTask_ConditionTaskOperator = "NOT_EQUAL" ) +// The status that all upstream jobs must have before a job completion trigger +// fires. +type JobCompletionTriggerConfiguration_IfStatus string + +const ( + JobCompletionTriggerConfiguration_IfStatus_Unspecified JobCompletionTriggerConfiguration_IfStatus = "" + // All upstream jobs completed successfully. A run is considered successful when + // its termination code is `SUCCESS` or `SUCCESS_WITH_FAILURES`. + JobCompletionTriggerConfiguration_IfStatus_Success JobCompletionTriggerConfiguration_IfStatus = "SUCCESS" + // All upstream jobs completed unsuccessfully. A run is considered unsuccessful + // when its termination code is neither `SUCCESS` nor `SUCCESS_WITH_FAILURES`. + JobCompletionTriggerConfiguration_IfStatus_Failed JobCompletionTriggerConfiguration_IfStatus = "FAILED" + // All upstream jobs completed, regardless of their termination codes. + JobCompletionTriggerConfiguration_IfStatus_Done JobCompletionTriggerConfiguration_IfStatus = "DONE" +) + // * `BUNDLE`: The job is managed by Databricks Asset Bundle. * // `SYSTEM_MANAGED`: The job is managed by and is read-only. type JobDeployment_DeploymentKind string @@ -1904,6 +1921,21 @@ type ClusterSpec_NewCluster_Size_Autoscale struct { func (*ClusterSpec_NewCluster_Size_Autoscale) isClusterSpec_NewCluster_Size() {} +// A single upstream completion that contributed to triggering the run, captured +// at trigger time. +type CompletedJob struct { + // The ID of the workspace containing the upstream job + WorkspaceId *string + // The ID of the upstream job + JobId *string + // The ID of the upstream run whose completion contributed to the trigger + RunId *string + // The termination code of the upstream run + TerminationCode TerminationCode_Code + // The completion time of the upstream run + CompletionTime *types.Time +} + type Compute struct { // Hardware accelerator configuration for Serverless GPU workloads. HardwareAccelerator HardwareAcceleratorType @@ -2086,13 +2118,16 @@ type CreateJobRequest struct { Deployment *JobDeployment // A list of task execution environment specifications that can be referenced by // tasks that use serverless compute or a compute resource that uses - // Environments mode. For notebook tasks that use serverless compute or a - // compute resource that uses Environments mode, if the environment_key is not - // specified, the notebook environment will be used if present. If a jobs - // environment is specified, it will override the notebook environment. For - // other tasks that use serverless compute or a compute resource that uses + // Environments mode. + // + // For notebook tasks that use serverless compute or a compute resource that + // uses Environments mode, if the `environment_key` is not specified, the + // notebook environment will be used if present. If a jobs environment is + // specified, it will override the notebook environment. + // + // For other tasks that use serverless compute or a compute resource that uses // Environments mode, the task environment is required to be specified using - // environment_key in the task settings. + // `environment_key` in the task settings. Environments []JobEnvironment // The id of the user specified budget policy to use for this job. If not // specified, a default budget policy may be applied when creating or modifying @@ -2481,37 +2516,41 @@ type Environment struct { // Use `environment_version` instead. Client *string // List of pip dependencies, as supported by the version of pip in this - // environment. Each dependency is a valid pip requirements file line per - // https://pip.pypa.io/en/stable/reference/requirements-file-format/. Allowed + // environment. Each dependency is a valid [pip requirements file line]. Allowed // dependencies include a requirement specifier, an archive URL, a local project - // path (such as WSFS or UC Volumes in ), or a VCS project URL. + // path (such as WSFS or UC Volumes in Databricks), or a VCS project URL. + // + // [pip requirements file line]: https://pip.pypa.io/en/stable/reference/requirements-file-format/ Dependencies []string // The base environment this environment is built on top of. A base environment // defines the environment version and a list of dependencies for serverless // compute. The value can be a file path to a custom `env.yaml` file (e.g., - // `/Workspace/path/to/env.yaml`). Support for a -provided base - // environment ID (e.g., `workspace-base-environments/databricks_ai_v4`) and - // workspace base environment ID (e.g., + // `/Workspace/path/to/env.yaml`). + // + // Support for a Databricks-provided base environment ID (e.g., + // `workspace-base-environments/databricks_ai_v4`) and workspace base + // environment ID (e.g., // `workspace-base-environments/dbe_b849b66e-b31a-4cb5-b161-1f2b10877fb7`) is in - // Beta. Either `environment_version` or `base_environment` can be provided. For - // more information about -provided base environments, see the [list - // workspace base - // environments](:method:Environments/ListWorkspaceBaseEnvironments) API. For - // more information, see + // Beta. + // + // Either `environment_version` or `base_environment` can be provided. + // + // For more information about Databricks-provided base environments, see the + // [list workspace base + // environments](:method:Environments/ListWorkspaceBaseEnvironments) API. BaseEnvironment *string - // Either `environment_version` or `base_environment` needs to be provided. - // Environment version used by the environment. Each version comes with a - // specific Python version and a set of Python packages. The version is a - // string, consisting of an integer. + // The environment version used by this environment. Either + // `environment_version` or `base_environment` must be provided. Each version + // comes with a specific Python version and a set of Python packages. The + // version is a string, consisting of an integer. EnvironmentVersion *string - // List of java dependencies. Each dependency is a string representing a java + // List of Java dependencies. Each dependency is a string representing a Java // library path. For example: `/Volumes/path/to/test.jar`. JavaDependencies []string // Path to the `pyproject.toml` file that defines the project environment. This // field cannot be combined with `environment_version`, `base_environment`, // dependency fields, or any other environment-source fields. Set the - // environment version and dependencies in `pyproject.toml` instead. For more - // information, see the serverless dependencies documentation. + // environment version and dependencies in `pyproject.toml` instead. ProjectEnvironment *string } @@ -3173,6 +3212,77 @@ type JobCluster struct { // JobCluster per job may set this field; the rate limit defined on the // referenced serverless compute applies across all tasks bound to this cluster. ServerlessComputeId *string + // Serverless compute settings for this cluster. At most one job cluster per job + // may set this field; the rate limit defined on the referenced policy applies + // across all tasks bound to this cluster. + ServerlessCompute *JobCluster_ServerlessCompute +} + +// Serverless compute settings for a job cluster.. +type JobCluster_ServerlessCompute struct { + // The ID of the serverless compute policy to apply to this cluster. + PolicyId *string +} + +// A trigger that starts a run after every upstream job completes with a +// configured status.. +type JobCompletionTriggerConfiguration struct { + // The upstream jobs to monitor. Each job must be in a workspace attached to the + // same Unity Catalog metastore as the downstream job. A maximum of 10 jobs can + // be monitored. + Jobs []JobCompletionTriggerConfiguration_MonitoredJob + // The status that all upstream jobs must have before this trigger fires. + // Defaults to SUCCESS. + IfStatus JobCompletionTriggerConfiguration_IfStatus +} + +// An upstream job to monitor.. +type JobCompletionTriggerConfiguration_MonitoredJob struct { + // The ID of the workspace containing the upstream job. This can differ from the + // caller's workspace and downstream services enforce correct entitlements and + // CAN_VIEW permissions for the user + job combination. SDR: + // https://databricks.atlassian.net/browse/SDR-5267 + WorkspaceId *string + // The ID of the upstream job. + JobId *string +} + +// Contains the immutable set of upstream completions that triggered the run, in +// configured jobs order. +type JobCompletionTriggerRunInfoDetails struct { + CompletedJobs []CompletedJob +} + +// Runtime state for a job completion trigger.. +type JobCompletionTriggerState struct { + // State for each configured upstream job, in the same order as `jobs`. + MonitoredJobStates []JobCompletionTriggerState_MonitoredJobState +} + +type JobCompletionTriggerState_MonitoredJobState struct { + // The ID of the workspace containing the upstream job. + WorkspaceId *string + // The ID of the upstream job. + JobId *string + // The completion time of the latest matching upstream run observed by the + // trigger. + LastSeenCompletionTime *types.Time + // The ID of the latest matching upstream run observed by the trigger. + LastSeenRunId *string + // Whether this job has contributed a matching completion toward the next + // trigger fire. + HasSeenCompletion *bool + // The termination code of the latest matching upstream run observed by the + // trigger. + LastSeenResult TerminationCode_Code + // Whether the upstream job was missing or deleted when last observed by this + // trigger. Omitted when deletion status is unknown. This observation may become + // stale while the trigger is paused or evaluation cannot access the upstream + // job. + IsDeleted *bool + // The termination code of the latest upstream run if it does not satisfy + // `if_status`. Unset when the latest run matches or no run has been observed. + LatestNonMatchingResult TerminationCode_Code } type JobDeployment struct { @@ -3431,13 +3541,16 @@ type JobSettings struct { Deployment *JobDeployment // A list of task execution environment specifications that can be referenced by // tasks that use serverless compute or a compute resource that uses - // Environments mode. For notebook tasks that use serverless compute or a - // compute resource that uses Environments mode, if the environment_key is not - // specified, the notebook environment will be used if present. If a jobs - // environment is specified, it will override the notebook environment. For - // other tasks that use serverless compute or a compute resource that uses + // Environments mode. + // + // For notebook tasks that use serverless compute or a compute resource that + // uses Environments mode, if the `environment_key` is not specified, the + // notebook environment will be used if present. If a jobs environment is + // specified, it will override the notebook environment. + // + // For other tasks that use serverless compute or a compute resource that uses // Environments mode, the task environment is required to be specified using - // environment_key in the task settings. + // `environment_key` in the task settings. Environments []JobEnvironment // The id of the user specified budget policy to use for this job. If not // specified, a default budget policy may be applied when creating or modifying @@ -3971,6 +4084,13 @@ type PerTriggerState_TriggerType_Model struct { func (*PerTriggerState_TriggerType_Model) isPerTriggerState_TriggerType() {} +// PerTriggerState_TriggerType_JobCompletion selects JobCompletion for PerTriggerState.TriggerType. +type PerTriggerState_TriggerType_JobCompletion struct { + JobCompletion JobCompletionTriggerState +} + +func (*PerTriggerState_TriggerType_JobCompletion) isPerTriggerState_TriggerType() {} + type PerformanceTarget struct { } @@ -5647,6 +5767,9 @@ func (*RunTaskSettings_Spec_JobClusterKey) isRunTaskSettings_Spec() {} type RunTriggerInfo struct { // SQL condition evaluation details for this run SqlCondition *SqlConditionRunInfoDetails + // Additional details for job runs triggered by a job completion trigger + // (trigger: "JOB_COMPLETION") + JobCompletion *JobCompletionTriggerRunInfoDetails // The run id of the Run Job task run RunId *int64 } @@ -6626,6 +6749,8 @@ type TriggerConfiguration struct { TableUpdate *TableTriggerConfiguration // Model trigger configuration. Model *ModelTriggerConfiguration + // Job completion trigger configuration. + JobCompletion *JobCompletionTriggerConfiguration // Optional SQL condition that gates whether this trigger fires. SqlCondition *SqlConditionConfiguration } @@ -6706,6 +6831,14 @@ type TriggerSettings_Configuration_Model struct { func (*TriggerSettings_Configuration_Model) isTriggerSettings_Configuration() {} +// TriggerSettings_Configuration_JobCompletion selects JobCompletion for TriggerSettings.Configuration. +// Job completion trigger settings. +type TriggerSettings_Configuration_JobCompletion struct { + JobCompletion JobCompletionTriggerConfiguration +} + +func (*TriggerSettings_Configuration_JobCompletion) isTriggerSettings_Configuration() {} + type TriggerState struct { // (-- Next ID: 8. --) TriggerType isTriggerState_TriggerType @@ -6735,6 +6868,13 @@ type TriggerState_TriggerType_FileArrival struct { func (*TriggerState_TriggerType_FileArrival) isTriggerState_TriggerType() {} +// TriggerState_TriggerType_JobCompletion selects JobCompletion for TriggerState.TriggerType. +type TriggerState_TriggerType_JobCompletion struct { + JobCompletion JobCompletionTriggerState +} + +func (*TriggerState_TriggerType_JobCompletion) isTriggerState_TriggerType() {} + type UpdateJobRequest struct { // The canonical identifier of the job to update. This field is required. JobId *int64 diff --git a/jobs/v2/wire.go b/jobs/v2/wire.go index cbba0141..62df5687 100644 --- a/jobs/v2/wire.go +++ b/jobs/v2/wire.go @@ -1534,6 +1534,27 @@ func clusterSpec_NewClusterFromWire(w *clusterSpec_NewClusterWire) (*ClusterSpec }, nil } +type completedJobWire struct { + WorkspaceId *string `json:"workspace_id,omitempty"` + JobId *string `json:"job_id,omitempty"` + RunId *string `json:"run_id,omitempty"` + TerminationCode TerminationCode_Code `json:"termination_code,omitempty"` + CompletionTime *types.Time `json:"completion_time,omitempty"` +} + +func completedJobFromWire(w *completedJobWire) (*CompletedJob, error) { + if w == nil { + return nil, nil + } + return &CompletedJob{ + WorkspaceId: w.WorkspaceId, + JobId: w.JobId, + RunId: w.RunId, + TerminationCode: w.TerminationCode, + CompletionTime: w.CompletionTime, + }, nil +} + type computeWire struct { HardwareAccelerator HardwareAcceleratorType `json:"hardware_accelerator,omitempty"` } @@ -3552,9 +3573,10 @@ func initScriptInfoFromWire(w *initScriptInfoWire) (*InitScriptInfo, error) { } type jobClusterWire struct { - JobClusterKey *string `json:"job_cluster_key,omitempty"` - NewCluster *clusterSpec_NewClusterWire `json:"new_cluster,omitempty"` - ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` + JobClusterKey *string `json:"job_cluster_key,omitempty"` + NewCluster *clusterSpec_NewClusterWire `json:"new_cluster,omitempty"` + ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` + ServerlessCompute *jobCluster_ServerlessComputeWire `json:"serverless_compute,omitempty"` } func jobClusterToWire(v *JobCluster) (*jobClusterWire, error) { @@ -3565,10 +3587,15 @@ func jobClusterToWire(v *JobCluster) (*jobClusterWire, error) { if err != nil { return nil, fmt.Errorf("%s: %w", "JobCluster.NewCluster", err) } + serverlessComputeWireValue, err := jobCluster_ServerlessComputeToWire(v.ServerlessCompute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCluster.ServerlessCompute", err) + } return &jobClusterWire{ JobClusterKey: v.JobClusterKey, NewCluster: newClusterWireValue, ServerlessComputeId: v.ServerlessComputeId, + ServerlessCompute: serverlessComputeWireValue, }, nil } @@ -3580,10 +3607,156 @@ func jobClusterFromWire(w *jobClusterWire) (*JobCluster, error) { if err != nil { return nil, fmt.Errorf("%s: %w", "JobCluster.NewCluster", err) } + serverlessComputePublicValue, err := jobCluster_ServerlessComputeFromWire(w.ServerlessCompute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCluster.ServerlessCompute", err) + } return &JobCluster{ JobClusterKey: w.JobClusterKey, NewCluster: newClusterPublicValue, ServerlessComputeId: w.ServerlessComputeId, + ServerlessCompute: serverlessComputePublicValue, + }, nil +} + +type jobCluster_ServerlessComputeWire struct { + PolicyId *string `json:"policy_id,omitempty"` +} + +func jobCluster_ServerlessComputeToWire(v *JobCluster_ServerlessCompute) (*jobCluster_ServerlessComputeWire, error) { + if v == nil { + return nil, nil + } + return &jobCluster_ServerlessComputeWire{ + PolicyId: v.PolicyId, + }, nil +} + +func jobCluster_ServerlessComputeFromWire(w *jobCluster_ServerlessComputeWire) (*JobCluster_ServerlessCompute, error) { + if w == nil { + return nil, nil + } + return &JobCluster_ServerlessCompute{ + PolicyId: w.PolicyId, + }, nil +} + +type jobCompletionTriggerConfigurationWire struct { + Jobs []jobCompletionTriggerConfiguration_MonitoredJobWire `json:"jobs,omitempty"` + IfStatus JobCompletionTriggerConfiguration_IfStatus `json:"if_status,omitempty"` +} + +func jobCompletionTriggerConfigurationToWire(v *JobCompletionTriggerConfiguration) (*jobCompletionTriggerConfigurationWire, error) { + if v == nil { + return nil, nil + } + jobsWireValue, err := convertSlice(v.Jobs, jobCompletionTriggerConfiguration_MonitoredJobToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCompletionTriggerConfiguration.Jobs", err) + } + return &jobCompletionTriggerConfigurationWire{ + Jobs: jobsWireValue, + IfStatus: v.IfStatus, + }, nil +} + +func jobCompletionTriggerConfigurationFromWire(w *jobCompletionTriggerConfigurationWire) (*JobCompletionTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + jobsPublicValue, err := convertSlice(w.Jobs, jobCompletionTriggerConfiguration_MonitoredJobFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCompletionTriggerConfiguration.Jobs", err) + } + return &JobCompletionTriggerConfiguration{ + Jobs: jobsPublicValue, + IfStatus: w.IfStatus, + }, nil +} + +type jobCompletionTriggerConfiguration_MonitoredJobWire struct { + WorkspaceId *string `json:"workspace_id,omitempty"` + JobId *string `json:"job_id,omitempty"` +} + +func jobCompletionTriggerConfiguration_MonitoredJobToWire(v *JobCompletionTriggerConfiguration_MonitoredJob) (*jobCompletionTriggerConfiguration_MonitoredJobWire, error) { + if v == nil { + return nil, nil + } + return &jobCompletionTriggerConfiguration_MonitoredJobWire{ + WorkspaceId: v.WorkspaceId, + JobId: v.JobId, + }, nil +} + +func jobCompletionTriggerConfiguration_MonitoredJobFromWire(w *jobCompletionTriggerConfiguration_MonitoredJobWire) (*JobCompletionTriggerConfiguration_MonitoredJob, error) { + if w == nil { + return nil, nil + } + return &JobCompletionTriggerConfiguration_MonitoredJob{ + WorkspaceId: w.WorkspaceId, + JobId: w.JobId, + }, nil +} + +type jobCompletionTriggerRunInfoDetailsWire struct { + CompletedJobs []completedJobWire `json:"completed_jobs,omitempty"` +} + +func jobCompletionTriggerRunInfoDetailsFromWire(w *jobCompletionTriggerRunInfoDetailsWire) (*JobCompletionTriggerRunInfoDetails, error) { + if w == nil { + return nil, nil + } + completedJobsPublicValue, err := convertSlice(w.CompletedJobs, completedJobFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCompletionTriggerRunInfoDetails.CompletedJobs", err) + } + return &JobCompletionTriggerRunInfoDetails{ + CompletedJobs: completedJobsPublicValue, + }, nil +} + +type jobCompletionTriggerStateWire struct { + MonitoredJobStates []jobCompletionTriggerState_MonitoredJobStateWire `json:"monitored_job_states,omitempty"` +} + +func jobCompletionTriggerStateFromWire(w *jobCompletionTriggerStateWire) (*JobCompletionTriggerState, error) { + if w == nil { + return nil, nil + } + monitoredJobStatesPublicValue, err := convertSlice(w.MonitoredJobStates, jobCompletionTriggerState_MonitoredJobStateFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCompletionTriggerState.MonitoredJobStates", err) + } + return &JobCompletionTriggerState{ + MonitoredJobStates: monitoredJobStatesPublicValue, + }, nil +} + +type jobCompletionTriggerState_MonitoredJobStateWire struct { + WorkspaceId *string `json:"workspace_id,omitempty"` + JobId *string `json:"job_id,omitempty"` + LastSeenCompletionTime *types.Time `json:"last_seen_completion_time,omitempty"` + LastSeenRunId *string `json:"last_seen_run_id,omitempty"` + HasSeenCompletion *bool `json:"has_seen_completion,omitempty"` + LastSeenResult TerminationCode_Code `json:"last_seen_result,omitempty"` + IsDeleted *bool `json:"is_deleted,omitempty"` + LatestNonMatchingResult TerminationCode_Code `json:"latest_non_matching_result,omitempty"` +} + +func jobCompletionTriggerState_MonitoredJobStateFromWire(w *jobCompletionTriggerState_MonitoredJobStateWire) (*JobCompletionTriggerState_MonitoredJobState, error) { + if w == nil { + return nil, nil + } + return &JobCompletionTriggerState_MonitoredJobState{ + WorkspaceId: w.WorkspaceId, + JobId: w.JobId, + LastSeenCompletionTime: w.LastSeenCompletionTime, + LastSeenRunId: w.LastSeenRunId, + HasSeenCompletion: w.HasSeenCompletion, + LastSeenResult: w.LastSeenResult, + IsDeleted: w.IsDeleted, + LatestNonMatchingResult: w.LatestNonMatchingResult, }, nil } @@ -4807,14 +4980,15 @@ func outputSchemaInfoFromWire(w *outputSchemaInfoWire) (*OutputSchemaInfo, error } type perTriggerStateWire struct { - Periodic *periodicTriggerStateWire `json:"periodic,omitempty"` - Schedule *scheduleTriggerStateWire `json:"schedule,omitempty"` - Continuous *continuousTriggerStateWire `json:"continuous,omitempty"` - FileArrival *fileArrivalTriggerStateWire `json:"file_arrival,omitempty"` - TableUpdate *tableTriggerStateWire `json:"table_update,omitempty"` - Model *modelTriggerStateWire `json:"model,omitempty"` - SqlCondition *sqlConditionStateWire `json:"sql_condition,omitempty"` - PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + Periodic *periodicTriggerStateWire `json:"periodic,omitempty"` + Schedule *scheduleTriggerStateWire `json:"schedule,omitempty"` + Continuous *continuousTriggerStateWire `json:"continuous,omitempty"` + FileArrival *fileArrivalTriggerStateWire `json:"file_arrival,omitempty"` + TableUpdate *tableTriggerStateWire `json:"table_update,omitempty"` + Model *modelTriggerStateWire `json:"model,omitempty"` + JobCompletion *jobCompletionTriggerStateWire `json:"job_completion,omitempty"` + SqlCondition *sqlConditionStateWire `json:"sql_condition,omitempty"` + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` } func perTriggerStateFromWire(w *perTriggerStateWire) (*PerTriggerState, error) { @@ -4840,6 +5014,9 @@ func perTriggerStateFromWire(w *perTriggerStateWire) (*PerTriggerState, error) { if w.Model != nil { triggerTypeMembers++ } + if w.JobCompletion != nil { + triggerTypeMembers++ + } if triggerTypeMembers > 1 { return nil, fmt.Errorf("%s: multiple oneof members set", "PerTriggerState.TriggerType") } @@ -4885,6 +5062,12 @@ func perTriggerStateFromWire(w *perTriggerStateWire) (*PerTriggerState, error) { return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType.Model", err) } triggerTypeSelection = &PerTriggerState_TriggerType_Model{Model: *triggerTypeModelConverted} + case w.JobCompletion != nil: + triggerTypeJobCompletionConverted, err := jobCompletionTriggerStateFromWire(w.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType.JobCompletion", err) + } + triggerTypeSelection = &PerTriggerState_TriggerType_JobCompletion{JobCompletion: *triggerTypeJobCompletionConverted} } return &PerTriggerState{ SqlCondition: sqlConditionPublicValue, @@ -6996,8 +7179,9 @@ func runTaskSettingsToWire(v *RunTaskSettings) (*runTaskSettingsWire, error) { } type runTriggerInfoWire struct { - SqlCondition *sqlConditionRunInfoDetailsWire `json:"sql_condition,omitempty"` - RunId *wireInt64 `json:"run_id,omitempty"` + SqlCondition *sqlConditionRunInfoDetailsWire `json:"sql_condition,omitempty"` + JobCompletion *jobCompletionTriggerRunInfoDetailsWire `json:"job_completion,omitempty"` + RunId *wireInt64 `json:"run_id,omitempty"` } func runTriggerInfoFromWire(w *runTriggerInfoWire) (*RunTriggerInfo, error) { @@ -7008,13 +7192,18 @@ func runTriggerInfoFromWire(w *runTriggerInfoWire) (*RunTriggerInfo, error) { if err != nil { return nil, fmt.Errorf("%s: %w", "RunTriggerInfo.SqlCondition", err) } + jobCompletionPublicValue, err := jobCompletionTriggerRunInfoDetailsFromWire(w.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTriggerInfo.JobCompletion", err) + } runIdPublicValue, err := int64FromWire(w.RunId) if err != nil { return nil, fmt.Errorf("%s: %w", "RunTriggerInfo.RunId", err) } return &RunTriggerInfo{ - SqlCondition: sqlConditionPublicValue, - RunId: runIdPublicValue, + SqlCondition: sqlConditionPublicValue, + JobCompletion: jobCompletionPublicValue, + RunId: runIdPublicValue, }, nil } @@ -8924,14 +9113,15 @@ func terminationDetailsFromWire(w *terminationDetailsWire) (*TerminationDetails, } type triggerConfigurationWire struct { - PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` - Periodic *periodicTriggerConfigurationWire `json:"periodic,omitempty"` - Schedule *cronTriggerConfigurationWire `json:"schedule,omitempty"` - Continuous *continuousTriggerConfigurationWire `json:"continuous,omitempty"` - FileArrival *fileArrivalTriggerConfigurationWire `json:"file_arrival,omitempty"` - TableUpdate *tableTriggerConfigurationWire `json:"table_update,omitempty"` - Model *modelTriggerConfigurationWire `json:"model,omitempty"` - SqlCondition *sqlConditionConfigurationWire `json:"sql_condition,omitempty"` + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + Periodic *periodicTriggerConfigurationWire `json:"periodic,omitempty"` + Schedule *cronTriggerConfigurationWire `json:"schedule,omitempty"` + Continuous *continuousTriggerConfigurationWire `json:"continuous,omitempty"` + FileArrival *fileArrivalTriggerConfigurationWire `json:"file_arrival,omitempty"` + TableUpdate *tableTriggerConfigurationWire `json:"table_update,omitempty"` + Model *modelTriggerConfigurationWire `json:"model,omitempty"` + JobCompletion *jobCompletionTriggerConfigurationWire `json:"job_completion,omitempty"` + SqlCondition *sqlConditionConfigurationWire `json:"sql_condition,omitempty"` } func triggerConfigurationToWire(v *TriggerConfiguration) (*triggerConfigurationWire, error) { @@ -8962,19 +9152,24 @@ func triggerConfigurationToWire(v *TriggerConfiguration) (*triggerConfigurationW if err != nil { return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Model", err) } + jobCompletionWireValue, err := jobCompletionTriggerConfigurationToWire(v.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.JobCompletion", err) + } sqlConditionWireValue, err := sqlConditionConfigurationToWire(v.SqlCondition) if err != nil { return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.SqlCondition", err) } return &triggerConfigurationWire{ - PauseStatus: v.PauseStatus, - Periodic: periodicWireValue, - Schedule: scheduleWireValue, - Continuous: continuousWireValue, - FileArrival: fileArrivalWireValue, - TableUpdate: tableUpdateWireValue, - Model: modelWireValue, - SqlCondition: sqlConditionWireValue, + PauseStatus: v.PauseStatus, + Periodic: periodicWireValue, + Schedule: scheduleWireValue, + Continuous: continuousWireValue, + FileArrival: fileArrivalWireValue, + TableUpdate: tableUpdateWireValue, + Model: modelWireValue, + JobCompletion: jobCompletionWireValue, + SqlCondition: sqlConditionWireValue, }, nil } @@ -9006,19 +9201,24 @@ func triggerConfigurationFromWire(w *triggerConfigurationWire) (*TriggerConfigur if err != nil { return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Model", err) } + jobCompletionPublicValue, err := jobCompletionTriggerConfigurationFromWire(w.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.JobCompletion", err) + } sqlConditionPublicValue, err := sqlConditionConfigurationFromWire(w.SqlCondition) if err != nil { return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.SqlCondition", err) } return &TriggerConfiguration{ - PauseStatus: w.PauseStatus, - Periodic: periodicPublicValue, - Schedule: schedulePublicValue, - Continuous: continuousPublicValue, - FileArrival: fileArrivalPublicValue, - TableUpdate: tableUpdatePublicValue, - Model: modelPublicValue, - SqlCondition: sqlConditionPublicValue, + PauseStatus: w.PauseStatus, + Periodic: periodicPublicValue, + Schedule: schedulePublicValue, + Continuous: continuousPublicValue, + FileArrival: fileArrivalPublicValue, + TableUpdate: tableUpdatePublicValue, + Model: modelPublicValue, + JobCompletion: jobCompletionPublicValue, + SqlCondition: sqlConditionPublicValue, }, nil } @@ -9100,12 +9300,13 @@ func triggerHistoryFromWire(w *triggerHistoryWire) (*TriggerHistory, error) { } type triggerSettingsWire struct { - PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` - FileArrival *fileArrivalTriggerConfigurationWire `json:"file_arrival,omitempty"` - Periodic *periodicTriggerConfigurationWire `json:"periodic,omitempty"` - TableUpdate *tableTriggerConfigurationWire `json:"table_update,omitempty"` - Model *modelTriggerConfigurationWire `json:"model,omitempty"` - SqlCondition *sqlConditionConfigurationWire `json:"sql_condition,omitempty"` + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + FileArrival *fileArrivalTriggerConfigurationWire `json:"file_arrival,omitempty"` + Periodic *periodicTriggerConfigurationWire `json:"periodic,omitempty"` + TableUpdate *tableTriggerConfigurationWire `json:"table_update,omitempty"` + Model *modelTriggerConfigurationWire `json:"model,omitempty"` + JobCompletion *jobCompletionTriggerConfigurationWire `json:"job_completion,omitempty"` + SqlCondition *sqlConditionConfigurationWire `json:"sql_condition,omitempty"` } func triggerSettingsToWire(v *TriggerSettings) (*triggerSettingsWire, error) { @@ -9120,6 +9321,7 @@ func triggerSettingsToWire(v *TriggerSettings) (*triggerSettingsWire, error) { var configurationPeriodicWire *periodicTriggerConfigurationWire var configurationTableUpdateWire *tableTriggerConfigurationWire var configurationModelWire *modelTriggerConfigurationWire + var configurationJobCompletionWire *jobCompletionTriggerConfigurationWire switch value := v.Configuration.(type) { case nil: case *TriggerSettings_Configuration_FileArrival: @@ -9154,16 +9356,25 @@ func triggerSettingsToWire(v *TriggerSettings) (*triggerSettingsWire, error) { } configurationModelWire = configurationModelConverted } + case *TriggerSettings_Configuration_JobCompletion: + if value != nil { + configurationJobCompletionConverted, err := jobCompletionTriggerConfigurationToWire(&value.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration.JobCompletion", err) + } + configurationJobCompletionWire = configurationJobCompletionConverted + } default: return nil, fmt.Errorf("%s: unsupported oneof implementation %T", "TriggerSettings.Configuration", value) } return &triggerSettingsWire{ - PauseStatus: v.PauseStatus, - FileArrival: configurationFileArrivalWire, - Periodic: configurationPeriodicWire, - TableUpdate: configurationTableUpdateWire, - Model: configurationModelWire, - SqlCondition: sqlConditionWireValue, + PauseStatus: v.PauseStatus, + FileArrival: configurationFileArrivalWire, + Periodic: configurationPeriodicWire, + TableUpdate: configurationTableUpdateWire, + Model: configurationModelWire, + JobCompletion: configurationJobCompletionWire, + SqlCondition: sqlConditionWireValue, }, nil } @@ -9184,6 +9395,9 @@ func triggerSettingsFromWire(w *triggerSettingsWire) (*TriggerSettings, error) { if w.Model != nil { configurationMembers++ } + if w.JobCompletion != nil { + configurationMembers++ + } if configurationMembers > 1 { return nil, fmt.Errorf("%s: multiple oneof members set", "TriggerSettings.Configuration") } @@ -9217,6 +9431,12 @@ func triggerSettingsFromWire(w *triggerSettingsWire) (*TriggerSettings, error) { return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration.Model", err) } configurationSelection = &TriggerSettings_Configuration_Model{Model: *configurationModelConverted} + case w.JobCompletion != nil: + configurationJobCompletionConverted, err := jobCompletionTriggerConfigurationFromWire(w.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration.JobCompletion", err) + } + configurationSelection = &TriggerSettings_Configuration_JobCompletion{JobCompletion: *configurationJobCompletionConverted} } return &TriggerSettings{ PauseStatus: w.PauseStatus, @@ -9226,10 +9446,11 @@ func triggerSettingsFromWire(w *triggerSettingsWire) (*TriggerSettings, error) { } type triggerStateWire struct { - Table *tableTriggerStateWire `json:"table,omitempty"` - FileArrival *fileArrivalTriggerStateWire `json:"file_arrival,omitempty"` - SqlCondition *sqlConditionStateWire `json:"sql_condition,omitempty"` - PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + Table *tableTriggerStateWire `json:"table,omitempty"` + FileArrival *fileArrivalTriggerStateWire `json:"file_arrival,omitempty"` + JobCompletion *jobCompletionTriggerStateWire `json:"job_completion,omitempty"` + SqlCondition *sqlConditionStateWire `json:"sql_condition,omitempty"` + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` } func triggerStateFromWire(w *triggerStateWire) (*TriggerState, error) { @@ -9243,6 +9464,9 @@ func triggerStateFromWire(w *triggerStateWire) (*TriggerState, error) { if w.FileArrival != nil { triggerTypeMembers++ } + if w.JobCompletion != nil { + triggerTypeMembers++ + } if triggerTypeMembers > 1 { return nil, fmt.Errorf("%s: multiple oneof members set", "TriggerState.TriggerType") } @@ -9264,6 +9488,12 @@ func triggerStateFromWire(w *triggerStateWire) (*TriggerState, error) { return nil, fmt.Errorf("%s: %w", "TriggerState.TriggerType.FileArrival", err) } triggerTypeSelection = &TriggerState_TriggerType_FileArrival{FileArrival: *triggerTypeFileArrivalConverted} + case w.JobCompletion != nil: + triggerTypeJobCompletionConverted, err := jobCompletionTriggerStateFromWire(w.JobCompletion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.TriggerType.JobCompletion", err) + } + triggerTypeSelection = &TriggerState_TriggerType_JobCompletion{JobCompletion: *triggerTypeJobCompletionConverted} } return &TriggerState{ SqlCondition: sqlConditionPublicValue, diff --git a/networking/CHANGELOG.md b/networking/CHANGELOG.md index 76979521..d94b3be5 100644 --- a/networking/CHANGELOG.md +++ b/networking/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.6.0 (2026-11-02) + ## Release v0.5.0 (2026-10-22) ## Release v0.4.0 (2026-10-15) diff --git a/networking/internal/version.go b/networking/internal/version.go index d1d65772..f819e136 100644 --- a/networking/internal/version.go +++ b/networking/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-networking" -const Version = "0.5.0" +const Version = "0.6.0" diff --git a/networking/v1/client.go b/networking/v1/client.go index 56d65011..c0e956cd 100644 --- a/networking/v1/client.go +++ b/networking/v1/client.go @@ -20,6 +20,7 @@ import ( "github.com/databricks/sdk-go/options/call" "github.com/databricks/sdk-go/options/client" "github.com/databricks/sdk-go/options/internaloptions" + "github.com/databricks/sdk-go/options/lro" ) type Client struct { @@ -1607,6 +1608,87 @@ func (c *internalClient) ListNetworkConnectivityConfigsPublicIter(ctx context.Co } } +// Updates the name or billing workspace for a network connectivity +// configuration. +// Account-level method. Uses the Client's accountID, overridable per call via req.AccountId. +func (c *internalClient) UpdateNetworkConnectivityConfig(ctx context.Context, req UpdateNetworkConnectivityConfigRequest, opts ...call.Option) (*NetworkConnectivityConfig, error) { + wireReq, err := updateNetworkConnectivityConfigRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq.NetworkConnectivityConfig) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + accountID := c.accountID + if req.AccountId != nil && *req.AccountId != "" { + accountID = *req.AccountId + } + pb := pathBuilder{} + pb.literal("/api/2.0/accounts/") + pb.singleSegment(accountID) + pb.literal("/network-connectivity-configs/") + if req.NetworkConnectivityConfigId == nil { + pb.singleSegment("") + } else { + pb.singleSegment(*req.NetworkConnectivityConfigId) + } + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "update_mask", wireReq.UpdateMask); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *NetworkConnectivityConfig + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "PATCH", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp networkConnectivityConfigWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = networkConnectivityConfigFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + // Create a private endpoint rule for the specified network connectivity config // object. Once the object is created, asynchronously provisions a // new Azure private endpoint to your specified Azure resource. @@ -2437,6 +2519,553 @@ func (c *internalClient) UpdateNetworkPolicyRpc(ctx context.Context, req UpdateN return resp, nil } +// Creates a private network gateway. +func (c *internalClient) createPrivateNetworkGatewayBase(ctx context.Context, req CreatePrivateNetworkGatewayRequest, opts ...call.Option) (*Operation, error) { + wireReq, err := createPrivateNetworkGatewayRequestToWire(&req) + if err != nil { + return nil, err + } + if wireReq.RequestId == nil || *wireReq.RequestId == "" { + wireReq.RequestId = new(generateRequestID()) + } + body, err := json.Marshal(wireReq.PrivateNetworkGateway) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/networking/v1/") + if req.Parent == nil { + return nil, fmt.Errorf("path parameter %q is required", "parent") + } + pb.singleSegment(*req.Parent) + pb.literal("/private-network-gateways") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "request_id", wireReq.RequestId); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Operation + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "POST", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp operationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = operationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Creates a private network gateway. +func (c *internalClient) CreatePrivateNetworkGateway(ctx context.Context, req CreatePrivateNetworkGatewayRequest, opts ...call.Option) (*CreatePrivateNetworkGatewayOperation, error) { + operation, err := c.createPrivateNetworkGatewayBase(ctx, req, opts...) + if err != nil { + return nil, err + } + if err := validateOperationName(operation.Name); err != nil { + return nil, err + } + return &CreatePrivateNetworkGatewayOperation{ + operation: operation, + getOperation: c.getPrivateNetworkGatewayOperation, + }, nil +} + +// CreatePrivateNetworkGatewayOperation tracks the state of the long-running operation started by CreatePrivateNetworkGateway. +type CreatePrivateNetworkGatewayOperation struct { + operation *Operation + getOperation func(context.Context, GetOperationRequest, ...call.Option) (*Operation, error) +} + +// Name returns the server-assigned operation name. +func (o *CreatePrivateNetworkGatewayOperation) Name() *string { + return o.operation.Name +} + +// Metadata returns metadata associated with the operation. +func (o *CreatePrivateNetworkGatewayOperation) Metadata() (*PrivateNetworkGatewayOperationMetadata, error) { + if len(o.operation.Metadata) == 0 || bytes.Equal(bytes.TrimSpace(o.operation.Metadata), []byte("null")) { + return nil, nil + } + var metadata privateNetworkGatewayOperationMetadataWire + if err := json.Unmarshal(o.operation.Metadata, &metadata); err != nil { + return nil, fmt.Errorf("decode operation metadata: %w", err) + } + converted, err := privateNetworkGatewayOperationMetadataFromWire(&metadata) + if err != nil { + return nil, err + } + return converted, nil +} + +// Done refreshes the operation and reports whether it has completed. +func (o *CreatePrivateNetworkGatewayOperation) Done(ctx context.Context, opts ...call.Option) (bool, error) { + operation, err := o.getOperation(ctx, GetOperationRequest{Name: o.operation.Name}, opts...) + if err != nil { + return false, err + } + if err := validateOperationName(operation.Name); err != nil { + return false, err + } + o.operation = operation + if operation.Done == nil { + return false, fmt.Errorf("invalid operation response: missing done field") + } + return *operation.Done, nil +} + +// Wait polls the operation until it completes. +func (o *CreatePrivateNetworkGatewayOperation) Wait(ctx context.Context, opts ...lro.Option) (*PrivateNetworkGateway, error) { + var result *PrivateNetworkGateway + poll := func(ctx context.Context) error { + operation, err := o.getOperation(ctx, GetOperationRequest{Name: o.operation.Name}) + if err != nil { + return err + } + if err := validateOperationName(operation.Name); err != nil { + return err + } + o.operation = operation + if operation.Done == nil { + return fmt.Errorf("invalid operation response: missing done field") + } + if !*operation.Done { + return errOperationStillRunning + } + if operationError, ok := operation.Result.(*Operation_Result_Error); ok && operationError != nil { + return fmt.Errorf("operation failed: %w", &operationError.Error) + } + operationResponse, ok := operation.Result.(*Operation_Result_Response) + if !ok || operationResponse == nil || len(operationResponse.Response) == 0 || bytes.Equal(bytes.TrimSpace(operationResponse.Response), []byte("null")) { + return fmt.Errorf("operation completed without a response") + } + var response privateNetworkGatewayWire + if err := json.Unmarshal(operationResponse.Response, &response); err != nil { + return fmt.Errorf("decode operation response: %w", err) + } + result, err = privateNetworkGatewayFromWire(&response) + if err != nil { + return err + } + return nil + } + if err := executeWait(ctx, poll, opts...); err != nil { + return nil, err + } + return result, nil +} + +// Permanently deletes a private network gateway. +func (c *internalClient) DeletePrivateNetworkGateway(ctx context.Context, req DeletePrivateNetworkGatewayRequest, opts ...call.Option) error { + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return err + } + pb := pathBuilder{} + pb.literal("/api/networking/v1/") + if req.Name == nil { + return fmt.Errorf("path parameter %q is required", "name") + } + pb.singleSegment(*req.Name) + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "DELETE", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + _ = respBody + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return err + } + return nil +} + +// Gets a private network gateway. +func (c *internalClient) GetPrivateNetworkGateway(ctx context.Context, req GetPrivateNetworkGatewayRequest, opts ...call.Option) (*PrivateNetworkGateway, error) { + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/networking/v1/") + if req.Name == nil { + return nil, fmt.Errorf("path parameter %q is required", "name") + } + pb.singleSegment(*req.Name) + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *PrivateNetworkGateway + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp privateNetworkGatewayWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = privateNetworkGatewayFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Gets the status of a private network gateway create operation. +func (c *internalClient) getPrivateNetworkGatewayOperation(ctx context.Context, req GetOperationRequest, opts ...call.Option) (*Operation, error) { + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/networking/v1/") + if req.Name == nil { + pb.singleSegment("") + } else { + pb.singleSegment(*req.Name) + } + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *Operation + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp operationWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = operationFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// Lists private network gateways under a network connectivity configuration. +func (c *internalClient) ListPrivateNetworkGateways(ctx context.Context, req ListPrivateNetworkGatewaysRequest, opts ...call.Option) (*ListPrivateNetworkGatewaysResponse, error) { + wireReq, err := listPrivateNetworkGatewaysRequestToWire(&req) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/networking/v1/") + if req.Parent == nil { + return nil, fmt.Errorf("path parameter %q is required", "parent") + } + pb.singleSegment(*req.Parent) + pb.literal("/private-network-gateways") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "page_token", wireReq.PageToken); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *ListPrivateNetworkGatewaysResponse + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp listPrivateNetworkGatewaysResponseWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = listPrivateNetworkGatewaysResponseFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + +// ListPrivateNetworkGatewaysIter returns an iterator that iterates +// over the results of ListPrivateNetworkGateways. +// +// For example: +// +// for item, err := range c.ListPrivateNetworkGatewaysIter(ctx, ListPrivateNetworkGatewaysRequest{}) { +// if err != nil { +// return err +// } +// fmt.Println(item) +// } +// +// Options opts are passed to each ListPrivateNetworkGateways call +// made by the iterator under the hood. +// +// Callers who need custom pagination logic should use +// ListPrivateNetworkGateways directly. +func (c *internalClient) ListPrivateNetworkGatewaysIter(ctx context.Context, req ListPrivateNetworkGatewaysRequest, opts ...call.Option) iter.Seq2[*PrivateNetworkGateway, error] { + return func(yield func(*PrivateNetworkGateway, error) bool) { + // Keep pagination state local to this traversal so reusing the iterator starts + // from the original request. Reference-bearing fields remain shared and read-only. + pageReq := req + for { + resp, err := c.ListPrivateNetworkGateways(ctx, pageReq, opts...) + if err != nil { + yield(nil, err) + return + } + for i := range resp.PrivateNetworkGateways { + if !yield(&resp.PrivateNetworkGateways[i], nil) { + return + } + } + if resp.NextPageToken == nil || *resp.NextPageToken == "" { + return + } + pageReq.PageToken = resp.NextPageToken + } + } +} + +// Updates a private network gateway. +func (c *internalClient) UpdatePrivateNetworkGateway(ctx context.Context, req UpdatePrivateNetworkGatewayRequest, opts ...call.Option) (*PrivateNetworkGateway, error) { + wireReq, err := updatePrivateNetworkGatewayRequestToWire(&req) + if err != nil { + return nil, err + } + body, err := json.Marshal(wireReq.PrivateNetworkGateway) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/networking/v1/") + if req.PrivateNetworkGateway == nil || req.PrivateNetworkGateway.Name == nil { + pb.singleSegment("") + } else { + pb.singleSegment(*req.PrivateNetworkGateway.Name) + } + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "update_mask", wireReq.UpdateMask); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *PrivateNetworkGateway + + call := func(ctx context.Context) error { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "PATCH", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: bytes.NewBuffer(body), + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + var wireResp privateNetworkGatewayWire + if err := json.Unmarshal(respBody, &wireResp); err != nil { + return err + } + resp, err = privateNetworkGatewayFromWire(&wireResp) + if err != nil { + return err + } + return nil + } + + if err := c.executeCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + // Creates a network configuration that represents an VPC and its // resources. The VPC will be used for new clusters. This requires // a pre-existing VPC and subnets. diff --git a/networking/v1/genhelper.go b/networking/v1/genhelper.go index b92183fa..e3ee39d4 100644 --- a/networking/v1/genhelper.go +++ b/networking/v1/genhelper.go @@ -5,7 +5,9 @@ package networking import ( "bytes" "context" + "crypto/rand" "encoding/json" + "errors" "fmt" "io" "log/slog" @@ -19,6 +21,7 @@ import ( "github.com/databricks/sdk-go/core/ops" "github.com/databricks/sdk-go/options/call" "github.com/databricks/sdk-go/options/internaloptions" + "github.com/databricks/sdk-go/options/lro" ) type httpCallOptions struct { @@ -161,6 +164,32 @@ func executeResolvedCall(ctx context.Context, op func(context.Context) error, cf ) } +func validateOperationName(operationName *string) error { + if operationName == nil || *operationName == "" { + return errors.New("invalid operation response: missing operation name") + } + return nil +} + +var errOperationStillRunning = errors.New("operation is still running") + +func executeWait(ctx context.Context, operation func(context.Context) error, opts ...lro.Option) error { + cfg := internaloptions.LROOptions{} + for _, opt := range opts { + if err := opt(&cfg); err != nil { + return err + } + } + return ops.Execute(ctx, operation, + ops.WithTimeout(cfg.Timeout), + ops.WithRetrier(func() ops.Retrier { + return ops.RetryIf(ops.BackoffPolicy{}, func(err error) bool { + return errors.Is(err, errOperationStillRunning) + }) + }), + ) +} + func addQueryValue(params url.Values, key string, value any) error { data, err := json.Marshal(value) if err != nil { @@ -193,6 +222,19 @@ func flattenQueryValue(params url.Values, key string, value any) { } } +// generateRequestID returns a random RFC 4122 version 4 UUID string, used as an +// idempotency token when the caller does not supply one. It uses crypto/rand to +// avoid a UUID dependency; a read failure is treated as unrecoverable. +func generateRequestID() string { + var b [16]byte + if _, err := rand.Read(b[:]); err != nil { + panic(fmt.Sprintf("generate request id: %v", err)) + } + b[6] = (b[6] & 0x0f) | 0x40 // version 4 + b[8] = (b[8] & 0x3f) | 0x80 // variant 10 + return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]) +} + // pathBuilder assembles request paths so "/" in parameter values remains a // path separator while characters that cannot appear literally in a URL path // are percent-encoded when the request URL is serialized. diff --git a/networking/v1/model.go b/networking/v1/model.go index 4b2f4136..159f592c 100644 --- a/networking/v1/model.go +++ b/networking/v1/model.go @@ -3,6 +3,9 @@ package networking import ( + "encoding/json" + "fmt" + "github.com/databricks/sdk-go/core/types" ) @@ -32,6 +35,402 @@ const ( EndpointState_Disconnected EndpointState = "DISCONNECTED" ) +// Error codes returned by Databricks APIs to indicate specific failure +// conditions. +type ErrorCode string + +const ( + ErrorCode_Unspecified ErrorCode = "" + // Internal error. This means that some invariants expected by the underlying + // system have been broken. This error code is reserved for serious errors, + // which generally cannot be resolved by the user. + // + // Prefer this over all kinds of detailed error messages (e.g IO_ERROR), unless + // there's some automation that relies on the custom error code. + // + // Maps to: - google.rpc.Code: INTERNAL = 13; - HTTP code: 500 Internal Server + // Error + ErrorCode_InternalError ErrorCode = "INTERNAL_ERROR" + // The service is currently unavailable. This is most likely a transient + // condition, which can be corrected by retrying with a backoff. Note that it is + // not always safe to retry non-idempotent operations. + // + // Prefer this over SERVICE_UNDER_MAINTENANCE, + // WORKSPACE_TEMPORARILY_UNAVAILABLE. + // + // See + // https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# + // for guideline on how to pick this vs RESOURCE_EXHAUSTED. + // + // Maps to: - google.rpc.Code: UNAVAILABLE = 14; - HTTP code: 503 Service + // Unavailable + ErrorCode_TemporarilyUnavailable ErrorCode = "TEMPORARILY_UNAVAILABLE" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. Indicates that an IOException has been internally + // thrown. + ErrorCode_IoError ErrorCode = "IO_ERROR" + // The request is invalid. Prefer more specific error code whenever possible. + // Also see similar recommendation for the google.rpc.Code.FAILED_PRECONDITION. + // + // Prefer this error code over MALFORMED_REQUEST, INVALID_STATE, + // UNPARSEABLE_HTTP_ERROR. + // + // Maps to: - google.rpc.Code: FAILED_PRECONDITION = 9; - HTTP code: 400 Bad + // Request + ErrorCode_BadRequest ErrorCode = "BAD_REQUEST" + // An external service is unavailable temporarily as it is being + // updated/re-deployed. Indicates gateway proxy to safely retry the request. + ErrorCode_ServiceUnderMaintenance ErrorCode = "SERVICE_UNDER_MAINTENANCE" + // A workspace is temporarily unavailable as the workspace is being re-assigned. + ErrorCode_WorkspaceTemporarilyUnavailable ErrorCode = "WORKSPACE_TEMPORARILY_UNAVAILABLE" + // The deadline expired before the operation could complete. For operations that + // change the state of the system, this error may be returned even if the + // operation has completed successfully. For example, a successful response from + // a server could have been delayed long enough for the deadline to expire. When + // possible - implementations should make sure further processing of the request + // is aborted, e.g. by throwing an exception instead of making the RPC request, + // making the database query, etc. + // + // Maps to: - google.rpc.Code: DEADLINE_EXCEEDED = 4; - HTTP code: 504 Gateway + // Timeout + ErrorCode_DeadlineExceeded ErrorCode = "DEADLINE_EXCEEDED" + // The operation was canceled by the caller. An example - client closed the + // connection without waiting for a response. + // + // Maps to: - google.rpc.Code: CANCELLED = 1; - HTTP code: 499 Client Closed + // Request + ErrorCode_Cancelled ErrorCode = "CANCELLED" + // The operation is rejected because of either rate limiting or resource quota, + // such as the client has sent too many requests recently or the client has + // allocated too many resources. + // + // See + // https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# + // for guideline on how to pick this vs TEMPORARILY_UNAVAILABLE. + // + // Maps to: - google.rpc.Code: RESOURCE_EXHAUSTED = 8; - HTTP code: 429 Too Many + // Requests + ErrorCode_ResourceExhausted ErrorCode = "RESOURCE_EXHAUSTED" + // The operation was aborted, typically due to a concurrency issue such as a + // sequencer check failure, transaction abort, or transaction conflict. + // + // Maps to: - google.rpc.Code: ABORTED = 10; - HTTP code: 409 Conflict + ErrorCode_Aborted ErrorCode = "ABORTED" + // Operation was performed on a resource that does not exist, e.g. file or + // directory was not found. + // + // Maps to: - google.rpc.Code: NOT_FOUND = 5; - HTTP code: 404 Not Found + ErrorCode_NotFound ErrorCode = "NOT_FOUND" + // Operation was rejected due a conflict with an existing resource, e.g. + // attempted to create file or directory that already exists. + // + // Prefer this over RESOURCE_CONFLICT. + // + // Maps to: - google.rpc.Code: ALREADY_EXISTS = 6; - HTTP code: 409 Conflict + ErrorCode_AlreadyExists ErrorCode = "ALREADY_EXISTS" + // The request does not have valid authentication (AuthN) credentials for the + // operation. + // + // Prefer this over CUSTOMER_UNAUTHORIZED, unless you need to keep consistent + // behavior with legacy code. For authorization (AuthZ) errors use + // PERMISSION_DENIED. Maps to: - google.rpc.Code: UNAUTHENTICATED = 16; - HTTP + // code: 401 Unauthorized + ErrorCode_Unauthenticated ErrorCode = "UNAUTHENTICATED" + // The service is currently unavailable. Please note that the unavailability may + // or may not be transient. That means if this is a non-transient condition, + // retrying it does not work. If the unavailability is certainly a transient + // condition, pleases use `TEMPORARILY_UNAVAILABLE` which signals its transient + // nature explicitly. An example of this error code’s use case is that when + // DNS resolution fails, the DNS resolver does not know whether it is because + // the domain name is completely wrong (non-transient situation) or the domain + // name is valid but the DNS server does not have an entry for this domain name + // yet (transient situation). Hence, `UNAVAILABLE` is suitable for this case. + // + // Maps to: - google.rpc.Code: UNAVAILABLE = 14; - HTTP code: 503 Service + // Unavailable + ErrorCode_Unavailable ErrorCode = "UNAVAILABLE" + // Supplied value for a parameter was invalid (e.g., giving a number for a + // string parameter). + // + // Maps to: - google.rpc.Code: INVALID_ARGUMENT = 3; - HTTP code: 400 Bad + // Request + ErrorCode_InvalidParameterValue ErrorCode = "INVALID_PARAMETER_VALUE" + // Indicates that the given API endpoint does not exist. Legacy, when possible - + // NOT_IMPLEMENTED should be used instead to indicate that API doesn't exist. + // + // Maps to: - google.rpc.Code: NOT_FOUND = 5; - HTTP code: 404 Not Found + ErrorCode_EndpointNotFound ErrorCode = "ENDPOINT_NOT_FOUND" + // Indicates that the given API request was malformed. + ErrorCode_MalformedRequest ErrorCode = "MALFORMED_REQUEST" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. If one or more of the inputs to a given RPC are not in + // a valid state for the action. + ErrorCode_InvalidState ErrorCode = "INVALID_STATE" + // The caller does not have permission to execute the specified operation. + // PERMISSION_DENIED must not be used for rejections caused by exhausting some + // resource, use RESOURCE_EXHAUSTED instead for those errors. PERMISSION_DENIED + // must not be used if the caller can not be identified, use + // CUSTOMER_UNAUTHORIZED instead for those errors. This error code does not + // imply the request is valid or the requested entity exists or satisfies other + // pre-conditions. + // + // Maps to: - google.rpc.Code: PERMISSION_DENIED = 7; - HTTP code: 403 Forbidden + ErrorCode_PermissionDenied ErrorCode = "PERMISSION_DENIED" + // NOTE: Deprecated due to inconsistent mapping in legacy code, see + // https://docs.google.com/document/d/17TZIKX_Y39cJMBr333lc-d5dTvvBLSu3DPUyGU5eMJg/edit?disco=AAAAzVGt6FA. + // Prefer using NOT_FOUND or PERMISSION_DENIED. + // + // If a given user/entity is trying to use a feature which has been disabled. + // + // Maps to: - google.rpc.Code: NOT_FOUND = 5; - HTTP code: 404 Not Found + ErrorCode_FeatureDisabled ErrorCode = "FEATURE_DISABLED" + // The request does not have valid authentication (AuthN) credentials for the + // operation. + // + // For authentication (AuthN) errors prefer using UNAUTHENTICATED, unless you + // need to keep consistent behavior with legacy code. For authorization (AuthZ) + // errors use PERMISSION_DENIED. + // + // Important: name is confusing, this error code is for authentication (AuthN) + // errors, not authorization (AuthZ) errors. It maps to 401 Unauthorized and + // suffers from the same confusing naming. See + // https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 - "[...] status + // code indicates that the request has not been applied because it lacks valid + // authentication credentials for the target resource. [...] If the request + // included authentication credentials, then the 401 response indicates that + // authorization has been refused for those credentials." + // + // Also, see https://stackoverflow.com/a/6937030/16352922, it covers it pretty + // well. + // + // Maps to: - google.rpc.Code: UNAUTHENTICATED = 16; - HTTP code: 401 + // Unauthorized + ErrorCode_CustomerUnauthorized ErrorCode = "CUSTOMER_UNAUTHORIZED" + // The operation is rejected because of request rate limit, for example rate + // limiting applied to users, workspaces, IP addresses, etc. + // + // Prefer a more generic RESOURCE_EXHAUSTED for the new use cases. + // + // See + // https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# + // for guideline on the rate limiting vs throttling. + // + // Maps to: - google.rpc.Code: RESOURCE_EXHAUSTED = 8; - HTTP code: 429 Too Many + // Requests + ErrorCode_RequestLimitExceeded ErrorCode = "REQUEST_LIMIT_EXCEEDED" + // Indicates API request was rejected due a conflict with an existing resource. + ErrorCode_ResourceConflict ErrorCode = "RESOURCE_CONFLICT" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. Indicates that the HTTP response cannot be correctly + // deserialized. This currently is only used in DUST test clients, and not by + // any real service code. + ErrorCode_UnparseableHttpError ErrorCode = "UNPARSEABLE_HTTP_ERROR" + // The operation is not implemented or is not supported/enabled in this service. + // + // Maps to: - google.rpc.Code: UNIMPLEMENTED = 12; - HTTP code: 501 Not + // Implemented + ErrorCode_NotImplemented ErrorCode = "NOT_IMPLEMENTED" + // Unrecoverable data loss or corruption. + // + // One of the major use cases is to indicate that server failed to validate the + // integrity of the request. This error can occur when the checksum specified in + // the `X-Databricks-Checksum` request header (or trailer) doesn't match the + // actual request content checksum. + // + // Note, in case of the severe corruption that results in a malformed request, + // the server may send a generic `400 Bad Request` response rather than sending + // this error code. + // + // Maps to: - google.rpc.Code: DATA_LOSS = 15; - HTTP code: 500 Internal Server + // Error + ErrorCode_DataLoss ErrorCode = "DATA_LOSS" + // If the user attempts to perform an invalid state transition on a shard. + ErrorCode_InvalidStateTransition ErrorCode = "INVALID_STATE_TRANSITION" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. Unable to perform the operation because the shard was + // locked by some other operation. + ErrorCode_CouldNotAcquireLock ErrorCode = "COULD_NOT_ACQUIRE_LOCK" + // NOTE: Deprecated, prefer using ALREADY_EXISTS. Unlike ALREADY_EXISTS - this + // maps to HTTP code 400 Bad Request due to legacy reasons, remapping will be a + // backwards incompatible change. + // + // Operation was performed on a resource that already exists. + ErrorCode_ResourceAlreadyExists ErrorCode = "RESOURCE_ALREADY_EXISTS" + // NOTE: Deprecated, prefer using NOT_FOUND - see the note for the + // RESOURCE_ALREADY_EXISTS, because this pair of codes is related and + // RESOURCE_ALREADY_EXISTS has bad mapping to the HTTP codes we added new error + // codes NOT_FOUND and ALREADY_EXISTS, and recommend to use them instead. + // + // Operation was performed on a resource that does not exist. + ErrorCode_ResourceDoesNotExist ErrorCode = "RESOURCE_DOES_NOT_EXIST" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_QuotaExceeded ErrorCode = "QUOTA_EXCEEDED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_MaxBlockSizeExceeded ErrorCode = "MAX_BLOCK_SIZE_EXCEEDED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_MaxReadSizeExceeded ErrorCode = "MAX_READ_SIZE_EXCEEDED" + ErrorCode_PartialDelete ErrorCode = "PARTIAL_DELETE" + ErrorCode_MaxListSizeExceeded ErrorCode = "MAX_LIST_SIZE_EXCEEDED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_DryRunFailed ErrorCode = "DRY_RUN_FAILED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. Cluster request was rejected because it would exceed a + // resource limit. + ErrorCode_ResourceLimitExceeded ErrorCode = "RESOURCE_LIMIT_EXCEEDED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_DirectoryNotEmpty ErrorCode = "DIRECTORY_NOT_EMPTY" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_DirectoryProtected ErrorCode = "DIRECTORY_PROTECTED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_MaxNotebookSizeExceeded ErrorCode = "MAX_NOTEBOOK_SIZE_EXCEEDED" + ErrorCode_MaxChildNodeSizeExceeded ErrorCode = "MAX_CHILD_NODE_SIZE_EXCEEDED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_SearchQueryTooLong ErrorCode = "SEARCH_QUERY_TOO_LONG" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_SearchQueryTooShort ErrorCode = "SEARCH_QUERY_TOO_SHORT" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_ManagedResourceGroupDoesNotExist ErrorCode = "MANAGED_RESOURCE_GROUP_DOES_NOT_EXIST" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_PermissionNotPropagated ErrorCode = "PERMISSION_NOT_PROPAGATED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_DeploymentTimeout ErrorCode = "DEPLOYMENT_TIMEOUT" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_GitConflict ErrorCode = "GIT_CONFLICT" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_GitUnknownRef ErrorCode = "GIT_UNKNOWN_REF" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_GitSensitiveTokenDetected ErrorCode = "GIT_SENSITIVE_TOKEN_DETECTED" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_GitUrlNotOnAllowList ErrorCode = "GIT_URL_NOT_ON_ALLOW_LIST" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_GitRemoteError ErrorCode = "GIT_REMOTE_ERROR" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_ProjectsOperationTimeout ErrorCode = "PROJECTS_OPERATION_TIMEOUT" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_IpynbFileInRepo ErrorCode = "IPYNB_FILE_IN_REPO" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_InsecurePartnerResponse ErrorCode = "INSECURE_PARTNER_RESPONSE" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_MalformedPartnerResponse ErrorCode = "MALFORMED_PARTNER_RESPONSE" + ErrorCode_MetastoreDoesNotExist ErrorCode = "METASTORE_DOES_NOT_EXIST" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_DacDoesNotExist ErrorCode = "DAC_DOES_NOT_EXIST" + ErrorCode_CatalogDoesNotExist ErrorCode = "CATALOG_DOES_NOT_EXIST" + ErrorCode_SchemaDoesNotExist ErrorCode = "SCHEMA_DOES_NOT_EXIST" + ErrorCode_TableDoesNotExist ErrorCode = "TABLE_DOES_NOT_EXIST" + ErrorCode_ShareDoesNotExist ErrorCode = "SHARE_DOES_NOT_EXIST" + ErrorCode_RecipientDoesNotExist ErrorCode = "RECIPIENT_DOES_NOT_EXIST" + ErrorCode_StorageCredentialDoesNotExist ErrorCode = "STORAGE_CREDENTIAL_DOES_NOT_EXIST" + ErrorCode_ExternalLocationDoesNotExist ErrorCode = "EXTERNAL_LOCATION_DOES_NOT_EXIST" + ErrorCode_PrincipalDoesNotExist ErrorCode = "PRINCIPAL_DOES_NOT_EXIST" + ErrorCode_ProviderDoesNotExist ErrorCode = "PROVIDER_DOES_NOT_EXIST" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_MetastoreAlreadyExists ErrorCode = "METASTORE_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_DacAlreadyExists ErrorCode = "DAC_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_CatalogAlreadyExists ErrorCode = "CATALOG_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_SchemaAlreadyExists ErrorCode = "SCHEMA_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_TableAlreadyExists ErrorCode = "TABLE_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_ShareAlreadyExists ErrorCode = "SHARE_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_RecipientAlreadyExists ErrorCode = "RECIPIENT_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_StorageCredentialAlreadyExists ErrorCode = "STORAGE_CREDENTIAL_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_ExternalLocationAlreadyExists ErrorCode = "EXTERNAL_LOCATION_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_ProviderAlreadyExists ErrorCode = "PROVIDER_ALREADY_EXISTS" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_CatalogNotEmpty ErrorCode = "CATALOG_NOT_EMPTY" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_SchemaNotEmpty ErrorCode = "SCHEMA_NOT_EMPTY" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_MetastoreNotEmpty ErrorCode = "METASTORE_NOT_EMPTY" + // NOTE: Deprecated and kept to maintain backwards compatibility for public APIs + // that use it, avoid using it in the new APIs, refer error codes listed in the + // http://go/error-codes. + ErrorCode_ProviderShareNotAccessible ErrorCode = "PROVIDER_SHARE_NOT_ACCESSIBLE" +) + // Type of IP access list. Valid values are as follows and are case-sensitive: // // * `ALLOW`: An allow list. Include this IP or range. * `BLOCK`: A block list. @@ -305,6 +704,58 @@ const ( NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_CreateFailed NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState = "CREATE_FAILED" ) +// The supported destination types. +type PrivateNetworkGateway_Destination_DestinationType string + +const ( + PrivateNetworkGateway_Destination_DestinationType_Unspecified PrivateNetworkGateway_Destination_DestinationType = "" + // A DNS name such as `database.internal`. + PrivateNetworkGateway_Destination_DestinationType_DnsName PrivateNetworkGateway_Destination_DestinationType = "DNS_NAME" +) + +// The lifecycle state of the gateway. +type PrivateNetworkGateway_GatewayState string + +const ( + PrivateNetworkGateway_GatewayState_Unspecified PrivateNetworkGateway_GatewayState = "" + // The gateway is being provisioned. + PrivateNetworkGateway_GatewayState_Creating PrivateNetworkGateway_GatewayState = "CREATING" + // The gateway is ready to route traffic. + PrivateNetworkGateway_GatewayState_Established PrivateNetworkGateway_GatewayState = "ESTABLISHED" + // The gateway could not be provisioned or encountered an unrecoverable error. + PrivateNetworkGateway_GatewayState_Failed PrivateNetworkGateway_GatewayState = "FAILED" + // The gateway is being permanently deleted. + PrivateNetworkGateway_GatewayState_Deleting PrivateNetworkGateway_GatewayState = "DELETING" +) + +// The supported resolver types. +type PrivateNetworkGateway_PrivateDnsResolver_ResolverType string + +const ( + PrivateNetworkGateway_PrivateDnsResolver_ResolverType_Unspecified PrivateNetworkGateway_PrivateDnsResolver_ResolverType = "" + // An IPv4 address. + PrivateNetworkGateway_PrivateDnsResolver_ResolverType_IpAddress PrivateNetworkGateway_PrivateDnsResolver_ResolverType = "IP_ADDRESS" +) + +// The traffic routed through the gateway. +type PrivateNetworkGateway_TrafficMode string + +const ( + PrivateNetworkGateway_TrafficMode_Unspecified PrivateNetworkGateway_TrafficMode = "" + // Route only the destinations configured on the gateway. + PrivateNetworkGateway_TrafficMode_SpecificDestinations PrivateNetworkGateway_TrafficMode = "SPECIFIC_DESTINATIONS" + // Route all traffic through the gateway. + PrivateNetworkGateway_TrafficMode_AllTraffic PrivateNetworkGateway_TrafficMode = "ALL_TRAFFIC" +) + +type PrivateNetworkGatewayOperationMetadata_OperationType string + +const ( + PrivateNetworkGatewayOperationMetadata_OperationType_Unspecified PrivateNetworkGatewayOperationMetadata_OperationType = "" + // A gateway create operation. + PrivateNetworkGatewayOperationMetadata_OperationType_Create PrivateNetworkGatewayOperationMetadata_OperationType = "CREATE" +) + // Definition of an IP Access list. type AccountIpAccessList struct { // Universally unique identifier (UUID) of the IP access list. @@ -347,6 +798,14 @@ type AccountNetworkPolicy struct { IngressDryRun *IngressNetworkPolicy } +// Databricks Error that is returned by all Databricks APIs.. +type ApiError struct { + ErrorCode ErrorCode + Message *string + StackTrace *string + Details []json.RawMessage +} + type AwsVpcEndpointInfo struct { // The ID of the underlying VPC endpoint in AWS. Provided by the customer when // registering an existing AWS VPC endpoint. @@ -585,6 +1044,16 @@ type CreatePrivateEndpointRule_Endpoint_GcpEndpoint struct { func (*CreatePrivateEndpointRule_Endpoint_GcpEndpoint) isCreatePrivateEndpointRule_Endpoint() {} +type CreatePrivateNetworkGatewayRequest struct { + // The network connectivity configuration that will contain the gateway. + Parent *string + // The gateway to create. + PrivateNetworkGateway *PrivateNetworkGateway + // A unique identifier for this request. The request is idempotent when this is + // provided. + RequestId *string +} + type CreateVpcEndpointRequest struct { AccountId *string // The human-readable name of the storage configuration. @@ -613,19 +1082,19 @@ type CustomerFacingNetworkConnectivityConfigEgressConfig struct { // The network connectivity rules that are applied by default without resource // specific configurations. You can find the stable network information of your // serverless compute resources here. - DefaultRules *NetworkConnectivityConfigEgressConfig_DefaultRule + DefaultRules *NetworkConnectivityConfigEgressConfig_DefaultRule `fieldmask:"default_rules"` // The network connectivity rules that configured for each destinations. These // rules override default rules. - TargetRules *CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule + TargetRules *CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule `fieldmask:"target_rules"` } // Target rule controls the egress rules that are dedicated to specific // resources.. type CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule struct { - AzurePrivateEndpointRules []NetworkConnectivityConfigAzurePrivateEndpointRule + AzurePrivateEndpointRules []NetworkConnectivityConfigAzurePrivateEndpointRule `fieldmask:"azure_private_endpoint_rules"` // AWS private endpoint rule controls the AWS private endpoint based egress // rules. - AwsPrivateEndpointRules []NetworkConnectivityConfigAwsPrivateEndpointRule + AwsPrivateEndpointRules []NetworkConnectivityConfigAwsPrivateEndpointRule `fieldmask:"aws_private_endpoint_rules"` } type DeleteAccountIpAccessListRequest struct { @@ -694,6 +1163,11 @@ type DeletePrivateAccessSettingsRequest struct { AccountId *string } +type DeletePrivateNetworkGatewayRequest struct { + // The canonical resource name of the gateway. + Name *string +} + type DeleteVpcEndpointRequest struct { VpcEndpointId *string AccountId *string @@ -978,11 +1452,22 @@ type GetNetworkRequest struct { AccountId *string } +// The request message for `GetOperation` method.. +type GetOperationRequest struct { + // The name of the operation resource. + Name *string +} + type GetPrivateAccessSettingsRequest struct { PrivateAccessSettingsId *string AccountId *string } +type GetPrivateNetworkGatewayRequest struct { + // The canonical resource name of the gateway. + Name *string +} + type GetVpcEndpointRequest struct { // Databricks VPC endpoint ID. VpcEndpointId *string @@ -1424,6 +1909,19 @@ type ListPrivateAccessSettingsResponse struct { PrivateAccessSettings []PrivateAccessSettings } +type ListPrivateNetworkGatewaysRequest struct { + // The network connectivity configuration containing the gateways. + Parent *string + // An opaque token returned by a previous list request. + PageToken *string +} + +type ListPrivateNetworkGatewaysResponse struct { + PrivateNetworkGateways []PrivateNetworkGateway + // An opaque token for the next page, or empty when there are no more results. + NextPageToken *string +} + type ListVpcEndpointRequest struct { AccountId *string } @@ -1555,25 +2053,29 @@ func (*Network_NetworkInfo_GcpNetworkInfo) isNetwork_NetworkInfo() {} // Properties of the new network connectivity configuration.. type NetworkConnectivityConfig struct { // network connectivity configuration ID. - NetworkConnectivityConfigId *string + NetworkConnectivityConfigId *string `fieldmask:"network_connectivity_config_id"` // Your account ID. You can find your account ID in your // accounts console. - AccountId *string + AccountId *string `fieldmask:"account_id"` // The name of the network connectivity configuration. The name can contain // alphanumeric characters, hyphens, and underscores. The length must be between // 3 and 30 characters. The name must match the regular expression // ^[0-9a-zA-Z-_]{3,30}$ - Name *string + Name *string `fieldmask:"name"` // The region for the network connectivity configuration. Only workspaces in the // same region can be attached to the network connectivity configuration. - Region *string + Region *string `fieldmask:"region"` // The network connectivity rules that apply to network traffic from your // serverless compute resources. - EgressConfig *CustomerFacingNetworkConnectivityConfigEgressConfig + EgressConfig *CustomerFacingNetworkConnectivityConfigEgressConfig `fieldmask:"egress_config"` // Time in epoch milliseconds when this object was updated. - UpdatedTime *int64 + UpdatedTime *int64 `fieldmask:"updated_time"` // Time in epoch milliseconds when this object was created. - CreationTime *int64 + CreationTime *int64 `fieldmask:"creation_time"` + // The workspace to which charges for this network connectivity configuration + // are attributed. The workspace must be active and attached to this network + // connectivity configuration when set. + BillingWorkspaceId *int64 `fieldmask:"billing_workspace_id"` } // Properties of the new private endpoint rule. Note that for private endpoints @@ -1688,8 +2190,8 @@ type NetworkConnectivityConfigEgressConfig struct { // Default rules don't have specific targets.. type NetworkConnectivityConfigEgressConfig_DefaultRule struct { - AzureServiceEndpointRule *NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule - AwsStableIpRule *NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule + AzureServiceEndpointRule *NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule `fieldmask:"azure_service_endpoint_rule"` + AwsStableIpRule *NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule `fieldmask:"aws_stable_ip_rule"` } // The stable AWS IP CIDR blocks. You can use these to configure the firewall of @@ -1697,7 +2199,7 @@ type NetworkConnectivityConfigEgressConfig_DefaultRule struct { type NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule struct { // The list of stable IP CIDR blocks from which network traffic // originates when accessing your resources. - CidrBlocks []string + CidrBlocks []string `fieldmask:"cidr_blocks"` } // The stable Azure service endpoints. You can configure the firewall of your @@ -1705,12 +2207,12 @@ type NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule struct { // resources.. type NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule struct { // The Azure region in which this service endpoint rule applies.. - TargetRegion *string + TargetRegion *string `fieldmask:"target_region"` // The Azure services to which this service endpoint rule applies to. - TargetServices []EgressResourceType + TargetServices []EgressResourceType `fieldmask:"target_services"` // The list of subnets from which network traffic originates when // accessing your Azure resources. - Subnets []string + Subnets []string `fieldmask:"subnets"` } type NetworkHealth struct { @@ -1733,6 +2235,48 @@ type NetworkWarning struct { WarningMessage *string } +// This resource represents a long-running operation that is the result of a +// network API call.. +type Operation struct { + // 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}`. + Name *string + // 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. + Metadata json.RawMessage + // 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. + Done *bool + // The operation result, which can be either an `error` or a valid `response`. + // If `done` == `false`, neither `error` nor `response` is set. If `done` == + // `true`, exactly one of `error` or `response` can be set. Some services might + // not provide the result. + Result isOperation_Result +} + +type isOperation_Result interface { + isOperation_Result() +} + +// Operation_Result_Error selects Error for Operation.Result. +// The error result of the operation in case of failure or cancellation. +type Operation_Result_Error struct { + Error ApiError +} + +func (*Operation_Result_Error) isOperation_Result() {} + +// Operation_Result_Response selects Response for Operation.Result. +// The normal, successful response of the operation. +type Operation_Result_Response struct { + Response json.RawMessage +} + +func (*Operation_Result_Response) isOperation_Result() {} + // *. type PrivateAccessSettings struct { // private access settings ID. @@ -1768,6 +2312,118 @@ type PrivateAccessSettings struct { AllowedVpcEndpointIds []string } +// A private network gateway connects serverless compute to destinations in a +// customer-managed VPC or VNet.. +type PrivateNetworkGateway struct { + // The canonical resource name of the gateway, in the form + // `accounts/{account_id}/network-connectivity-configs/{ncc_id}/private-network-gateways/{gateway_id}`. + Name *string `fieldmask:"name"` + // The human-readable name of the gateway. + DisplayName *string `fieldmask:"display_name"` + // Exactly one cloud connection must be provided when creating a gateway. + CloudConnection isPrivateNetworkGateway_CloudConnection + // The destinations routed through this gateway. + Destinations []PrivateNetworkGateway_Destination `fieldmask:"destinations"` + // The DNS resolvers used for private name resolution. + PrivateDnsResolvers []PrivateNetworkGateway_PrivateDnsResolver `fieldmask:"private_dns_resolvers"` + // The traffic routed through this gateway. + TrafficMode PrivateNetworkGateway_TrafficMode `fieldmask:"traffic_mode"` + // The time when the gateway was created. + CreateTime *types.Time `fieldmask:"create_time"` + // The time when the gateway was last updated. + UpdateTime *types.Time `fieldmask:"update_time"` + // The current lifecycle state of the gateway. + State PrivateNetworkGateway_GatewayState `fieldmask:"state"` + // The failure reason when the gateway is in the FAILED state. + ErrorMessage *string `fieldmask:"error_message"` + // The provisioned bandwidth tier for an Azure gateway, in gigabits per second. + // Required when creating an Azure gateway. + BandwidthTierGigabitsPerSecond *int `fieldmask:"bandwidth_tier_gigabits_per_second"` + _ [0]privateNetworkGatewayCloudConnectionFieldMaskMetadata `fieldmask_oneof:"CloudConnection"` +} + +type isPrivateNetworkGateway_CloudConnection interface { + isPrivateNetworkGateway_CloudConnection() +} + +// PrivateNetworkGateway_CloudConnection_AzureCloudConnection selects AzureCloudConnection for PrivateNetworkGateway.CloudConnection. +// The Azure connection used by the gateway. +type PrivateNetworkGateway_CloudConnection_AzureCloudConnection struct { + AzureCloudConnection PrivateNetworkGateway_AzureCloudConnection `fieldmask:"azure_cloud_connection"` +} + +func (*PrivateNetworkGateway_CloudConnection_AzureCloudConnection) isPrivateNetworkGateway_CloudConnection() { +} + +// PrivateNetworkGateway_CloudConnection_AwsCloudConnection selects AwsCloudConnection for PrivateNetworkGateway.CloudConnection. +// The AWS connection used by the gateway. +type PrivateNetworkGateway_CloudConnection_AwsCloudConnection struct { + AwsCloudConnection PrivateNetworkGateway_AwsCloudConnection `fieldmask:"aws_cloud_connection"` +} + +func (*PrivateNetworkGateway_CloudConnection_AwsCloudConnection) isPrivateNetworkGateway_CloudConnection() { +} + +type privateNetworkGatewayCloudConnectionFieldMaskMetadata struct { + *PrivateNetworkGateway_CloudConnection_AzureCloudConnection + *PrivateNetworkGateway_CloudConnection_AwsCloudConnection +} + +// AWS connection configuration.. +type PrivateNetworkGateway_AwsCloudConnection struct { + // The subnets where the gateway establishes connectivity. + GatewaySubnets []PrivateNetworkGateway_AwsCloudConnection_AwsGatewaySubnet `fieldmask:"gateway_subnets"` + // The IAM role that assumes to manage gateway resources. + CrossAccountRole *PrivateNetworkGateway_AwsCloudConnection_CrossAccountRole `fieldmask:"cross_account_role"` + // The security groups attached to the gateway network interface. + SecurityGroupIds []string `fieldmask:"security_group_ids"` +} + +// An AWS subnet used by the gateway.. +type PrivateNetworkGateway_AwsCloudConnection_AwsGatewaySubnet struct { + // The AWS subnet ID. + SubnetId *string +} + +// A cross-account IAM role used to manage gateway resources.. +type PrivateNetworkGateway_AwsCloudConnection_CrossAccountRole struct { + // The ARN of the IAM role. + RoleArn *string `fieldmask:"role_arn"` +} + +// Azure connection configuration.. +type PrivateNetworkGateway_AzureCloudConnection struct { + // The subnet where the gateway establishes connectivity. + GatewaySubnet *PrivateNetworkGateway_AzureCloudConnection_AzureGatewaySubnet `fieldmask:"gateway_subnet"` +} + +// An Azure subnet used by the gateway.. +type PrivateNetworkGateway_AzureCloudConnection_AzureGatewaySubnet struct { + // The full Azure resource ID of the subnet. + ResourceId *string `fieldmask:"resource_id"` +} + +// A destination routed through the gateway.. +type PrivateNetworkGateway_Destination struct { + // The destination type. + DestinationType PrivateNetworkGateway_Destination_DestinationType + // The destination value. + Value *string +} + +// A private DNS resolver used by the gateway.. +type PrivateNetworkGateway_PrivateDnsResolver struct { + // The resolver type. + ResolverType PrivateNetworkGateway_PrivateDnsResolver_ResolverType + // The resolver value. + Value *string +} + +type PrivateNetworkGatewayOperationMetadata struct { + // The operation performed on the gateway. + OperationType PrivateNetworkGatewayOperationMetadata_OperationType +} + // Details required to replace an IP access list.. type ReplaceAccountIpAccessListRequest struct { AccountId *string @@ -1852,6 +2508,18 @@ type UpdateNccPrivateEndpointRuleRequest struct { UpdateMask *types.FieldMask[UpdatePrivateEndpointRule] } +// Request to update a network connectivity configuration.. +type UpdateNetworkConnectivityConfigRequest struct { + // Your account ID. + AccountId *string + // Your Network Connectivity Configuration ID. + NetworkConnectivityConfigId *string + // The network connectivity configuration fields to update. + NetworkConnectivityConfig *NetworkConnectivityConfig + // Must contain at least one of `name` or `billing_workspace_id`. + UpdateMask *types.FieldMask[NetworkConnectivityConfig] +} + type UpdateNetworkPolicyRequest struct { // The unique identifier for the network policy. NetworkPolicyId *string @@ -1952,6 +2620,13 @@ type updatePrivateEndpointRuleEndpointFieldMaskMetadata struct { *UpdatePrivateEndpointRule_Endpoint_GcpEndpoint } +type UpdatePrivateNetworkGatewayRequest struct { + // The gateway containing the desired mutable field values. + PrivateNetworkGateway *PrivateNetworkGateway + // The fields to update. + UpdateMask *types.FieldMask[PrivateNetworkGateway] +} + type UpdateWorkspaceNetworkOptionRequest struct { // Your account ID. You can find your account ID in your // accounts console. @@ -2022,3 +2697,15 @@ type WorkspaceNetworkOption struct { // The workspace ID. WorkspaceId *int64 } + +// Error returns the LRO error code and message. +func (e *ApiError) Error() string { + message := "unknown error" + if e.Message != nil && *e.Message != "" { + message = *e.Message + } + if e.ErrorCode != "" { + return fmt.Sprintf("[%v] %s", e.ErrorCode, message) + } + return message +} diff --git a/networking/v1/wire.go b/networking/v1/wire.go index 49486704..984de71e 100644 --- a/networking/v1/wire.go +++ b/networking/v1/wire.go @@ -167,6 +167,25 @@ func accountNetworkPolicyFromWire(w *accountNetworkPolicyWire) (*AccountNetworkP }, nil } +type apiErrorWire struct { + ErrorCode ErrorCode `json:"error_code,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stack_trace,omitempty"` + Details []json.RawMessage `json:"details,omitempty"` +} + +func apiErrorFromWire(w *apiErrorWire) (*ApiError, error) { + if w == nil { + return nil, nil + } + return &ApiError{ + ErrorCode: w.ErrorCode, + Message: w.Message, + StackTrace: w.StackTrace, + Details: w.Details, + }, nil +} + type awsVpcEndpointInfoWire struct { AwsVpcEndpointId *string `json:"aws_vpc_endpoint_id,omitempty"` AwsEndpointServiceId *string `json:"aws_endpoint_service_id,omitempty"` @@ -540,6 +559,27 @@ func createPrivateEndpointRuleToWire(v *CreatePrivateEndpointRule) (*createPriva }, nil } +type createPrivateNetworkGatewayRequestWire struct { + Parent *string `json:"parent,omitempty"` + PrivateNetworkGateway *privateNetworkGatewayWire `json:"private_network_gateway,omitempty"` + RequestId *string `json:"request_id,omitempty"` +} + +func createPrivateNetworkGatewayRequestToWire(v *CreatePrivateNetworkGatewayRequest) (*createPrivateNetworkGatewayRequestWire, error) { + if v == nil { + return nil, nil + } + privateNetworkGatewayWireValue, err := privateNetworkGatewayToWire(v.PrivateNetworkGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePrivateNetworkGatewayRequest.PrivateNetworkGateway", err) + } + return &createPrivateNetworkGatewayRequestWire{ + Parent: v.Parent, + PrivateNetworkGateway: privateNetworkGatewayWireValue, + RequestId: v.RequestId, + }, nil +} + type createVpcEndpointRequestWire struct { AccountId *string `json:"account_id,omitempty"` VpcEndpointName *string `json:"vpc_endpoint_name,omitempty"` @@ -2442,6 +2482,40 @@ func listNetworkPoliciesResponseFromWire(w *listNetworkPoliciesResponseWire) (*L }, nil } +type listPrivateNetworkGatewaysRequestWire struct { + Parent *string `json:"parent,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +func listPrivateNetworkGatewaysRequestToWire(v *ListPrivateNetworkGatewaysRequest) (*listPrivateNetworkGatewaysRequestWire, error) { + if v == nil { + return nil, nil + } + return &listPrivateNetworkGatewaysRequestWire{ + Parent: v.Parent, + PageToken: v.PageToken, + }, nil +} + +type listPrivateNetworkGatewaysResponseWire struct { + PrivateNetworkGateways []privateNetworkGatewayWire `json:"private_network_gateways,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +func listPrivateNetworkGatewaysResponseFromWire(w *listPrivateNetworkGatewaysResponseWire) (*ListPrivateNetworkGatewaysResponse, error) { + if w == nil { + return nil, nil + } + privateNetworkGatewaysPublicValue, err := convertSlice(w.PrivateNetworkGateways, privateNetworkGatewayFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPrivateNetworkGatewaysResponse.PrivateNetworkGateways", err) + } + return &ListPrivateNetworkGatewaysResponse{ + PrivateNetworkGateways: privateNetworkGatewaysPublicValue, + NextPageToken: w.NextPageToken, + }, nil +} + type nccPrivateEndpointRuleWire struct { RuleId *string `json:"rule_id,omitempty"` NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` @@ -2598,6 +2672,39 @@ type networkConnectivityConfigWire struct { EgressConfig *customerFacingNetworkConnectivityConfigEgressConfigWire `json:"egress_config,omitempty"` UpdatedTime *wireInt64 `json:"updated_time,omitempty"` CreationTime *wireInt64 `json:"creation_time,omitempty"` + BillingWorkspaceId *wireInt64 `json:"billing_workspace_id,omitempty"` +} + +func networkConnectivityConfigToWire(v *NetworkConnectivityConfig) (*networkConnectivityConfigWire, error) { + if v == nil { + return nil, nil + } + egressConfigWireValue, err := customerFacingNetworkConnectivityConfigEgressConfigToWire(v.EgressConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.EgressConfig", err) + } + updatedTimeWireValue, err := int64ToWire(v.UpdatedTime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.UpdatedTime", err) + } + creationTimeWireValue, err := int64ToWire(v.CreationTime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.CreationTime", err) + } + billingWorkspaceIdWireValue, err := int64ToWire(v.BillingWorkspaceId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.BillingWorkspaceId", err) + } + return &networkConnectivityConfigWire{ + NetworkConnectivityConfigId: v.NetworkConnectivityConfigId, + AccountId: v.AccountId, + Name: v.Name, + Region: v.Region, + EgressConfig: egressConfigWireValue, + UpdatedTime: updatedTimeWireValue, + CreationTime: creationTimeWireValue, + BillingWorkspaceId: billingWorkspaceIdWireValue, + }, nil } func networkConnectivityConfigFromWire(w *networkConnectivityConfigWire) (*NetworkConnectivityConfig, error) { @@ -2616,6 +2723,10 @@ func networkConnectivityConfigFromWire(w *networkConnectivityConfigWire) (*Netwo if err != nil { return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.CreationTime", err) } + billingWorkspaceIdPublicValue, err := int64FromWire(w.BillingWorkspaceId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.BillingWorkspaceId", err) + } return &NetworkConnectivityConfig{ NetworkConnectivityConfigId: w.NetworkConnectivityConfigId, AccountId: w.AccountId, @@ -2624,6 +2735,7 @@ func networkConnectivityConfigFromWire(w *networkConnectivityConfigWire) (*Netwo EgressConfig: egressConfigPublicValue, UpdatedTime: updatedTimePublicValue, CreationTime: creationTimePublicValue, + BillingWorkspaceId: billingWorkspaceIdPublicValue, }, nil } @@ -2937,6 +3049,47 @@ func networkWarningFromWire(w *networkWarningWire) (*NetworkWarning, error) { }, nil } +type operationWire struct { + Name *string `json:"name,omitempty"` + Metadata json.RawMessage `json:"metadata,omitempty"` + Done *bool `json:"done,omitempty"` + Error *apiErrorWire `json:"error,omitempty"` + Response json.RawMessage `json:"response,omitempty"` +} + +func operationFromWire(w *operationWire) (*Operation, error) { + if w == nil { + return nil, nil + } + resultMembers := 0 + if w.Error != nil { + resultMembers++ + } + if w.Response != nil { + resultMembers++ + } + if resultMembers > 1 { + return nil, fmt.Errorf("%s: multiple oneof members set", "Operation.Result") + } + var resultSelection isOperation_Result + switch { + case w.Error != nil: + resultErrorConverted, err := apiErrorFromWire(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result.Error", err) + } + resultSelection = &Operation_Result_Error{Error: *resultErrorConverted} + case w.Response != nil: + resultSelection = &Operation_Result_Response{Response: w.Response} + } + return &Operation{ + Name: w.Name, + Metadata: w.Metadata, + Done: w.Done, + Result: resultSelection, + }, nil +} + type privateAccessSettingsWire struct { PrivateAccessSettingsId *string `json:"private_access_settings_id,omitempty"` AccountId *string `json:"account_id,omitempty"` @@ -2977,6 +3130,327 @@ func privateAccessSettingsFromWire(w *privateAccessSettingsWire) (*PrivateAccess }, nil } +type privateNetworkGatewayWire struct { + Name *string `json:"name,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + AzureCloudConnection *privateNetworkGateway_AzureCloudConnectionWire `json:"azure_cloud_connection,omitempty"` + AwsCloudConnection *privateNetworkGateway_AwsCloudConnectionWire `json:"aws_cloud_connection,omitempty"` + Destinations []privateNetworkGateway_DestinationWire `json:"destinations,omitempty"` + PrivateDnsResolvers []privateNetworkGateway_PrivateDnsResolverWire `json:"private_dns_resolvers,omitempty"` + TrafficMode PrivateNetworkGateway_TrafficMode `json:"traffic_mode,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` + State PrivateNetworkGateway_GatewayState `json:"state,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + BandwidthTierGigabitsPerSecond *int `json:"bandwidth_tier_gigabits_per_second,omitempty"` +} + +func privateNetworkGatewayToWire(v *PrivateNetworkGateway) (*privateNetworkGatewayWire, error) { + if v == nil { + return nil, nil + } + destinationsWireValue, err := convertSlice(v.Destinations, privateNetworkGateway_DestinationToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.Destinations", err) + } + privateDnsResolversWireValue, err := convertSlice(v.PrivateDnsResolvers, privateNetworkGateway_PrivateDnsResolverToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.PrivateDnsResolvers", err) + } + var cloudConnectionAzureCloudConnectionWire *privateNetworkGateway_AzureCloudConnectionWire + var cloudConnectionAwsCloudConnectionWire *privateNetworkGateway_AwsCloudConnectionWire + switch value := v.CloudConnection.(type) { + case nil: + case *PrivateNetworkGateway_CloudConnection_AzureCloudConnection: + if value != nil { + cloudConnectionAzureCloudConnectionConverted, err := privateNetworkGateway_AzureCloudConnectionToWire(&value.AzureCloudConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.CloudConnection.AzureCloudConnection", err) + } + cloudConnectionAzureCloudConnectionWire = cloudConnectionAzureCloudConnectionConverted + } + case *PrivateNetworkGateway_CloudConnection_AwsCloudConnection: + if value != nil { + cloudConnectionAwsCloudConnectionConverted, err := privateNetworkGateway_AwsCloudConnectionToWire(&value.AwsCloudConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.CloudConnection.AwsCloudConnection", err) + } + cloudConnectionAwsCloudConnectionWire = cloudConnectionAwsCloudConnectionConverted + } + default: + return nil, fmt.Errorf("%s: unsupported oneof implementation %T", "PrivateNetworkGateway.CloudConnection", value) + } + return &privateNetworkGatewayWire{ + Name: v.Name, + DisplayName: v.DisplayName, + AzureCloudConnection: cloudConnectionAzureCloudConnectionWire, + AwsCloudConnection: cloudConnectionAwsCloudConnectionWire, + Destinations: destinationsWireValue, + PrivateDnsResolvers: privateDnsResolversWireValue, + TrafficMode: v.TrafficMode, + CreateTime: v.CreateTime, + UpdateTime: v.UpdateTime, + State: v.State, + ErrorMessage: v.ErrorMessage, + BandwidthTierGigabitsPerSecond: v.BandwidthTierGigabitsPerSecond, + }, nil +} + +func privateNetworkGatewayFromWire(w *privateNetworkGatewayWire) (*PrivateNetworkGateway, error) { + if w == nil { + return nil, nil + } + cloudConnectionMembers := 0 + if w.AzureCloudConnection != nil { + cloudConnectionMembers++ + } + if w.AwsCloudConnection != nil { + cloudConnectionMembers++ + } + if cloudConnectionMembers > 1 { + return nil, fmt.Errorf("%s: multiple oneof members set", "PrivateNetworkGateway.CloudConnection") + } + destinationsPublicValue, err := convertSlice(w.Destinations, privateNetworkGateway_DestinationFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.Destinations", err) + } + privateDnsResolversPublicValue, err := convertSlice(w.PrivateDnsResolvers, privateNetworkGateway_PrivateDnsResolverFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.PrivateDnsResolvers", err) + } + var cloudConnectionSelection isPrivateNetworkGateway_CloudConnection + switch { + case w.AzureCloudConnection != nil: + cloudConnectionAzureCloudConnectionConverted, err := privateNetworkGateway_AzureCloudConnectionFromWire(w.AzureCloudConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.CloudConnection.AzureCloudConnection", err) + } + cloudConnectionSelection = &PrivateNetworkGateway_CloudConnection_AzureCloudConnection{AzureCloudConnection: *cloudConnectionAzureCloudConnectionConverted} + case w.AwsCloudConnection != nil: + cloudConnectionAwsCloudConnectionConverted, err := privateNetworkGateway_AwsCloudConnectionFromWire(w.AwsCloudConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway.CloudConnection.AwsCloudConnection", err) + } + cloudConnectionSelection = &PrivateNetworkGateway_CloudConnection_AwsCloudConnection{AwsCloudConnection: *cloudConnectionAwsCloudConnectionConverted} + } + return &PrivateNetworkGateway{ + Name: w.Name, + DisplayName: w.DisplayName, + Destinations: destinationsPublicValue, + PrivateDnsResolvers: privateDnsResolversPublicValue, + TrafficMode: w.TrafficMode, + CreateTime: w.CreateTime, + UpdateTime: w.UpdateTime, + State: w.State, + ErrorMessage: w.ErrorMessage, + BandwidthTierGigabitsPerSecond: w.BandwidthTierGigabitsPerSecond, + CloudConnection: cloudConnectionSelection, + }, nil +} + +type privateNetworkGateway_AwsCloudConnectionWire struct { + GatewaySubnets []privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetWire `json:"gateway_subnets,omitempty"` + CrossAccountRole *privateNetworkGateway_AwsCloudConnection_CrossAccountRoleWire `json:"cross_account_role,omitempty"` + SecurityGroupIds []string `json:"security_group_ids,omitempty"` +} + +func privateNetworkGateway_AwsCloudConnectionToWire(v *PrivateNetworkGateway_AwsCloudConnection) (*privateNetworkGateway_AwsCloudConnectionWire, error) { + if v == nil { + return nil, nil + } + gatewaySubnetsWireValue, err := convertSlice(v.GatewaySubnets, privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetToWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway_AwsCloudConnection.GatewaySubnets", err) + } + crossAccountRoleWireValue, err := privateNetworkGateway_AwsCloudConnection_CrossAccountRoleToWire(v.CrossAccountRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway_AwsCloudConnection.CrossAccountRole", err) + } + return &privateNetworkGateway_AwsCloudConnectionWire{ + GatewaySubnets: gatewaySubnetsWireValue, + CrossAccountRole: crossAccountRoleWireValue, + SecurityGroupIds: v.SecurityGroupIds, + }, nil +} + +func privateNetworkGateway_AwsCloudConnectionFromWire(w *privateNetworkGateway_AwsCloudConnectionWire) (*PrivateNetworkGateway_AwsCloudConnection, error) { + if w == nil { + return nil, nil + } + gatewaySubnetsPublicValue, err := convertSlice(w.GatewaySubnets, privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetFromWire) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway_AwsCloudConnection.GatewaySubnets", err) + } + crossAccountRolePublicValue, err := privateNetworkGateway_AwsCloudConnection_CrossAccountRoleFromWire(w.CrossAccountRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway_AwsCloudConnection.CrossAccountRole", err) + } + return &PrivateNetworkGateway_AwsCloudConnection{ + GatewaySubnets: gatewaySubnetsPublicValue, + CrossAccountRole: crossAccountRolePublicValue, + SecurityGroupIds: w.SecurityGroupIds, + }, nil +} + +type privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetWire struct { + SubnetId *string `json:"subnet_id,omitempty"` +} + +func privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetToWire(v *PrivateNetworkGateway_AwsCloudConnection_AwsGatewaySubnet) (*privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetWire, error) { + if v == nil { + return nil, nil + } + return &privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetWire{ + SubnetId: v.SubnetId, + }, nil +} + +func privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetFromWire(w *privateNetworkGateway_AwsCloudConnection_AwsGatewaySubnetWire) (*PrivateNetworkGateway_AwsCloudConnection_AwsGatewaySubnet, error) { + if w == nil { + return nil, nil + } + return &PrivateNetworkGateway_AwsCloudConnection_AwsGatewaySubnet{ + SubnetId: w.SubnetId, + }, nil +} + +type privateNetworkGateway_AwsCloudConnection_CrossAccountRoleWire struct { + RoleArn *string `json:"role_arn,omitempty"` +} + +func privateNetworkGateway_AwsCloudConnection_CrossAccountRoleToWire(v *PrivateNetworkGateway_AwsCloudConnection_CrossAccountRole) (*privateNetworkGateway_AwsCloudConnection_CrossAccountRoleWire, error) { + if v == nil { + return nil, nil + } + return &privateNetworkGateway_AwsCloudConnection_CrossAccountRoleWire{ + RoleArn: v.RoleArn, + }, nil +} + +func privateNetworkGateway_AwsCloudConnection_CrossAccountRoleFromWire(w *privateNetworkGateway_AwsCloudConnection_CrossAccountRoleWire) (*PrivateNetworkGateway_AwsCloudConnection_CrossAccountRole, error) { + if w == nil { + return nil, nil + } + return &PrivateNetworkGateway_AwsCloudConnection_CrossAccountRole{ + RoleArn: w.RoleArn, + }, nil +} + +type privateNetworkGateway_AzureCloudConnectionWire struct { + GatewaySubnet *privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetWire `json:"gateway_subnet,omitempty"` +} + +func privateNetworkGateway_AzureCloudConnectionToWire(v *PrivateNetworkGateway_AzureCloudConnection) (*privateNetworkGateway_AzureCloudConnectionWire, error) { + if v == nil { + return nil, nil + } + gatewaySubnetWireValue, err := privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetToWire(v.GatewaySubnet) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway_AzureCloudConnection.GatewaySubnet", err) + } + return &privateNetworkGateway_AzureCloudConnectionWire{ + GatewaySubnet: gatewaySubnetWireValue, + }, nil +} + +func privateNetworkGateway_AzureCloudConnectionFromWire(w *privateNetworkGateway_AzureCloudConnectionWire) (*PrivateNetworkGateway_AzureCloudConnection, error) { + if w == nil { + return nil, nil + } + gatewaySubnetPublicValue, err := privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetFromWire(w.GatewaySubnet) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PrivateNetworkGateway_AzureCloudConnection.GatewaySubnet", err) + } + return &PrivateNetworkGateway_AzureCloudConnection{ + GatewaySubnet: gatewaySubnetPublicValue, + }, nil +} + +type privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetWire struct { + ResourceId *string `json:"resource_id,omitempty"` +} + +func privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetToWire(v *PrivateNetworkGateway_AzureCloudConnection_AzureGatewaySubnet) (*privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetWire, error) { + if v == nil { + return nil, nil + } + return &privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetWire{ + ResourceId: v.ResourceId, + }, nil +} + +func privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetFromWire(w *privateNetworkGateway_AzureCloudConnection_AzureGatewaySubnetWire) (*PrivateNetworkGateway_AzureCloudConnection_AzureGatewaySubnet, error) { + if w == nil { + return nil, nil + } + return &PrivateNetworkGateway_AzureCloudConnection_AzureGatewaySubnet{ + ResourceId: w.ResourceId, + }, nil +} + +type privateNetworkGateway_DestinationWire struct { + DestinationType PrivateNetworkGateway_Destination_DestinationType `json:"destination_type,omitempty"` + Value *string `json:"value,omitempty"` +} + +func privateNetworkGateway_DestinationToWire(v *PrivateNetworkGateway_Destination) (*privateNetworkGateway_DestinationWire, error) { + if v == nil { + return nil, nil + } + return &privateNetworkGateway_DestinationWire{ + DestinationType: v.DestinationType, + Value: v.Value, + }, nil +} + +func privateNetworkGateway_DestinationFromWire(w *privateNetworkGateway_DestinationWire) (*PrivateNetworkGateway_Destination, error) { + if w == nil { + return nil, nil + } + return &PrivateNetworkGateway_Destination{ + DestinationType: w.DestinationType, + Value: w.Value, + }, nil +} + +type privateNetworkGateway_PrivateDnsResolverWire struct { + ResolverType PrivateNetworkGateway_PrivateDnsResolver_ResolverType `json:"resolver_type,omitempty"` + Value *string `json:"value,omitempty"` +} + +func privateNetworkGateway_PrivateDnsResolverToWire(v *PrivateNetworkGateway_PrivateDnsResolver) (*privateNetworkGateway_PrivateDnsResolverWire, error) { + if v == nil { + return nil, nil + } + return &privateNetworkGateway_PrivateDnsResolverWire{ + ResolverType: v.ResolverType, + Value: v.Value, + }, nil +} + +func privateNetworkGateway_PrivateDnsResolverFromWire(w *privateNetworkGateway_PrivateDnsResolverWire) (*PrivateNetworkGateway_PrivateDnsResolver, error) { + if w == nil { + return nil, nil + } + return &PrivateNetworkGateway_PrivateDnsResolver{ + ResolverType: w.ResolverType, + Value: w.Value, + }, nil +} + +type privateNetworkGatewayOperationMetadataWire struct { + OperationType PrivateNetworkGatewayOperationMetadata_OperationType `json:"operation_type,omitempty"` +} + +func privateNetworkGatewayOperationMetadataFromWire(w *privateNetworkGatewayOperationMetadataWire) (*PrivateNetworkGatewayOperationMetadata, error) { + if w == nil { + return nil, nil + } + return &PrivateNetworkGatewayOperationMetadata{ + OperationType: w.OperationType, + }, nil +} + type replaceAccountIpAccessListRequestWire struct { AccountId *string `json:"account_id,omitempty"` ListId *string `json:"list_id,omitempty"` @@ -3158,6 +3632,29 @@ func updateNccPrivateEndpointRuleRequestToWire(v *UpdateNccPrivateEndpointRuleRe }, nil } +type updateNetworkConnectivityConfigRequestWire struct { + AccountId *string `json:"account_id,omitempty"` + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + NetworkConnectivityConfig *networkConnectivityConfigWire `json:"network_connectivity_config,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +func updateNetworkConnectivityConfigRequestToWire(v *UpdateNetworkConnectivityConfigRequest) (*updateNetworkConnectivityConfigRequestWire, error) { + if v == nil { + return nil, nil + } + networkConnectivityConfigWireValue, err := networkConnectivityConfigToWire(v.NetworkConnectivityConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNetworkConnectivityConfigRequest.NetworkConnectivityConfig", err) + } + return &updateNetworkConnectivityConfigRequestWire{ + AccountId: v.AccountId, + NetworkConnectivityConfigId: v.NetworkConnectivityConfigId, + NetworkConnectivityConfig: networkConnectivityConfigWireValue, + UpdateMask: fieldMaskToWire(v.UpdateMask), + }, nil +} + type updateNetworkPolicyRequestWire struct { NetworkPolicyId *string `json:"network_policy_id,omitempty"` AccountId *string `json:"account_id,omitempty"` @@ -3269,6 +3766,25 @@ func updatePrivateEndpointRuleToWire(v *UpdatePrivateEndpointRule) (*updatePriva }, nil } +type updatePrivateNetworkGatewayRequestWire struct { + PrivateNetworkGateway *privateNetworkGatewayWire `json:"private_network_gateway,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +func updatePrivateNetworkGatewayRequestToWire(v *UpdatePrivateNetworkGatewayRequest) (*updatePrivateNetworkGatewayRequestWire, error) { + if v == nil { + return nil, nil + } + privateNetworkGatewayWireValue, err := privateNetworkGatewayToWire(v.PrivateNetworkGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePrivateNetworkGatewayRequest.PrivateNetworkGateway", err) + } + return &updatePrivateNetworkGatewayRequestWire{ + PrivateNetworkGateway: privateNetworkGatewayWireValue, + UpdateMask: fieldMaskToWire(v.UpdateMask), + }, nil +} + type updateWorkspaceNetworkOptionRequestWire struct { AccountId *string `json:"account_id,omitempty"` WorkspaceId *wireInt64 `json:"workspace_id,omitempty"` diff --git a/postgres/CHANGELOG.md b/postgres/CHANGELOG.md index 1d486083..374f48fd 100644 --- a/postgres/CHANGELOG.md +++ b/postgres/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.7.0 (2026-11-02) + ## Release v0.6.0 (2026-10-22) ## Release v0.5.0 (2026-10-14) diff --git a/postgres/internal/version.go b/postgres/internal/version.go index ed33e142..f5d44bbb 100644 --- a/postgres/internal/version.go +++ b/postgres/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-postgres" -const Version = "0.6.0" +const Version = "0.7.0" diff --git a/postgres/v1/client.go b/postgres/v1/client.go index 75782bba..5e71a363 100644 --- a/postgres/v1/client.go +++ b/postgres/v1/client.go @@ -6490,7 +6490,13 @@ func (o *UpdateProjectOperation) Wait(ctx context.Context, opts ...lro.Option) ( return result, nil } -// Update a role for a branch. +// Updates the mutable fields of a Postgres role for a branch. +// +// The fields `spec.identity_type`, `spec.auth_method`, and `spec.postgres_role` +// are fixed when the role is created. UpdateRole ignores values supplied for +// these fields in the request body and retains their existing values. +// Explicitly naming one of these fields in `update_mask` returns an +// INVALID_PARAMETER_VALUE error. func (c *internalClient) updateRoleBase(ctx context.Context, req UpdateRoleRequest, opts ...call.Option) (*Operation, error) { wireReq, err := updateRoleRequestToWire(&req) if err != nil { @@ -6566,7 +6572,13 @@ func (c *internalClient) updateRoleBase(ctx context.Context, req UpdateRoleReque return resp, nil } -// Update a role for a branch. +// Updates the mutable fields of a Postgres role for a branch. +// +// The fields `spec.identity_type`, `spec.auth_method`, and `spec.postgres_role` +// are fixed when the role is created. UpdateRole ignores values supplied for +// these fields in the request body and retains their existing values. +// Explicitly naming one of these fields in `update_mask` returns an +// INVALID_PARAMETER_VALUE error. func (c *internalClient) UpdateRole(ctx context.Context, req UpdateRoleRequest, opts ...call.Option) (*UpdateRoleOperation, error) { operation, err := c.updateRoleBase(ctx, req, opts...) if err != nil { diff --git a/postgres/v1/model.go b/postgres/v1/model.go index 84d18ddc..9ebfa10d 100644 --- a/postgres/v1/model.go +++ b/postgres/v1/model.go @@ -1041,9 +1041,14 @@ type CreateRoleRequest struct { // The desired specification of a Role. Role *Role // If true, update the role if it already exists instead of returning an error. - // - // When the role already exists, the provided `role` spec fully replaces the - // existing one: `membership_roles` is overwritten, not merged. Leaving + // This requires `role_id` to be set. Without `role_id`, the request follows the + // normal create path and fails if the role name already exists. + // + // When the role already exists, only mutable fields are updated. Attributes + // omitted from the request retain their current values. Set an attribute + // explicitly to false to disable it. `identity_type`, `auth_method`, and + // `postgres_role` retain their existing values; supplied values for these + // fields are ignored. `membership_roles` is overwritten, not merged. Leaving // `membership_roles` empty clears all of the role's existing memberships, // including `DATABRICKS_SUPERUSER`. Always send the complete desired list of // memberships when using this field. @@ -2089,6 +2094,11 @@ type Role_RoleSpec struct { // // * application ID for SERVICE_PRINCIPAL * user email for USER * group name for // GROUP + // + // This field is set when the role is created and cannot be changed by + // UpdateRole. If provided in an UpdateRole request body, its value is ignored + // and the existing value is retained. Do not include this field as an explicit + // path in update_mask. IdentityType Role_IdentityType `fieldmask:"identity_type"` // The desired API-exposed Postgres role attribute to associate with the role. // Optional. @@ -2113,6 +2123,11 @@ type Role_RoleSpec struct { // // NOTE: for the identity type GROUP, LAKEBASE_OAUTH_V1 is the // default auth method (group can login as well). + // + // This field is set when the role is created and cannot be changed by + // UpdateRole. If provided in an UpdateRole request body, its value is ignored + // and the existing value is retained. Do not include this field as an explicit + // path in update_mask. AuthMethod Role_AuthMethod `fieldmask:"auth_method"` // The name of the Postgres role. // @@ -2126,6 +2141,11 @@ type Role_RoleSpec struct { // // 1. user email for IdentityType.USER 2. app ID for // IdentityType.SERVICE_PRINCIPAL 2. group name for IdentityType.GROUP + // + // This field is set when the role is created and cannot be changed by + // UpdateRole. If provided in an UpdateRole request body, its value is ignored + // and the existing value is retained. Do not include this field as an explicit + // path in update_mask. PostgresRole *string `fieldmask:"postgres_role"` } @@ -2569,7 +2589,21 @@ type UpdateRoleRequest struct { // The role's `name` field is used to identify the role to update. Format: // projects/{project_id}/branches/{branch_id}/roles/{role_id} Role *Role - // The list of fields to update. + // The list of fields to update. Supported fields are `spec.membership_roles`, + // `spec.attributes.createdb`, `spec.attributes.createrole`, and + // `spec.attributes.bypassrls`. + // + // `spec.identity_type`, `spec.auth_method`, and `spec.postgres_role` cannot be + // changed. Values supplied for these fields in the request body are ignored. + // Including one of these fields as an explicit path in update_mask returns an + // INVALID_PARAMETER_VALUE error. When `spec` is the only path in the mask, only + // the supplied mutable attributes are updated. `*` by itself, or `spec` + // combined with other supported paths, selects all supported mutable fields. + // For these masks, all three attributes (`createdb`, `createrole`, and + // `bypassrls`) must be supplied; omitting any returns an + // INVALID_PARAMETER_VALUE error. Each of these mask forms replaces + // `membership_roles`. Omitting it or supplying an empty list clears all + // memberships, including `DATABRICKS_SUPERUSER`. UpdateMask *types.FieldMask[Role] } diff --git a/sandbox/CHANGELOG.md b/sandbox/CHANGELOG.md index e49784cc..e63af129 100644 --- a/sandbox/CHANGELOG.md +++ b/sandbox/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.7.0 (2026-11-02) + ## Release v0.6.0 (2026-10-26) ## Release v0.5.0 (2026-10-22) diff --git a/sandbox/internal/version.go b/sandbox/internal/version.go index cd150742..7403e233 100644 --- a/sandbox/internal/version.go +++ b/sandbox/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-sandbox" -const Version = "0.6.0" +const Version = "0.7.0" diff --git a/sandbox/v1/client.go b/sandbox/v1/client.go index 8820b108..96ea4fd5 100644 --- a/sandbox/v1/client.go +++ b/sandbox/v1/client.go @@ -7,10 +7,12 @@ import ( "context" "encoding/json" "fmt" + "io" "iter" "log/slog" "net/http" "net/url" + "strconv" "sync" "time" @@ -992,6 +994,226 @@ func (c *internalClient) RenamePath(ctx context.Context, req RenamePathRequest, return resp, nil } +// Downloads a regular file from a sandbox as an application/octet-stream body. +// The sandbox starts automatically if it is stopped. Filesystem access uses the +// sandbox user's permissions and follows symbolic links. +// +// A full download returns 200 OK. A satisfiable single byte range returns 206 +// Partial Content. Multiple byte ranges are unsupported and return 400. Invalid +// ranges are ignored; an unsatisfiable range returns 416 with Content-Range +// describing the file length. Range is ignored for empty files. +// +// Conditional requests can return 304 Not Modified or 412 Precondition Failed. +// If-Range selects a partial response only when its strong entity tag matches; +// otherwise, the entire file is returned. HTTP-date validators in If-Range +// cause a full download. Reads are not snapshots: concurrent in-place writes +// can affect the returned bytes. HEAD is unsupported. +// +// Range and conditional options may be supplied as query parameters or HTTP +// headers. A parameter and one header may both be supplied when their values +// match exactly. Conflicting values or repeated parameters return 400. +// A timeout configured with [client.WithTimeout] or [call.WithTimeout] applies +// until this method returns. It does not apply while reading the response stream. +func (c *internalClient) DownloadFile(ctx context.Context, req DownloadFileRequest, opts ...call.Option) (*DownloadFileResponse, error) { + wireReq, err := downloadFileRequestToWire(&req) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/json") + headers.Set("Accept", "application/octet-stream") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/2.0/sandbox-files/") + if req.Parent == nil { + return nil, fmt.Errorf("path parameter %q is required", "parent") + } + pb.singleSegment(*req.Parent) + pb.literal("/content") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "path", wireReq.Path); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "byte_range", wireReq.Range); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "if_range", wireReq.IfRange); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "if_match", wireReq.IfMatch); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "if_none_match", wireReq.IfNoneMatch); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "if_modified_since", wireReq.IfModifiedSince); err != nil { + return nil, err + } + if err := addQueryValue(queryParams, "if_unmodified_since", wireReq.IfUnmodifiedSince); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *DownloadFileResponse + + call := func(ctx context.Context) (io.ReadCloser, error) { + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "GET", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + }) + if err != nil { + return nil, err + } + + httpResp, err := executeStreamingHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return nil, err + } + resp = &DownloadFileResponse{} + if v := httpResp.Header.Get("Content-Length"); v != "" { + n, err := strconv.ParseInt(v, 10, 64) + if err != nil { + httpResp.Body.Close() // avoid leaking the connection + return nil, err + } + resp.ContentLength = &n + } + if v := httpResp.Header.Get("etag"); v != "" { + h := v + resp.Etag = &h + } + if v := httpResp.Header.Get("Last-Modified"); v != "" { + h := v + resp.LastModified = &h + } + if v := httpResp.Header.Get("Content-Range"); v != "" { + h := v + resp.ContentRange = &h + } + if v := httpResp.Header.Get("Accept-Ranges"); v != "" { + h := v + resp.AcceptRanges = &h + } + if v := httpResp.Header.Get("Content-Type"); v != "" { + h := v + resp.ContentType = &h + } + return httpResp.Body, nil + } + + contents, err := c.executeStreamingResponseCall(ctx, call, opts) + if err != nil { + return nil, err + } + resp.Contents = contents + return resp, nil +} + +// Uploads an application/octet-stream body to a sandbox. The sandbox starts +// automatically if it is stopped. Filesystem access uses the sandbox user's +// permissions and follows symbolic links. +// +// Creates the file or replaces its entire contents, creating parent directories +// if missing. The completed upload becomes visible atomically. A failure before +// commit leaves an existing destination unchanged; a lost response after commit +// does not undo the upload. Completion does not guarantee crash durability. +// +// Returns 201 Created for a new file or 204 No Content for a replacement. +// Partial and conditional uploads are unsupported: Content-Range, If-Match, +// If-None-Match, and If-Unmodified-Since return 400. +// +// This method has a one-hour SDK timeout by default. Use [client.WithTimeout] +// to set a client default or [call.WithTimeout] to override it for this call. +// A zero timeout disables the SDK timeout. +// +// The call returns an error if a retrier is configured because replaying the +// request body is not supported. +func (c *internalClient) UploadFile(ctx context.Context, req UploadFileRequest, opts ...call.Option) (*UploadFileResponse, error) { + wireReq, err := uploadFileRequestToWire(&req) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Set("Content-Type", "application/octet-stream") + if c.workspaceID != "" { + headers.Set("X-Databricks-Workspace-Id", c.workspaceID) + } + + baseURL, err := url.Parse(c.host) + if err != nil { + return nil, err + } + pb := pathBuilder{} + pb.literal("/api/2.0/sandbox-files/") + if req.Parent == nil { + return nil, fmt.Errorf("path parameter %q is required", "parent") + } + pb.singleSegment(*req.Parent) + pb.literal("/content") + baseURL.Path, baseURL.RawPath = pb.build() + queryParams := url.Values{} + if err := addQueryValue(queryParams, "path", wireReq.Path); err != nil { + return nil, err + } + baseURL.RawQuery = queryParams.Encode() + urlStr := baseURL.String() + + var resp *UploadFileResponse + + call := func(ctx context.Context) error { + var reqBody io.Reader + if req.Contents != nil { + reqBody = req.Contents + } + httpReq, err := newHTTPRequest(ctx, httpRequestOptions{ + Method: "PUT", + URL: urlStr, + Credentials: c.credentials, + UserAgent: c.userAgent, + Headers: headers, + Body: reqBody, + }) + if err != nil { + return err + } + + respBody, _, err := executeHTTPCall(httpCallOptions{ + req: httpReq, + client: c.httpClient, + logger: c.logger, + }) + if err != nil { + return err + } + _ = respBody + resp = &UploadFileResponse{} + return nil + } + + if err := c.executeStreamingRequestCall(ctx, call, opts); err != nil { + return nil, err + } + return resp, nil +} + // Runs a command in the sandbox and blocks until it exits, returning the // captured stdout, stderr and exit code in a single response. func (c *internalClient) ExecuteCommandSync(ctx context.Context, req ExecuteCommandSyncRequest, opts ...call.Option) (*ExecuteCommandSyncResponse, error) { diff --git a/sandbox/v1/genhelper.go b/sandbox/v1/genhelper.go index ae7301e3..7bd25956 100644 --- a/sandbox/v1/genhelper.go +++ b/sandbox/v1/genhelper.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "log/slog" @@ -153,6 +154,21 @@ func (c *internalClient) executeCall( return executeResolvedCall(ctx, op, cfg) } +func (c *internalClient) executeStreamingRequestCall( + ctx context.Context, + op func(context.Context) error, + opts []call.Option, +) error { + cfg, err := c.resolveCallOptions(opts, time.Hour) + if err != nil { + return err + } + if cfg.Retrier != nil { + return errors.New("retries are unsupported for client-side streaming methods") + } + return executeResolvedCall(ctx, op, cfg) +} + func executeResolvedCall(ctx context.Context, op func(context.Context) error, cfg internaloptions.CallOptions) error { return ops.Execute(ctx, op, ops.WithRetrier(cfg.Retrier), @@ -161,6 +177,81 @@ func executeResolvedCall(ctx context.Context, op func(context.Context) error, cf ) } +var errNilStream = errors.New("streaming operation returned a nil stream") + +// executeStreamingResponseCall runs a call whose response body is returned as a +// stream. The context and options apply until the stream is returned. After +// that handoff, the caller owns the stream and must close it. +func (c *internalClient) executeStreamingResponseCall( + ctx context.Context, + op func(context.Context) (io.ReadCloser, error), + opts []call.Option, +) (io.ReadCloser, error) { + cfg, err := c.resolveCallOptions(opts, 5*time.Minute) + if err != nil { + return nil, err + } + + executionCtx := ctx + cancelExecution := context.CancelFunc(func() {}) + if cfg.Timeout != 0 { + executionCtx, cancelExecution = context.WithTimeout(ctx, cfg.Timeout) + } + defer cancelExecution() + + // Preserve context values while allowing the request to outlive the call. + requestCtx, cancelRequest := context.WithCancelCause(context.WithoutCancel(ctx)) + stopForwarding := context.AfterFunc(executionCtx, func() { + cancelRequest(context.Cause(executionCtx)) + }) + + var stream io.ReadCloser + err = ops.Execute(executionCtx, func(context.Context) error { + var opErr error + stream, opErr = op(requestCtx) + return opErr + }, + ops.WithRetrier(cfg.Retrier), + ops.WithLimiter(cfg.RateLimiter), + ) + + // Disconnect before deferred cleanup cancels executionCtx. A timeout that + // already started cancellation must fail the handoff instead of returning a broken body. + stopForwarding() + if cause := context.Cause(executionCtx); cause != nil { + err = cause + } + if err == nil && stream == nil { + err = errNilStream + } + if err != nil { + cancelRequest(err) + if stream != nil { + stream.Close() + } + return nil, err + } + return &cancelingReadCloser{ReadCloser: stream, cancel: func() { cancelRequest(nil) }}, nil +} + +type cancelingReadCloser struct { + io.ReadCloser + cancel context.CancelFunc +} + +func (r *cancelingReadCloser) Read(p []byte) (int, error) { + n, err := r.ReadCloser.Read(p) + if err != nil { + r.cancel() + } + return n, err +} + +func (r *cancelingReadCloser) Close() error { + r.cancel() + return r.ReadCloser.Close() +} + func addQueryValue(params url.Values, key string, value any) error { data, err := json.Marshal(value) if err != nil { @@ -237,3 +328,29 @@ func (b *pathBuilder) multiSegments(v any) { func (b *pathBuilder) build() (path, rawPath string) { return b.path.String(), b.raw.String() } + +// executeStreamingHTTPCall executes an HTTP call whose response body is a raw +// byte stream. On success it returns the response with its body still open, so +// the caller can stream and close it. On a non-2xx status it reads and closes +// the body to build the API error; the returned response is nil in that case. +func executeStreamingHTTPCall(opts httpCallOptions) (*http.Response, error) { + opts.logger.Debug("HTTP request", "request", lazyRequest{opts.req}) + resp, err := opts.client.Do(opts.req) + if err != nil { + return nil, err + } + if resp.StatusCode >= 400 { + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, nil}) + return nil, err + } + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, body}) + if apiErr := apierr.FromHTTPError(resp.StatusCode, resp.Header, body); apiErr != nil { + return nil, apiErr + } + } + opts.logger.Debug("HTTP response", "response", lazyResponse{resp, []byte("")}) + return resp, nil +} diff --git a/sandbox/v1/model.go b/sandbox/v1/model.go index af2681b8..2117c746 100644 --- a/sandbox/v1/model.go +++ b/sandbox/v1/model.go @@ -3,6 +3,8 @@ package sandbox import ( + "io" + "github.com/databricks/sdk-go/core/types" ) @@ -105,6 +107,52 @@ type DeleteSandboxRequest struct { Name *string } +// Parameters for a file download. Range and conditional parameters are aliases +// for the corresponding HTTP headers.. +type DownloadFileRequest struct { + // The sandbox resource name, in the form sandboxes/{sandbox_id}. + Parent *string + // The absolute UTF-8 path of the file inside the sandbox. + Path *string + // A single byte range, such as bytes=0-1023 or bytes=-1024. Equivalent to the + // Range header. + Range *string + // A strong entity tag. A mismatch, weak entity tag, or HTTP-date causes a full + // download. Equivalent to the If-Range header. + IfRange *string + // Entity tags or *. A mismatch returns 412 Precondition Failed. Equivalent to + // the If-Match header. + IfMatch *string + // Entity tags or *. A match returns 304 Not Modified. Equivalent to the + // If-None-Match header. + IfNoneMatch *string + // An HTTP-date. Returns 304 if the file has not changed since this time. + // Ignored when If-None-Match is present. Equivalent to the If-Modified-Since + // header. + IfModifiedSince *string + // An HTTP-date. Returns 412 if the file has changed since this time. Ignored + // when If-Match is present. Equivalent to the If-Unmodified-Since header. + IfUnmodifiedSince *string +} + +// A streamed file body and its HTTP response headers.. +type DownloadFileResponse struct { + // The full file or the requested byte range. + Contents io.ReadCloser + // The length of the response body in bytes. + ContentLength *int64 + // The entity tag used for conditional requests. + Etag *string + // The modification time as an HTTP-date, when representable. + LastModified *string + // The returned byte range and full file length, for a partial response. + ContentRange *string + // The supported range unit: bytes. + AcceptRanges *string + // The media type of the response body: application/octet-stream. + ContentType *string +} + type EnvironmentSpec struct { // The Unity Catalog container image to use for the sandbox environment (for // example, `catalog.schema.folder.image:tag`). See [Artifact Registry]. @@ -317,3 +365,17 @@ type UpdateSandboxRequest struct { // INVALID_PARAMETER_VALUE. UpdateMask *types.FieldMask[Sandbox] } + +// Parameters and streamed HTTP body for a whole-file upload.. +type UploadFileRequest struct { + // The sandbox resource name, in the form sandboxes/{sandbox_id}. + Parent *string + // The absolute UTF-8 destination path inside the sandbox. + Path *string + // The complete file contents. An empty body creates an empty file. + Contents io.ReadCloser +} + +// A successful upload returns no response body.. +type UploadFileResponse struct { +} diff --git a/sandbox/v1/wire.go b/sandbox/v1/wire.go index 63e1fa8c..ab0e84fb 100644 --- a/sandbox/v1/wire.go +++ b/sandbox/v1/wire.go @@ -164,6 +164,33 @@ func deletePathRequestToWire(v *DeletePathRequest) (*deletePathRequestWire, erro }, nil } +type downloadFileRequestWire struct { + Parent *string `json:"parent,omitempty"` + Path *string `json:"path,omitempty"` + Range *string `json:"byte_range,omitempty"` + IfRange *string `json:"if_range,omitempty"` + IfMatch *string `json:"if_match,omitempty"` + IfNoneMatch *string `json:"if_none_match,omitempty"` + IfModifiedSince *string `json:"if_modified_since,omitempty"` + IfUnmodifiedSince *string `json:"if_unmodified_since,omitempty"` +} + +func downloadFileRequestToWire(v *DownloadFileRequest) (*downloadFileRequestWire, error) { + if v == nil { + return nil, nil + } + return &downloadFileRequestWire{ + Parent: v.Parent, + Path: v.Path, + Range: v.Range, + IfRange: v.IfRange, + IfMatch: v.IfMatch, + IfNoneMatch: v.IfNoneMatch, + IfModifiedSince: v.IfModifiedSince, + IfUnmodifiedSince: v.IfUnmodifiedSince, + }, nil +} + type environmentSpecWire struct { ImageUri *string `json:"image_uri,omitempty"` } @@ -618,6 +645,21 @@ func updateSandboxRequestToWire(v *UpdateSandboxRequest) (*updateSandboxRequestW }, nil } +type uploadFileRequestWire struct { + Parent *string `json:"parent,omitempty"` + Path *string `json:"path,omitempty"` +} + +func uploadFileRequestToWire(v *UploadFileRequest) (*uploadFileRequestWire, error) { + if v == nil { + return nil, nil + } + return &uploadFileRequestWire{ + Parent: v.Parent, + Path: v.Path, + }, nil +} + func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { if s == nil { return nil, nil diff --git a/uc/abacpolicies/CHANGELOG.md b/uc/abacpolicies/CHANGELOG.md index 65276ae3..f50e9742 100644 --- a/uc/abacpolicies/CHANGELOG.md +++ b/uc/abacpolicies/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.5.0 (2026-11-02) + ## Release v0.4.0 (2026-10-19) ## Release v0.3.0 (2026-10-13) diff --git a/uc/abacpolicies/internal/version.go b/uc/abacpolicies/internal/version.go index 54a490fd..6e4cffec 100644 --- a/uc/abacpolicies/internal/version.go +++ b/uc/abacpolicies/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-abacpolicies" -const Version = "0.4.0" +const Version = "0.5.0" diff --git a/uc/abacpolicies/v1/model.go b/uc/abacpolicies/v1/model.go index 1317207a..45e31f27 100644 --- a/uc/abacpolicies/v1/model.go +++ b/uc/abacpolicies/v1/model.go @@ -45,6 +45,9 @@ const ( SecurableType_ModelProviderService SecurableType = "MODEL_PROVIDER_SERVICE" SecurableType_AgentService SecurableType = "AGENT_SERVICE" SecurableType_Skill SecurableType = "SKILL" + // A Feature Store feature in Unity Catalog. Three-level namespace + // catalog.schema.feature. + SecurableType_Feature SecurableType = "FEATURE" ) type ColumnMaskOptions struct { diff --git a/uc/catalogs/CHANGELOG.md b/uc/catalogs/CHANGELOG.md index 444d06f2..94155535 100644 --- a/uc/catalogs/CHANGELOG.md +++ b/uc/catalogs/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.4.0 (2026-11-02) + ## Release v0.3.0 (2026-10-13) ## Release v0.2.0 (2026-10-06) diff --git a/uc/catalogs/internal/version.go b/uc/catalogs/internal/version.go index 7dd66d05..f5a864d5 100644 --- a/uc/catalogs/internal/version.go +++ b/uc/catalogs/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-catalogs" -const Version = "0.3.0" +const Version = "0.4.0" diff --git a/uc/catalogs/v1/model.go b/uc/catalogs/v1/model.go index 8a7a54cf..d08e8e7c 100644 --- a/uc/catalogs/v1/model.go +++ b/uc/catalogs/v1/model.go @@ -52,6 +52,9 @@ const ( SecurableType_ModelProviderService SecurableType = "MODEL_PROVIDER_SERVICE" SecurableType_AgentService SecurableType = "AGENT_SERVICE" SecurableType_Skill SecurableType = "SKILL" + // A Feature Store feature in Unity Catalog. Three-level namespace + // catalog.schema.feature. + SecurableType_Feature SecurableType = "FEATURE" ) type ProvisioningInfo_State string diff --git a/uc/connections/CHANGELOG.md b/uc/connections/CHANGELOG.md index 65276ae3..f50e9742 100644 --- a/uc/connections/CHANGELOG.md +++ b/uc/connections/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.5.0 (2026-11-02) + ## Release v0.4.0 (2026-10-19) ## Release v0.3.0 (2026-10-13) diff --git a/uc/connections/internal/version.go b/uc/connections/internal/version.go index 41136e51..9912c357 100644 --- a/uc/connections/internal/version.go +++ b/uc/connections/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-connections" -const Version = "0.4.0" +const Version = "0.5.0" diff --git a/uc/connections/v1/model.go b/uc/connections/v1/model.go index e230957e..59bf13c8 100644 --- a/uc/connections/v1/model.go +++ b/uc/connections/v1/model.go @@ -90,6 +90,9 @@ const ( SecurableType_ModelProviderService SecurableType = "MODEL_PROVIDER_SERVICE" SecurableType_AgentService SecurableType = "AGENT_SERVICE" SecurableType_Skill SecurableType = "SKILL" + // A Feature Store feature in Unity Catalog. Three-level namespace + // catalog.schema.feature. + SecurableType_Feature SecurableType = "FEATURE" ) type ProvisioningInfo_State string diff --git a/uc/credentials/CHANGELOG.md b/uc/credentials/CHANGELOG.md index 2fca2529..081443ac 100644 --- a/uc/credentials/CHANGELOG.md +++ b/uc/credentials/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.4.0 (2026-11-02) + ## Release v0.3.0 (2026-10-13) ## Release v0.2.0 (2026-10-06) diff --git a/uc/credentials/internal/version.go b/uc/credentials/internal/version.go index deccdcfd..42df7e3d 100644 --- a/uc/credentials/internal/version.go +++ b/uc/credentials/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-credentials" -const Version = "0.3.0" +const Version = "0.4.0" diff --git a/uc/credentials/v1/client.go b/uc/credentials/v1/client.go index 33b328f4..95a3ca39 100644 --- a/uc/credentials/v1/client.go +++ b/uc/credentials/v1/client.go @@ -1540,15 +1540,11 @@ func (c *internalClient) UpdateStorageCredential(ctx context.Context, req Update // Validates a credential. // -// For service credentials (purpose is **SERVICE**), either the -// __credential_name__ or the cloud-specific credential must be provided. -// // For storage credentials (purpose is **STORAGE**), at least one of // __external_location_name__ and __url__ need to be provided. If only one of // them is provided, it will be used for validation. And if both are provided, // the __url__ will be used for validation, and __external_location_name__ will -// be ignored when checking overlapping urls. Either the __credential_name__ or -// the cloud-specific credential must be provided. +// be ignored when checking overlapping urls. // // The caller must be a metastore admin or the credential owner or have the // required permission on the metastore and the credential (e.g., @@ -1624,9 +1620,6 @@ func (c *internalClient) ValidateCredential(ctx context.Context, req ValidateCre // validation, and __external_location_name__ will be ignored when checking // overlapping urls. // -// Either the __storage_credential_name__ or the cloud-specific credential must -// be provided. -// // The caller must be a metastore admin or the storage credential owner or have // the **CREATE_EXTERNAL_LOCATION** privilege on the metastore and the storage // credential. diff --git a/uc/credentials/v1/model.go b/uc/credentials/v1/model.go index f806ad7b..d62e88a8 100644 --- a/uc/credentials/v1/model.go +++ b/uc/credentials/v1/model.go @@ -1532,6 +1532,7 @@ func (*ValidateCredentialRequest_Credential_CredentialName) isValidateCredential } // ValidateCredentialRequest_Credential_AwsIamRole selects AwsIamRole for ValidateCredentialRequest.Credential. +// Deprecated: create a credential and pass its credential_name instead. type ValidateCredentialRequest_Credential_AwsIamRole struct { AwsIamRole AwsIamRole } @@ -1539,6 +1540,7 @@ type ValidateCredentialRequest_Credential_AwsIamRole struct { func (*ValidateCredentialRequest_Credential_AwsIamRole) isValidateCredentialRequest_Credential() {} // ValidateCredentialRequest_Credential_AzureManagedIdentity selects AzureManagedIdentity for ValidateCredentialRequest.Credential. +// Deprecated: create a credential and pass its credential_name instead. type ValidateCredentialRequest_Credential_AzureManagedIdentity struct { AzureManagedIdentity AzureManagedIdentity } @@ -1547,6 +1549,7 @@ func (*ValidateCredentialRequest_Credential_AzureManagedIdentity) isValidateCred } // ValidateCredentialRequest_Credential_DatabricksGcpServiceAccount selects DatabricksGcpServiceAccount for ValidateCredentialRequest.Credential. +// Deprecated: create a credential and pass its credential_name instead. type ValidateCredentialRequest_Credential_DatabricksGcpServiceAccount struct { DatabricksGcpServiceAccount DatabricksGcpServiceAccount } @@ -1594,7 +1597,8 @@ func (*ValidateStorageCredentialRequest_Credential_StorageCredentialName) isVali } // ValidateStorageCredentialRequest_Credential_AwsIamRole selects AwsIamRole for ValidateStorageCredentialRequest.Credential. -// The AWS IAM role configuration. +// Deprecated: create a storage credential and pass its storage_credential_name +// instead. The AWS IAM role configuration. type ValidateStorageCredentialRequest_Credential_AwsIamRole struct { AwsIamRole AwsIamRole } @@ -1603,7 +1607,8 @@ func (*ValidateStorageCredentialRequest_Credential_AwsIamRole) isValidateStorage } // ValidateStorageCredentialRequest_Credential_AzureServicePrincipal selects AzureServicePrincipal for ValidateStorageCredentialRequest.Credential. -// The Azure service principal configuration. +// Deprecated: create a storage credential and pass its storage_credential_name +// instead. The Azure service principal configuration. type ValidateStorageCredentialRequest_Credential_AzureServicePrincipal struct { AzureServicePrincipal AzureServicePrincipal } @@ -1612,7 +1617,8 @@ func (*ValidateStorageCredentialRequest_Credential_AzureServicePrincipal) isVali } // ValidateStorageCredentialRequest_Credential_AzureManagedIdentity selects AzureManagedIdentity for ValidateStorageCredentialRequest.Credential. -// The Azure managed identity configuration. +// Deprecated: create a storage credential and pass its storage_credential_name +// instead. The Azure managed identity configuration. type ValidateStorageCredentialRequest_Credential_AzureManagedIdentity struct { AzureManagedIdentity AzureManagedIdentity } @@ -1621,7 +1627,8 @@ func (*ValidateStorageCredentialRequest_Credential_AzureManagedIdentity) isValid } // ValidateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount selects DatabricksGcpServiceAccount for ValidateStorageCredentialRequest.Credential. -// The created GCP service account configuration. +// Deprecated: create a storage credential and pass its storage_credential_name +// instead. The created GCP service account configuration. type ValidateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount struct { DatabricksGcpServiceAccount DatabricksGcpServiceAccount } @@ -1630,7 +1637,8 @@ func (*ValidateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount) } // ValidateStorageCredentialRequest_Credential_CloudflareApiToken selects CloudflareApiToken for ValidateStorageCredentialRequest.Credential. -// The Cloudflare API token configuration. +// Deprecated: create a storage credential and pass its storage_credential_name +// instead. The Cloudflare API token configuration. type ValidateStorageCredentialRequest_Credential_CloudflareApiToken struct { CloudflareApiToken CloudflareApiToken } diff --git a/uc/resourcequotas/CHANGELOG.md b/uc/resourcequotas/CHANGELOG.md index 444d06f2..94155535 100644 --- a/uc/resourcequotas/CHANGELOG.md +++ b/uc/resourcequotas/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.4.0 (2026-11-02) + ## Release v0.3.0 (2026-10-13) ## Release v0.2.0 (2026-10-06) diff --git a/uc/resourcequotas/internal/version.go b/uc/resourcequotas/internal/version.go index e36f20a5..07fc4e21 100644 --- a/uc/resourcequotas/internal/version.go +++ b/uc/resourcequotas/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-resourcequotas" -const Version = "0.3.0" +const Version = "0.4.0" diff --git a/uc/resourcequotas/v1/model.go b/uc/resourcequotas/v1/model.go index 3aad012c..db82e821 100644 --- a/uc/resourcequotas/v1/model.go +++ b/uc/resourcequotas/v1/model.go @@ -31,6 +31,9 @@ const ( SecurableType_ModelProviderService SecurableType = "MODEL_PROVIDER_SERVICE" SecurableType_AgentService SecurableType = "AGENT_SERVICE" SecurableType_Skill SecurableType = "SKILL" + // A Feature Store feature in Unity Catalog. Three-level namespace + // catalog.schema.feature. + SecurableType_Feature SecurableType = "FEATURE" ) type GetQuotaRequest struct { diff --git a/uc/rfa/CHANGELOG.md b/uc/rfa/CHANGELOG.md index 444d06f2..94155535 100644 --- a/uc/rfa/CHANGELOG.md +++ b/uc/rfa/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.4.0 (2026-11-02) + ## Release v0.3.0 (2026-10-13) ## Release v0.2.0 (2026-10-06) diff --git a/uc/rfa/internal/version.go b/uc/rfa/internal/version.go index f06ae2ad..58dbef56 100644 --- a/uc/rfa/internal/version.go +++ b/uc/rfa/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-rfa" -const Version = "0.3.0" +const Version = "0.4.0" diff --git a/uc/rfa/v1/model.go b/uc/rfa/v1/model.go index f0af740c..05b8ce5d 100644 --- a/uc/rfa/v1/model.go +++ b/uc/rfa/v1/model.go @@ -55,6 +55,9 @@ const ( SecurableType_ModelProviderService SecurableType = "MODEL_PROVIDER_SERVICE" SecurableType_AgentService SecurableType = "AGENT_SERVICE" SecurableType_Skill SecurableType = "SKILL" + // A Feature Store feature in Unity Catalog. Three-level namespace + // catalog.schema.feature. + SecurableType_Feature SecurableType = "FEATURE" ) type SpecialDestination string diff --git a/uc/tables/CHANGELOG.md b/uc/tables/CHANGELOG.md index 99aeb067..52a34f51 100644 --- a/uc/tables/CHANGELOG.md +++ b/uc/tables/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.5.0 (2026-11-02) + ## Release v0.4.0 (2026-10-13) ## Release v0.3.0 (2026-10-06) diff --git a/uc/tables/internal/version.go b/uc/tables/internal/version.go index d31795fa..4a598579 100644 --- a/uc/tables/internal/version.go +++ b/uc/tables/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-tables" -const Version = "0.4.0" +const Version = "0.5.0" diff --git a/uc/tables/v1/model.go b/uc/tables/v1/model.go index bd4a9981..fbddf27a 100644 --- a/uc/tables/v1/model.go +++ b/uc/tables/v1/model.go @@ -195,6 +195,9 @@ const ( SecurableType_ModelProviderService SecurableType = "MODEL_PROVIDER_SERVICE" SecurableType_AgentService SecurableType = "AGENT_SERVICE" SecurableType_Skill SecurableType = "SKILL" + // A Feature Store feature in Unity Catalog. Three-level namespace + // catalog.schema.feature. + SecurableType_Feature SecurableType = "FEATURE" ) type SseEncryptionAlgorithm string diff --git a/uc/volumes/CHANGELOG.md b/uc/volumes/CHANGELOG.md index 2fca2529..081443ac 100644 --- a/uc/volumes/CHANGELOG.md +++ b/uc/volumes/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.4.0 (2026-11-02) + ## Release v0.3.0 (2026-10-13) ## Release v0.2.0 (2026-10-06) diff --git a/uc/volumes/internal/version.go b/uc/volumes/internal/version.go index f7c218ea..47625e7b 100644 --- a/uc/volumes/internal/version.go +++ b/uc/volumes/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-uc-volumes" -const Version = "0.3.0" +const Version = "0.4.0" diff --git a/uc/volumes/v1/model.go b/uc/volumes/v1/model.go index e8a0af5c..6d273bae 100644 --- a/uc/volumes/v1/model.go +++ b/uc/volumes/v1/model.go @@ -86,7 +86,7 @@ func (*EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails) isEncryptio } type GetVolumeRequest struct { - // The three-level (fully qualified) name of the volume + // The fully qualified name of the volume. FullNameArg *string // Whether to include volumes in the response for which the principal can only // access selective metadata for diff --git a/warehouses/CHANGELOG.md b/warehouses/CHANGELOG.md index 1579356a..13e1bbbc 100644 --- a/warehouses/CHANGELOG.md +++ b/warehouses/CHANGELOG.md @@ -1,5 +1,7 @@ # Version changelog +## Release v0.7.0 (2026-11-02) + ## Release v0.6.0 (2026-10-21) ## Release v0.5.0 (2026-10-14) diff --git a/warehouses/internal/version.go b/warehouses/internal/version.go index e1f399f2..6a5d4030 100644 --- a/warehouses/internal/version.go +++ b/warehouses/internal/version.go @@ -2,4 +2,4 @@ package internal const ModuleName = "sdk-go-warehouses" -const Version = "0.6.0" +const Version = "0.7.0" diff --git a/warehouses/v1/model.go b/warehouses/v1/model.go index 5b52b942..cdb78e9d 100644 --- a/warehouses/v1/model.go +++ b/warehouses/v1/model.go @@ -724,8 +724,8 @@ type CreateWarehouseRequest struct { // Compute version label for a REALTIME warehouse. This field is output only. CustomerVersionLabel *string // Maximum compute capacity of a real-time SQL warehouse, in DBU per hour. Must - // be a multiple of 3 between 3 and 960. The effective maximum cannot be lower - // than the warehouse's minimum capacity. + // be at least the minimum DBU for the selected warehouse size and no greater + // than the configured DBU limit. Actual capacity may be below this ceiling. MaxDbu *int } @@ -842,8 +842,8 @@ type EditWarehouseRequest struct { // Compute version label for a REALTIME warehouse. This field is output only. CustomerVersionLabel *string // Maximum compute capacity of a real-time SQL warehouse, in DBU per hour. Must - // be a multiple of 3 between 3 and 960. The effective maximum cannot be lower - // than the warehouse's minimum capacity. + // be at least the minimum DBU for the selected warehouse size and no greater + // than the configured DBU limit. Actual capacity may be below this ceiling. MaxDbu *int } @@ -944,8 +944,8 @@ type EndpointInfo struct { // Compute version label for a REALTIME warehouse. This field is output only. CustomerVersionLabel *string // Maximum compute capacity of a real-time SQL warehouse, in DBU per hour. Must - // be a multiple of 3 between 3 and 960. The effective maximum cannot be lower - // than the warehouse's minimum capacity. + // be at least the minimum DBU for the selected warehouse size and no greater + // than the configured DBU limit. Actual capacity may be below this ceiling. MaxDbu *int // current number of clusters running for the service NumClusters *int @@ -1061,8 +1061,8 @@ type GetWarehouseResponse struct { // Compute version label for a REALTIME warehouse. This field is output only. CustomerVersionLabel *string // Maximum compute capacity of a real-time SQL warehouse, in DBU per hour. Must - // be a multiple of 3 between 3 and 960. The effective maximum cannot be lower - // than the warehouse's minimum capacity. + // be at least the minimum DBU for the selected warehouse size and no greater + // than the configured DBU limit. Actual capacity may be below this ceiling. MaxDbu *int // current number of clusters running for the service NumClusters *int